Skip to content

Commit e96763e

Browse files
rmurphy-armjoergroedel
authored andcommitted
iommu: Merge strictness and domain type configs
To parallel the sysfs behaviour, merge the new build-time option for DMA domain strictness into the default domain type choice. Suggested-by: Joerg Roedel <[email protected]> Reviewed-by: Lu Baolu <[email protected]> Reviewed-by: Jean-Philippe Brucker <[email protected]> Reviewed-by: John Garry <[email protected]> Signed-off-by: Robin Murphy <[email protected]> Link: https://lore.kernel.org/r/d04af35b9c0f2a1d39605d7a9b451f5e1f0c7736.1628682049.git.robin.murphy@arm.com Signed-off-by: Joerg Roedel <[email protected]>
1 parent 7cf8a63 commit e96763e

File tree

3 files changed

+45
-47
lines changed

3 files changed

+45
-47
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,11 +2045,9 @@
20452045
1 - Strict mode.
20462046
DMA unmap operations invalidate IOMMU hardware TLBs
20472047
synchronously.
2048-
unset - Use value of CONFIG_IOMMU_DEFAULT_{LAZY,STRICT}.
2049-
Note: on x86, the default behaviour depends on the
2050-
equivalent driver-specific parameters, but a strict
2051-
mode explicitly specified by either method takes
2052-
precedence.
2048+
unset - Use value of CONFIG_IOMMU_DEFAULT_DMA_{LAZY,STRICT}.
2049+
Note: on x86, strict mode specified via one of the
2050+
legacy driver-specific options takes precedence.
20532051

20542052
iommu.passthrough=
20552053
[ARM64, X86] Configure DMA to bypass the IOMMU by default.

drivers/iommu/Kconfig

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -79,55 +79,55 @@ config IOMMU_DEBUGFS
7979
debug/iommu directory, and then populate a subdirectory with
8080
entries as required.
8181

82-
config IOMMU_DEFAULT_PASSTHROUGH
83-
bool "IOMMU passthrough by default"
82+
choice
83+
prompt "IOMMU default domain type"
8484
depends on IOMMU_API
85+
default IOMMU_DEFAULT_DMA_LAZY if AMD_IOMMU || INTEL_IOMMU
86+
default IOMMU_DEFAULT_DMA_STRICT
8587
help
86-
Enable passthrough by default, removing the need to pass in
87-
iommu.passthrough=on or iommu=pt through command line. If this
88-
is enabled, you can still disable with iommu.passthrough=off
89-
or iommu=nopt depending on the architecture.
88+
Choose the type of IOMMU domain used to manage DMA API usage by
89+
device drivers. The options here typically represent different
90+
levels of tradeoff between robustness/security and performance,
91+
depending on the IOMMU driver. Not all IOMMUs support all options.
92+
This choice can be overridden at boot via the command line, and for
93+
some devices also at runtime via sysfs.
9094

91-
If unsure, say N here.
95+
If unsure, keep the default.
9296

93-
choice
94-
prompt "IOMMU default DMA IOTLB invalidation mode"
95-
depends on IOMMU_DMA
97+
config IOMMU_DEFAULT_DMA_STRICT
98+
bool "Translated - Strict"
99+
help
100+
Trusted devices use translation to restrict their access to only
101+
DMA-mapped pages, with strict TLB invalidation on unmap. Equivalent
102+
to passing "iommu.passthrough=0 iommu.strict=1" on the command line.
96103

97-
default IOMMU_DEFAULT_LAZY if (AMD_IOMMU || INTEL_IOMMU)
98-
default IOMMU_DEFAULT_STRICT
104+
Untrusted devices always use this mode, with an additional layer of
105+
bounce-buffering such that they cannot gain access to any unrelated
106+
data within a mapped page.
107+
108+
config IOMMU_DEFAULT_DMA_LAZY
109+
bool "Translated - Lazy"
99110
help
100-
This option allows an IOMMU DMA IOTLB invalidation mode to be
101-
chosen at build time, to override the default mode of each ARCH,
102-
removing the need to pass in kernel parameters through command line.
103-
It is still possible to provide common boot params to override this
104-
config.
111+
Trusted devices use translation to restrict their access to only
112+
DMA-mapped pages, but with "lazy" batched TLB invalidation. This
113+
mode allows higher performance with some IOMMUs due to reduced TLB
114+
flushing, but at the cost of reduced isolation since devices may be
115+
able to access memory for some time after it has been unmapped.
116+
Equivalent to passing "iommu.passthrough=0 iommu.strict=0" on the
117+
command line.
105118

106-
If unsure, keep the default.
119+
If this mode is not supported by the IOMMU driver, the effective
120+
runtime default will fall back to IOMMU_DEFAULT_DMA_STRICT.
121+
122+
config IOMMU_DEFAULT_PASSTHROUGH
123+
bool "Passthrough"
124+
help
125+
Trusted devices are identity-mapped, giving them unrestricted access
126+
to memory with minimal performance overhead. Equivalent to passing
127+
"iommu.passthrough=1" (historically "iommu=pt") on the command line.
107128

108-
config IOMMU_DEFAULT_STRICT
109-
bool "strict"
110-
help
111-
For every IOMMU DMA unmap operation, the flush operation of IOTLB and
112-
the free operation of IOVA are guaranteed to be done in the unmap
113-
function.
114-
115-
config IOMMU_DEFAULT_LAZY
116-
bool "lazy"
117-
help
118-
Support lazy mode, where for every IOMMU DMA unmap operation, the
119-
flush operation of IOTLB and the free operation of IOVA are deferred.
120-
They are only guaranteed to be done before the related IOVA will be
121-
reused.
122-
123-
The isolation provided in this mode is not as secure as STRICT mode,
124-
such that a vulnerable time window may be created between the DMA
125-
unmap and the mappings cached in the IOMMU IOTLB or device TLB
126-
finally being invalidated, where the device could still access the
127-
memory which has already been unmapped by the device driver.
128-
However this mode may provide better performance in high throughput
129-
scenarios, and is still considerably more secure than passthrough
130-
mode or no IOMMU.
129+
If this mode is not supported by the IOMMU driver, the effective
130+
runtime default will fall back to IOMMU_DEFAULT_DMA_STRICT.
131131

132132
endchoice
133133

drivers/iommu/iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static struct kset *iommu_group_kset;
3131
static DEFINE_IDA(iommu_group_ida);
3232

3333
static unsigned int iommu_def_domain_type __read_mostly;
34-
static bool iommu_dma_strict __read_mostly = IS_ENABLED(CONFIG_IOMMU_DEFAULT_STRICT);
34+
static bool iommu_dma_strict __read_mostly = IS_ENABLED(CONFIG_IOMMU_DEFAULT_DMA_STRICT);
3535
static u32 iommu_cmd_line __read_mostly;
3636

3737
struct iommu_group {

0 commit comments

Comments
 (0)