Skip to content

Commit 58d1131

Browse files
olofjjoergroedel
authored andcommitted
iommu: Add config option to set passthrough as default
This allows the default behavior to be controlled by a kernel config option instead of changing the commandline for the kernel to include "iommu.passthrough=on" or "iommu=pt" on machines where this is desired. Likewise, for machines where this config option is enabled, it can be disabled at boot time with "iommu.passthrough=off" or "iommu=nopt". Also corrected iommu=pt documentation for IA-64, since it has no code that parses iommu= at all. Signed-off-by: Olof Johansson <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent c52c72d commit 58d1131

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,8 @@
17161716
merge
17171717
nomerge
17181718
soft
1719-
pt [x86, IA-64]
1719+
pt [x86]
1720+
nopt [x86]
17201721
nobypass [PPC/POWERNV]
17211722
Disable IOMMU bypass, using IOMMU for PCI devices.
17221723

arch/x86/kernel/pci-dma.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,14 @@ int iommu_detected __read_mostly = 0;
4040
* devices and allow every device to access to whole physical memory. This is
4141
* useful if a user wants to use an IOMMU only for KVM device assignment to
4242
* guests and not for driver dma translation.
43+
* It is also possible to disable by default in kernel config, and enable with
44+
* iommu=nopt at boot time.
4345
*/
46+
#ifdef CONFIG_IOMMU_DEFAULT_PASSTHROUGH
47+
int iommu_pass_through __read_mostly = 1;
48+
#else
4449
int iommu_pass_through __read_mostly;
50+
#endif
4551

4652
extern struct iommu_table_entry __iommu_table[], __iommu_table_end[];
4753

@@ -135,6 +141,8 @@ static __init int iommu_setup(char *p)
135141
#endif
136142
if (!strncmp(p, "pt", 2))
137143
iommu_pass_through = 1;
144+
if (!strncmp(p, "nopt", 4))
145+
iommu_pass_through = 0;
138146

139147
gart_parse_options(p);
140148

drivers/iommu/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ config IOMMU_DEBUGFS
7070
debug/iommu directory, and then populate a subdirectory with
7171
entries as required.
7272

73+
config IOMMU_DEFAULT_PASSTHROUGH
74+
bool "IOMMU passthrough by default"
75+
depends on IOMMU_API
76+
help
77+
Enable passthrough by default, removing the need to pass in
78+
iommu.passthrough=on or iommu=pt through command line. If this
79+
is enabled, you can still disable with iommu.passthrough=off
80+
or iommu=nopt depending on the architecture.
81+
82+
If unsure, say N here.
83+
7384
config IOMMU_IOVA
7485
tristate
7586

drivers/iommu/iommu.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@
3636

3737
static struct kset *iommu_group_kset;
3838
static DEFINE_IDA(iommu_group_ida);
39+
#ifdef CONFIG_IOMMU_DEFAULT_PASSTHROUGH
40+
static unsigned int iommu_def_domain_type = IOMMU_DOMAIN_IDENTITY;
41+
#else
3942
static unsigned int iommu_def_domain_type = IOMMU_DOMAIN_DMA;
43+
#endif
4044

4145
struct iommu_callback_data {
4246
const struct iommu_ops *ops;

0 commit comments

Comments
 (0)