All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sairaj Kodilkar" <sarunkod@amd.com>, kvm@vger.kernel.org
Subject: Re: [PATCH v7 7/7] iommu/amd: Provide kernel command line option to enable GAPPI
Date: Wed, 11 Nov 2026 07:06:00 +0000	[thread overview]
Message-ID: <sashiko-outbox-208489@kernel.org> (raw)
In-Reply-To: <20261111064242.29336-8-sarunkod@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] iommu/amd: enable_iommus_vapic() leaves amd_iommu_gappi true
  on early return
--

commit c24e6331ec8e811c471b1e85ddce5dfb41ecad29
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 option to enable
GAPPI when the IOMMU GAPPISup extended feature bit is supported, and
documents the option and mechanism.

> diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
> index 054ef7262f3cc..6a248327047ac 100644
> --- a/drivers/iommu/amd/init.c
> +++ b/drivers/iommu/amd/init.c

[ ... ]

> @@ -3131,18 +3141,27 @@ static void enable_iommus_vapic(void)
>  	if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir))
>  		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]
Does the early return when !AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)
make the AMD_IOMMU_GUEST_IR_VAPIC() check right below it unreachable when
false and leave amd_iommu_gappi set to true?

parse_amd_iommu_options() sets amd_iommu_gappi = true before Virtual APIC
support is validated.  If the kernel is booted with amd_iommu=gappi and
IOMMU Virtual APIC is disabled or downgraded (for example with
amd_iommu_intr=legacy or when check_vapic_support() falls back to legacy
GA mode), enable_iommus_vapic() returns before clearing amd_iommu_gappi
(and likewise if the IOMMU is disabled or fails to initialize).

When CPU AVIC is active in KVM SVM, avic_update_iommu_vcpu_affinity() and
avic_vcpu_free() check amd_iommu_gappi before checking whether the vCPU
has any IOMMU IRTEs:

arch/x86/kvm/svm/avic.c:avic_update_iommu_vcpu_affinity() {
	...
	if (!amd_iommu_gappi)
		goto skip_wakeup_handler;
	...
	if (is_running) {
		kvm_pi_disable_wakeup_handler(vcpu, svm->gappi_cpu);
		svm->gappi_cpu = cpu;
	} else {
		apicid = cpu_physical_id(svm->gappi_cpu);
		kvm_pi_enable_wakeup_handler(vcpu, svm->gappi_cpu);
	}

skip_wakeup_handler:
	if (list_empty(&svm->ir_list))
		return;
	...
}

Leaving amd_iommu_gappi set to true when CONTROL_GAPPI_EN is not enabled
causes KVM to register and unregister per-CPU wakeup handlers on every
vCPU load, put, block, and free even though IOMMU Virtual APIC is not in
use.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261111064242.29336-1-sarunkod@amd.com?part=7

      reply	other threads:[~2026-11-11  7:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11  6:42 [PATCH v7 0/7] Add support for AMD IOMMU GAPPI Sairaj Kodilkar
2026-11-11  6:42 ` [PATCH v7 1/7] iommu/amd: KVM: SVM: Rename cpu to apicid in IOMMU interface Sairaj Kodilkar
2026-11-11  6:42 ` [PATCH v7 2/7] iommu/amd: KVM: SVM: Rename ga_log_intr to wakeup_intr " Sairaj Kodilkar
2026-11-11  6:42 ` [PATCH v7 3/7] iommu/amd: KVM: SVM: Add explicit vCPU running state to " Sairaj Kodilkar
2026-11-11  6:42 ` [PATCH v7 4/7] iommu/amd: Program guest-mode IRTEs for GAPPI wakeup when IRTE[IsRun] = 0 Sairaj Kodilkar
2026-11-11  6:42 ` [PATCH v7 5/7] KVM: VMX: Factor out wakeup list handling code to KVM Sairaj Kodilkar
2026-11-11  6:42 ` [PATCH v7 6/7] KVM: SVM: Add support for AMD IOMMU Guest APIC Physical Processor Interrupt (GAPPI) Sairaj Kodilkar
2026-11-11  7:15   ` sashiko-bot
2026-11-11  6:42 ` [PATCH v7 7/7] iommu/amd: Provide kernel command line option to enable GAPPI Sairaj Kodilkar
2026-11-11  7:06   ` 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-208489@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.