aboutsummaryrefslogtreecommitdiff
path: root/linux-user/nios2
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2022-04-21 08:17:28 -0700
committerRichard Henderson <richard.henderson@linaro.org>2022-04-26 08:17:05 -0700
commite84f1768449330a5b4c62a8aaa68f102ba6ec573 (patch)
treeaf6ca0b49c5612a35ac77da507974dba9ee71713 /linux-user/nios2
parenta25c4eff32ba6192cff648ccaf0316bd829c80af (diff)
downloadqemu-e84f1768449330a5b4c62a8aaa68f102ba6ec573.zip
qemu-e84f1768449330a5b4c62a8aaa68f102ba6ec573.tar.gz
qemu-e84f1768449330a5b4c62a8aaa68f102ba6ec573.tar.bz2
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')
-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 30a27f2..a5e8699 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");