From: sashiko-bot@kernel.org
To: "Sairaj Kodilkar" <sarunkod@amd.com>
Cc: kvm@vger.kernel.org
Subject: Re: [RFC PATCH v3 3/6] iommu/amd: KVM: SVM: Add explicit vCPU running state to IOMMU interface
Date: Mon, 13 Jul 2026 11:08:58 +0000 [thread overview]
Message-ID: <20260713110858.EAEF31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260713105033.15405-4-sarunkod@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] KVM continues to infer the vCPU running state via `is_running = apicid >= 0`, completely defeating the purpose of the newly decoupled IOMMU API.
--
--- Patch [3]: [RFC PATCH v3 3/6] iommu/amd: KVM: SVM: Add explicit vCPU running state to IOMMU interface ---
commit bbb2175fc26e0d5c105e610aeee4bcf1fe796a2d
Author: Sairaj Kodilkar <sarunkod@amd.com>
iommu/amd: KVM: SVM: Add explicit vCPU running state to IOMMU interface
This commit adds an explicit is_running parameter to the AMD IOMMU guest
mode interface. It states that this decoupling is necessary for GAPPI to
pass a valid destination apicid when a vCPU is not running. The change
intends to allow KVM to pass the vCPU running state explicitly rather than
inferring it from the apicid value.
> diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c
> index 8e87a7f2f64f7..3b2d92a587098 100644
> --- a/arch/x86/kvm/svm/avic.c
> +++ b/arch/x86/kvm/svm/avic.c
[ ... ]
> @@ -1008,6 +1010,7 @@ static void avic_update_iommu_vcpu_affinity(struct kvm_vcpu *vcpu, int apicid,
> enum avic_vcpu_action action)
> {
> bool wakeup_intr = (action & AVIC_START_BLOCKING);
> + bool is_running = apicid >= 0;
[Severity: Medium]
Does this assignment defeat the purpose of the API decoupling described
in the commit message?
The commit message states that KVM must supply a valid apicid even when
the vCPU is not running, and that we can no longer derive the vCPU running
state from the apicid alone.
However, by defining is_running as apicid >= 0 here in
avic_update_iommu_vcpu_affinity(), aren't we continuing to infer the
running state directly from the apicid?
If a caller attempts to pass a valid GAPPI destination APIC ID for a
scheduled-out vCPU, won't this helper erroneously force is_running to true?
Because of this hardcoded logic, other KVM paths handling scheduled-out
vCPUs would be forced to continue passing -1 for the APIC ID rather than
a valid GAPPI destination.
> struct vcpu_svm *svm = to_svm(vcpu);
> struct kvm_kernel_irqfd *irqfd;
>
[ ... ]
> @@ -1024,9 +1027,10 @@ static void avic_update_iommu_vcpu_affinity(struct kvm_vcpu *vcpu, int apicid,
> void *data = irqfd->irq_bypass_data;
>
> if (!(action & AVIC_TOGGLE_ON_OFF))
> - WARN_ON_ONCE(amd_iommu_update_ga(data, apicid, wakeup_intr));
> - else if (apicid >= 0)
> - WARN_ON_ONCE(amd_iommu_activate_guest_mode(data, apicid, wakeup_intr));
> + WARN_ON_ONCE(amd_iommu_update_ga(data, apicid, wakeup_intr, is_running));
> + else if (is_running)
> + WARN_ON_ONCE(amd_iommu_activate_guest_mode(data, apicid, wakeup_intr,
> + is_running));
> else
> WARN_ON_ONCE(amd_iommu_deactivate_guest_mode(data));
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260713105033.15405-1-sarunkod@amd.com?part=3
next prev parent reply other threads:[~2026-07-13 11:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 10:50 [RFC PATCH v3 0/6] Add support for AMD IOMMU GAPPI Sairaj Kodilkar
2026-07-13 10:50 ` [RFC PATCH v3 1/6] iommu/amd: KVM: SVM: Rename cpu to apicid in IOMMU interface Sairaj Kodilkar
2026-07-13 10:50 ` [RFC PATCH v3 2/6] iommu/amd: KVM: SVM: Rename ga_log_intr to wakeup_intr " Sairaj Kodilkar
2026-07-13 10:50 ` [RFC PATCH v3 3/6] iommu/amd: KVM: SVM: Add explicit vCPU running state to " Sairaj Kodilkar
2026-07-13 11:08 ` sashiko-bot [this message]
2026-07-13 10:50 ` [RFC PATCH v3 4/6] iommu/amd: Program guest-mode IRTEs for GAPPI wakeup when IRTE[IsRun] = 0 Sairaj Kodilkar
2026-07-13 11:07 ` sashiko-bot
2026-07-13 10:50 ` [RFC PATCH v3 5/6] KVM: SVM: Add support for AMD IOMMU Guest APIC Physical Processor Interrupt (GAPPI) Sairaj Kodilkar
2026-07-13 11:11 ` sashiko-bot
2026-07-13 12:56 ` Sairaj Kodilkar
2026-07-13 10:50 ` [RFC PATCH v3 6/6] iommu/amd: Provide kernel command line option to enable GAPPI Sairaj Kodilkar
2026-07-13 11:11 ` sashiko-bot
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=20260713110858.EAEF31F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=sarunkod@amd.com \
--cc=sashiko-reviews@lists.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