public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Sean Christopherson <seanjc@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Yosry Ahmed <yosry.ahmed@linux.dev>
Subject: [PATCH v2 2/3] KVM: SVM: Don't update IRTEs if APICv/AVIC is disable
Date: Thu, 20 Mar 2025 07:20:21 -0700	[thread overview]
Message-ID: <20250320142022.766201-3-seanjc@google.com> (raw)
In-Reply-To: <20250320142022.766201-1-seanjc@google.com>

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>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 arch/x86/kvm/svm/avic.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c
index 65fd245a9953..901d8d2dc169 100644
--- a/arch/x86/kvm/svm/avic.c
+++ b/arch/x86/kvm/svm/avic.c
@@ -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",
-- 
2.49.0.395.g12beb8f557-goog


  parent reply	other threads:[~2025-03-20 14:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-20 14:20 [PATCH v2 0/3] KVM: x86: Add a module param for device posted IRQs Sean Christopherson
2025-03-20 14:20 ` [PATCH v2 1/3] KVM: VMX: Don't send UNBLOCK when starting device assignment without APICv Sean Christopherson
2025-03-20 14:20 ` Sean Christopherson [this message]
2025-03-20 16:08   ` [PATCH v2 2/3] KVM: SVM: Don't update IRTEs if APICv/AVIC is disable Jim Mattson
2025-03-20 14:20 ` [PATCH v2 3/3] KVM: x86: Add a module param to control and enumerate device posted IRQs Sean Christopherson
2025-03-20 16:02   ` Jim Mattson
2025-03-20 17:54     ` Sean Christopherson
2025-03-20 17:59   ` Sean Christopherson
2025-03-20 18:14     ` Yosry Ahmed
2025-03-21  1:57     ` Chao Gao
2025-03-21 20:44       ` Sean Christopherson
2025-03-24  9:26         ` Chao Gao
2025-03-24 13:41           ` Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250320142022.766201-3-seanjc@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=yosry.ahmed@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox