]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: Clarify the check for reset callback in check_sysreg_table()
authorMarc Zyngier <maz@kernel.org>
Fri, 18 Jul 2025 11:11:52 +0000 (12:11 +0100)
committerOliver Upton <oliver.upton@linux.dev>
Sat, 26 Jul 2025 15:36:57 +0000 (08:36 -0700)
check_sysreg_table() has a wonky 'is_32" parameter, which is really
an indication that we should enforce the presence of a reset helper.

Clean this up by naming the variable accordingly and inverting the
condition. Contrary to popular belief, system instructions don't
have a reset value (duh!), and therefore do not need to be checked
for reset (they escaped the check through luck...).

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

index 554c7145ec1cda12848c92848358110e0e544cbb..765d8659eed45bf43b12829f26c95c1ff75222dd 100644 (file)
@@ -4304,12 +4304,12 @@ static const struct sys_reg_desc cp15_64_regs[] = {
 };
 
 static bool check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
-                              bool is_32)
+                              bool reset_check)
 {
        unsigned int i;
 
        for (i = 0; i < n; i++) {
-               if (!is_32 && table[i].reg && !table[i].reset) {
+               if (reset_check && table[i].reg && !table[i].reset) {
                        kvm_err("sys_reg table %pS entry %d (%s) lacks reset\n",
                                &table[i], i, table[i].name);
                        return false;
@@ -5303,11 +5303,11 @@ int __init kvm_sys_reg_table_init(void)
        int ret = 0;
 
        /* Make sure tables are unique and in order. */
-       valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs), false);
-       valid &= check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), true);
-       valid &= check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), true);
-       valid &= check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), true);
-       valid &= check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), true);
+       valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs), true);
+       valid &= check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), false);
+       valid &= check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), false);
+       valid &= check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), false);
+       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);
 
        if (!valid)