From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796216321; b=aF53j4UV6oR4SubRMmzE+rTDRJqrCC5gLP111XbcJcAwg0ocU/DtN0Xk4DU7APmy5igL 9Fz5Fx5Oxs8CQyewH6lpN88OM7SznGiVyOSpviMlQK47lNBv7mPUE1l2O97vfFeJDADWw vG+Dz+JECPuV8gbWHJb6BICsijxYXcgWrGs1KqLLVr49JTj8w95EoLw1jVZ0tcpiw/qLe ldGrBQlcaD9BYbGBJZup0AuHLosYw4qcMiGISj070YaRa/Eqm/eAa8eAa1wZ7LcxjcX6M o2nXZOHzqgTEa7MBmZ8riJpkWUjxT5xM9C6t+TfEvzr2iVimbzFzJQpNMSqmQGX1R2g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796216321; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Transfer-Encoding; bh=YUDS1Dra7K0+BktQFa3qSFj1C8YuxBRcN7wawXlNcnI=; b=aKq/Oq5G7dHH1xH/+pG/MMOs2x+eNe1RlMZKY6NjGoUdpbH2HA2NFiVwbMWBpF2BIA4R EVDayRZGaut1LjxvpH8tXYY9qXj1I2aHqIyCHjMZNFDtzxE8qhlNealfBXJmjLOjOOMoU 1QQgTcR5Sec1eHTsb9c7nQHMCIkevKk6xqYvSoPRGT2S5fVcITBQgKmEwU6vyHwJj7OkK zU6gXHLAs4ojB1MGw3YwjH8T+nwKTF4SbJ40jOxlKTEELml+KkZ51M3Cdg4JJ+NJq5qKy 9IiKPEBPVs4m2YO04kTTyd5WFfAqapwaRFqest0wHiaA2DqvRZpTuD7UCiqJmrLydMw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=e6djyaKR; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79339606A322; Wed, 2 Dec 2026 12:58:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=e6djyaKR Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3AA931F00893; Wed, 2 Dec 2026 12:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796216321; bh=YUDS1Dra7K0+BktQFa3qSFj1C8YuxBRcN7wawXlNcnI=; h=From:To:Cc:Subject:Date; b=e6djyaKR+a7RGr/U65kmRQYKFouT4SoXvU+tjB2xsca0PIRypIR11q17qOM4llAzv 09XsaPyF/tt1PcE7KvoqQd8IUBNhYXZiT4oR3IuQwiJXIMVAsUc5l73fZpSB19Ne50 W84/JZFxAEjWJ8tGzWOzgyte52o7SRTFJDqKBqSNo+8cttvYYpvcsisIed14RAbufU HOg9lwVacpBV9qn8+7AveOuRnARX2z8Xt7IxwWeqF+CqRJwPCWa8xG1o2lT23B473N zlmmK3S+F1qWz+lg7nG6uDHbBxAFSDS2IDm5q3GMP4H0d9uC3pMY2pZBrrKGuJ4Fa6 LWWJScIbOjCug== From: "Naveen N Rao (AMD)" To: Joerg Roedel , Vasant Hegde , Suravee Suthikulpanit Cc: , Will Deacon , Robin Murphy , Sairaj Kodilkar , Sean Christopherson , Paolo Bonzini , Subject: [PATCH] iommu/amd: Explicitly disable GAPPI Date: Wed, 2 Dec 2026 18:25:22 +0530 Message-ID: <20261202125522.1993642-1-naveen@kernel.org> X-Mailer: git-send-email 2.56.0 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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) --- 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