From e97c07cdca9bfdc3d6f655ce35fcae765aa8045e Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Sun, 11 Feb 2018 16:51:17 -0500 Subject: [PATCH] target-mips: Add missing calls to synchronise SoftFloat status Add missing calls to synchronise the SoftFloat status with the CP1.FSCR: + for the rounding and flush-to-zero modes upon processor reset, + for the flush-to-zero mode on FSCR updates through the GDB stub. Refactor code accordingly and remove the redundant RESTORE_ROUNDING_MODE macro. Backports commit bb962386b82c1b0e9e12fdb6b9bb62106bf1f822 from qemu --- qemu/target-mips/cpu.h | 13 +++++++++++++ qemu/target-mips/op_helper.c | 12 ------------ qemu/target-mips/translate.c | 2 ++ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/qemu/target-mips/cpu.h b/qemu/target-mips/cpu.h index 1500ce87..791019a5 100644 --- a/qemu/target-mips/cpu.h +++ b/qemu/target-mips/cpu.h @@ -771,6 +771,19 @@ target_ulong exception_resume_pc (CPUMIPSState *env); extern unsigned int ieee_rm[]; int ieee_ex_to_mips(int xcpt); +static inline void restore_rounding_mode(CPUMIPSState *env) +{ + set_float_rounding_mode(ieee_rm[env->active_fpu.fcr31 & 3], + &env->active_fpu.fp_status); +} + +static inline void restore_flush_mode(CPUMIPSState *env) +{ + set_flush_to_zero((env->active_fpu.fcr31 & (1 << 24)) != 0, + &env->active_fpu.fp_status); +} + + static inline void cpu_get_tb_cpu_state(CPUMIPSState *env, target_ulong *pc, target_ulong *cs_base, int *flags) { diff --git a/qemu/target-mips/op_helper.c b/qemu/target-mips/op_helper.c index b56a82c3..15b85a74 100644 --- a/qemu/target-mips/op_helper.c +++ b/qemu/target-mips/op_helper.c @@ -2283,18 +2283,6 @@ unsigned int ieee_rm[] = { float_round_down }; -static inline void restore_rounding_mode(CPUMIPSState *env) -{ - set_float_rounding_mode(ieee_rm[env->active_fpu.fcr31 & 3], - &env->active_fpu.fp_status); -} - -static inline void restore_flush_mode(CPUMIPSState *env) -{ - set_flush_to_zero((env->active_fpu.fcr31 & (1 << 24)) != 0, - &env->active_fpu.fp_status); -} - target_ulong helper_cfc1(CPUMIPSState *env, uint32_t reg) { target_ulong arg1 = 0; diff --git a/qemu/target-mips/translate.c b/qemu/target-mips/translate.c index 64882ba8..48faa5ae 100644 --- a/qemu/target-mips/translate.c +++ b/qemu/target-mips/translate.c @@ -19826,6 +19826,8 @@ void cpu_state_reset(CPUMIPSState *env) } compute_hflags(env); + restore_rounding_mode(env); + restore_flush_mode(env); cs->exception_index = EXCP_NONE; }