Kconfig 12 KB

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