summaryrefslogtreecommitdiffstats
path: root/linux-user/nios2/cpu_loop.c
diff options
context:
space:
mode:
authorRichard Henderson2022-04-21 17:17:28 +0200
committerRichard Henderson2022-04-26 17:17:05 +0200
commite84f1768449330a5b4c62a8aaa68f102ba6ec573 (patch)
treeaf6ca0b49c5612a35ac77da507974dba9ee71713 /linux-user/nios2/cpu_loop.c
parenttarget/nios2: Implement EIC interrupt processing (diff)
downloadqemu-e84f1768449330a5b4c62a8aaa68f102ba6ec573.tar.gz
qemu-e84f1768449330a5b4c62a8aaa68f102ba6ec573.tar.xz
qemu-e84f1768449330a5b4c62a8aaa68f102ba6ec573.zip
target/nios2: Advance pc when raising exceptions
The exception return address for nios2 is the instruction after the one that was executing at the time of the exception. We have so far implemented this by advancing the pc during the process of raising the exception. It is perhaps a little less confusing to do this advance in the translator (and helpers) when raising the exception in the first place, so that we may more closely match kernel sources. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20220421151735.31996-58-richard.henderson@linaro.org>
Diffstat (limited to 'linux-user/nios2/cpu_loop.c')
-rw-r--r--linux-user/nios2/cpu_loop.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c
index 30a27f252b..a5e86990e2 100644
--- a/linux-user/nios2/cpu_loop.c
+++ b/linux-user/nios2/cpu_loop.c
@@ -39,6 +39,8 @@ void cpu_loop(CPUNios2State *env)
break;
case EXCP_DIV:
+ /* Match kernel's handle_diverror_c(). */
+ env->pc -= 4;
force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTDIV, env->pc);
break;
@@ -49,12 +51,6 @@ void cpu_loop(CPUNios2State *env)
break;
case EXCP_TRAP:
- /*
- * TODO: This advance should be done in the translator, as
- * hardware produces an advanced pc as part of all exceptions.
- */
- env->pc += 4;
-
switch (env->error_code) {
case 0:
qemu_log_mask(CPU_LOG_INT, "\nSyscall\n");