]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: Don't skip per-vcpu NV initialisation
authorMarc Zyngier <maz@kernel.org>
Wed, 1 Apr 2026 10:35:57 +0000 (11:35 +0100)
committerMarc Zyngier <maz@kernel.org>
Wed, 1 Apr 2026 14:42:25 +0000 (15:42 +0100)
Some GICv5-related rework have resulted in the NV sanitisation of
registers being skipped for secondary vcpus, which is a pretty bad
idea.

Hoist the NV init early so that it is always executed.

Reviewed-by: Sascha Bischoff <sascha.bischoff@arm.com>
Fixes: cbd8c958be54a ("KVM: arm64: Return early from kvm_finalize_sys_regs() if guest has run")
Link: https://sashiko.dev/#/patchset/20260319154937.3619520-1-sascha.bischoff%40arm.com
Link: https://patch.msgid.link/20260401103611.357092-3-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/sys_regs.c

index e1001544d4f40c0eb3c51fd90526b8aaf61c9a30..18e2d2fccedb8356cd73b54196b56bbf392fa1b8 100644 (file)
@@ -5772,6 +5772,12 @@ int kvm_finalize_sys_regs(struct kvm_vcpu *vcpu)
 
        guard(mutex)(&kvm->arch.config_lock);
 
+       if (vcpu_has_nv(vcpu)) {
+               int ret = kvm_init_nv_sysregs(vcpu);
+               if (ret)
+                       return ret;
+       }
+
        if (kvm_vm_has_ran_once(kvm))
                return 0;
 
@@ -5820,12 +5826,6 @@ int kvm_finalize_sys_regs(struct kvm_vcpu *vcpu)
                kvm_vgic_finalize_idregs(kvm);
        }
 
-       if (vcpu_has_nv(vcpu)) {
-               int ret = kvm_init_nv_sysregs(vcpu);
-               if (ret)
-                       return ret;
-       }
-
        return 0;
 }