]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: SVM: Fix IRQ window inhibit handling across multiple vCPUs
authorSean Christopherson <seanjc@google.com>
Fri, 23 Jan 2026 22:45:12 +0000 (14:45 -0800)
committerSean Christopherson <seanjc@google.com>
Mon, 2 Mar 2026 22:51:36 +0000 (14:51 -0800)
commit6563ddadd169cc6f509a75b3ff8354309dcb9080
tree2dda4952dc68b182502db5cdb6e8f0c26aeadd36
parent7b402ec851cb66e73ee35913c7d802bba820086b
KVM: SVM: Fix IRQ window inhibit handling across multiple vCPUs

IRQ window inhibits can be requested by multiple vCPUs at the same time
for injecting interrupts meant for different vCPUs. However, AVIC
inhibition is VM-wide and hence it is possible for the inhibition to be
cleared prematurely by the first vCPU that obtains the IRQ window even
though a second vCPU is still waiting for its IRQ window. This is likely
not a functional issue since the other vCPU will again see that
interrupts are pending to be injected (due to KVM_REQ_EVENT), and will
again request for an IRQ window inhibition. However, this can result in
AVIC being rapidly toggled resulting in high contention on
apicv_update_lock and degrading performance of the guest.

Address this by maintaining a VM-wide count of the number of vCPUs that
have requested for an IRQ window. Set/clear the inhibit reason when the
count transitions between 0 and 1. This ensures that the inhibit reason
is not cleared as long as there are some vCPUs still waiting for an IRQ
window.

Co-developed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Co-developed-by: Naveen N Rao (AMD) <naveen@kernel.org>
Signed-off-by: Naveen N Rao (AMD) <naveen@kernel.org>
Tested-by: Naveen N Rao (AMD) <naveen@kernel.org>
Link: https://patch.msgid.link/20260123224514.2509129-3-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/svm/svm.c
arch/x86/kvm/svm/svm.h
arch/x86/kvm/x86.c