Skip to contentSkip to conversation

Fix TA0_Shutdown feature

PATCH In review Julien Grall 2 participants 4 messages May 17, 2011 – May 20, 2011 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 2/2 Fix TA0_Shutdown feature

Fix TA0_SHUTDOWN feature

---
 target-sparc/op_helper.c |   13 +++++++++++--
 target-sparc/translate.c |    9 +--------
 2 files changed, 12 insertions(+), 10 deletions(-)
target-sparc/op_helper.c +11 -2
index a6fabad..cb775f5 100644
@@ -326,8 +326,17 @@ void HELPER(raise_exception)(int tt)
 
 void HELPER(trap_always)(int tt)
 {
-    env->exception_index = tt;
-    do_interrupt(env);
+    if (tt == TT_TRAP
+        && env->def->features & CPU_FEATURE_TA0_SHUTDOWN
+#ifndef TARGET_SPARC64
+        && env->psret == 0
+#endif
+        ) {
+        helper_shutdown();
+    } else {
+        env->exception_index = tt;
+        do_interrupt(env);
+    }
 }
 
 void helper_shutdown(void)
target-sparc/translate.c +1 -8
index b30003b..a47a2de 100644
@@ -2009,14 +2009,7 @@ static void disas_sparc_insn(DisasContext * dc)
                     tcg_gen_addi_tl(cpu_dst, cpu_dst, TT_TRAP);
                     tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst);
 
-                    if (rs2 == 0 &&
-                        dc->def->features & CPU_FEATURE_TA0_SHUTDOWN) {
-
-                        gen_helper_shutdown();
-
-                    } else {
-                        gen_helper_trap_always(cpu_tmp32);
-                    }
+                    gen_helper_trap_always(cpu_tmp32);
                 } else if (cond != 0) {
                     TCGv r_cond = tcg_temp_new();
                     int l1;
Signature · 1 line
1.7.4.4
#2 lore raw
Quoted 1 line · Julien Grall

Fix TA0_SHUTDOWN feature

But what would be the bug?

Quoted 37 lines

---
 target-sparc/op_helper.c |   13 +++++++++++--
 target-sparc/translate.c |    9 +--------

 2 files changed, 12 insertions(+), 10 deletions(-)
target-sparc/op_helper.c +11 -2
index a6fabad..cb775f5 100644
@@ -326,8 +326,17 @@ void HELPER(raise_exception)(int tt)
 
  void HELPER(trap_always)(int tt)
  {
-    env->exception_index = tt;
-    do_interrupt(env);
+    if (tt == TT_TRAP
+        && env->def->features & CPU_FEATURE_TA0_SHUTDOWN
+#ifndef TARGET_SPARC64
+        && env->psret == 0
+#endif
+        ) {
+        helper_shutdown();
+    } else {
+        env->exception_index = tt;
+        do_interrupt(env);
+    }
  }
 
  void helper_shutdown(void)
target-sparc/translate.c +0 -0
index b30003b..a47a2de 100644
@@ -2009,14 +2009,7 @@ static void disas_sparc_insn(DisasContext * dc)
                     tcg_gen_addi_tl(cpu_dst, cpu_dst, TT_TRAP);
                     tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst);

target-sparc/translate.c static void disas_sparc_insn(DisasContext * dc) · line 2012

Quoted 10 lines
target-sparc/translate.c +1 -8
 
-                    if (rs2 == 0 &&
-                        dc->def->features & CPU_FEATURE_TA0_SHUTDOWN) {
-
-                        gen_helper_shutdown();
-
-                    } else {
-                        gen_helper_trap_always(cpu_tmp32);
-                    }
+                    gen_helper_trap_always(cpu_tmp32);

No, this would actually be just opposite to how QEMU works. Performance comes from doing more work at translation time in order to save time during executing the generated code.

#3 lore raw
Quoted 4 lines · Blue Swirl
Quoted 1 line · Julien Grall

Fix TA0_SHUTDOWN feature

But what would be the bug?

We try to add RTEMS's support on leon platform for QEMU. RTEMS uses software trap 0 for various syscall.
The current implementation of TA0_SHUTDOWN breaks the RTEMS boot.

Quoted 3 lines

No, this would actually be just opposite to how QEMU works. Performance comes from doing more work at translation time in order to save time during executing the generated code.

I agree, this solution slows down the execution, but I didn't find another solution to fix this bug.

Signature · 1 line
Grall Julien
#4 lore raw
Quoted 10 lines · Julien Grall
Quoted 4 lines · Blue Swirl
Quoted 1 line · Julien Grall

Fix TA0_SHUTDOWN feature

But what would be the bug?

We try to add RTEMS's support on leon platform for QEMU. RTEMS uses software trap 0 for various syscall.
The current implementation of TA0_SHUTDOWN breaks the RTEMS boot.

Quoted 6 lines
Quoted 3 lines

No, this would actually be just opposite to how QEMU works. Performance comes from doing more work at translation time in order to save time during executing the generated code.

I agree, this solution slows down the execution, but I didn't find another solution to fix this bug.

You should retain the feature check in translate.c but add a leon specific helper in place of helper_shutdown, which can check for psret.

It would be also possible to generate code for the psret check if the helper overhead were an issue.