Re: [PATCH v4 3/7] iommu/amd: KVM: SVM: Add explicit vCPU running state to IOMMU interface

Vasant Hegde <[email protected]>
Newsgroups dev.linux.lists.linux-coco,dev.linux.lists.iommu,org.kernel.vger.kvm,org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel
Message-ID <[email protected]>

On 8/21/2026 11:26 AM, Sairaj Kodilkar wrote:
> Guest APIC Physical Processor Interrupt (GAPPI) is an AMD IOMMU mechanism
> for notifying the host when a device interrupt targets a non-running vCPU
> (IRTE[IsRun] = 0). Unlike the GA log path, GAPPI delivers a physical APIC
> interrupt directly to the host CPU described by IRTE[Destination], with
> the vector carried in IRTE[GATag], while still posting the interrupt into
> the guest virtual APIC backing page as usual.
> 
> In GAPPI mode, the IOMMU delivers the notification to the host CPU using
> the physical APIC ID in IRTE[Destination] and the vector in IRTE[GATag].
> KVM must therefore supply a valid apicid even when the vCPU is not running.
> The prior interface inferred running state from apicid: apicid >= 0 meant
> running and apicid == -1 meant not running. That encoding breaks once
> apicid carries the GAPPI destination while the vCPU is not running; the
> IOMMU driver can no longer derive vCPU running state from apicid alone
> and needs an explicit indication from KVM.
> 
> Add an explicit is_running indication to the IOMMU interface so that
> SVM can pass vCPU running state to the IOMMU.
> 
> SVM calls amd_iommu_activate_guest_mode() only when the vCPU is running,
> so keep is_running out of the exported prototype and make it a thin
> wrapper that hardcodes is_running = true. The IOMMU internal caller,
> amd_ir_set_vcpu_affinity(), calls __amd_iommu_activate_guest_mode()
> directly and passes the running state supplied by KVM, i.e. it handles
> both a running and a non-running vCPU.
> 
> No functional change is intended.
> 
> Signed-off-by: Sairaj Kodilkar <[email protected]>

Reviewed-by: Vasant Hegde <[email protected]>

-Vasant
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.