linux-user/sparc: Handle division by zero traps
authorRichard Henderson <richard.henderson@linaro.org>
Thu, 16 Feb 2023 05:45:09 +0000 (19:45 -1000)
committerLaurent Vivier <laurent@vivier.eu>
Fri, 10 Mar 2023 19:45:47 +0000 (20:45 +0100)
In addition to the hw trap vector, there is a software trap
assigned for older sparc without hw division instructions.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230216054516.1267305-9-richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
linux-user/sparc/cpu_loop.c

index c14eaea16370227c63c2b9ffdc82d9ca04848bbb..e04c842867691766e86e4784b95d8fd0ee54c9e2 100644 (file)
@@ -211,6 +211,11 @@ void cpu_loop (CPUSPARCState *env)
             force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc);
             break;
 
+        case TT_TRAP + 0x02: /* div0 */
+        case TT_DIV_ZERO:
+            force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTDIV, env->pc);
+            break;
+
         case TT_TRAP + 0x03: /* flush windows */
             flush_windows(env);
             /* next instruction */