xref: /linux/drivers/iommu/Kconfig (revision 2d7eaeb05ae265bd64270376e6a2c0d80244771f)
1# SPDX-License-Identifier: GPL-2.0-only
2# The IOVA library may also be used by non-IOMMU_API users
3config IOMMU_IOVA
4	tristate
5
6# IOMMU_API always gets selected by whoever wants it.
7config IOMMU_API
8	bool
9
10config IOMMUFD_DRIVER
11	bool
12	default n
13
14menuconfig IOMMU_SUPPORT
15	bool "IOMMU Hardware Support"
16	depends on MMU
17	default y
18	help
19	  Say Y here if you want to compile device drivers for IO Memory
20	  Management Units into the kernel. These devices usually allow to
21	  remap DMA requests and/or remap interrupts from other devices on the
22	  system.
23
24if IOMMU_SUPPORT
25
26menu "Generic IOMMU Pagetable Support"
27
28# Selected by the actual pagetable implementations
29config IOMMU_IO_PGTABLE
30	bool
31
32config IOMMU_IO_PGTABLE_LPAE
33	bool "ARMv7/v8 Long Descriptor Format"
34	select IOMMU_IO_PGTABLE
35	depends on ARM || ARM64 || COMPILE_TEST
36	depends on !GENERIC_ATOMIC64	# for cmpxchg64()
37	help
38	  Enable support for the ARM long descriptor pagetable format.
39	  This allocator supports 4K/2M/1G, 16K/32M and 64K/512M page
40	  sizes at both stage-1 and stage-2, as well as address spaces
41	  up to 48-bits in size.
42
43config IOMMU_IO_PGTABLE_LPAE_KUNIT_TEST
44	tristate "KUnit tests for LPAE"
45	depends on IOMMU_IO_PGTABLE_LPAE && KUNIT
46	default KUNIT_ALL_TESTS
47	help
48	  Enable kunit tests for LPAE page table allocator. This performs
49	  a series of page-table consistency checks.
50
51	  If unsure, say N here.
52
53config IOMMU_IO_PGTABLE_ARMV7S
54	bool "ARMv7/v8 Short Descriptor Format"
55	select IOMMU_IO_PGTABLE
56	depends on ARM || ARM64 || COMPILE_TEST
57	help
58	  Enable support for the ARM Short-descriptor pagetable format.
59	  This supports 32-bit virtual and physical addresses mapped using
60	  2-level tables with 4KB pages/1MB sections, and contiguous entries
61	  for 64KB pages/16MB supersections if indicated by the IOMMU driver.
62
63config IOMMU_IO_PGTABLE_ARMV7S_SELFTEST
64	bool "ARMv7s selftests"
65	depends on IOMMU_IO_PGTABLE_ARMV7S
66	help
67	  Enable self-tests for ARMv7s page table allocator. This performs
68	  a series of page-table consistency checks during boot.
69
70	  If unsure, say N here.
71
72config IOMMU_IO_PGTABLE_DART
73	bool "Apple DART Formats"
74	select IOMMU_IO_PGTABLE
75	depends on ARM64 || COMPILE_TEST
76	depends on !GENERIC_ATOMIC64	# for cmpxchg64()
77	help
78	  Enable support for the Apple DART pagetable formats. These include
79	  the t8020 and t6000/t8110 DART formats used in Apple M1/M2 family
80	  SoCs.
81
82	  If unsure, say N here.
83
84endmenu
85
86config IOMMU_DEBUGFS
87	bool "Export IOMMU internals in DebugFS"
88	depends on DEBUG_FS
89	help
90	  Allows exposure of IOMMU device internals. This option enables
91	  the use of debugfs by IOMMU drivers as required. Devices can,
92	  at initialization time, cause the IOMMU code to create a top-level
93	  debug/iommu directory, and then populate a subdirectory with
94	  entries as required.
95
96choice
97	prompt "IOMMU default domain type"
98	depends on IOMMU_API
99	default IOMMU_DEFAULT_DMA_LAZY if X86 || S390
100	default IOMMU_DEFAULT_DMA_STRICT
101	help
102	  Choose the type of IOMMU domain used to manage DMA API usage by
103	  device drivers. The options here typically represent different
104	  levels of tradeoff between robustness/security and performance,
105	  depending on the IOMMU driver. Not all IOMMUs support all options.
106	  This choice can be overridden at boot via the command line, and for
107	  some devices also at runtime via sysfs.
108
109	  If unsure, keep the default.
110
111config IOMMU_DEFAULT_DMA_STRICT
112	bool "Translated - Strict"
113	help
114	  Trusted devices use translation to restrict their access to only
115	  DMA-mapped pages, with strict TLB invalidation on unmap. Equivalent
116	  to passing "iommu.passthrough=0 iommu.strict=1" on the command line.
117
118	  Untrusted devices always use this mode, with an additional layer of
119	  bounce-buffering such that they cannot gain access to any unrelated
120	  data within a mapped page.
121
122config IOMMU_DEFAULT_DMA_LAZY
123	bool "Translated - Lazy"
124	help
125	  Trusted devices use translation to restrict their access to only
126	  DMA-mapped pages, but with "lazy" batched TLB invalidation. This
127	  mode allows higher performance with some IOMMUs due to reduced TLB
128	  flushing, but at the cost of reduced isolation since devices may be
129	  able to access memory for some time after it has been unmapped.
130	  Equivalent to passing "iommu.passthrough=0 iommu.strict=0" on the
131	  command line.
132
133	  If this mode is not supported by the IOMMU driver, the effective
134	  runtime default will fall back to IOMMU_DEFAULT_DMA_STRICT.
135
136config IOMMU_DEFAULT_PASSTHROUGH
137	bool "Passthrough"
138	help
139	  Trusted devices are identity-mapped, giving them unrestricted access
140	  to memory with minimal performance overhead. Equivalent to passing
141	  "iommu.passthrough=1" (historically "iommu=pt") on the command line.
142
143	  If this mode is not supported by the IOMMU driver, the effective
144	  runtime default will fall back to IOMMU_DEFAULT_DMA_STRICT.
145
146endchoice
147
148config OF_IOMMU
149	def_bool y
150	depends on OF && IOMMU_API
151
152# IOMMU-agnostic DMA-mapping layer
153config IOMMU_DMA
154	def_bool ARM64 || X86 || S390
155	select DMA_OPS_HELPERS
156	select IOMMU_API
157	select IOMMU_IOVA
158	select NEED_SG_DMA_LENGTH
159	select NEED_SG_DMA_FLAGS if SWIOTLB
160
161# Shared Virtual Addressing
162config IOMMU_SVA
163	select IOMMU_MM_DATA
164	bool
165
166config IOMMU_IOPF
167	bool
168
169config FSL_PAMU
170	bool "Freescale IOMMU support"
171	depends on PCI
172	depends on PHYS_64BIT
173	depends on PPC_E500MC || (COMPILE_TEST && PPC)
174	select IOMMU_API
175	select GENERIC_ALLOCATOR
176	help
177	  Freescale PAMU support. PAMU is the IOMMU present on Freescale QorIQ platforms.
178	  PAMU can authorize memory access, remap the memory address, and remap I/O
179	  transaction types.
180
181# MSM IOMMU support
182config MSM_IOMMU
183	bool "MSM IOMMU Support"
184	depends on ARM
185	depends on ARCH_QCOM || COMPILE_TEST
186	select IOMMU_API
187	select IOMMU_IO_PGTABLE_ARMV7S
188	help
189	  Support for the IOMMUs found on certain Qualcomm SOCs.
190	  These IOMMUs allow virtualization of the address space used by most
191	  cores within the multimedia subsystem.
192
193	  If unsure, say N here.
194
195source "drivers/iommu/amd/Kconfig"
196source "drivers/iommu/arm/Kconfig"
197source "drivers/iommu/intel/Kconfig"
198source "drivers/iommu/hyperv/Kconfig"
199source "drivers/iommu/iommufd/Kconfig"
200source "drivers/iommu/riscv/Kconfig"
201
202config IRQ_REMAP
203	bool "Support for Interrupt Remapping"
204	depends on X86_64 && X86_IO_APIC && PCI_MSI && ACPI
205	select IRQ_MSI_LIB
206	help
207	  Supports Interrupt remapping for IO-APIC and MSI devices.
208	  To use x2apic mode in the CPU's which support x2APIC enhancements or
209	  to support platforms with CPU's having > 8 bit APIC ID, say Y.
210
211# OMAP IOMMU support
212config OMAP_IOMMU
213	bool "OMAP IOMMU Support"
214	depends on ARCH_OMAP2PLUS || COMPILE_TEST
215	select IOMMU_API
216	help
217	  The OMAP3 media platform drivers depend on iommu support,
218	  if you need them say Y here.
219
220config OMAP_IOMMU_DEBUG
221	bool "Export OMAP IOMMU internals in DebugFS"
222	depends on OMAP_IOMMU && DEBUG_FS
223	help
224	  Select this to see extensive information about
225	  the internal state of OMAP IOMMU in debugfs.
226
227	  Say N unless you know you need this.
228
229config ROCKCHIP_IOMMU
230	bool "Rockchip IOMMU Support"
231	depends on ARCH_ROCKCHIP || COMPILE_TEST
232	select IOMMU_API
233	select ARM_DMA_USE_IOMMU
234	help
235	  Support for IOMMUs found on Rockchip rk32xx SOCs.
236	  These IOMMUs allow virtualization of the address space used by most
237	  cores within the multimedia subsystem.
238	  Say Y here if you are using a Rockchip SoC that includes an IOMMU
239	  device.
240
241config SUN50I_IOMMU
242	bool "Allwinner H6 IOMMU Support"
243	depends on HAS_DMA
244	depends on ARCH_SUNXI || COMPILE_TEST
245	select ARM_DMA_USE_IOMMU
246	select IOMMU_API
247	help
248	  Support for the IOMMU introduced in the Allwinner H6 SoCs.
249
250config TEGRA_IOMMU_SMMU
251	bool "NVIDIA Tegra SMMU Support"
252	depends on ARCH_TEGRA || COMPILE_TEST
253	depends on TEGRA_AHB
254	depends on TEGRA_MC
255	select IOMMU_API
256	help
257	  This driver supports the IOMMU hardware (SMMU) found on NVIDIA Tegra
258	  SoCs (Tegra30 up to Tegra210).
259
260config EXYNOS_IOMMU
261	bool "Exynos IOMMU Support"
262	depends on ARCH_EXYNOS || COMPILE_TEST
263	depends on !CPU_BIG_ENDIAN # revisit driver if we can enable big-endian ptes
264	select IOMMU_API
265	select ARM_DMA_USE_IOMMU
266	help
267	  Support for the IOMMU (System MMU) of Samsung Exynos application
268	  processor family. This enables H/W multimedia accelerators to see
269	  non-linear physical memory chunks as linear memory in their
270	  address space.
271
272	  If unsure, say N here.
273
274config EXYNOS_IOMMU_DEBUG
275	bool "Debugging log for Exynos IOMMU"
276	depends on EXYNOS_IOMMU
277	help
278	  Select this to see the detailed log message that shows what
279	  happens in the IOMMU driver.
280
281	  Say N unless you need kernel log message for IOMMU debugging.
282
283config IPMMU_VMSA
284	bool "Renesas VMSA-compatible IPMMU"
285	depends on ARCH_RENESAS || COMPILE_TEST
286	depends on ARM || ARM64 || COMPILE_TEST
287	depends on !GENERIC_ATOMIC64	# for IOMMU_IO_PGTABLE_LPAE
288	select IOMMU_API
289	select IOMMU_IO_PGTABLE_LPAE
290	select ARM_DMA_USE_IOMMU
291	help
292	  Support for the Renesas VMSA-compatible IPMMU found in the R-Mobile
293	  APE6, R-Car Gen{2,3} and RZ/G{1,2} SoCs.
294
295	  If unsure, say N.
296
297config SPAPR_TCE_IOMMU
298	bool "sPAPR TCE IOMMU Support"
299	depends on PPC_POWERNV || PPC_PSERIES
300	select IOMMU_API
301	help
302	  Enables bits of IOMMU API required by VFIO. The iommu_ops
303	  is not implemented as it is not necessary for VFIO.
304
305config APPLE_DART
306	tristate "Apple DART IOMMU Support"
307	depends on ARCH_APPLE || (COMPILE_TEST && 64BIT)
308	depends on !GENERIC_ATOMIC64	# for IOMMU_IO_PGTABLE_DART
309	select IOMMU_API
310	select IOMMU_IO_PGTABLE_DART
311	help
312	  Support for Apple DART (Device Address Resolution Table) IOMMUs
313	  found in Apple ARM SoCs like the M1.
314	  This IOMMU is required for most peripherals using DMA to access
315	  the main memory.
316
317	  Say Y here if you are using an Apple SoC.
318
319config S390_IOMMU
320	def_bool y if S390 && PCI
321	depends on S390 && PCI
322	select IOMMU_API
323	help
324	  Support for the IOMMU API for s390 PCI devices.
325
326config MTK_IOMMU
327	tristate "MediaTek IOMMU Support"
328	depends on ARCH_MEDIATEK || COMPILE_TEST
329	select ARM_DMA_USE_IOMMU
330	select IOMMU_API
331	select IOMMU_IO_PGTABLE_ARMV7S
332	select MEMORY
333	select MTK_SMI
334	help
335	  Support for the M4U on certain Mediatek SOCs. M4U is MultiMedia
336	  Memory Management Unit. This option enables remapping of DMA memory
337	  accesses for the multimedia subsystem.
338
339	  If unsure, say N here.
340
341config MTK_IOMMU_V1
342	tristate "MediaTek IOMMU Version 1 (M4U gen1) Support"
343	depends on (ARCH_MEDIATEK && ARM) || COMPILE_TEST
344	select ARM_DMA_USE_IOMMU
345	select IOMMU_API
346	select MEMORY
347	select MTK_SMI
348	help
349	  Support for the M4U on certain Mediatek SoCs. M4U generation 1 HW is
350	  Multimedia Memory Managememt Unit. This option enables remapping of
351	  DMA memory accesses for the multimedia subsystem.
352
353	  if unsure, say N here.
354
355config VIRTIO_IOMMU
356	tristate "Virtio IOMMU driver"
357	depends on VIRTIO
358	depends on (ARM64 || X86)
359	select IOMMU_API
360	select INTERVAL_TREE
361	select ACPI_VIOT if ACPI
362	help
363	  Para-virtualised IOMMU driver with virtio.
364
365	  Say Y here if you intend to run this kernel as a guest.
366
367config SPRD_IOMMU
368	tristate "Unisoc IOMMU Support"
369	depends on ARCH_SPRD || COMPILE_TEST
370	select IOMMU_API
371	help
372	  Support for IOMMU on Unisoc's SoCs, this IOMMU can be used by
373	  Unisoc's multimedia devices, such as display, Image codec(jpeg)
374	  and a few signal processors, including VSP(video), GSP(graphic),
375	  ISP(image), and CPP(camera pixel processor), etc.
376
377	  Say Y here if you want to use the multimedia devices listed above.
378
379config VSI_IOMMU
380	tristate "Verisilicon IOMMU Support"
381	depends on (ARCH_ROCKCHIP && ARM64) || COMPILE_TEST
382	select IOMMU_API
383	help
384	  Support for IOMMUs used by Verisilicon sub-systems like video
385	  decoders or encoder hardware blocks.
386
387	  Say Y here if you want to use this IOMMU in front of these
388	  hardware blocks.
389
390config BCM2712_IOMMU
391	bool "BCM2712 IOMMU driver"
392	depends on (ARCH_BCM2835 && ARM64) || COMPILE_TEST
393	select IOMMU_API
394	select GENERIC_PT
395	select IOMMU_PT
396	select IOMMU_PT_BCM2712
397	help
398	  Support for IOMMU on BCM2712 SoC. This IOMMU can be used by the
399	  display controller and various multimedia devices to perform
400	  efficient memory management.
401
402	  Say Y here if you want to use this IOMMU in front of these
403	  hardware blocks.
404
405config IOMMU_DEBUG_PAGEALLOC
406	bool "Debug IOMMU mappings against page allocations"
407	depends on DEBUG_PAGEALLOC && IOMMU_API && PAGE_EXTENSION
408	help
409	  This enables a consistency check between the kernel page allocator and
410	  the IOMMU subsystem. It verifies that pages being allocated or freed
411	  are not currently mapped in any IOMMU domain.
412
413	  This helps detect DMA use-after-free bugs where a driver frees a page
414	  but forgets to unmap it from the IOMMU, potentially allowing a device
415	  to overwrite memory that the kernel has repurposed.
416
417	  These checks are best-effort and may not detect all problems.
418
419	  Due to performance overhead, this feature is disabled by default.
420	  You must enable "iommu.debug_pagealloc" from the kernel command
421	  line to activate the runtime checks.
422
423	  If unsure, say N.
424endif # IOMMU_SUPPORT
425
426source "drivers/iommu/generic_pt/Kconfig"
427