Skip to contentSkip to conversation

iommu/vt-d: Make intel-iommu.h private

PATCH In review Lu Baolu 6 participants 22 messages May 14, 2022 – May 18, 2022

Subsystems (10)
DRM drivers x86 Intel i915 Tracing +6 more subsystems
lore
Share & tools
lore

Lu Baolu

author maintainer
#0 lore raw

cover iommu/vt-d: Make intel-iommu.h private

Hi folks,

The include/linux/intel-iommu.h should be private to the Intel IOMMU driver. Other drivers or components should interact with the IOMMU drivers through the kAPIs provided by the iommu core.

This series cleanups all includes of intel-iommu.h outside of the Intel IOMMU driver and move this header from include/linux to drivers/iommu/intel/.

No functional changes intended. Please help to review and suggest.

Best regards,
baolu

Lu Baolu (7):
iommu/vt-d: Move trace/events/intel_iommu.h under iommu agp/intel: Use per device iommu check iommu/vt-d: Remove unnecessary exported symbol drm/i915: Remove unnecessary include
KVM: x86: Remove unnecessary include x86/boot/tboot: Move tboot_force_iommu() to Intel IOMMU iommu/vt-d: Move include/linux/intel_iommu.h under iommu

 include/linux/tboot.h                         |  2 --
 drivers/gpu/drm/i915/i915_drv.h               |  1 -
 .../iommu/intel/iommu.h                       |  1 -
 .../iommu/intel/trace.h                       |  7 +++++-
 arch/x86/kernel/tboot.c                       | 15 -------------
 arch/x86/kvm/x86.c                            |  1 -
 drivers/char/agp/intel-gtt.c                  | 17 ++++++--------
 drivers/gpu/drm/i915/display/intel_display.c  |  1 -
 .../gpu/drm/i915/gem/i915_gem_execbuffer.c    |  1 -
 drivers/iommu/intel/cap_audit.c               |  2 +-
 drivers/iommu/intel/debugfs.c                 |  2 +-
 drivers/iommu/intel/dmar.c                    |  4 ++--
 drivers/iommu/intel/iommu.c                   | 22 +++++++++++++------
 drivers/iommu/intel/irq_remapping.c           |  2 +-
 drivers/iommu/intel/pasid.c                   |  2 +-
 drivers/iommu/intel/perf.c                    |  2 +-
 drivers/iommu/intel/svm.c                     |  4 ++--
 drivers/iommu/intel/trace.c                   |  2 +-
 MAINTAINERS                                   |  1 -
 19 files changed, 38 insertions(+), 51 deletions(-)
 rename include/linux/intel-iommu.h => drivers/iommu/intel/iommu.h (99%)
 rename include/trace/events/intel_iommu.h => drivers/iommu/intel/trace.h (93%)
Signature · 6 lines
2.25.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
author maintainer
#1 lore raw

PATCH 1/7 iommu/vt-d: Move trace/events/intel_iommu.h under iommu

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

---
 .../trace/events/intel_iommu.h => drivers/iommu/intel/trace.h | 4 ++++
 drivers/iommu/intel/dmar.c                                    | 2 +-
 drivers/iommu/intel/svm.c                                     | 2 +-
 drivers/iommu/intel/trace.c                                   | 2 +-
 4 files changed, 7 insertions(+), 3 deletions(-)
 rename include/trace/events/intel_iommu.h => drivers/iommu/intel/trace.h (94%)
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 e5c1ca6d16ee..25cb7f88e1a2 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>
drivers/iommu/intel/dmar.c +1 -1
index 4de960834a1b..b02d72097a8c 100644
@@ -31,10 +31,10 @@
 #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 "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 7ee37d996e15..70b40d007a52 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 bfb6a6e37a88..117e626e3ea9 100644
@@ -11,4 +11,4 @@
 #include <linux/types.h>
 
 #define CREATE_TRACE_POINTS
-#include <trace/events/intel_iommu.h>
+#include "trace.h"
Signature · 6 lines
2.25.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Reviewed-by on v1 1/7
#2 lore raw

Re: [PATCH 1/7] iommu/vt-d: Move trace/events/intel_iommu.h under iommu

Quoted 11 lines · Lu Baolu

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

---
 .../trace/events/intel_iommu.h => drivers/iommu/intel/trace.h | 4 ++++
 drivers/iommu/intel/dmar.c                                    | 2 +-
 drivers/iommu/intel/svm.c                                     | 2 +-
 drivers/iommu/intel/trace.c                                   | 2 +-
 4 files changed, 7 insertions(+), 3 deletions(-)
 rename include/trace/events/intel_iommu.h => drivers/iommu/intel/trace.h (94%)

Jason
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

author maintainer
#3 lore raw

PATCH 2/7 agp/intel: Use per device iommu check

In reply to Lu Baolu

The IOMMU subsystem has already provided an interface to query whether the IOMMU hardware is enabled for a specific device. This changes the check from Intel specific intel_iommu_gfx_mapped (globally exported by the Intel IOMMU driver) to probing the presence of IOMMU on a specific device using the generic device_iommu_mapped().

This follows commit cca084692394a ("drm/i915: Use per device iommu check") which converted drm/i915 driver to use device_iommu_mapped().

---
 drivers/char/agp/intel-gtt.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/char/agp/intel-gtt.c +7 -10
index 79a1b65527c2..cfcb450e9b59 100644
@@ -20,7 +20,7 @@
 #include <linux/kernel.h>
 #include <linux/pagemap.h>
 #include <linux/agp_backend.h>
-#include <linux/intel-iommu.h>
+#include <linux/iommu.h>
 #include <linux/delay.h>
 #include <asm/smp.h>
 #include "agp.h"
@@ -573,18 +573,15 @@ static void intel_gtt_cleanup(void)
  */
 static inline int needs_ilk_vtd_wa(void)
 {
-#ifdef CONFIG_INTEL_IOMMU
 	const unsigned short gpu_devid = intel_private.pcidev->device;
 
-	/* Query intel_iommu to see if we need the workaround. Presumably that
-	 * was loaded first.
+	/*
+	 * Query iommu subsystem to see if we need the workaround. Presumably
+	 * that was loaded first.
 	 */
-	if ((gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG ||
-	     gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG) &&
-	     intel_iommu_gfx_mapped)
-		return 1;
-#endif
-	return 0;
+	return ((gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG ||
+		 gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG) &&
+		device_iommu_mapped(&intel_private.pcidev->dev));
 }
 
 static bool intel_gtt_can_wc(void)
Signature · 6 lines
2.25.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Reviewed-by on v1 2/7
#4 lore raw

Re: [PATCH 2/7] agp/intel: Use per device iommu check

Quoted 6 lines · Lu Baolu

The IOMMU subsystem has already provided an interface to query whether the IOMMU hardware is enabled for a specific device. This changes the check from Intel specific intel_iommu_gfx_mapped (globally exported by the Intel IOMMU driver) to probing the presence of IOMMU on a specific device using the generic device_iommu_mapped().

Quoted 7 lines

This follows commit cca084692394a ("drm/i915: Use per device iommu check") which converted drm/i915 driver to use device_iommu_mapped().

---
 drivers/char/agp/intel-gtt.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

Jason

author maintainer
#5 lore raw

PATCH 3/7 iommu/vt-d: Remove unnecessary exported symbol

In reply to Lu Baolu

The exported symbol intel_iommu_gfx_mapped is not used anywhere in the tree. Remove it to avoid dead code.

---
 include/linux/intel-iommu.h | 1 -
 drivers/iommu/intel/iommu.c | 6 ------
 2 files changed, 7 deletions(-)
include/linux/intel-iommu.h +0 -1
index 4f29139bbfc3..0f9df5a19ef7 100644
@@ -790,7 +790,6 @@ extern int iommu_calculate_agaw(struct intel_iommu *iommu);
 extern int iommu_calculate_max_sagaw(struct intel_iommu *iommu);
 extern int dmar_disabled;
 extern int intel_iommu_enabled;
-extern int intel_iommu_gfx_mapped;
 #else
 static inline int iommu_calculate_agaw(struct intel_iommu *iommu)
 {
drivers/iommu/intel/iommu.c +0 -6
index e56b3a4b6998..744af407d0da 100644
@@ -314,9 +314,6 @@ static int iommu_skip_te_disable;
 #define IDENTMAP_GFX		2
 #define IDENTMAP_AZALIA		4
 
-int intel_iommu_gfx_mapped;
-EXPORT_SYMBOL_GPL(intel_iommu_gfx_mapped);
-
 DEFINE_SPINLOCK(device_domain_lock);
 static LIST_HEAD(device_domain_list);
 
@@ -4117,9 +4114,6 @@ int __init intel_iommu_init(void)
 	if (list_empty(&dmar_satc_units))
 		pr_info("No SATC found\n");
 
-	if (dmar_map_gfx)
-		intel_iommu_gfx_mapped = 1;
-
 	init_no_remapping_devices();
 
 	ret = init_dmars();
Signature · 6 lines
2.25.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Reviewed-by on v1 3/7
#6 lore raw

Re: [PATCH 3/7] iommu/vt-d: Remove unnecessary exported symbol

Quoted 8 lines · Lu Baolu

The exported symbol intel_iommu_gfx_mapped is not used anywhere in the tree. Remove it to avoid dead code.

---
 include/linux/intel-iommu.h | 1 -
 drivers/iommu/intel/iommu.c | 6 ------
 2 files changed, 7 deletions(-)

Maybe could squash to the prior patch

Jason

author maintainer
#7 lore raw

PATCH 4/7 drm/i915: Remove unnecessary include

In reply to Lu Baolu

intel-iommu.h is not needed in drm/i915 anymore. Remove its include.

---
 drivers/gpu/drm/i915/i915_drv.h                | 1 -
 drivers/gpu/drm/i915/display/intel_display.c   | 1 -
 drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 1 -
 3 files changed, 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
index fa14da84362e..f2a6982c3bef 100644
@@ -36,7 +36,6 @@
 
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
-#include <linux/intel-iommu.h>
 #include <linux/pm_qos.h>
 
 #include <drm/drm_connector.h>
drivers/gpu/drm/i915/display/intel_display.c +0 -1
index 7dfeb458aa65..686ddbeebadc 100644
@@ -27,7 +27,6 @@
 #include <acpi/video.h>
 #include <linux/i2c.h>
 #include <linux/input.h>
-#include <linux/intel-iommu.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/dma-resv.h>
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +0 -1
index d42f437149c9..c9823528ea94 100644
@@ -4,7 +4,6 @@
  * Copyright © 2008,2010 Intel Corporation
  */
 
-#include <linux/intel-iommu.h>
 #include <linux/dma-resv.h>
 #include <linux/sync_file.h>
 #include <linux/uaccess.h>
Signature · 6 lines
2.25.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
maintainer Acked-by on v1 4/7
#8 lore raw

Re: [PATCH 4/7] drm/i915: Remove unnecessary include

Quoted 1 line · Lu Baolu

intel-iommu.h is not needed in drm/i915 anymore. Remove its include.

Thanks for the cleanups. Do you want to keep the patches together or want us to pick this up via drm-intel?

If you want to keep the patches together,

for merging via whichever tree suits you best. Just let us know.

BR,
Jani.

Quoted 44 lines
---
 drivers/gpu/drm/i915/i915_drv.h                | 1 -
 drivers/gpu/drm/i915/display/intel_display.c   | 1 -
 drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 1 -
 3 files changed, 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
index fa14da84362e..f2a6982c3bef 100644
@@ -36,7 +36,6 @@
 
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
-#include <linux/intel-iommu.h>
 #include <linux/pm_qos.h>
 
 #include <drm/drm_connector.h>
drivers/gpu/drm/i915/display/intel_display.c +0 -1
index 7dfeb458aa65..686ddbeebadc 100644
@@ -27,7 +27,6 @@
 #include <acpi/video.h>
 #include <linux/i2c.h>
 #include <linux/input.h>
-#include <linux/intel-iommu.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/dma-resv.h>
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +0 -1
index d42f437149c9..c9823528ea94 100644
@@ -4,7 +4,6 @@
  * Copyright © 2008,2010 Intel Corporation
  */
 
-#include <linux/intel-iommu.h>
 #include <linux/dma-resv.h>
 #include <linux/sync_file.h>
 #include <linux/uaccess.h>
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Reviewed-by on v1 4/7
#9 lore raw

Re: [PATCH 4/7] drm/i915: Remove unnecessary include

In reply to Lu Baolu
Quoted 8 lines · Lu Baolu

intel-iommu.h is not needed in drm/i915 anymore. Remove its include.

---
 drivers/gpu/drm/i915/i915_drv.h                | 1 -
 drivers/gpu/drm/i915/display/intel_display.c   | 1 -
 drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 1 -
 3 files changed, 3 deletions(-)

Jason
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

author maintainer
#10 lore raw

PATCH 5/7 KVM: x86: Remove unnecessary include

In reply to Lu Baolu

intel-iommu.h is not needed in kvm/x86 anymore. Remove its include.

---
 arch/x86/kvm/x86.c | 1 -
 1 file changed, 1 deletion(-)
arch/x86/kvm/x86.c +0 -1
index 4790f0d7d40b..fdf6ce5855d9 100644
@@ -41,7 +41,6 @@
 #include <linux/mman.h>
 #include <linux/highmem.h>
 #include <linux/iommu.h>
-#include <linux/intel-iommu.h>
 #include <linux/cpufreq.h>
 #include <linux/user-return-notifier.h>
 #include <linux/srcu.h>
Signature · 6 lines
2.25.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Reviewed-by on v1 5/7
#11 lore raw

Re: [PATCH 5/7] KVM: x86: Remove unnecessary include

Quoted 6 lines · Lu Baolu

intel-iommu.h is not needed in kvm/x86 anymore. Remove its include.

---
 arch/x86/kvm/x86.c | 1 -
 1 file changed, 1 deletion(-)

Jason
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

author maintainer
#12 lore raw

PATCH 6/7 x86/boot/tboot: Move tboot_force_iommu() to Intel IOMMU

In reply to Lu Baolu

tboot_force_iommu() is only called by the Intel IOMMU driver. Move the helper into that driver. No functional change intended.

---
 include/linux/tboot.h       |  2 --
 arch/x86/kernel/tboot.c     | 15 ---------------
 drivers/iommu/intel/iommu.c | 14 ++++++++++++++
 3 files changed, 14 insertions(+), 17 deletions(-)
include/linux/tboot.h +0 -2
index 5146d2574e85..d2279160ef39 100644
@@ -126,7 +126,6 @@ extern void tboot_probe(void);
 extern void tboot_shutdown(u32 shutdown_type);
 extern struct acpi_table_header *tboot_get_dmar_table(
 				      struct acpi_table_header *dmar_tbl);
-extern int tboot_force_iommu(void);
 
 #else
 
@@ -136,7 +135,6 @@ extern int tboot_force_iommu(void);
 #define tboot_sleep(sleep_state, pm1a_control, pm1b_control)	\
 					do { } while (0)
 #define tboot_get_dmar_table(dmar_tbl)	(dmar_tbl)
-#define tboot_force_iommu()		0
 
 #endif /* !CONFIG_INTEL_TXT */
 
arch/x86/kernel/tboot.c +0 -15
index f9af561c3cd4..6eb9c4146f17 100644
@@ -6,7 +6,6 @@
  * Copyright (c) 2006-2009, Intel Corporation
  */
 
-#include <linux/intel-iommu.h>
 #include <linux/init_task.h>
 #include <linux/spinlock.h>
 #include <linux/export.h>
@@ -517,17 +516,3 @@ struct acpi_table_header *tboot_get_dmar_table(struct acpi_table_header *dmar_tb
 
 	return dmar_tbl;
 }
-
-int tboot_force_iommu(void)
-{
-	if (!tboot_enabled())
-		return 0;
-
-	if (no_iommu || dmar_disabled)
-		pr_warn("Forcing Intel-IOMMU to enabled\n");
-
-	dmar_disabled = 0;
-	no_iommu = 0;
-
-	return 1;
-}
drivers/iommu/intel/iommu.c +14 -0
index 744af407d0da..ea1c3bcd38d5 100644
@@ -4043,6 +4043,20 @@ static int __init probe_acpi_namespace_devices(void)
 	return 0;
 }
 
+static __init int tboot_force_iommu(void)
+{
+	if (!tboot_enabled())
+		return 0;
+
+	if (no_iommu || dmar_disabled)
+		pr_warn("Forcing Intel-IOMMU to enabled\n");
+
+	dmar_disabled = 0;
+	no_iommu = 0;
+
+	return 1;
+}
+
 int __init intel_iommu_init(void)
 {
 	int ret = -ENODEV;
Signature · 6 lines
2.25.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Reviewed-by on v1 6/7
#13 lore raw

Re: [PATCH 6/7] x86/boot/tboot: Move tboot_force_iommu() to Intel IOMMU

Quoted 9 lines · Lu Baolu

tboot_force_iommu() is only called by the Intel IOMMU driver. Move the helper into that driver. No functional change intended.

---
 include/linux/tboot.h       |  2 --
 arch/x86/kernel/tboot.c     | 15 ---------------
 drivers/iommu/intel/iommu.c | 14 ++++++++++++++
 3 files changed, 14 insertions(+), 17 deletions(-)

drivers/iommu/intel/iommu.c static int __init probe_acpi_namespace_devices(void) · line 4052

Quoted 7 lines
drivers/iommu/intel/iommu.c +7 -0
+static __init int tboot_force_iommu(void)
+{
+	if (!tboot_enabled())
+		return 0;
+
+	if (no_iommu || dmar_disabled)
+		pr_warn("Forcing Intel-IOMMU to enabled\n");

Unrelated, but when we are in the special secure IOMMU modes, do we force ATS off? Specifically does the IOMMU reject TLPs that are marked as translated?

Jason
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

#14 lore raw

Re: [PATCH 6/7] x86/boot/tboot: Move tboot_force_iommu() to Intel IOMMU

Hi Jason,

Quoted 3 lines · Jason Gunthorpe

Unrelated, but when we are in the special secure IOMMU modes, do we force ATS off? Specifically does the IOMMU reject TLPs that are marked as translated?

Yes, VT-d context entry has a Device TLB Enable bit, if 0, it means "Translation Requests (with or without PASID) and Translated Requests received and processed through this scalable-mode context-entry are blocked."

Thanks,

Jacob
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

author maintainer
#15 lore raw

Re: [PATCH 6/7] x86/boot/tboot: Move tboot_force_iommu() to Intel IOMMU

In reply to Jason Gunthorpe

Hi Jason,

Quoted 10 lines · Jason Gunthorpe

drivers/iommu/intel/iommu.c static int __init probe_acpi_namespace_devices(void) · line 4052

Quoted 7 lines
drivers/iommu/intel/iommu.c +7 -0
+static __init int tboot_force_iommu(void)
+{
+	if (!tboot_enabled())
+		return 0;
+
+	if (no_iommu || dmar_disabled)
+		pr_warn("Forcing Intel-IOMMU to enabled\n");

Unrelated, but when we are in the special secure IOMMU modes, do we force ATS off? Specifically does the IOMMU reject TLPs that are marked as translated?

Good question. From IOMMU point of view, I don't see a point to force ATS off, but trust boot involves lots of other things that I am not familiar with. Anybody else could help to answer?

Best regards,
baolu
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

#16 lore raw

Re: [PATCH 6/7] x86/boot/tboot: Move tboot_force_iommu() to Intel IOMMU

Quoted 14 lines · Baolu Lu

Hi Jason,

Quoted 10 lines · Jason Gunthorpe

drivers/iommu/intel/iommu.c static int __init probe_acpi_namespace_devices(void) · line 4052

Quoted 7 lines
drivers/iommu/intel/iommu.c +7 -0
+static __init int tboot_force_iommu(void)
+{
+	if (!tboot_enabled())
+		return 0;
+
+	if (no_iommu || dmar_disabled)
+		pr_warn("Forcing Intel-IOMMU to enabled\n");

Unrelated, but when we are in the special secure IOMMU modes, do we force ATS off? Specifically does the IOMMU reject TLPs that are marked as translated?

Quoted 3 lines

Good question. From IOMMU point of view, I don't see a point to force ATS off, but trust boot involves lots of other things that I am not familiar with. Anybody else could help to answer?

ATS is inherently not secure, if a rouge device can issue a TLP with the translated bit set then it has unlimited access to host memory.

Many of these trusted iommu scenarios rely on the idea that a rouge device cannot DMA to arbitary system memory.

Jason
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

author maintainer
#17 lore raw

Re: [PATCH 6/7] x86/boot/tboot: Move tboot_force_iommu() to Intel IOMMU

Quoted 15 lines · Jason Gunthorpe
Quoted 14 lines · Baolu Lu

Hi Jason,

Quoted 10 lines · Jason Gunthorpe

drivers/iommu/intel/iommu.c static int __init probe_acpi_namespace_devices(void) · line 4052

Quoted 7 lines
drivers/iommu/intel/iommu.c +7 -0
+static __init int tboot_force_iommu(void)
+{
+	if (!tboot_enabled())
+		return 0;
+
+	if (no_iommu || dmar_disabled)
+		pr_warn("Forcing Intel-IOMMU to enabled\n");

Unrelated, but when we are in the special secure IOMMU modes, do we force ATS off? Specifically does the IOMMU reject TLPs that are marked as translated?

Quoted 6 lines
Quoted 3 lines

Good question. From IOMMU point of view, I don't see a point to force ATS off, but trust boot involves lots of other things that I am not familiar with. Anybody else could help to answer?

ATS is inherently not secure, if a rouge device can issue a TLP with the translated bit set then it has unlimited access to host memory.

Agreed. The current logic is that the platform lets the OS know such devices through firmware (ACPI/DT) and OS sets the untrusted flag in their device structures. The IOMMU subsystem will disable ATS on devices with the untrusted flag set.

There is some discussion about allowing the supervisor users to set the trust policy through the sysfs ABI, but I don't think this has happened in upstream kernel.

Quoted 2 lines

Many of these trusted iommu scenarios rely on the idea that a rouge device cannot DMA to arbitary system memory.

I am not sure whether tboot has the same requirement.

Best regards,
baolu

author maintainer
#18 lore raw

PATCH 7/7 iommu/vt-d: Move include/linux/intel_iommu.h under iommu

In reply to Lu Baolu

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

---
 include/linux/intel-iommu.h => drivers/iommu/intel/iommu.h | 0
 drivers/iommu/intel/trace.h                                | 3 ++-
 drivers/iommu/intel/cap_audit.c                            | 2 +-
 drivers/iommu/intel/debugfs.c                              | 2 +-
 drivers/iommu/intel/dmar.c                                 | 2 +-
 drivers/iommu/intel/iommu.c                                | 2 +-
 drivers/iommu/intel/irq_remapping.c                        | 2 +-
 drivers/iommu/intel/pasid.c                                | 2 +-
 drivers/iommu/intel/perf.c                                 | 2 +-
 drivers/iommu/intel/svm.c                                  | 2 +-
 MAINTAINERS                                                | 1 -
 11 files changed, 10 insertions(+), 10 deletions(-)
 rename include/linux/intel-iommu.h => drivers/iommu/intel/iommu.h (100%)
drivers/iommu/intel/iommu.h renamed from include/linux/intel-iommu.h +0 -0
similarity index 100%
rename from include/linux/intel-iommu.h
rename to drivers/iommu/intel/iommu.h
drivers/iommu/intel/trace.h +2 -1
index 25cb7f88e1a2..93d96f93a89b 100644
@@ -13,7 +13,8 @@
 #define _TRACE_INTEL_IOMMU_H
 
 #include <linux/tracepoint.h>
-#include <linux/intel-iommu.h>
+
+#include "iommu.h"
 
 #define MSG_MAX		256
 
drivers/iommu/intel/cap_audit.c +1 -1
index 71596fc62822..3ee68393122f 100644
@@ -10,7 +10,7 @@
 
 #define pr_fmt(fmt)	"DMAR: " fmt
 
-#include <linux/intel-iommu.h>
+#include "iommu.h"
 #include "cap_audit.h"
 
 static u64 intel_iommu_cap_sanity;
drivers/iommu/intel/debugfs.c +1 -1
index ed796eea4581..d927ef10641b 100644
@@ -10,11 +10,11 @@
 
 #include <linux/debugfs.h>
 #include <linux/dmar.h>
-#include <linux/intel-iommu.h>
 #include <linux/pci.h>
 
 #include <asm/irq_remapping.h>
 
+#include "iommu.h"
 #include "pasid.h"
 #include "perf.h"
 
drivers/iommu/intel/dmar.c +1 -1
index b02d72097a8c..059af0ef2a9d 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>
@@ -32,6 +31,7 @@
 #include <asm/irq_remapping.h>
 #include <asm/iommu_table.h>
 
+#include "iommu.h"
 #include "../irq_remapping.h"
 #include "perf.h"
 #include "trace.h"
drivers/iommu/intel/iommu.c +1 -1
index ea1c3bcd38d5..1af4b6562266 100644
@@ -17,7 +17,6 @@
 #include <linux/dma-direct.h>
 #include <linux/dma-iommu.h>
 #include <linux/dmi.h>
-#include <linux/intel-iommu.h>
 #include <linux/intel-svm.h>
 #include <linux/memory.h>
 #include <linux/pci.h>
@@ -26,6 +25,7 @@
 #include <linux/syscore_ops.h>
 #include <linux/tboot.h>
 
+#include "iommu.h"
 #include "../irq_remapping.h"
 #include "../iommu-sva-lib.h"
 #include "pasid.h"
drivers/iommu/intel/irq_remapping.c +1 -1
index a67319597884..2e9683e970f8 100644
@@ -10,7 +10,6 @@
 #include <linux/hpet.h>
 #include <linux/pci.h>
 #include <linux/irq.h>
-#include <linux/intel-iommu.h>
 #include <linux/acpi.h>
 #include <linux/irqdomain.h>
 #include <linux/crash_dump.h>
@@ -21,6 +20,7 @@
 #include <asm/irq_remapping.h>
 #include <asm/pci-direct.h>
 
+#include "iommu.h"
 #include "../irq_remapping.h"
 #include "cap_audit.h"
 
drivers/iommu/intel/pasid.c +1 -1
index cb4c1d0cf25c..b2ac5869286f 100644
@@ -12,13 +12,13 @@
 #include <linux/bitops.h>
 #include <linux/cpufeature.h>
 #include <linux/dmar.h>
-#include <linux/intel-iommu.h>
 #include <linux/iommu.h>
 #include <linux/memory.h>
 #include <linux/pci.h>
 #include <linux/pci-ats.h>
 #include <linux/spinlock.h>
 
+#include "iommu.h"
 #include "pasid.h"
 
 /*
drivers/iommu/intel/perf.c +1 -1
index 0e8e03252d92..94ee70ac38e3 100644
@@ -9,8 +9,8 @@
  */
 
 #include <linux/spinlock.h>
-#include <linux/intel-iommu.h>
 
+#include "iommu.h"
 #include "perf.h"
 
 static DEFINE_SPINLOCK(latency_lock);
drivers/iommu/intel/svm.c +1 -1
index 70b40d007a52..580713aa9e07 100644
@@ -5,7 +5,6 @@
  * Authors: David Woodhouse <[email protected]>
  */
 
-#include <linux/intel-iommu.h>
 #include <linux/mmu_notifier.h>
 #include <linux/sched.h>
 #include <linux/sched/mm.h>
@@ -22,6 +21,7 @@
 #include <asm/page.h>
 #include <asm/fpu/api.h>
 
+#include "iommu.h"
 #include "pasid.h"
 #include "perf.h"
 #include "../iommu-sva-lib.h"
MAINTAINERS +0 -1
index a2095c832d84..81458c7f9a32 100644
@@ -9870,7 +9870,6 @@ L:	[email protected]
 S:	Supported
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git
 F:	drivers/iommu/intel/
-F:	include/linux/intel-iommu.h
 F:	include/linux/intel-svm.h
 
 INTEL IOP-ADMA DMA DRIVER
Signature · 6 lines
2.25.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Reviewed-by on v1 7/7
#19 lore raw

Re: [PATCH 7/7] iommu/vt-d: Move include/linux/intel_iommu.h under iommu

Quoted 4 lines · Lu Baolu

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

Quoted 14 lines
---
 include/linux/intel-iommu.h => drivers/iommu/intel/iommu.h | 0
 drivers/iommu/intel/trace.h                                | 3 ++-
 drivers/iommu/intel/cap_audit.c                            | 2 +-
 drivers/iommu/intel/debugfs.c                              | 2 +-
 drivers/iommu/intel/dmar.c                                 | 2 +-
 drivers/iommu/intel/iommu.c                                | 2 +-
 drivers/iommu/intel/irq_remapping.c                        | 2 +-
 drivers/iommu/intel/pasid.c                                | 2 +-
 drivers/iommu/intel/perf.c                                 | 2 +-
 drivers/iommu/intel/svm.c                                  | 2 +-
 MAINTAINERS                                                | 1 -
 11 files changed, 10 insertions(+), 10 deletions(-)
 rename include/linux/intel-iommu.h => drivers/iommu/intel/iommu.h (100%)

Jason

Reviewed-by on the v1 series
#20 lore raw
In reply to Lu Baolu
Quoted 11 lines · Lu Baolu

Hi folks,

The include/linux/intel-iommu.h should be private to the Intel IOMMU driver. Other drivers or components should interact with the IOMMU drivers through the kAPIs provided by the iommu core.

This series cleanups all includes of intel-iommu.h outside of the Intel IOMMU driver and move this header from include/linux to drivers/iommu/intel/.

No functional changes intended. Please help to review and suggest.

Thanks, this was long overdue!

The series looks good to me:

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reviewed-by on the v1 series
#21 lore raw
In reply to Lu Baolu
Quoted 11 lines · Lu Baolu

Hi folks,

The include/linux/intel-iommu.h should be private to the Intel IOMMU driver. Other drivers or components should interact with the IOMMU drivers through the kAPIs provided by the iommu core.

This series cleanups all includes of intel-iommu.h outside of the Intel IOMMU driver and move this header from include/linux to drivers/iommu/intel/.

No functional changes intended. Please help to review and suggest.

I went through and examined the changes as well. These changes make the robots complaint against my patch go away, which is great by me!

Signature · 5 lines
Steve Wahl, Hewlett Packard Enterprise
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu