All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Naveen N Rao (AMD)" <naveen@kernel.org>
To: Joerg Roedel <joro@8bytes.org>,
	Vasant Hegde <vasant.hegde@amd.com>,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Cc: <iommu@lists.linux.dev>, Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Sairaj Kodilkar <sarunkod@amd.com>,
	Sean Christopherson <seanjc@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>, <kvm@vger.kernel.org>
Subject: [PATCH] iommu/amd: Explicitly disable GAPPI
Date: Wed,  2 Dec 2026 18:25:22 +0530	[thread overview]
Message-ID: <20261202125522.1993642-1-naveen@kernel.org> (raw)

Since commit b03500f03ea0 ("KVM: SVM: Generate GA log IRQs only if the
associated vCPUs is blocking"), running a VM with AVIC enabled and a
passed-through (VFIO) device can result in unexpected host interrupts
with kernel log messages such as:
  No irq handler for 99.39

Or worse, the host hangs, or panics with:
  Kernel panic - not syncing: Unexpected external interrupt 0x80

AMD IOMMU supports GAPPI mode (Guest APIC Physical Processor Interrupt)
wherein device interrupts for vCPUs that are not running can result in
host interrupts. More specifically, if IRTE[IsRun]=0 and
IRTE[GALogIntr]=0, and if GAPPI mode is enabled, IOMMU sends a host
interrupt to IRTE[destination] with vector number derived from the low
byte of IRTE[GATag] (which KVM populates with the vCPU index).

Prior to the above commit, KVM never cleared IRTE[GALogIntr] and so 
device interrupts for non-running vCPUs always resulted in a GALog 
entry, with an optional GALog interrupt to the host. Since the above 
commit, KVM clears IRTE[GALogIntr] if the vCPU is scheduled out without 
blocking, which can trigger GAPPI interrupts if GAPPI mode is enabled.

GAPPI mode is controlled by GAPPIEn in the IOMMU Control register with a
reset value of 0 and Linux never sets it. So, GAPPI mode is not enabled
by default. However, enabling SEV-SNP in the BIOS sets GAPPIEn to 1
resulting in GAPPI mode being enabled on boot.

Fix this by disabling GAPPI mode in iommu_disable(). Disabling GAPPI
mode in kdump path is left for the series that enables GAPPI, since
GAPPI is never otherwise left enabled by Linux kernel today.


Fixes: b03500f03ea0 ("KVM: SVM: Generate GA log IRQs only if the associated vCPUs is blocking")
Cc: stable@vger.kernel.org
Signed-off-by: Naveen N Rao (AMD) <naveen@kernel.org>
---
 drivers/iommu/amd/amd_iommu_types.h | 1 +
 drivers/iommu/amd/init.c            | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h
index f98770db0090..31bdcb6b3bbf 100644
--- a/drivers/iommu/amd/amd_iommu_types.h
+++ b/drivers/iommu/amd/amd_iommu_types.h
@@ -180,6 +180,7 @@
 #define CONTROL_EPH_EN		45
 #define CONTROL_XT_EN		50
 #define CONTROL_INTCAPXT_EN	51
+#define CONTROL_GAPPI_EN	55
 #define CONTROL_GCR3TRPMODE	58
 #define CONTROL_IRTCACHEDIS	59
 #define CONTROL_SNPAVIC_EN	61
diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
index 58f63298493b..a31ad62b472b 100644
--- a/drivers/iommu/amd/init.c
+++ b/drivers/iommu/amd/init.c
@@ -481,6 +481,9 @@ static void iommu_disable(struct amd_iommu *iommu)
 	iommu_feature_disable(iommu, CONTROL_GALOG_EN);
 	iommu_feature_disable(iommu, CONTROL_GAINT_EN);
 
+	/* Disable IOMMU GAPPI */
+	iommu_feature_disable(iommu, CONTROL_GAPPI_EN);
+
 	/* Disable IOMMU PPR logging */
 	iommu_feature_disable(iommu, CONTROL_PPRLOG_EN);
 	iommu_feature_disable(iommu, CONTROL_PPRINT_EN);

base-commit: 10bcc637f7a657725dd8bbcc2b30d027acee6f2d
-- 
2.56.0


                 reply	other threads:[~2026-12-02 12:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261202125522.1993642-1-naveen@kernel.org \
    --to=naveen@kernel.org \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=robin.murphy@arm.com \
    --cc=sarunkod@amd.com \
    --cc=seanjc@google.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=vasant.hegde@amd.com \
    --cc=will@kernel.org \
    /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.