]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: Enforce absence of FEAT_SCTLR2 on SCTLR2_EL{1,2}
authorMarc Zyngier <maz@kernel.org>
Thu, 18 Sep 2025 15:13:59 +0000 (16:13 +0100)
committerMarc Zyngier <maz@kernel.org>
Fri, 19 Sep 2025 12:43:26 +0000 (13:43 +0100)
Enforce that SCTLR2_EL{1,2} are RES0 when FEAT_SCTLR2 isn't present.

Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/config.c

index a6d3701e28707fc925269be33361842727a5ddc1..5927ef89778fab1bf24dcfecce0cb480e97a8f87 100644 (file)
@@ -1026,6 +1026,9 @@ static const struct reg_bits_to_feat_map sctlr2_feat_map[] = {
                   FEAT_CPA2),
 };
 
+static const DECLARE_FEAT_MAP(sctlr2_desc, SCTLR2_EL1,
+                             sctlr2_feat_map, FEAT_SCTLR2);
+
 static const struct reg_bits_to_feat_map tcr2_el2_feat_map[] = {
        NEEDS_FEAT(TCR2_EL2_FNG1        |
                   TCR2_EL2_FNG0        |
@@ -1192,8 +1195,7 @@ void __init check_feature_map(void)
        check_reg_desc(&hdfgwtr2_desc);
        check_reg_desc(&hcrx_desc);
        check_reg_desc(&hcr_desc);
-       check_feat_map(sctlr2_feat_map, ARRAY_SIZE(sctlr2_feat_map),
-                      SCTLR2_EL1_RES0, "SCTLR2_EL1");
+       check_reg_desc(&sctlr2_desc);
        check_feat_map(tcr2_el2_feat_map, ARRAY_SIZE(tcr2_el2_feat_map),
                       TCR2_EL2_RES0, "TCR2_EL2");
        check_feat_map(sctlr_el1_feat_map, ARRAY_SIZE(sctlr_el1_feat_map),
@@ -1399,9 +1401,7 @@ void get_reg_fixed_bits(struct kvm *kvm, enum vcpu_sysreg reg, u64 *res0, u64 *r
                break;
        case SCTLR2_EL1:
        case SCTLR2_EL2:
-               *res0 = compute_res0_bits(kvm, sctlr2_feat_map,
-                                         ARRAY_SIZE(sctlr2_feat_map), 0, 0);
-               *res0 |= SCTLR2_EL1_RES0;
+               *res0 = compute_reg_res0_bits(kvm, &sctlr2_desc, 0, 0);
                *res1 = SCTLR2_EL1_RES1;
                break;
        case TCR2_EL2: