[PATCH] target/arm: Clear the local monitor on AArch32 (v8) exception returns

Chris Copeland posted 1 patch 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261108-armv8-exception-return-clrex-v1-1-ec11079bf695@chrisnc.net
Maintainers: Peter Maydell <peter.maydell@linaro.org>
target/arm/tcg/op_helper.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] target/arm: Clear the local monitor on AArch32 (v8) exception returns
Posted by Chris Copeland 2 weeks ago
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".

Signed-off-by: Chris Copeland <chris@chrisnc.net>
---
 target/arm/tcg/op_helper.c | 4 ++++
 1 file changed, 4 insertions(+)

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

---
base-commit: 71f25c75417d31c214ba2cd26b273c114fc99987
change-id: 20261108-armv8-exception-return-clrex-fcfca37d1738


Re: [PATCH] target/arm: Clear the local monitor on AArch32 (v8) exception returns
Posted by Peter Maydell 1 week, 6 days ago
On Mon, 9 Nov 2026 at 00:01, Chris Copeland <chris@chrisnc.net> wrote:
>
> 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".
>
> Signed-off-by: Chris Copeland <chris@chrisnc.net>

Oops, yes; we do this correctly for A64 exception return
but missed that A32 returns need this updated.

Applied to target-arm.next, thanks.

-- PMM