Skip to contentSkip to conversation

linux-user/sh4: Deliver SIGILL on invalid instruction

PATCH In review Mikulas Patocka 3 participants 3 messages Aug 5 – Aug 6

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 linux-user/sh4: Deliver SIGILL on invalid instruction

On invalid instruction, deliver SIGILL rather than crashing the whole process unconditionally.

---
 linux-user/sh4/cpu_loop.c |    7 +++++++
 1 file changed, 7 insertions(+)
linux-user/sh4/cpu_loop.c +7 -0
Index: qemu/linux-user/sh4/cpu_loop.c
===================================================================
@@ -64,6 +64,13 @@ void cpu_loop(CPUSH4State *env)
             cpu_exec_step_atomic(cs);
             arch_interrupt = false;
             break;
+        case 0x180:
+            /* Illegal instruction */
+            /* fallthrough */
+        case 0x1a0:
+            /* Illegal instruction in delay slot */
+            force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPC, env->pc);
+            break;
         default:
             fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr);
             cpu_dump_state(cs, stderr, 0);
Reviewed-by on v2 1/1
#1 lore raw
Quoted 19 lines · Mikulas Patocka

On invalid instruction, deliver SIGILL rather than crashing the whole process unconditionally.

---
  linux-user/sh4/cpu_loop.c |    7 +++++++
  1 file changed, 7 insertions(+)

Index: qemu/linux-user/sh4/cpu_loop.c
===================================================================

linux-user/sh4/cpu_loop.c +0 -0
@@ -64,6 +64,13 @@ void cpu_loop(CPUSH4State *env)
              cpu_exec_step_atomic(cs);
              arch_interrupt = false;
              break;

linux-user/sh4/cpu_loop.c void cpu_loop(CPUSH4State *env) · line 76

Quoted 10 lines
linux-user/sh4/cpu_loop.c +7 -0
+        case 0x180:
+            /* Illegal instruction */
+            /* fallthrough */
+        case 0x1a0:
+            /* Illegal instruction in delay slot */
+            force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPC, env->pc);
+            break;
          default:
              fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr);
              cpu_dump_state(cs, stderr, 0);

r~

Reviewed-by on v2 1/1
#2 lore raw
In reply to Mikulas Patocka
Quoted 20 lines · Mikulas Patocka

On invalid instruction, deliver SIGILL rather than crashing the whole process unconditionally.

---
 linux-user/sh4/cpu_loop.c |    7 +++++++
 1 file changed, 7 insertions(+)

Index: qemu/linux-user/sh4/cpu_loop.c
===================================================================

linux-user/sh4/cpu_loop.c +0 -0
@@ -64,6 +64,13 @@ void cpu_loop(CPUSH4State *env)
             cpu_exec_step_atomic(cs);
             arch_interrupt = false;
             break;

linux-user/sh4/cpu_loop.c void cpu_loop(CPUSH4State *env) · line 76

Quoted 10 lines
linux-user/sh4/cpu_loop.c +7 -0
+        case 0x180:
+            /* Illegal instruction */
+            /* fallthrough */
+        case 0x1a0:
+            /* Illegal instruction in delay slot */
+            force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPC, env->pc);
+            break;
         default:
             fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr);
             cpu_dump_state(cs, stderr, 0);
Signature · 1 line
Yosinori Sato