From: Sean Christopherson Date: Wed, 11 Jun 2025 22:45:54 +0000 (-0700) Subject: KVM: x86: WARN if IRQ bypass routing is updated without in-kernel local APIC X-Git-Tag: v6.17-rc1~111^2~11^2~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25ef059e8bc51219f18fb7444aff1907960a3a53;p=thirdparty%2Fkernel%2Flinux.git KVM: x86: WARN if IRQ bypass routing is updated without in-kernel local APIC Yell if kvm_pi_update_irte() is reached without an in-kernel local APIC, as kvm_arch_irqfd_allowed() should prevent attaching an irqfd and thus any and all postable IRQs to an APIC-less VM. Link: https://lore.kernel.org/r/20250611224604.313496-53-seanjc@google.com Signed-off-by: Sean Christopherson --- diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c index 81a19d6afe44f..f87f63a53edeb 100644 --- a/arch/x86/kvm/irq.c +++ b/arch/x86/kvm/irq.c @@ -517,8 +517,8 @@ static int kvm_pi_update_irte(struct kvm_kernel_irqfd *irqfd, struct kvm_lapic_irq irq; int r; - if (!irqchip_in_kernel(kvm) || WARN_ON_ONCE(!kvm_arch_has_irq_bypass())) - return 0; + if (WARN_ON_ONCE(!irqchip_in_kernel(kvm) || !kvm_arch_has_irq_bypass())) + return -EINVAL; if (entry && entry->type == KVM_IRQ_ROUTING_MSI) { kvm_set_msi_irq(kvm, entry, &irq);