]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: Enforce the sorting of the GICv3 system register table
authorMarc Zyngier <maz@kernel.org>
Fri, 18 Jul 2025 11:11:53 +0000 (12:11 +0100)
committerOliver Upton <oliver.upton@linux.dev>
Sat, 26 Jul 2025 15:36:58 +0000 (08:36 -0700)
In order to avoid further embarassing bugs, enforce that the GICv3
sysreg table is actually sorted, just like all the other tables.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Sebastian Ott <sebott@redhat.com>
Link: https://lore.kernel.org/r/20250718111154.104029-4-maz@kernel.org
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
arch/arm64/kvm/sys_regs.c
arch/arm64/kvm/vgic-sys-reg-v3.c
arch/arm64/kvm/vgic/vgic.h

index 765d8659eed45bf43b12829f26c95c1ff75222dd..61bfe90efa20c4ceaf632eae4e5a0c7a0b73309a 100644 (file)
@@ -5298,8 +5298,9 @@ int kvm_finalize_sys_regs(struct kvm_vcpu *vcpu)
 
 int __init kvm_sys_reg_table_init(void)
 {
+       const struct sys_reg_desc *gicv3_regs;
        bool valid = true;
-       unsigned int i;
+       unsigned int i, sz;
        int ret = 0;
 
        /* Make sure tables are unique and in order. */
@@ -5310,6 +5311,9 @@ int __init kvm_sys_reg_table_init(void)
        valid &= check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), false);
        valid &= check_sysreg_table(sys_insn_descs, ARRAY_SIZE(sys_insn_descs), false);
 
+       gicv3_regs = vgic_v3_get_sysreg_table(&sz);
+       valid &= check_sysreg_table(gicv3_regs, sz, false);
+
        if (!valid)
                return -EINVAL;
 
index 1850f1727eb935792b4b862a58218f81f497a9d3..bdc2d57370b27ebf3b20b883a732dc88eb0293e2 100644 (file)
@@ -443,6 +443,12 @@ static const struct sys_reg_desc gic_v3_icc_reg_descs[] = {
        EL2_REG(ICH_LR15_EL2, ich_reg),
 };
 
+const struct sys_reg_desc *vgic_v3_get_sysreg_table(unsigned int *sz)
+{
+       *sz = ARRAY_SIZE(gic_v3_icc_reg_descs);
+       return gic_v3_icc_reg_descs;
+}
+
 static u64 attr_to_id(u64 attr)
 {
        return ARM64_SYS_REG(FIELD_GET(KVM_REG_ARM_VGIC_SYSREG_OP0_MASK, attr),
index 67233fa04e709d576e197d202abb57dfa92f4785..4f8694ffde46e2e80192cf92cb431770d6954bb6 100644 (file)
@@ -315,6 +315,7 @@ int vgic_v3_redist_uaccess(struct kvm_vcpu *vcpu, bool is_write,
 int vgic_v3_cpu_sysregs_uaccess(struct kvm_vcpu *vcpu,
                                struct kvm_device_attr *attr, bool is_write);
 int vgic_v3_has_cpu_sysregs_attr(struct kvm_vcpu *vcpu, struct kvm_device_attr *attr);
+const struct sys_reg_desc *vgic_v3_get_sysreg_table(unsigned int *sz);
 int vgic_v3_line_level_info_uaccess(struct kvm_vcpu *vcpu, bool is_write,
                                    u32 intid, u32 *val);
 int kvm_register_vgic_device(unsigned long type);