Skip to content

Commit 39ec3fc

Browse files
committed
target/arm: HCR_EL2.RW should be RAO/WI if EL1 doesn't support AArch32
When EL1 doesn't support AArch32, the HCR_EL2.RW bit is supposed to be RAO/WI. Enforce the RAO/WI behaviour. Note that we handle "reset value should honour RES1 bits" in the same way that SCR_EL3 does, via a reset function. We do already have some CPU types which don't implement AArch32 above EL0, so this is technically a bug; it doesn't seem worth backporting to stable because no sensible guest code will be deliberately attempting to set the RW bit to a value corresponding to an unimplemented execution state and then checking that we did the right thing. Signed-off-by: Peter Maydell <[email protected]> Reviewed-by: Richard Henderson <[email protected]>
1 parent 5d71c68 commit 39ec3fc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

target/arm/helper.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5326,6 +5326,11 @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask)
53265326
/* Clear RES0 bits. */
53275327
value &= valid_mask;
53285328

5329+
/* RW is RAO/WI if EL1 is AArch64 only */
5330+
if (!cpu_isar_feature(aa64_aa32_el1, cpu)) {
5331+
value |= HCR_RW;
5332+
}
5333+
53295334
/*
53305335
* These bits change the MMU setup:
53315336
* HCR_VM enables stage 2 translation
@@ -5383,6 +5388,12 @@ static void hcr_writelow(CPUARMState *env, const ARMCPRegInfo *ri,
53835388
do_hcr_write(env, value, MAKE_64BIT_MASK(32, 32));
53845389
}
53855390

5391+
static void hcr_reset(CPUARMState *env, const ARMCPRegInfo *ri)
5392+
{
5393+
/* hcr_write will set the RES1 bits on an AArch64-only CPU */
5394+
hcr_write(env, ri, 0);
5395+
}
5396+
53865397
/*
53875398
* Return the effective value of HCR_EL2, at the given security state.
53885399
* Bits that are not included here:
@@ -5618,6 +5629,7 @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
56185629
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0,
56195630
.access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2),
56205631
.nv2_redirect_offset = 0x78,
5632+
.resetfn = hcr_reset,
56215633
.writefn = hcr_write, .raw_writefn = raw_write },
56225634
{ .name = "HCR", .state = ARM_CP_STATE_AA32,
56235635
.type = ARM_CP_ALIAS | ARM_CP_IO,

0 commit comments

Comments
 (0)