target/arm: Trap registers when HCR_EL2.{NV, NV1} == {1, 1}
When HCR_EL2.{NV,NV1} is {1,1} we must trap five extra registers to EL2: VBAR_EL1, ELR_EL1, SPSR_EL1, SCXTNUM_EL1 and TFSR_EL1. Implement these traps. This trap does not apply when FEAT_NV2 is implemented and enabled; include the check that HCR_EL2.NV2 is 0 here, to save us having to come back and add it later. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Tested-by: Miguel Luis <miguel.luis@oracle.com>
This commit is contained in:
parent
29eda9cd19
commit
ad4e2d4db1
@ -5355,6 +5355,19 @@ static void mdcr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri,
|
||||
}
|
||||
}
|
||||
|
||||
static CPAccessResult access_nv1(CPUARMState *env, const ARMCPRegInfo *ri,
|
||||
bool isread)
|
||||
{
|
||||
if (arm_current_el(env) == 1) {
|
||||
uint64_t hcr_nv = arm_hcr_el2_eff(env) & (HCR_NV | HCR_NV1 | HCR_NV2);
|
||||
|
||||
if (hcr_nv == (HCR_NV | HCR_NV1)) {
|
||||
return CP_ACCESS_TRAP_EL2;
|
||||
}
|
||||
}
|
||||
return CP_ACCESS_OK;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
/*
|
||||
* `IC IVAU` is handled to improve compatibility with JITs that dual-map their
|
||||
@ -5703,12 +5716,12 @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
|
||||
{ .name = "ELR_EL1", .state = ARM_CP_STATE_AA64,
|
||||
.type = ARM_CP_ALIAS,
|
||||
.opc0 = 3, .opc1 = 0, .crn = 4, .crm = 0, .opc2 = 1,
|
||||
.access = PL1_RW,
|
||||
.access = PL1_RW, .accessfn = access_nv1,
|
||||
.fieldoffset = offsetof(CPUARMState, elr_el[1]) },
|
||||
{ .name = "SPSR_EL1", .state = ARM_CP_STATE_AA64,
|
||||
.type = ARM_CP_ALIAS,
|
||||
.opc0 = 3, .opc1 = 0, .crn = 4, .crm = 0, .opc2 = 0,
|
||||
.access = PL1_RW,
|
||||
.access = PL1_RW, .accessfn = access_nv1,
|
||||
.fieldoffset = offsetof(CPUARMState, banked_spsr[BANK_SVC]) },
|
||||
/*
|
||||
* We rely on the access checks not allowing the guest to write to the
|
||||
@ -7831,6 +7844,17 @@ static CPAccessResult access_mte(CPUARMState *env, const ARMCPRegInfo *ri,
|
||||
return CP_ACCESS_OK;
|
||||
}
|
||||
|
||||
static CPAccessResult access_tfsr_el1(CPUARMState *env, const ARMCPRegInfo *ri,
|
||||
bool isread)
|
||||
{
|
||||
CPAccessResult nv1 = access_nv1(env, ri, isread);
|
||||
|
||||
if (nv1 != CP_ACCESS_OK) {
|
||||
return nv1;
|
||||
}
|
||||
return access_mte(env, ri, isread);
|
||||
}
|
||||
|
||||
static CPAccessResult access_tfsr_el2(CPUARMState *env, const ARMCPRegInfo *ri,
|
||||
bool isread)
|
||||
{
|
||||
@ -7875,7 +7899,7 @@ static const ARMCPRegInfo mte_reginfo[] = {
|
||||
.fieldoffset = offsetof(CPUARMState, cp15.tfsr_el[0]) },
|
||||
{ .name = "TFSR_EL1", .state = ARM_CP_STATE_AA64,
|
||||
.opc0 = 3, .opc1 = 0, .crn = 5, .crm = 6, .opc2 = 0,
|
||||
.access = PL1_RW, .accessfn = access_mte,
|
||||
.access = PL1_RW, .accessfn = access_tfsr_el1,
|
||||
.fieldoffset = offsetof(CPUARMState, cp15.tfsr_el[1]) },
|
||||
{ .name = "TFSR_EL2", .state = ARM_CP_STATE_AA64,
|
||||
.opc0 = 3, .opc1 = 4, .crn = 5, .crm = 6, .opc2 = 0,
|
||||
@ -8027,6 +8051,18 @@ static CPAccessResult access_scxtnum(CPUARMState *env, const ARMCPRegInfo *ri,
|
||||
return CP_ACCESS_OK;
|
||||
}
|
||||
|
||||
static CPAccessResult access_scxtnum_el1(CPUARMState *env,
|
||||
const ARMCPRegInfo *ri,
|
||||
bool isread)
|
||||
{
|
||||
CPAccessResult nv1 = access_nv1(env, ri, isread);
|
||||
|
||||
if (nv1 != CP_ACCESS_OK) {
|
||||
return nv1;
|
||||
}
|
||||
return access_scxtnum(env, ri, isread);
|
||||
}
|
||||
|
||||
static const ARMCPRegInfo scxtnum_reginfo[] = {
|
||||
{ .name = "SCXTNUM_EL0", .state = ARM_CP_STATE_AA64,
|
||||
.opc0 = 3, .opc1 = 3, .crn = 13, .crm = 0, .opc2 = 7,
|
||||
@ -8035,7 +8071,7 @@ static const ARMCPRegInfo scxtnum_reginfo[] = {
|
||||
.fieldoffset = offsetof(CPUARMState, scxtnum_el[0]) },
|
||||
{ .name = "SCXTNUM_EL1", .state = ARM_CP_STATE_AA64,
|
||||
.opc0 = 3, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 7,
|
||||
.access = PL1_RW, .accessfn = access_scxtnum,
|
||||
.access = PL1_RW, .accessfn = access_scxtnum_el1,
|
||||
.fgt = FGT_SCXTNUM_EL1,
|
||||
.fieldoffset = offsetof(CPUARMState, scxtnum_el[1]) },
|
||||
{ .name = "SCXTNUM_EL2", .state = ARM_CP_STATE_AA64,
|
||||
@ -9417,6 +9453,7 @@ void register_cp_regs_for_features(ARMCPU *cpu)
|
||||
{ .name = "VBAR", .state = ARM_CP_STATE_BOTH,
|
||||
.opc0 = 3, .crn = 12, .crm = 0, .opc1 = 0, .opc2 = 0,
|
||||
.access = PL1_RW, .writefn = vbar_write,
|
||||
.accessfn = access_nv1,
|
||||
.fgt = FGT_VBAR_EL1,
|
||||
.bank_fieldoffsets = { offsetof(CPUARMState, cp15.vbar_s),
|
||||
offsetof(CPUARMState, cp15.vbar_ns) },
|
||||
|
Loading…
Reference in New Issue
Block a user