From: sashiko-bot@kernel.org
To: "Sairaj Kodilkar" <sarunkod@amd.com>, kvm@vger.kernel.org
Subject: Re: [PATCH v6 7/7] iommu/amd: Provide kernel command line option to enable GAPPI
Date: Thu, 22 Oct 2026 14:23:26 +0000 [thread overview]
Message-ID: <sashiko-outbox-181630@kernel.org> (raw)
In-Reply-To: <20261022140425.27465-8-sarunkod@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] iommu/amd: enable_iommus_vapic() leaves amd_iommu_gappi true on early return
--
commit 2f329c3e02b74f486082bc1f7b970f7b86fabe68
Author: Sairaj Kodilkar <sarunkod@amd.com>
iommu/amd: Provide kernel command line option to enable GAPPI
This commit adds the amd_iommu=gappi kernel command-line parameter to enable
GAPPI when the hardware supports FEATURE_GAPPI and Virtual APIC mode is
active, along with documentation for the new option.
> diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
> index 78e3c14dc1c28..72394c92a3fa0 100644
> --- a/drivers/iommu/amd/init.c
> +++ b/drivers/iommu/amd/init.c
[ ... ]
> @@ -3027,10 +3037,19 @@ static void enable_iommus_vapic(void)
> return;
> }
>
> + if (amd_iommu_gappi &&
> + !(check_feature(FEATURE_GAPPI) &&
> + AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir))) {
> + pr_warn("GAPPI is not supported.\n");
> + amd_iommu_gappi = false;
> + }
[Severity: Medium]
In drivers/iommu/amd/init.c, parse_amd_iommu_options() sets the exported
global amd_iommu_gappi to true during early boot when amd_iommu=gappi is
passed on the command line (with CONFIG_IRQ_REMAP enabled):
drivers/iommu/amd/init.c:parse_amd_iommu_options() {
...
} else if (strncmp(str, "gappi", 5) == 0) {
#ifdef CONFIG_IRQ_REMAP
amd_iommu_gappi = true;
#else
pr_warn("amd_iommu=gappi ignored, IRQ remapping is not enabled\n");
#endif
}
...
}
However, earlier in enable_iommus_vapic(), all paths where Virtual APIC mode
is not enabled or gets downgraded to legacy GA mode return before reaching
this check:
drivers/iommu/amd/init.c:enable_iommus_vapic() {
...
if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir))
return;
if (!check_feature(FEATURE_GAM_VAPIC)) {
amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY_GA;
return;
}
if (amd_iommu_snp_en &&
!FEATURE_SNPAVICSUP_GAM(amd_iommu_efr2)) {
pr_warn("Force to disable Virtual APIC due to SNP\n");
amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY_GA;
return;
}
...
}
Doesn't this mean AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) is always true
when this check is reached, leaving amd_iommu_gappi set to true whenever
enable_iommus_vapic() returns early (including on the
MMIO_STATUS_GALOG_RUN_MASK poll timeout) or is never called because the
IOMMU is disabled?
When amd_iommu_gappi remains true while IOMMU Virtual APIC and
CONTROL_GAPPI_EN are not enabled, avic_update_iommu_vcpu_affinity() and
avic_vcpu_free() in arch/x86/kvm/svm/avic.c still see amd_iommu_gappi set
before checking list_empty(&svm->ir_list):
arch/x86/kvm/svm/avic.c:avic_update_iommu_vcpu_affinity() {
...
if (amd_iommu_gappi && is_running) {
kvm_pi_disable_wakeup_handler(vcpu, svm->gappi_cpu);
svm->gappi_cpu = cpu; /* Store cpu number as target for GAPPI */
} else if (amd_iommu_gappi && wakeup_intr) {
apicid = cpu_physical_id(svm->gappi_cpu);
kvm_pi_enable_wakeup_handler(vcpu, svm->gappi_cpu);
}
if (list_empty(&svm->ir_list))
return 0;
...
}
Wouldn't that cause KVM to unnecessarily call kvm_pi_enable_wakeup_handler()
and kvm_pi_disable_wakeup_handler() on every vCPU load, block, and free when
running guests with AVIC enabled?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261022140425.27465-1-sarunkod@amd.com?part=7
prev parent reply other threads:[~2026-10-22 14:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 14:04 [PATCH v6 0/7] Add support for AMD IOMMU GAPPI Sairaj Kodilkar
2026-10-22 14:04 ` [PATCH v6 1/7] iommu/amd: KVM: SVM: Rename cpu to apicid in IOMMU interface Sairaj Kodilkar
2026-10-22 14:04 ` [PATCH v6 2/7] iommu/amd: KVM: SVM: Rename ga_log_intr to wakeup_intr " Sairaj Kodilkar
2026-10-22 14:04 ` [PATCH v6 3/7] iommu/amd: KVM: SVM: Add explicit vCPU running state to " Sairaj Kodilkar
2026-10-22 14:04 ` [PATCH v6 4/7] iommu/amd: Program guest-mode IRTEs for GAPPI wakeup when IRTE[IsRun] = 0 Sairaj Kodilkar
2026-10-22 14:04 ` [PATCH v6 5/7] KVM: VMX: Factor out wakeup list handling code to KVM Sairaj Kodilkar
2026-10-22 14:04 ` [PATCH v6 6/7] KVM: SVM: Add support for AMD IOMMU Guest APIC Physical Processor Interrupt (GAPPI) Sairaj Kodilkar
2026-10-22 14:32 ` sashiko-bot
2026-10-23 5:53 ` Sairaj Kodilkar
2026-10-22 14:04 ` [PATCH v6 7/7] iommu/amd: Provide kernel command line option to enable GAPPI Sairaj Kodilkar
2026-10-22 14:23 ` sashiko-bot [this message]
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=sashiko-outbox-181630@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.