OSDN Git Service

linux-user/sparc: Raise SIGILL for all unhandled software traps
authorRichard Henderson <richard.henderson@linaro.org>
Wed, 1 Feb 2023 20:56:15 +0000 (10:56 -1000)
committerRichard Henderson <richard.henderson@linaro.org>
Tue, 21 Feb 2023 18:44:13 +0000 (08:44 -1000)
The linux kernel's trap tables vector all unassigned trap
numbers to BAD_TRAP, which then raises SIGILL.

Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reported-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
linux-user/sparc/cpu_loop.c

index 434c90a..c120c42 100644 (file)
@@ -248,6 +248,14 @@ void cpu_loop (CPUSPARCState *env)
             cpu_exec_step_atomic(cs);
             break;
         default:
+            /*
+             * Most software trap numbers vector to BAD_TRAP.
+             * Handle anything not explicitly matched above.
+             */
+            if (trapnr >= TT_TRAP && trapnr <= TT_TRAP + 0x7f) {
+                force_sig_fault(TARGET_SIGILL, ILL_ILLTRP, env->pc);
+                break;
+            }
             fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr);
             cpu_dump_state(cs, stderr, 0);
             exit(EXIT_FAILURE);