Use do_raise_exception() directly for reserved-instruction traps in the
FPU helpers, passing GETPC() to restore guest state. Keep helper_wait() on
the zero-PC path, where the guest PC was already updated.

Signed-off-by: Yonggang Luo <[email protected]>
---
 target/mips/tcg/exception.c  | 7 +------
 target/mips/tcg/fpu_helper.c | 6 +++---
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/target/mips/tcg/exception.c b/target/mips/tcg/exception.c
index 630b8b809fa..514880ccba8 100644
--- a/target/mips/tcg/exception.c
+++ b/target/mips/tcg/exception.c
@@ -60,11 +60,6 @@ void helper_raise_exception_debug(CPUMIPSState *env)
     do_raise_exception(env, EXCP_DEBUG, 0);
 }
 
-static void raise_exception(CPUMIPSState *env, uint32_t exception)
-{
-    do_raise_exception(env, exception, 0);
-}
-
 void helper_wait(CPUMIPSState *env)
 {
     CPUState *cs = env_cpu(env);
@@ -75,7 +70,7 @@ void helper_wait(CPUMIPSState *env)
      * Last instruction in the block, PC was updated before
      * - no need to recover PC and icount.
      */
-    raise_exception(env, EXCP_HLT);
+    do_raise_exception(env, EXCP_HLT, 0);
 }
 
 void mips_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb)
diff --git a/target/mips/tcg/fpu_helper.c b/target/mips/tcg/fpu_helper.c
index 36af9808025..ce68cda1e43 100644
--- a/target/mips/tcg/fpu_helper.c
+++ b/target/mips/tcg/fpu_helper.c
@@ -61,7 +61,7 @@ target_ulong helper_cfc1(CPUMIPSState *env, uint32_t reg)
             if (env->CP0_Config5 & (1 << CP0C5_UFE)) {
                 arg1 = (env->CP0_Config5 >> CP0C5_FRE) & 1;
             } else {
-                helper_raise_exception(env, EXCP_RI);
+                do_raise_exception(env, EXCP_RI, GETPC());
             }
         }
         break;
@@ -120,7 +120,7 @@ void helper_ctc1(CPUMIPSState *env, target_ulong arg1, 
uint32_t fs, uint32_t rt)
             env->CP0_Config5 &= ~(1 << CP0C5_FRE);
             compute_hflags(env);
         } else {
-            helper_raise_exception(env, EXCP_RI);
+            do_raise_exception(env, EXCP_RI, GETPC());
         }
         break;
     case 6:
@@ -132,7 +132,7 @@ void helper_ctc1(CPUMIPSState *env, target_ulong arg1, 
uint32_t fs, uint32_t rt)
             env->CP0_Config5 |= (1 << CP0C5_FRE);
             compute_hflags(env);
         } else {
-            helper_raise_exception(env, EXCP_RI);
+            do_raise_exception(env, EXCP_RI, GETPC());
         }
         break;
     case 25:
-- 
2.52.0.windows.1


Reply via email to