Commit 47ecb80041 for qemu.org
commit 47ecb80041034b09b96490e4ee72d06232dfc919
Author: Chris Copeland <chris@chrisnc.net>
Date: Mon Nov 9 13:52:08 2026 +0000
target/arm: Clear the local monitor on AArch32 (v8) exception returns
A/R-profile exception returns prior to Armv8 do not clear the local
exclusive monitor, but in Armv8-A/R it is cleared.
From the Arm Architecture Reference Manual for A-profile architecture
(DDI0487 M.d) §E2.10.4 "Context switch support":
"An exception return clears the local monitor."
The same language appears in the R-profile manual (DDI111353 A.a)
§B2.11.4 "Context switch support".
We correctly clear the monitor for an A64 exception return, but
in adding v8 support we missed that the A32 exception return path
needed updating.
Cc: qemu-stable@nongnu.org
Signed-off-by: Chris Copeland <chris@chrisnc.net>
Message-id: 20261108-armv8-exception-return-clrex-v1-1-ec11079bf695@chrisnc.net
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
[PMM: commit message tweak]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c
index 4a31ce979c..22f47f7450 100644
--- a/target/arm/tcg/op_helper.c
+++ b/target/arm/tcg/op_helper.c
@@ -803,6 +803,10 @@ void HELPER(cpsr_write_eret)(CPUARMState *env, uint32_t val)
mask = aarch32_cpsr_valid_mask(env->features, &env_archcpu(env)->isar);
cpsr_write(env, val, mask, CPSRWriteExceptionReturn);
+ if (arm_feature(env, ARM_FEATURE_V8)) {
+ arm_clear_exclusive(env);
+ }
+
/* Generated code has already stored the new PC value, but
* without masking out its low bits, because which bits need
* masking depends on whether we're returning to Thumb or ARM