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# The IOASID library may also be used by non-IOMMU_API users 7config IOASID 8 tristate 9 10# IOMMU_API always gets selected by whoever wants it. 11config IOMMU_API 12 bool 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 && !GENERIC_ATOMIC64) 36 help 37 Enable support for the ARM long descriptor pagetable format. 38 This allocator supports 4K/2M/1G, 16K/32M and 64K/512M page 39 sizes at both stage-1 and stage-2, as well as address spaces 40 up to 48-bits in size. 41 42config IOMMU_IO_PGTABLE_LPAE_SELFTEST 43 bool "LPAE selftests" 44 depends on IOMMU_IO_PGTABLE_LPAE 45 help 46 Enable self-tests for LPAE page table allocator. This performs 47 a series of page-table consistency checks during boot. 48 49 If unsure, say N here. 50 51config IOMMU_IO_PGTABLE_ARMV7S 52 bool "ARMv7/v8 Short Descriptor Format" 53 select IOMMU_IO_PGTABLE 54 depends on ARM || ARM64 || COMPILE_TEST 55 help 56 Enable support for the ARM Short-descriptor pagetable format. 57 This supports 32-bit virtual and physical addresses mapped using 58 2-level tables with 4KB pages/1MB sections, and contiguous entries 59 for 64KB pages/16MB supersections if indicated by the IOMMU driver. 60 61config IOMMU_IO_PGTABLE_ARMV7S_SELFTEST 62 bool "ARMv7s selftests" 63 depends on IOMMU_IO_PGTABLE_ARMV7S 64 help 65 Enable self-tests for ARMv7s page table allocator. This performs 66 a series of page-table consistency checks during boot. 67 68 If unsure, say N here. 69 70endmenu 71 72config IOMMU_DEBUGFS 73 bool "Export IOMMU internals in DebugFS" 74 depends on DEBUG_FS 75 help 76 Allows exposure of IOMMU device internals. This option enables 77 the use of debugfs by IOMMU drivers as required. Devices can, 78 at initialization time, cause the IOMMU code to create a top-level 79 debug/iommu directory, and then populate a subdirectory with 80 entries as required. 81 82config IOMMU_DEFAULT_PASSTHROUGH 83 bool "IOMMU passthrough by default" 84 depends on IOMMU_API 85 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. 90 91 If unsure, say N here. 92 93choice 94 prompt "IOMMU default DMA IOTLB invalidation mode" 95 depends on IOMMU_DMA 96 97 default IOMMU_DEFAULT_STRICT 98 help 99 This option allows an IOMMU DMA IOTLB invalidation mode to be 100 chosen at build time, to override the default mode of each ARCH, 101 removing the need to pass in kernel parameters through command line. 102 It is still possible to provide common boot params to override this 103 config. 104 105 If unsure, keep the default. 106 107config IOMMU_DEFAULT_STRICT 108 bool "strict" 109 help 110 For every IOMMU DMA unmap operation, the flush operation of IOTLB and 111 the free operation of IOVA are guaranteed to be done in the unmap 112 function. 113 114config IOMMU_DEFAULT_LAZY 115 bool "lazy" 116 help 117 Support lazy mode, where for every IOMMU DMA unmap operation, the 118 flush operation of IOTLB and the free operation of IOVA are deferred. 119 They are only guaranteed to be done before the related IOVA will be 120 reused. 121 122 The isolation provided in this mode is not as secure as STRICT mode, 123 such that a vulnerable time window may be created between the DMA 124 unmap and the mappings cached in the IOMMU IOTLB or device TLB 125 finally being invalidated, where the device could still access the 126 memory which has already been unmapped by the device driver. 127 However this mode may provide better performance in high throughput 128 scenarios, and is still considerably more secure than passthrough 129 mode or no IOMMU. 130 131endchoice 132 133config OF_IOMMU 134 def_bool y 135 depends on OF && IOMMU_API 136 137# IOMMU-agnostic DMA-mapping layer 138config IOMMU_DMA 139 bool 140 select DMA_OPS 141 select IOMMU_API 142 select IOMMU_IOVA 143 select IRQ_MSI_IOMMU 144 select NEED_SG_DMA_LENGTH 145 146# Shared Virtual Addressing library 147config IOMMU_SVA_LIB 148 bool 149 select IOASID 150 151config FSL_PAMU 152 bool "Freescale IOMMU support" 153 depends on PCI 154 depends on PHYS_64BIT 155 depends on PPC_E500MC || (COMPILE_TEST && PPC) 156 select IOMMU_API 157 select GENERIC_ALLOCATOR 158 help 159 Freescale PAMU support. PAMU is the IOMMU present on Freescale QorIQ platforms. 160 PAMU can authorize memory access, remap the memory address, and remap I/O 161 transaction types. 162 163# MSM IOMMU support 164config MSM_IOMMU 165 bool "MSM IOMMU Support" 166 depends on ARM 167 depends on ARCH_MSM8X60 || ARCH_MSM8960 || COMPILE_TEST 168 select IOMMU_API 169 select IOMMU_IO_PGTABLE_ARMV7S 170 help 171 Support for the IOMMUs found on certain Qualcomm SOCs. 172 These IOMMUs allow virtualization of the address space used by most 173 cores within the multimedia subsystem. 174 175 If unsure, say N here. 176 177source "drivers/iommu/amd/Kconfig" 178source "drivers/iommu/intel/Kconfig" 179 180config IRQ_REMAP 181 bool "Support for Interrupt Remapping" 182 depends on X86_64 && X86_IO_APIC && PCI_MSI && ACPI 183 select DMAR_TABLE 184 help 185 Supports Interrupt remapping for IO-APIC and MSI devices. 186 To use x2apic mode in the CPU's which support x2APIC enhancements or 187 to support platforms with CPU's having > 8 bit APIC ID, say Y. 188 189# OMAP IOMMU support 190config OMAP_IOMMU 191 bool "OMAP IOMMU Support" 192 depends on ARCH_OMAP2PLUS || COMPILE_TEST 193 select IOMMU_API 194 help 195 The OMAP3 media platform drivers depend on iommu support, 196 if you need them say Y here. 197 198config OMAP_IOMMU_DEBUG 199 bool "Export OMAP IOMMU internals in DebugFS" 200 depends on OMAP_IOMMU && DEBUG_FS 201 help 202 Select this to see extensive information about 203 the internal state of OMAP IOMMU in debugfs. 204 205 Say N unless you know you need this. 206 207config ROCKCHIP_IOMMU 208 bool "Rockchip IOMMU Support" 209 depends on ARCH_ROCKCHIP || COMPILE_TEST 210 select IOMMU_API 211 select ARM_DMA_USE_IOMMU 212 help 213 Support for IOMMUs found on Rockchip rk32xx SOCs. 214 These IOMMUs allow virtualization of the address space used by most 215 cores within the multimedia subsystem. 216 Say Y here if you are using a Rockchip SoC that includes an IOMMU 217 device. 218 219config SUN50I_IOMMU 220 bool "Allwinner H6 IOMMU Support" 221 depends on HAS_DMA 222 depends on ARCH_SUNXI || COMPILE_TEST 223 select ARM_DMA_USE_IOMMU 224 select IOMMU_API 225 help 226 Support for the IOMMU introduced in the Allwinner H6 SoCs. 227 228config TEGRA_IOMMU_GART 229 bool "Tegra GART IOMMU Support" 230 depends on ARCH_TEGRA_2x_SOC 231 depends on TEGRA_MC 232 select IOMMU_API 233 help 234 Enables support for remapping discontiguous physical memory 235 shared with the operating system into contiguous I/O virtual 236 space through the GART (Graphics Address Relocation Table) 237 hardware included on Tegra SoCs. 238 239config TEGRA_IOMMU_SMMU 240 bool "NVIDIA Tegra SMMU Support" 241 depends on ARCH_TEGRA 242 depends on TEGRA_AHB 243 depends on TEGRA_MC 244 select IOMMU_API 245 help 246 This driver supports the IOMMU hardware (SMMU) found on NVIDIA Tegra 247 SoCs (Tegra30 up to Tegra210). 248 249config EXYNOS_IOMMU 250 bool "Exynos IOMMU Support" 251 depends on ARCH_EXYNOS || COMPILE_TEST 252 depends on !CPU_BIG_ENDIAN # revisit driver if we can enable big-endian ptes 253 select IOMMU_API 254 select ARM_DMA_USE_IOMMU 255 help 256 Support for the IOMMU (System MMU) of Samsung Exynos application 257 processor family. This enables H/W multimedia accelerators to see 258 non-linear physical memory chunks as linear memory in their 259 address space. 260 261 If unsure, say N here. 262 263config EXYNOS_IOMMU_DEBUG 264 bool "Debugging log for Exynos IOMMU" 265 depends on EXYNOS_IOMMU 266 help 267 Select this to see the detailed log message that shows what 268 happens in the IOMMU driver. 269 270 Say N unless you need kernel log message for IOMMU debugging. 271 272config IPMMU_VMSA 273 bool "Renesas VMSA-compatible IPMMU" 274 depends on ARCH_RENESAS || (COMPILE_TEST && !GENERIC_ATOMIC64) 275 select IOMMU_API 276 select IOMMU_IO_PGTABLE_LPAE 277 select ARM_DMA_USE_IOMMU 278 help 279 Support for the Renesas VMSA-compatible IPMMU found in the R-Mobile 280 APE6, R-Car Gen{2,3} and RZ/G{1,2} SoCs. 281 282 If unsure, say N. 283 284config SPAPR_TCE_IOMMU 285 bool "sPAPR TCE IOMMU Support" 286 depends on PPC_POWERNV || PPC_PSERIES 287 select IOMMU_API 288 help 289 Enables bits of IOMMU API required by VFIO. The iommu_ops 290 is not implemented as it is not necessary for VFIO. 291 292# ARM IOMMU support 293config ARM_SMMU 294 tristate "ARM Ltd. System MMU (SMMU) Support" 295 depends on ARM64 || ARM || (COMPILE_TEST && !GENERIC_ATOMIC64) 296 select IOMMU_API 297 select IOMMU_IO_PGTABLE_LPAE 298 select ARM_DMA_USE_IOMMU if ARM 299 help 300 Support for implementations of the ARM System MMU architecture 301 versions 1 and 2. 302 303 Say Y here if your SoC includes an IOMMU device implementing 304 the ARM SMMU architecture. 305 306config ARM_SMMU_LEGACY_DT_BINDINGS 307 bool "Support the legacy \"mmu-masters\" devicetree bindings" 308 depends on ARM_SMMU=y && OF 309 help 310 Support for the badly designed and deprecated "mmu-masters" 311 devicetree bindings. This allows some DMA masters to attach 312 to the SMMU but does not provide any support via the DMA API. 313 If you're lucky, you might be able to get VFIO up and running. 314 315 If you say Y here then you'll make me very sad. Instead, say N 316 and move your firmware to the utopian future that was 2016. 317 318config ARM_SMMU_DISABLE_BYPASS_BY_DEFAULT 319 bool "Default to disabling bypass on ARM SMMU v1 and v2" 320 depends on ARM_SMMU 321 default y 322 help 323 Say Y here to (by default) disable bypass streams such that 324 incoming transactions from devices that are not attached to 325 an iommu domain will report an abort back to the device and 326 will not be allowed to pass through the SMMU. 327 328 Any old kernels that existed before this KConfig was 329 introduced would default to _allowing_ bypass (AKA the 330 equivalent of NO for this config). However the default for 331 this option is YES because the old behavior is insecure. 332 333 There are few reasons to allow unmatched stream bypass, and 334 even fewer good ones. If saying YES here breaks your board 335 you should work on fixing your board. This KConfig option 336 is expected to be removed in the future and we'll simply 337 hardcode the bypass disable in the code. 338 339 NOTE: the kernel command line parameter 340 'arm-smmu.disable_bypass' will continue to override this 341 config. 342 343config ARM_SMMU_V3 344 tristate "ARM Ltd. System MMU Version 3 (SMMUv3) Support" 345 depends on ARM64 346 select IOMMU_API 347 select IOMMU_IO_PGTABLE_LPAE 348 select GENERIC_MSI_IRQ_DOMAIN 349 help 350 Support for implementations of the ARM System MMU architecture 351 version 3 providing translation support to a PCIe root complex. 352 353 Say Y here if your system includes an IOMMU device implementing 354 the ARM SMMUv3 architecture. 355 356config ARM_SMMU_V3_SVA 357 bool "Shared Virtual Addressing support for the ARM SMMUv3" 358 depends on ARM_SMMU_V3 359 select IOMMU_SVA_LIB 360 select MMU_NOTIFIER 361 help 362 Support for sharing process address spaces with devices using the 363 SMMUv3. 364 365 Say Y here if your system supports SVA extensions such as PCIe PASID 366 and PRI. 367 368config S390_IOMMU 369 def_bool y if S390 && PCI 370 depends on S390 && PCI 371 select IOMMU_API 372 help 373 Support for the IOMMU API for s390 PCI devices. 374 375config S390_CCW_IOMMU 376 bool "S390 CCW IOMMU Support" 377 depends on S390 && CCW || COMPILE_TEST 378 select IOMMU_API 379 help 380 Enables bits of IOMMU API required by VFIO. The iommu_ops 381 is not implemented as it is not necessary for VFIO. 382 383config S390_AP_IOMMU 384 bool "S390 AP IOMMU Support" 385 depends on S390 && ZCRYPT || COMPILE_TEST 386 select IOMMU_API 387 help 388 Enables bits of IOMMU API required by VFIO. The iommu_ops 389 is not implemented as it is not necessary for VFIO. 390 391config MTK_IOMMU 392 tristate "MediaTek IOMMU Support" 393 depends on ARCH_MEDIATEK || COMPILE_TEST 394 select ARM_DMA_USE_IOMMU 395 select IOMMU_API 396 select IOMMU_IO_PGTABLE_ARMV7S 397 select MEMORY 398 select MTK_SMI 399 help 400 Support for the M4U on certain Mediatek SOCs. M4U is MultiMedia 401 Memory Management Unit. This option enables remapping of DMA memory 402 accesses for the multimedia subsystem. 403 404 If unsure, say N here. 405 406config MTK_IOMMU_V1 407 tristate "MediaTek IOMMU Version 1 (M4U gen1) Support" 408 depends on ARM 409 depends on ARCH_MEDIATEK || COMPILE_TEST 410 select ARM_DMA_USE_IOMMU 411 select IOMMU_API 412 select MEMORY 413 select MTK_SMI 414 help 415 Support for the M4U on certain Mediatek SoCs. M4U generation 1 HW is 416 Multimedia Memory Managememt Unit. This option enables remapping of 417 DMA memory accesses for the multimedia subsystem. 418 419 if unsure, say N here. 420 421config QCOM_IOMMU 422 # Note: iommu drivers cannot (yet?) be built as modules 423 bool "Qualcomm IOMMU Support" 424 depends on ARCH_QCOM || (COMPILE_TEST && !GENERIC_ATOMIC64) 425 select IOMMU_API 426 select IOMMU_IO_PGTABLE_LPAE 427 select ARM_DMA_USE_IOMMU 428 help 429 Support for IOMMU on certain Qualcomm SoCs. 430 431config HYPERV_IOMMU 432 bool "Hyper-V x2APIC IRQ Handling" 433 depends on HYPERV && X86 434 select IOMMU_API 435 default HYPERV 436 help 437 Stub IOMMU driver to handle IRQs as to allow Hyper-V Linux 438 guests to run with x2APIC mode enabled. 439 440config VIRTIO_IOMMU 441 tristate "Virtio IOMMU driver" 442 depends on VIRTIO 443 depends on (ARM64 || X86) 444 select IOMMU_API 445 select IOMMU_DMA 446 select INTERVAL_TREE 447 select ACPI_VIOT if ACPI 448 help 449 Para-virtualised IOMMU driver with virtio. 450 451 Say Y here if you intend to run this kernel as a guest. 452 453config SPRD_IOMMU 454 tristate "Unisoc IOMMU Support" 455 depends on ARCH_SPRD || COMPILE_TEST 456 select IOMMU_API 457 help 458 Support for IOMMU on Unisoc's SoCs, this IOMMU can be used by 459 Unisoc's multimedia devices, such as display, Image codec(jpeg) 460 and a few signal processors, including VSP(video), GSP(graphic), 461 ISP(image), and CPP(camera pixel processor), etc. 462 463 Say Y here if you want to use the multimedia devices listed above. 464 465endif # IOMMU_SUPPORT 466