]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
KVM: arm64: nv: Properly check ESR_EL2.VNCR on taking a VNCR_EL2 related fault
authorMarc Zyngier <maz@kernel.org>
Wed, 30 Jul 2025 10:18:28 +0000 (11:18 +0100)
committerOliver Upton <oliver.upton@linux.dev>
Tue, 5 Aug 2025 05:15:29 +0000 (22:15 -0700)
Instead of checking for the ESR_EL2.VNCR bit being set (the only case
we should be here), we are actually testing random bits in ESR_EL2.DFSC.

13 obviously being a lucky number, it matches both permission and
translation fault status codes, which explains why we never saw it
failing. This was found by inspection, while reviewing a vaguely
related patch.

Whilst we're at it, turn the BUG_ON() into a WARN_ON_ONCE(), as
exploding here is just silly.

Fixes: 069a05e535496 ("KVM: arm64: nv: Handle VNCR_EL2-triggered faults")
Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Joey Gouly <joey.gouly@arm.com>
Link: https://lore.kernel.org/r/20250730101828.1168707-1-maz@kernel.org
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
arch/arm64/kvm/nested.c

index efb37aad11ece704906a13dfc052e2f5ba3655ec..74a2a94dad9bafbeb6c6a13ad006c7884eb2834c 100644 (file)
@@ -1287,7 +1287,7 @@ int kvm_handle_vncr_abort(struct kvm_vcpu *vcpu)
        struct vncr_tlb *vt = vcpu->arch.vncr_tlb;
        u64 esr = kvm_vcpu_get_esr(vcpu);
 
-       BUG_ON(!(esr & ESR_ELx_VNCR_SHIFT));
+       WARN_ON_ONCE(!(esr & ESR_ELx_VNCR));
 
        if (esr_fsc_is_permission_fault(esr)) {
                inject_vncr_perm(vcpu);