qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] SPARC: Fix LEON3 power down instruction


From: Sebastian Huber
Subject: [Qemu-devel] [PATCH] SPARC: Fix LEON3 power down instruction
Date: Mon, 25 Nov 2013 15:22:24 +0100

The env->pc is not necessarily up-to-date in the helper function.  Use
the program counter of the disassembly context instead.

Signed-off-by: Sebastian Huber <address@hidden>
---
 target-sparc/helper.c    |    6 +++---
 target-sparc/helper.h    |    2 +-
 target-sparc/translate.c |    3 ++-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/target-sparc/helper.c b/target-sparc/helper.c
index e70d1bc..50912ff 100644
--- a/target-sparc/helper.c
+++ b/target-sparc/helper.c
@@ -314,14 +314,14 @@ target_ulong helper_tsubcctv(CPUSPARCState *env, 
target_ulong src1,
 }
 
 #ifndef TARGET_SPARC64
-void helper_power_down(CPUSPARCState *env)
+void helper_power_down(CPUSPARCState *env, uint32_t pc)
 {
     CPUState *cs = CPU(sparc_env_get_cpu(env));
 
     cs->halted = 1;
     env->exception_index = EXCP_HLT;
-    env->pc = env->npc;
-    env->npc = env->pc + 4;
+    env->pc = pc + 4;
+    env->npc = pc + 8;
     cpu_loop_exit(env);
 }
 #endif
diff --git a/target-sparc/helper.h b/target-sparc/helper.h
index fc49cd8..c4752c7 100644
--- a/target-sparc/helper.h
+++ b/target-sparc/helper.h
@@ -6,7 +6,7 @@ DEF_HELPER_2(trace_insn, void, env, i32)
 DEF_HELPER_1(rett, void, env)
 DEF_HELPER_2(wrpsr, void, env, tl)
 DEF_HELPER_1(rdpsr, tl, env)
-DEF_HELPER_1(power_down, void, env)
+DEF_HELPER_2(power_down, void, env, i32)
 #else
 DEF_HELPER_2(wrpil, void, env, tl)
 DEF_HELPER_2(wrpstate, void, env, tl)
diff --git a/target-sparc/translate.c b/target-sparc/translate.c
index 0588d23..d9ee90c 100644
--- a/target-sparc/translate.c
+++ b/target-sparc/translate.c
@@ -3631,7 +3631,8 @@ static void disas_sparc_insn(DisasContext * dc, unsigned 
int insn)
                                 if ((rd == 0x13) && (dc->def->features &
                                                      CPU_FEATURE_POWERDOWN)) {
                                     /* LEON3 power-down */
-                                    gen_helper_power_down(cpu_env);
+                                    tcg_gen_movi_i32(cpu_tmp0, dc->pc);
+                                    gen_helper_power_down(cpu_env, cpu_tmp0);
                                 }
                                 break;
 #else
-- 
1.7.7




reply via email to

[Prev in Thread] Current Thread [Next in Thread]