Skip to contentSkip to conversation

FAILED: patch "[PATCH] iommu/vt-d: Force requesting ACS when tboot is enabled" failed to apply to 5.15-stable tree

PATCH New [email protected] 2 participants 4 messages Sep 3 – Sep 9

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 607432b2618b61df81134be0ef2562b8300c1216
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090351-clapper-monorail-cc3a@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 607432b2618b61df81134be0ef2562b8300c1216 Mon Sep 17 00:00:00 2001
From: Kevin Tian <[email protected]>
Date: Wed, 5 Aug 2026 07:43:00 +0800
Subject: [PATCH] iommu/vt-d: Force requesting ACS when tboot is enabled

Currently the conditions of requesting ACS in detect_intel_iommu() don't include tboot, leading to a possible misconfiguration with ACS disabled (e.g. due to user opts) while iommu is later forced on by tboot_force_iommu().

Fix it by checking tboot in detect_intel_iommu().

Fixes 5d990b627537 ("PCI: add pci_request_acs")
drivers/iommu/intel/dmar.c +13 -2
index 767ec092accd..e32685402f74 100644
@@ -915,6 +915,18 @@ dmar_validate_one_drhd(struct acpi_dmar_header *entry, void *arg)
 	return 0;
 }
 
+static bool dmar_required(void)
+{
+	/* tboot supersedes any user/platform opt */
+	if (!intel_iommu_tboot_noforce && tboot_enabled())
+		return true;
+
+	if (!no_iommu && (!dmar_disabled || dmar_platform_optin()))
+		return true;
+
+	return false;
+}
+
 void __init detect_intel_iommu(void)
 {
 	int ret;
@@ -928,8 +940,7 @@ void __init detect_intel_iommu(void)
 	if (!ret)
 		ret = dmar_walk_dmar_table((struct acpi_table_dmar *)dmar_tbl,
 					   &validate_drhd_cb);
-	if (!ret && !no_iommu && !iommu_detected &&
-	    (!dmar_disabled || dmar_platform_optin())) {
+	if (!ret && !iommu_detected && dmar_required()) {
 		iommu_detected = 1;
 		/* Make sure ACS will be enabled */
 		pci_request_acs();
drivers/iommu/intel/iommu.c +1 -1
index 1a1f27a51063..4d03d9a517de 100644
@@ -57,7 +57,7 @@ static int rwbf_quirk;
  * (used when kernel is launched w/ TXT)
  */
 static int force_on = 0;
-static int intel_iommu_tboot_noforce;
+int intel_iommu_tboot_noforce;
 static int no_platform_optin;
 
 #define ROOT_ENTRY_NR (VTD_PAGE_SIZE/sizeof(struct root_entry))
drivers/iommu/intel/iommu.h +2 -0
index 775f1c4ae346..2cee36138d6e 100644
@@ -1354,6 +1354,7 @@ static inline bool ecmd_has_pmu_essential(struct intel_iommu *iommu)
 
 extern int dmar_disabled;
 extern int intel_iommu_enabled;
+extern int intel_iommu_tboot_noforce;
 #else
 static inline int iommu_calculate_agaw(struct intel_iommu *iommu)
 {
@@ -1366,6 +1367,7 @@ static inline int iommu_calculate_max_sagaw(struct intel_iommu *iommu)
 #define dmar_disabled	(1)
 #define intel_iommu_enabled (0)
 #define intel_iommu_sm (0)
+#define intel_iommu_tboot_noforce (0)
 #endif
 
 static inline const char *decode_prq_descriptor(char *str, size_t size,
maintainer
#1 lore raw

PATCH 1/3 x86: remove the IOMMU table infrastructure

From: Christoph Hellwig <[email protected]>

[ Upstream commit 78013eaadf696d2105982abb4018fbae394ca08f ]

The IOMMU table tries to separate the different IOMMUs into different backends, but actually requires various cross calls.

Rewrite the code to do the generic swiotlb/swiotlb-xen setup directly in pci-dma.c and then just call into the IOMMU drivers.

[5.15 dependency adaptation for 607432b2618b]

Limit the table removal to Intel VT-d detection. Call detect_intel_iommu() directly after the remaining table entries, and return when a backend has IOMMU_FINISH_IF_DETECTED so Xen, forced SWIOTLB and AMD retain their stop semantics. Keep the existing SWIOTLB, GART and AMD implementations: this branch uses sme_active() and already removed amd_iommu_init_dma_ops(). Guard the direct call with CONFIG_DMAR_TABLE instead of adding a stub.

Move the existing Intel IOMMU header to drivers/iommu/intel/iommu.h while preserving the public include path through a forwarding include. Keep the existing graphics declaration and align the enabled/disabled Intel IOMMU declaration blocks with the target's context. All existing inline function bodies are retained without additions or changes.

This retains the target's required void detect_intel_iommu() interface and header layout without importing the full x86 IOMMU/SWIOTLB rewrite.

[ sashal: Reduced backport -- upstream 78013eaadf696 touches 21 file(s), this
backport carries 6. Not backported here:
arch/ia64/include/asm/iommu_table.h arch/x86/include/asm/dma-mapping.h
arch/x86/include/asm/gart.h
arch/x86/include/asm/iommu.h
arch/x86/include/asm/iommu_table.h arch/x86/include/asm/swiotlb.h arch/x86/include/asm/xen/swiotlb-xen.h arch/x86/kernel/amd_gart_64.c
... and 10 more
This note is generated from the file lists only; see the resolution record for the reasoning. ]

Stable-dep-of: 607432b2618b ("iommu/vt-d: Force requesting ACS when tboot is enabled")

---
 arch/x86/kernel/pci-dma.c   |   6 +-
 drivers/iommu/intel/dmar.c  |   8 +-
 drivers/iommu/intel/iommu.c |   2 +-
 drivers/iommu/intel/iommu.h | 862 ++++++++++++++++++++++++++++++++++++
 include/linux/dmar.h        |   2 +-
 include/linux/intel-iommu.h | 861 +----------------------------------
 6 files changed, 873 insertions(+), 868 deletions(-)
 create mode 100644 drivers/iommu/intel/iommu.h
arch/x86/kernel/pci-dma.c +5 -1
index de234e7a8962e..cecf6b6b8ab2f 100644
@@ -49,9 +49,13 @@ void __init pci_iommu_alloc(void)
 			if (p->early_init)
 				p->early_init();
 			if (p->flags & IOMMU_FINISH_IF_DETECTED)
-				break;
+				return;
 		}
 	}
+
+#ifdef CONFIG_DMAR_TABLE
+	detect_intel_iommu();
+#endif
 }
 
 /*
drivers/iommu/intel/dmar.c +2 -6
index f0d34ba78b4a9..adea04ac0bd47 100644
@@ -19,7 +19,6 @@
 #include <linux/pci.h>
 #include <linux/dmar.h>
 #include <linux/iova.h>
-#include <linux/intel-iommu.h>
 #include <linux/timer.h>
 #include <linux/irq.h>
 #include <linux/interrupt.h>
@@ -30,10 +29,10 @@
 #include <linux/numa.h>
 #include <linux/limits.h>
 #include <asm/irq_remapping.h>
-#include <asm/iommu_table.h>
 #include <trace/events/intel_iommu.h>
 
 #include "../irq_remapping.h"
+#include "iommu.h"
 #include "perf.h"
 
 typedef int (*dmar_res_handler_t)(struct acpi_dmar_header *, void *);
@@ -914,7 +913,7 @@ dmar_validate_one_drhd(struct acpi_dmar_header *entry, void *arg)
 	return 0;
 }
 
-int __init detect_intel_iommu(void)
+void __init detect_intel_iommu(void)
 {
 	int ret;
 	struct dmar_res_callback validate_drhd_cb = {
@@ -947,8 +946,6 @@ int __init detect_intel_iommu(void)
 		dmar_tbl = NULL;
 	}
 	up_write(&dmar_global_lock);
-
-	return ret ? ret : 1;
 }
 
 static void unmap_iommu(struct intel_iommu *iommu)
@@ -2184,7 +2181,6 @@ static int __init dmar_free_unused_resources(void)
 }
 
 late_initcall(dmar_free_unused_resources);
-IOMMU_INIT_POST(detect_intel_iommu);
 
 /*
  * DMAR Hotplug Support
drivers/iommu/intel/iommu.c +1 -1
index 2680ba77e55de..86e23fe27c896 100644
@@ -32,7 +32,6 @@
 #include <linux/iova.h>
 #include <linux/iommu.h>
 #include <linux/dma-iommu.h>
-#include <linux/intel-iommu.h>
 #include <linux/intel-svm.h>
 #include <linux/syscore_ops.h>
 #include <linux/tboot.h>
@@ -48,6 +47,7 @@
 
 #include "../irq_remapping.h"
 #include "../iommu-sva-lib.h"
+#include "iommu.h"
 #include "pasid.h"
 #include "cap_audit.h"
 
drivers/iommu/intel/iommu.h new file +862 -0

862 lines not on this page · raw message

include/linux/dmar.h +1 -1
index e04436a7ff271..c4485252d0b81 100644
@@ -121,7 +121,7 @@ extern int dmar_remove_dev_scope(struct dmar_pci_notify_info *info,
 				 u16 segment, struct dmar_dev_scope *devices,
 				 int count);
 /* Intel IOMMU detection */
-extern int detect_intel_iommu(void);
+void detect_intel_iommu(void);
 extern int enable_drhd_fault_handling(void);
 extern int dmar_device_add(acpi_handle handle);
 extern int dmar_device_remove(acpi_handle handle);
include/linux/intel-iommu.h +2 -859

862 lines not on this page · raw message

Signature · 1 line
2.53.0
maintainer
#2 lore raw

PATCH 2/3 iommu/vt-d: Move trace/events/intel_iommu.h under iommu

From: Lu Baolu <[email protected]>

[ Upstream commit 933ab6d30153f937ffa9471ce64207e6d9acf56e ]

This header file is private to the Intel IOMMU driver. Move it to the driver folder.

Stable-dep-of: 607432b2618b ("iommu/vt-d: Force requesting ACS when tboot is enabled")

---
 drivers/iommu/intel/dmar.c                                    | 2 +-
 drivers/iommu/intel/svm.c                                     | 2 +-
 drivers/iommu/intel/trace.c                                   | 2 +-
 .../trace/events/intel_iommu.h => drivers/iommu/intel/trace.h | 4 ++++
 4 files changed, 7 insertions(+), 3 deletions(-)
 rename include/trace/events/intel_iommu.h => drivers/iommu/intel/trace.h (94%)
drivers/iommu/intel/dmar.c +1 -1
index adea04ac0bd47..37fc660634081 100644
@@ -29,11 +29,11 @@
 #include <linux/numa.h>
 #include <linux/limits.h>
 #include <asm/irq_remapping.h>
-#include <trace/events/intel_iommu.h>
 
 #include "../irq_remapping.h"
 #include "iommu.h"
 #include "perf.h"
+#include "trace.h"
 
 typedef int (*dmar_res_handler_t)(struct acpi_dmar_header *, void *);
 struct dmar_res_callback {
drivers/iommu/intel/svm.c +1 -1
index bf97e003af1d8..9f1c30f254858 100644
@@ -21,11 +21,11 @@
 #include <linux/ioasid.h>
 #include <asm/page.h>
 #include <asm/fpu/api.h>
-#include <trace/events/intel_iommu.h>
 
 #include "pasid.h"
 #include "perf.h"
 #include "../iommu-sva-lib.h"
+#include "trace.h"
 
 static irqreturn_t prq_event_thread(int irq, void *d);
 static void intel_svm_drain_prq(struct device *dev, u32 pasid);
drivers/iommu/intel/trace.c +1 -1
index bfb6a6e37a88b..117e626e3ea98 100644
@@ -11,4 +11,4 @@
 #include <linux/types.h>
 
 #define CREATE_TRACE_POINTS
-#include <trace/events/intel_iommu.h>
+#include "trace.h"
drivers/iommu/intel/trace.h renamed from include/trace/events/intel_iommu.h +4 -0
similarity index 94%
rename from include/trace/events/intel_iommu.h
rename to drivers/iommu/intel/trace.h
index e5c1ca6d16eea..25cb7f88e1a2c 100644
@@ -91,4 +91,8 @@ TRACE_EVENT(prq_report,
 #endif /* _TRACE_INTEL_IOMMU_H */
 
 /* This part must be outside protection */
+#undef TRACE_INCLUDE_PATH
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_PATH ../../drivers/iommu/intel/
+#define TRACE_INCLUDE_FILE trace
 #include <trace/define_trace.h>
Signature · 1 line
2.53.0
maintainer
#3 lore raw

PATCH 3/3 iommu/vt-d: Force requesting ACS when tboot is enabled

In reply to Sasha Levin

From: Kevin Tian <[email protected]>

[ Upstream commit 607432b2618b61df81134be0ef2562b8300c1216 ]

Currently the conditions of requesting ACS in detect_intel_iommu() don't include tboot, leading to a possible misconfiguration with ACS disabled (e.g. due to user opts) while iommu is later forced on by tboot_force_iommu().

Fix it by checking tboot in detect_intel_iommu().

Fixes 5d990b627537 ("PCI: add pci_request_acs")
---
 drivers/iommu/intel/dmar.c  | 15 +++++++++++++--
 drivers/iommu/intel/iommu.c |  2 +-
 drivers/iommu/intel/iommu.h |  2 ++
 3 files changed, 16 insertions(+), 3 deletions(-)
drivers/iommu/intel/dmar.c +13 -2
index 37fc660634081..7a580155389ce 100644
@@ -913,6 +913,18 @@ dmar_validate_one_drhd(struct acpi_dmar_header *entry, void *arg)
 	return 0;
 }
 
+static bool dmar_required(void)
+{
+	/* tboot supersedes any user/platform opt */
+	if (!intel_iommu_tboot_noforce && tboot_enabled())
+		return true;
+
+	if (!no_iommu && (!dmar_disabled || dmar_platform_optin()))
+		return true;
+
+	return false;
+}
+
 void __init detect_intel_iommu(void)
 {
 	int ret;
@@ -926,8 +938,7 @@ void __init detect_intel_iommu(void)
 	if (!ret)
 		ret = dmar_walk_dmar_table((struct acpi_table_dmar *)dmar_tbl,
 					   &validate_drhd_cb);
-	if (!ret && !no_iommu && !iommu_detected &&
-	    (!dmar_disabled || dmar_platform_optin())) {
+	if (!ret && !iommu_detected && dmar_required()) {
 		iommu_detected = 1;
 		/* Make sure ACS will be enabled */
 		pci_request_acs();
drivers/iommu/intel/iommu.c +1 -1
index 86e23fe27c896..3ce3ed37b152e 100644
@@ -162,7 +162,7 @@ static int rwbf_quirk;
  * (used when kernel is launched w/ TXT)
  */
 static int force_on = 0;
-static int intel_iommu_tboot_noforce;
+int intel_iommu_tboot_noforce;
 static int no_platform_optin;
 
 #define ROOT_ENTRY_NR (VTD_PAGE_SIZE/sizeof(struct root_entry))
drivers/iommu/intel/iommu.h +2 -0
index 3c8bfc2cfccb8..861babac03689 100644
@@ -817,6 +817,7 @@ extern int intel_iommu_sm;
 
 extern int dmar_disabled;
 extern int intel_iommu_enabled;
+extern int intel_iommu_tboot_noforce;
 #else
 static inline int iommu_calculate_agaw(struct intel_iommu *iommu)
 {
@@ -829,6 +830,7 @@ static inline int iommu_calculate_max_sagaw(struct intel_iommu *iommu)
 #define dmar_disabled	(1)
 #define intel_iommu_enabled (0)
 #define intel_iommu_sm (0)
+#define intel_iommu_tboot_noforce (0)
 #endif
 
 static inline const char *decode_prq_descriptor(char *str, size_t size,
Signature · 1 line
2.53.0