target/nios2: Enable unaligned traps for system mode
authorRichard Henderson <richard.henderson@linaro.org>
Thu, 21 Apr 2022 15:17:18 +0000 (08:17 -0700)
committerRichard Henderson <richard.henderson@linaro.org>
Tue, 26 Apr 2022 15:17:05 +0000 (08:17 -0700)
Unaligned traps are optional, but required with an mmu.
Turn them on always, because the fallback behaviour undefined.

Enable alignment checks in the config file.
Unwind the guest pc properly from do_unaligned_access.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20220421151735.31996-48-richard.henderson@linaro.org>

configs/targets/nios2-softmmu.mak
target/nios2/helper.c

index 9a372f071772032ae5d568f4322530e5704e5711..1e93b54cd13a9b4158c31faee47756286e25aaf1 100644 (file)
@@ -1 +1,2 @@
 TARGET_ARCH=nios2
+TARGET_ALIGNED_ONLY=y
index c5a2dd65b128a5e337fba7368b256577c661846d..2e9fea4a012dd7b15775a8c201509ad5fbab35b8 100644 (file)
@@ -241,8 +241,8 @@ void nios2_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
     CPUNios2State *env = &cpu->env;
 
     env->ctrl[CR_BADADDR] = addr;
-    env->ctrl[CR_EXCEPTION] = FIELD_DP32(0, CR_EXCEPTION, CAUSE, EXCP_UNALIGN);
-    helper_raise_exception(env, EXCP_UNALIGN);
+    cs->exception_index = EXCP_UNALIGN;
+    cpu_loop_exit_restore(cs, retaddr);
 }
 
 bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size,