Skip to content

Commit a0ca34b

Browse files
committed
KVM: SVM: Delete IRTE link from previous vCPU irrespective of new routing
Delete the IRTE link from the previous vCPU irrespective of the new routing state, i.e. even if the IRTE won't be configured to post IRQs to a vCPU. Whether or not the new route is postable as no bearing on the *old* route. Failure to delete the link can result in KVM incorrectly updating the IRTE, e.g. if the "old" vCPU is scheduled in/out. Fixes: 411b44b ("svm: Implements update_pi_irte hook to setup posted interrupt") Tested-by: Sairaj Kodilkar <sarunkod@amd.com> Link: https://lore.kernel.org/r/20250611224604.313496-9-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 1da19c5 commit a0ca34b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arch/x86/kvm/svm/avic.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,12 @@ int avic_pi_update_irte(struct kvm_kernel_irqfd *irqfd, struct kvm *kvm,
862862
if (!kvm_arch_has_assigned_device(kvm) || !kvm_arch_has_irq_bypass())
863863
return 0;
864864

865+
/*
866+
* If the IRQ was affined to a different vCPU, remove the IRTE metadata
867+
* from the *previous* vCPU's list.
868+
*/
869+
svm_ir_list_del(irqfd);
870+
865871
pr_debug("SVM: %s: host_irq=%#x, guest_irq=%#x, set=%#x\n",
866872
__func__, host_irq, guest_irq, set);
867873

@@ -884,8 +890,6 @@ int avic_pi_update_irte(struct kvm_kernel_irqfd *irqfd, struct kvm *kvm,
884890

885891
WARN_ON_ONCE(new && memcmp(e, new, sizeof(*new)));
886892

887-
svm_ir_list_del(irqfd);
888-
889893
/**
890894
* Here, we setup with legacy mode in the following cases:
891895
* 1. When cannot target interrupt to a specific vcpu.

0 commit comments

Comments
 (0)