]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: SVM: Don't update IRTEs if APICv/AVIC is disabled
authorSean Christopherson <seanjc@google.com>
Tue, 1 Apr 2025 16:18:03 +0000 (09:18 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 24 Apr 2025 13:52:31 +0000 (09:52 -0400)
Skip IRTE updates if AVIC is disabled/unsupported, as forcing the IRTE
into remapped mode (kvm_vcpu_apicv_active() will never be true) is
unnecessary and wasteful.  The IOMMU driver is responsible for putting
IRTEs into remapped mode when an IRQ is allocated by a device, long before
that device is assigned to a VM.  I.e. the kernel as a whole has major
issues if the IRTE isn't already in remapped mode.

Opportunsitically kvm_arch_has_irq_bypass() to query for APICv/AVIC, so
so that all checks in KVM x86 incorporate the same information.

Cc: Yosry Ahmed <yosry.ahmed@linux.dev>
Cc: Jim Mattson <jmattson@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-ID: <20250401161804.842968-3-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm/avic.c

index 65fd245a9953ce5b1096f6041033c718daf1e899..901d8d2dc1691f1ca48763d6e14cf46cd666a6e3 100644 (file)
@@ -898,8 +898,7 @@ int avic_pi_update_irte(struct kvm *kvm, unsigned int host_irq,
        struct kvm_irq_routing_table *irq_rt;
        int idx, ret = 0;
 
-       if (!kvm_arch_has_assigned_device(kvm) ||
-           !irq_remapping_cap(IRQ_POSTING_CAP))
+       if (!kvm_arch_has_assigned_device(kvm) || !kvm_arch_has_irq_bypass())
                return 0;
 
        pr_debug("SVM: %s: host_irq=%#x, guest_irq=%#x, set=%#x\n",