Skip to contentSkip to conversation

target/arm: Don't set HCR.RW for AArch32 only CPUs

PATCH In review Peter Maydell 3 participants 3 messages Sep 25, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/arm: Don't set HCR.RW for AArch32 only CPUs

In commit 39ec3fc0301 we fixed a bug where we were not implementing HCR_EL2.RW as RAO/WI for CPUs where EL1 doesn't support AArch32. However, we got the condition wrong, so we now set this bit even on CPUs which have no AArch64 support at all. This is wrong because the AArch32 HCR register defines this bit as RES0.

Correct the condition we use for forcing HCR_RW to be set.

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3128

Fixes 39ec3fc0301 ("target/arm: HCR_EL2.RW should be RAO/WI if EL1 doesn't support AArch32")
---
 target/arm/helper.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
target/arm/helper.c +2 -1
index c44294711f8..ba1f7296dd0 100644
@@ -3695,7 +3695,8 @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask)
     value &= valid_mask;
 
     /* RW is RAO/WI if EL1 is AArch64 only */
-    if (!cpu_isar_feature(aa64_aa32_el1, cpu)) {
+    if (arm_feature(env, ARM_FEATURE_AARCH64) &&
+        !cpu_isar_feature(aa64_aa32_el1, cpu)) {
         value |= HCR_RW;
     }
 
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Peter Maydell

In commit 39ec3fc0301 we fixed a bug where we were not implementing HCR_EL2.RW as RAO/WI for CPUs where EL1 doesn't support AArch32. However, we got the condition wrong, so we now set this bit even on CPUs which have no AArch64 support at all. This is wrong because the AArch32 HCR register defines this bit as RES0.

Correct the condition we use for forcing HCR_RW to be set.

Quoted 7 lines

Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3128

Fixes 39ec3fc0301 ("target/arm: HCR_EL2.RW should be RAO/WI if EL1 doesn't support AArch32")
---
  target/arm/helper.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
Reviewed-by on v1 1/1
#2 lore raw
In reply to Peter Maydell
Quoted 8 lines · Peter Maydell

In commit 39ec3fc0301 we fixed a bug where we were not implementing HCR_EL2.RW as RAO/WI for CPUs where EL1 doesn't support AArch32. However, we got the condition wrong, so we now set this bit even on CPUs which have no AArch64 support at all. This is wrong because the AArch32 HCR register defines this bit as RES0.

Correct the condition we use for forcing HCR_RW to be set.

Quoted 7 lines

Cc:[email protected] Resolves:https://gitlab.com/qemu-project/qemu/-/issues/3128

Fixes 39ec3fc0301 ("target/arm: HCR_EL2.RW should be RAO/WI if EL1 doesn't support AArch32")
---
  target/arm/helper.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

r~