From: Paolo Bonzini <pbonzini@redhat.com>
To: Sean Christopherson <seanjc@google.com>,
Joerg Roedel <joro@8bytes.org>,
David Woodhouse <dwmw2@infradead.org>,
Lu Baolu <baolu.lu@linux.intel.com>
Cc: kvm@vger.kernel.org, iommu@lists.linux.dev,
linux-kernel@vger.kernel.org, Sairaj Kodilkar <sarunkod@amd.com>,
Vasant Hegde <vasant.hegde@amd.com>,
Maxim Levitsky <mlevitsk@redhat.com>,
Joao Martins <joao.m.martins@oracle.com>,
Francesco Lavra <francescolavra.fl@gmail.com>,
David Matlack <dmatlack@google.com>
Subject: Re: [PATCH v2 00/59] KVM: iommu: Overhaul device posted IRQs support
Date: Wed, 4 Jun 2025 19:11:54 +0200 [thread overview]
Message-ID: <8b57d98d-aa53-40d9-ac5e-3f9b74643b38@redhat.com> (raw)
In-Reply-To: <20250523010004.3240643-1-seanjc@google.com>
On 5/23/25 02:59, Sean Christopherson wrote:
> TL;DR: Overhaul device posted interrupts in KVM and IOMMU, and AVIC in
> general.
>
> This applies on the series to add CONFIG_KVM_IOAPIC (and to kill irq_comm.c):
>
> https://lore.kernel.org/all/20250519232808.2745331-1-seanjc@google.com
>
> Fix a variety of bugs related to device posted IRQs, especially on the
> AMD side, and clean up KVM's implementation (this series actually removes
> more code than it adds).
>
> Stating the obvious, this series is comically large. Though it's smaller than
> v1! (Ignoring that I cheated by moving 15 patches to a prep series, and that
> Paolo already grabbed several patches).
>
> Sairaj, I applied your Tested-by somewhat sparingly, as some of the patches
> changed (most notably "Consolidate IRTE update when toggling AVIC on/off").
> Please holler if you want me to remove/add any tags. And when you get time,
> I'd greatly appreciate a sanity check!
>
> Batch #1 is mostly SVM specific:
>
> - Cleans up various warts and bugs in the IRTE tracking
> - Fixes AVIC to not reject large VMs (honor KVM's ABI)
> - Wire up AVIC to enable_ipiv to support disabling IPI virtualization while
> still utilizing device posted interrupts, and to workaround erratum #1235.
>
> Batch #3 overhauls the guts of IRQ bypass in KVM, and moves the vast majority
> of the logic to common x86; only the code that needs to communicate with the
> IOMMU is truly vendor specific.
>
> Batch #4 is more SVM/AVIC cleanups that are made possible by batch #3.
>
> Batch #5 adds WARNs and drops dead code after all the previous cleanups and
> fixes (I don't want to add the WARNs earlier; I don't see any point in adding
> WARNs in code that's known to be broken).
>
> Batch #6 is yet more SVM/AVIC cleanups, with the specific goal of configuring
> IRTEs to generate GA log interrupts if and only if KVM actually needs a wake
> event.
Looks good - it's not even that different from v1. Thanks!
Paolo
> v2:
> - Drop patches that were already merged.
> - Move code into irq.c, not x86.c. [Paolo]
> - Collect review/testing tags. [Sairaj, Vasant]
> - Sqaush fixup for a comment that was added in the prior patch. [Sairaj]
> - Rewrote the changelog for "Delete IRTE link from previous vCPU irrespective
> of new routing". [Sairaj]
> - Actually drop "struct amd_svm_iommu_ir" and all usage in "Track per-vCPU
> IRTEs using kvm_kernel_irqfd structure" (the previous version was getting
> hilarious lucky with struct offsets). [Sairaj]
> - Drop unused params from kvm_pi_update_irte() and pi_update_irte(). [Sairaj]
> - Document the rules and behavior of amd_iommu_update_ga(). [Joerg]
> - Fix a changelog typo. [Paolo]
> - Document that GALogIntr isn't cached, i.e. can be safely updated without
> an invalidation. [Joao, Vasant]
> - Rework avic_vcpu_{load,put}() to use an enumerated parameter instead of a
> series of booleans. [Paolo]
> - Drop a redundant "&& new". [Francesco]
> - Drop the *** DO NOT MERGE *** testing hack patches.
>
> v1: https://lore.kernel.org/all/20250404193923.1413163-1-seanjc@google.com
>
> Maxim Levitsky (2):
> KVM: SVM: Add enable_ipiv param, never set IsRunning if disabled
> KVM: SVM: Disable (x2)AVIC IPI virtualization if CPU has erratum #1235
>
> Sean Christopherson (57):
> KVM: x86: Pass new routing entries and irqfd when updating IRTEs
> KVM: SVM: Track per-vCPU IRTEs using kvm_kernel_irqfd structure
> KVM: SVM: Delete IRTE link from previous vCPU before setting new IRTE
> iommu/amd: KVM: SVM: Delete now-unused cached/previous GA tag fields
> KVM: SVM: Delete IRTE link from previous vCPU irrespective of new
> routing
> KVM: SVM: Drop pointless masking of default APIC base when setting
> V_APIC_BAR
> KVM: SVM: Drop pointless masking of kernel page pa's with AVIC HPA
> masks
> KVM: SVM: Add helper to deduplicate code for getting AVIC backing page
> KVM: SVM: Drop vcpu_svm's pointless avic_backing_page field
> KVM: SVM: Inhibit AVIC if ID is too big instead of rejecting vCPU
> creation
> KVM: SVM: Drop redundant check in AVIC code on ID during vCPU creation
> KVM: SVM: Track AVIC tables as natively sized pointers, not "struct
> pages"
> KVM: SVM: Drop superfluous "cache" of AVIC Physical ID entry pointer
> KVM: VMX: Move enable_ipiv knob to common x86
> KVM: VMX: Suppress PI notifications whenever the vCPU is put
> KVM: SVM: Add a comment to explain why avic_vcpu_blocking() ignores
> IRQ blocking
> iommu/amd: KVM: SVM: Use pi_desc_addr to derive ga_root_ptr
> iommu/amd: KVM: SVM: Pass NULL @vcpu_info to indicate "not guest mode"
> KVM: SVM: Stop walking list of routing table entries when updating
> IRTE
> KVM: VMX: Stop walking list of routing table entries when updating
> IRTE
> KVM: SVM: Extract SVM specific code out of get_pi_vcpu_info()
> KVM: x86: Move IRQ routing/delivery APIs from x86.c => irq.c
> KVM: x86: Nullify irqfd->producer after updating IRTEs
> KVM: x86: Dedup AVIC vs. PI code for identifying target vCPU
> KVM: x86: Move posted interrupt tracepoint to common code
> KVM: SVM: Clean up return handling in avic_pi_update_irte()
> iommu: KVM: Split "struct vcpu_data" into separate AMD vs. Intel
> structs
> KVM: Don't WARN if updating IRQ bypass route fails
> KVM: Fold kvm_arch_irqfd_route_changed() into
> kvm_arch_update_irqfd_routing()
> KVM: x86: Track irq_bypass_vcpu in common x86 code
> KVM: x86: Skip IOMMU IRTE updates if there's no old or new vCPU being
> targeted
> KVM: x86: Don't update IRTE entries when old and new routes were !MSI
> KVM: SVM: Revert IRTE to legacy mode if IOMMU doesn't provide IR
> metadata
> KVM: SVM: Take and hold ir_list_lock across IRTE updates in IOMMU
> iommu/amd: Document which IRTE fields amd_iommu_update_ga() can modify
> iommu/amd: KVM: SVM: Infer IsRun from validity of pCPU destination
> iommu/amd: Factor out helper for manipulating IRTE GA/CPU info
> iommu/amd: KVM: SVM: Set pCPU info in IRTE when setting vCPU affinity
> iommu/amd: KVM: SVM: Add IRTE metadata to affined vCPU's list if AVIC
> is inhibited
> KVM: SVM: Don't check for assigned device(s) when updating affinity
> KVM: SVM: Don't check for assigned device(s) when activating AVIC
> KVM: SVM: WARN if (de)activating guest mode in IOMMU fails
> KVM: SVM: Process all IRTEs on affinity change even if one update
> fails
> KVM: SVM: WARN if updating IRTE GA fields in IOMMU fails
> KVM: x86: Drop superfluous "has assigned device" check in
> kvm_pi_update_irte()
> KVM: x86: WARN if IRQ bypass isn't supported in kvm_pi_update_irte()
> KVM: x86: WARN if IRQ bypass routing is updated without in-kernel
> local APIC
> KVM: SVM: WARN if ir_list is non-empty at vCPU free
> KVM: x86: Decouple device assignment from IRQ bypass
> KVM: VMX: WARN if VT-d Posted IRQs aren't possible when starting IRQ
> bypass
> KVM: SVM: Use vcpu_idx, not vcpu_id, for GA log tag/metadata
> iommu/amd: WARN if KVM calls GA IRTE helpers without virtual APIC
> support
> KVM: SVM: Fold avic_set_pi_irte_mode() into its sole caller
> KVM: SVM: Don't check vCPU's blocking status when toggling AVIC on/off
> KVM: SVM: Consolidate IRTE update when toggling AVIC on/off
> iommu/amd: KVM: SVM: Allow KVM to control need for GA log interrupts
> KVM: SVM: Generate GA log IRQs only if the associated vCPUs is
> blocking
>
> arch/x86/include/asm/irq_remapping.h | 17 +-
> arch/x86/include/asm/kvm-x86-ops.h | 2 +-
> arch/x86/include/asm/kvm_host.h | 20 +-
> arch/x86/include/asm/svm.h | 13 +-
> arch/x86/kvm/irq.c | 140 ++++++
> arch/x86/kvm/svm/avic.c | 702 ++++++++++++---------------
> arch/x86/kvm/svm/svm.c | 4 +
> arch/x86/kvm/svm/svm.h | 32 +-
> arch/x86/kvm/trace.h | 19 +-
> arch/x86/kvm/vmx/capabilities.h | 1 -
> arch/x86/kvm/vmx/main.c | 2 +-
> arch/x86/kvm/vmx/posted_intr.c | 140 ++----
> arch/x86/kvm/vmx/posted_intr.h | 10 +-
> arch/x86/kvm/vmx/vmx.c | 2 -
> arch/x86/kvm/x86.c | 90 +---
> drivers/iommu/amd/amd_iommu_types.h | 1 -
> drivers/iommu/amd/iommu.c | 125 +++--
> drivers/iommu/intel/irq_remapping.c | 10 +-
> include/linux/amd-iommu.h | 25 +-
> include/linux/kvm_host.h | 9 +-
> include/linux/kvm_irqfd.h | 4 +
> virt/kvm/eventfd.c | 22 +-
> 22 files changed, 672 insertions(+), 718 deletions(-)
>
>
> base-commit: 3debd5461fba1dcb33e732b16153da0cf5d0c251
next prev parent reply other threads:[~2025-06-04 17:12 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-23 0:59 Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 01/59] KVM: x86: Pass new routing entries and irqfd when updating IRTEs Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 02/59] KVM: SVM: Track per-vCPU IRTEs using kvm_kernel_irqfd structure Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 03/59] KVM: SVM: Delete IRTE link from previous vCPU before setting new IRTE Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 04/59] iommu/amd: KVM: SVM: Delete now-unused cached/previous GA tag fields Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 05/59] KVM: SVM: Delete IRTE link from previous vCPU irrespective of new routing Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 06/59] KVM: SVM: Drop pointless masking of default APIC base when setting V_APIC_BAR Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 07/59] KVM: SVM: Drop pointless masking of kernel page pa's with AVIC HPA masks Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 08/59] KVM: SVM: Add helper to deduplicate code for getting AVIC backing page Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 09/59] KVM: SVM: Drop vcpu_svm's pointless avic_backing_page field Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 10/59] KVM: SVM: Inhibit AVIC if ID is too big instead of rejecting vCPU creation Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 11/59] KVM: SVM: Drop redundant check in AVIC code on ID during " Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 12/59] KVM: SVM: Track AVIC tables as natively sized pointers, not "struct pages" Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 13/59] KVM: SVM: Drop superfluous "cache" of AVIC Physical ID entry pointer Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 14/59] KVM: VMX: Move enable_ipiv knob to common x86 Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 15/59] KVM: SVM: Add enable_ipiv param, never set IsRunning if disabled Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 16/59] KVM: SVM: Disable (x2)AVIC IPI virtualization if CPU has erratum #1235 Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 17/59] KVM: VMX: Suppress PI notifications whenever the vCPU is put Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 18/59] KVM: SVM: Add a comment to explain why avic_vcpu_blocking() ignores IRQ blocking Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 19/59] iommu/amd: KVM: SVM: Use pi_desc_addr to derive ga_root_ptr Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 20/59] iommu/amd: KVM: SVM: Pass NULL @vcpu_info to indicate "not guest mode" Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 21/59] KVM: SVM: Stop walking list of routing table entries when updating IRTE Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 22/59] KVM: VMX: " Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 23/59] KVM: SVM: Extract SVM specific code out of get_pi_vcpu_info() Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 24/59] KVM: x86: Move IRQ routing/delivery APIs from x86.c => irq.c Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 25/59] KVM: x86: Nullify irqfd->producer after updating IRTEs Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 26/59] KVM: x86: Dedup AVIC vs. PI code for identifying target vCPU Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 27/59] KVM: x86: Move posted interrupt tracepoint to common code Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 28/59] KVM: SVM: Clean up return handling in avic_pi_update_irte() Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 29/59] iommu: KVM: Split "struct vcpu_data" into separate AMD vs. Intel structs Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 30/59] KVM: Don't WARN if updating IRQ bypass route fails Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 31/59] KVM: Fold kvm_arch_irqfd_route_changed() into kvm_arch_update_irqfd_routing() Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 32/59] KVM: x86: Track irq_bypass_vcpu in common x86 code Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 33/59] KVM: x86: Skip IOMMU IRTE updates if there's no old or new vCPU being targeted Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 34/59] KVM: x86: Don't update IRTE entries when old and new routes were !MSI Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 35/59] KVM: SVM: Revert IRTE to legacy mode if IOMMU doesn't provide IR metadata Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 36/59] KVM: SVM: Take and hold ir_list_lock across IRTE updates in IOMMU Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 37/59] iommu/amd: Document which IRTE fields amd_iommu_update_ga() can modify Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 38/59] iommu/amd: KVM: SVM: Infer IsRun from validity of pCPU destination Sean Christopherson
2025-05-30 10:13 ` Sairaj Kodilkar
2025-06-02 21:59 ` Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 39/59] iommu/amd: Factor out helper for manipulating IRTE GA/CPU info Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 40/59] iommu/amd: KVM: SVM: Set pCPU info in IRTE when setting vCPU affinity Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 41/59] iommu/amd: KVM: SVM: Add IRTE metadata to affined vCPU's list if AVIC is inhibited Sean Christopherson
2025-05-30 10:06 ` Sairaj Kodilkar
2025-06-02 22:26 ` Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 42/59] KVM: SVM: Don't check for assigned device(s) when updating affinity Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 43/59] KVM: SVM: Don't check for assigned device(s) when activating AVIC Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 44/59] KVM: SVM: WARN if (de)activating guest mode in IOMMU fails Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 45/59] KVM: SVM: Process all IRTEs on affinity change even if one update fails Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 46/59] KVM: SVM: WARN if updating IRTE GA fields in IOMMU fails Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 47/59] KVM: x86: Drop superfluous "has assigned device" check in kvm_pi_update_irte() Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 48/59] KVM: x86: WARN if IRQ bypass isn't supported " Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 49/59] KVM: x86: WARN if IRQ bypass routing is updated without in-kernel local APIC Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 50/59] KVM: SVM: WARN if ir_list is non-empty at vCPU free Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 51/59] KVM: x86: Decouple device assignment from IRQ bypass Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 52/59] KVM: VMX: WARN if VT-d Posted IRQs aren't possible when starting " Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 53/59] KVM: SVM: Use vcpu_idx, not vcpu_id, for GA log tag/metadata Sean Christopherson
2025-05-23 0:59 ` [PATCH v2 54/59] iommu/amd: WARN if KVM calls GA IRTE helpers without virtual APIC support Sean Christopherson
2025-05-23 1:00 ` [PATCH v2 55/59] KVM: SVM: Fold avic_set_pi_irte_mode() into its sole caller Sean Christopherson
2025-05-23 1:00 ` [PATCH v2 56/59] KVM: SVM: Don't check vCPU's blocking status when toggling AVIC on/off Sean Christopherson
2025-05-23 1:00 ` [PATCH v2 57/59] KVM: SVM: Consolidate IRTE update " Sean Christopherson
2025-05-23 1:00 ` [PATCH v2 58/59] iommu/amd: KVM: SVM: Allow KVM to control need for GA log interrupts Sean Christopherson
2025-05-23 1:00 ` [PATCH v2 59/59] KVM: SVM: Generate GA log IRQs only if the associated vCPUs is blocking Sean Christopherson
2025-06-04 17:11 ` Paolo Bonzini [this message]
2025-06-09 12:20 ` Re:[PATCH v2 00/59] KVM: iommu: Overhaul device posted IRQs support Sairaj Kodilkar
2025-06-09 14:34 ` [PATCH " Sean Christopherson
2025-06-12 11:03 ` Sairaj Kodilkar
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=8b57d98d-aa53-40d9-ac5e-3f9b74643b38@redhat.com \
--to=pbonzini@redhat.com \
--cc=baolu.lu@linux.intel.com \
--cc=dmatlack@google.com \
--cc=dwmw2@infradead.org \
--cc=francescolavra.fl@gmail.com \
--cc=iommu@lists.linux.dev \
--cc=joao.m.martins@oracle.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mlevitsk@redhat.com \
--cc=sarunkod@amd.com \
--cc=seanjc@google.com \
--cc=vasant.hegde@amd.com \
/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
all inboxes | Powered by JetHome®