Commit b3f00f492f for qemu.org
commit b3f00f492f8a9e6a750554cb6dcb21bdcfd80db9
Author: Peter Maydell <peter.maydell@linaro.org>
Date: Mon Aug 17 13:38:31 2026 +0100
target/arm: Handle NSACR.NSASEDIS in CPACR accesses
In cpacr_read() and cpacr_write() we have code that implements the
"CPACR.{cp10,cp11} behave as RAZ/WI from NonSecure when NSACR.cp10 is
0" behaviour. There is a similar requirement for CPACR.ASEDIS: if
NSACR.NSASEDIS is 1 then CPACR.ASEDIS behaves as RAO/WI in NS.
This doesn't matter to us yet because we don't currently implement
ASEDIS or NSASEDIS. But we're about to do that, so add the handling
to cpacr_read() and cpacr_write().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20260817123838.1578060-2-peter.maydell@linaro.org
diff --git a/target/arm/helper.c b/target/arm/helper.c
index adae2b2b8e..6a707b80cf 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -588,11 +588,19 @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri,
/*
* For A-profile AArch32 EL3 (but not M-profile secure mode), if NSACR.CP10
* is 0 then CPACR.{CP11,CP10} ignore writes and read as 0b00.
+ * Similarly, if NSACR.NSASEDIS is 1 then CPACR.ASEDIS ignores writes
+ * and reads as 1.
*/
if (arm_feature(env, ARM_FEATURE_EL3) && !arm_el_is_aa64(env, 3) &&
- !arm_is_secure(env) && !FIELD_EX32(env->cp15.nsacr, NSACR, CP10)) {
- mask = R_CPACR_CP11_MASK | R_CPACR_CP10_MASK;
- value = (value & ~mask) | (env->cp15.cpacr_el1 & mask);
+ !arm_is_secure(env)) {
+ if (!FIELD_EX32(env->cp15.nsacr, NSACR, CP10)) {
+ mask = R_CPACR_CP11_MASK | R_CPACR_CP10_MASK;
+ value = (value & ~mask) | (env->cp15.cpacr_el1 & mask);
+ }
+ if (FIELD_EX32(env->cp15.nsacr, NSACR, NSASEDIS)) {
+ mask = R_CPACR_ASEDIS_MASK;
+ value = (value & ~mask) | (env->cp15.cpacr_el1 & mask);
+ }
}
env->cp15.cpacr_el1 = value;
@@ -603,12 +611,18 @@ static uint64_t cpacr_read(CPUARMState *env, const ARMCPRegInfo *ri)
/*
* For A-profile AArch32 EL3 (but not M-profile secure mode), if NSACR.CP10
* is 0 then CPACR.{CP11,CP10} ignore writes and read as 0b00.
+ * Similarly NSACR.NSASEDIS makes CPACR.ASEDIS read as 1.
*/
uint64_t value = env->cp15.cpacr_el1;
if (arm_feature(env, ARM_FEATURE_EL3) && !arm_el_is_aa64(env, 3) &&
- !arm_is_secure(env) && !FIELD_EX32(env->cp15.nsacr, NSACR, CP10)) {
- value = ~(R_CPACR_CP11_MASK | R_CPACR_CP10_MASK);
+ !arm_is_secure(env)) {
+ if (!FIELD_EX32(env->cp15.nsacr, NSACR, CP10)) {
+ value = ~(R_CPACR_CP11_MASK | R_CPACR_CP10_MASK);
+ }
+ if (FIELD_EX32(env->cp15.nsacr, NSACR, NSASEDIS)) {
+ value |= R_CPACR_ASEDIS_MASK;
+ }
}
return value;
}