Skip to content

Commit abc693f

Browse files
committed
KVM: arm64: Describe SCTLR2_ELx RESx masks
External abort injection will soon rely on a sanitised view of SCTLR2_ELx to determine exception routing. Compute the RESx masks. Reviewed-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 7fb7660 commit abc693f

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

arch/arm64/kvm/config.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ struct reg_bits_to_feat_map {
131131
#define FEAT_SPMU ID_AA64DFR1_EL1, SPMU, IMP
132132
#define FEAT_SPE_nVM ID_AA64DFR2_EL1, SPE_nVM, IMP
133133
#define FEAT_STEP2 ID_AA64DFR2_EL1, STEP, IMP
134+
#define FEAT_SYSREG128 ID_AA64ISAR2_EL1, SYSREG_128, IMP
135+
#define FEAT_CPA2 ID_AA64ISAR3_EL1, CPA, CPA2
134136

135137
static bool not_feat_aa64el3(struct kvm *kvm)
136138
{
@@ -832,6 +834,23 @@ static const struct reg_bits_to_feat_map hcr_feat_map[] = {
832834
NEEDS_FEAT_FIXED(HCR_EL2_E2H, compute_hcr_e2h),
833835
};
834836

837+
static const struct reg_bits_to_feat_map sctlr2_feat_map[] = {
838+
NEEDS_FEAT(SCTLR2_EL1_NMEA |
839+
SCTLR2_EL1_EASE,
840+
FEAT_DoubleFault2),
841+
NEEDS_FEAT(SCTLR2_EL1_EnADERR, feat_aderr),
842+
NEEDS_FEAT(SCTLR2_EL1_EnANERR, feat_anerr),
843+
NEEDS_FEAT(SCTLR2_EL1_EnIDCP128, FEAT_SYSREG128),
844+
NEEDS_FEAT(SCTLR2_EL1_EnPACM |
845+
SCTLR2_EL1_EnPACM0,
846+
feat_pauth_lr),
847+
NEEDS_FEAT(SCTLR2_EL1_CPTA |
848+
SCTLR2_EL1_CPTA0 |
849+
SCTLR2_EL1_CPTM |
850+
SCTLR2_EL1_CPTM0,
851+
FEAT_CPA2),
852+
};
853+
835854
static void __init check_feat_map(const struct reg_bits_to_feat_map *map,
836855
int map_size, u64 res0, const char *str)
837856
{
@@ -863,6 +882,8 @@ void __init check_feature_map(void)
863882
__HCRX_EL2_RES0, "HCRX_EL2");
864883
check_feat_map(hcr_feat_map, ARRAY_SIZE(hcr_feat_map),
865884
HCR_EL2_RES0, "HCR_EL2");
885+
check_feat_map(sctlr2_feat_map, ARRAY_SIZE(sctlr2_feat_map),
886+
SCTLR2_EL1_RES0, "SCTLR2_EL1");
866887
}
867888

868889
static bool idreg_feat_match(struct kvm *kvm, const struct reg_bits_to_feat_map *map)
@@ -1077,6 +1098,13 @@ void get_reg_fixed_bits(struct kvm *kvm, enum vcpu_sysreg reg, u64 *res0, u64 *r
10771098
*res0 |= HCR_EL2_RES0 | (mask & ~fixed);
10781099
*res1 = HCR_EL2_RES1 | (mask & fixed);
10791100
break;
1101+
case SCTLR2_EL1:
1102+
case SCTLR2_EL2:
1103+
*res0 = compute_res0_bits(kvm, sctlr2_feat_map,
1104+
ARRAY_SIZE(sctlr2_feat_map), 0, 0);
1105+
*res0 |= SCTLR2_EL1_RES0;
1106+
*res1 = SCTLR2_EL1_RES1;
1107+
break;
10801108
default:
10811109
WARN_ON_ONCE(1);
10821110
*res0 = *res1 = 0;

arch/arm64/kvm/nested.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,6 +1690,12 @@ int kvm_init_nv_sysregs(struct kvm_vcpu *vcpu)
16901690
res0 |= SCTLR_EL1_EPAN;
16911691
set_sysreg_masks(kvm, SCTLR_EL1, res0, res1);
16921692

1693+
/* SCTLR2_ELx */
1694+
get_reg_fixed_bits(kvm, SCTLR2_EL1, &res0, &res1);
1695+
set_sysreg_masks(kvm, SCTLR2_EL1, res0, res1);
1696+
get_reg_fixed_bits(kvm, SCTLR2_EL2, &res0, &res1);
1697+
set_sysreg_masks(kvm, SCTLR2_EL2, res0, res1);
1698+
16931699
/* MDCR_EL2 */
16941700
res0 = MDCR_EL2_RES0;
16951701
res1 = MDCR_EL2_RES1;

0 commit comments

Comments
 (0)