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 93config OF_IOMMU 94 def_bool y 95 depends on OF && IOMMU_API 96 97# IOMMU-agnostic DMA-mapping layer 98config IOMMU_DMA 99 bool 100 select DMA_OPS 101 select IOMMU_API 102 select IOMMU_IOVA 103 select IRQ_MSI_IOMMU 104 select NEED_SG_DMA_LENGTH 105 106config FSL_PAMU 107 bool "Freescale IOMMU support" 108 depends on PCI 109 depends on PHYS_64BIT 110 depends on PPC_E500MC || (COMPILE_TEST && PPC) 111 select IOMMU_API 112 select GENERIC_ALLOCATOR 113 help 114 Freescale PAMU support. PAMU is the IOMMU present on Freescale QorIQ platforms. 115 PAMU can authorize memory access, remap the memory address, and remap I/O 116 transaction types. 117 118# MSM IOMMU support 119config MSM_IOMMU 120 bool "MSM IOMMU Support" 121 depends on ARM 122 depends on ARCH_MSM8X60 || ARCH_MSM8960 || COMPILE_TEST 123 select IOMMU_API 124 select IOMMU_IO_PGTABLE_ARMV7S 125 help 126 Support for the IOMMUs found on certain Qualcomm SOCs. 127 These IOMMUs allow virtualization of the address space used by most 128 cores within the multimedia subsystem. 129 130 If unsure, say N here. 131 132config IOMMU_PGTABLES_L2 133 def_bool y 134 depends on MSM_IOMMU && MMU && SMP && CPU_DCACHE_DISABLE=n 135 136# AMD IOMMU support 137config AMD_IOMMU 138 bool "AMD IOMMU support" 139 select SWIOTLB 140 select PCI_MSI 141 select PCI_ATS 142 select PCI_PRI 143 select PCI_PASID 144 select IOMMU_API 145 select IOMMU_IOVA 146 select IOMMU_DMA 147 depends on X86_64 && PCI && ACPI 148 help 149 With this option you can enable support for AMD IOMMU hardware in 150 your system. An IOMMU is a hardware component which provides 151 remapping of DMA memory accesses from devices. With an AMD IOMMU you 152 can isolate the DMA memory of different devices and protect the 153 system from misbehaving device drivers or hardware. 154 155 You can find out if your system has an AMD IOMMU if you look into 156 your BIOS for an option to enable it or if you have an IVRS ACPI 157 table. 158 159config AMD_IOMMU_V2 160 tristate "AMD IOMMU Version 2 driver" 161 depends on AMD_IOMMU 162 select MMU_NOTIFIER 163 help 164 This option enables support for the AMD IOMMUv2 features of the IOMMU 165 hardware. Select this option if you want to use devices that support 166 the PCI PRI and PASID interface. 167 168config AMD_IOMMU_DEBUGFS 169 bool "Enable AMD IOMMU internals in DebugFS" 170 depends on AMD_IOMMU && IOMMU_DEBUGFS 171 help 172 !!!WARNING!!! !!!WARNING!!! !!!WARNING!!! !!!WARNING!!! 173 174 DO NOT ENABLE THIS OPTION UNLESS YOU REALLY, -REALLY- KNOW WHAT YOU ARE DOING!!! 175 Exposes AMD IOMMU device internals in DebugFS. 176 177 This option is -NOT- intended for production environments, and should 178 not generally be enabled. 179 180# Intel IOMMU support 181config DMAR_TABLE 182 bool 183 184config INTEL_IOMMU 185 bool "Support for Intel IOMMU using DMA Remapping Devices" 186 depends on PCI_MSI && ACPI && (X86 || IA64) 187 select DMA_OPS 188 select IOMMU_API 189 select IOMMU_IOVA 190 select NEED_DMA_MAP_STATE 191 select DMAR_TABLE 192 select SWIOTLB 193 select IOASID 194 help 195 DMA remapping (DMAR) devices support enables independent address 196 translations for Direct Memory Access (DMA) from devices. 197 These DMA remapping devices are reported via ACPI tables 198 and include PCI device scope covered by these DMA 199 remapping devices. 200 201config INTEL_IOMMU_DEBUGFS 202 bool "Export Intel IOMMU internals in Debugfs" 203 depends on INTEL_IOMMU && IOMMU_DEBUGFS 204 help 205 !!!WARNING!!! 206 207 DO NOT ENABLE THIS OPTION UNLESS YOU REALLY KNOW WHAT YOU ARE DOING!!! 208 209 Expose Intel IOMMU internals in Debugfs. 210 211 This option is -NOT- intended for production environments, and should 212 only be enabled for debugging Intel IOMMU. 213 214config INTEL_IOMMU_SVM 215 bool "Support for Shared Virtual Memory with Intel IOMMU" 216 depends on INTEL_IOMMU && X86_64 217 select PCI_PASID 218 select PCI_PRI 219 select MMU_NOTIFIER 220 select IOASID 221 help 222 Shared Virtual Memory (SVM) provides a facility for devices 223 to access DMA resources through process address space by 224 means of a Process Address Space ID (PASID). 225 226config INTEL_IOMMU_DEFAULT_ON 227 def_bool y 228 prompt "Enable Intel DMA Remapping Devices by default" 229 depends on INTEL_IOMMU 230 help 231 Selecting this option will enable a DMAR device at boot time if 232 one is found. If this option is not selected, DMAR support can 233 be enabled by passing intel_iommu=on to the kernel. 234 235config INTEL_IOMMU_BROKEN_GFX_WA 236 bool "Workaround broken graphics drivers (going away soon)" 237 depends on INTEL_IOMMU && BROKEN && X86 238 help 239 Current Graphics drivers tend to use physical address 240 for DMA and avoid using DMA APIs. Setting this config 241 option permits the IOMMU driver to set a unity map for 242 all the OS-visible memory. Hence the driver can continue 243 to use physical addresses for DMA, at least until this 244 option is removed in the 2.6.32 kernel. 245 246config INTEL_IOMMU_FLOPPY_WA 247 def_bool y 248 depends on INTEL_IOMMU && X86 249 help 250 Floppy disk drivers are known to bypass DMA API calls 251 thereby failing to work when IOMMU is enabled. This 252 workaround will setup a 1:1 mapping for the first 253 16MiB to make floppy (an ISA device) work. 254 255config INTEL_IOMMU_SCALABLE_MODE_DEFAULT_ON 256 bool "Enable Intel IOMMU scalable mode by default" 257 depends on INTEL_IOMMU 258 help 259 Selecting this option will enable by default the scalable mode if 260 hardware presents the capability. The scalable mode is defined in 261 VT-d 3.0. The scalable mode capability could be checked by reading 262 /sys/devices/virtual/iommu/dmar*/intel-iommu/ecap. If this option 263 is not selected, scalable mode support could also be enabled by 264 passing intel_iommu=sm_on to the kernel. If not sure, please use 265 the default value. 266 267config IRQ_REMAP 268 bool "Support for Interrupt Remapping" 269 depends on X86_64 && X86_IO_APIC && PCI_MSI && ACPI 270 select DMAR_TABLE 271 help 272 Supports Interrupt remapping for IO-APIC and MSI devices. 273 To use x2apic mode in the CPU's which support x2APIC enhancements or 274 to support platforms with CPU's having > 8 bit APIC ID, say Y. 275 276# OMAP IOMMU support 277config OMAP_IOMMU 278 bool "OMAP IOMMU Support" 279 depends on ARM && MMU || (COMPILE_TEST && (ARM || ARM64 || IA64 || SPARC)) 280 depends on ARCH_OMAP2PLUS || COMPILE_TEST 281 select IOMMU_API 282 help 283 The OMAP3 media platform drivers depend on iommu support, 284 if you need them say Y here. 285 286config OMAP_IOMMU_DEBUG 287 bool "Export OMAP IOMMU internals in DebugFS" 288 depends on OMAP_IOMMU && DEBUG_FS 289 help 290 Select this to see extensive information about 291 the internal state of OMAP IOMMU in debugfs. 292 293 Say N unless you know you need this. 294 295config ROCKCHIP_IOMMU 296 bool "Rockchip IOMMU Support" 297 depends on ARM || ARM64 || (COMPILE_TEST && (ARM64 || IA64 || SPARC)) 298 depends on ARCH_ROCKCHIP || COMPILE_TEST 299 select IOMMU_API 300 select ARM_DMA_USE_IOMMU 301 help 302 Support for IOMMUs found on Rockchip rk32xx SOCs. 303 These IOMMUs allow virtualization of the address space used by most 304 cores within the multimedia subsystem. 305 Say Y here if you are using a Rockchip SoC that includes an IOMMU 306 device. 307 308config SUN50I_IOMMU 309 bool "Allwinner H6 IOMMU Support" 310 depends on HAS_DMA 311 depends on ARCH_SUNXI || COMPILE_TEST 312 select ARM_DMA_USE_IOMMU 313 select IOMMU_API 314 select IOMMU_DMA 315 help 316 Support for the IOMMU introduced in the Allwinner H6 SoCs. 317 318config TEGRA_IOMMU_GART 319 bool "Tegra GART IOMMU Support" 320 depends on ARCH_TEGRA_2x_SOC 321 depends on TEGRA_MC 322 select IOMMU_API 323 help 324 Enables support for remapping discontiguous physical memory 325 shared with the operating system into contiguous I/O virtual 326 space through the GART (Graphics Address Relocation Table) 327 hardware included on Tegra SoCs. 328 329config TEGRA_IOMMU_SMMU 330 bool "NVIDIA Tegra SMMU Support" 331 depends on ARCH_TEGRA 332 depends on TEGRA_AHB 333 depends on TEGRA_MC 334 select IOMMU_API 335 help 336 This driver supports the IOMMU hardware (SMMU) found on NVIDIA Tegra 337 SoCs (Tegra30 up to Tegra210). 338 339config EXYNOS_IOMMU 340 bool "Exynos IOMMU Support" 341 depends on ARCH_EXYNOS && MMU || (COMPILE_TEST && (ARM || ARM64 || IA64 || SPARC)) 342 depends on !CPU_BIG_ENDIAN # revisit driver if we can enable big-endian ptes 343 select IOMMU_API 344 select ARM_DMA_USE_IOMMU 345 help 346 Support for the IOMMU (System MMU) of Samsung Exynos application 347 processor family. This enables H/W multimedia accelerators to see 348 non-linear physical memory chunks as linear memory in their 349 address space. 350 351 If unsure, say N here. 352 353config EXYNOS_IOMMU_DEBUG 354 bool "Debugging log for Exynos IOMMU" 355 depends on EXYNOS_IOMMU 356 help 357 Select this to see the detailed log message that shows what 358 happens in the IOMMU driver. 359 360 Say N unless you need kernel log message for IOMMU debugging. 361 362config IPMMU_VMSA 363 bool "Renesas VMSA-compatible IPMMU" 364 depends on ARM || IOMMU_DMA 365 depends on ARCH_RENESAS || (COMPILE_TEST && !GENERIC_ATOMIC64) 366 select IOMMU_API 367 select IOMMU_IO_PGTABLE_LPAE 368 select ARM_DMA_USE_IOMMU 369 help 370 Support for the Renesas VMSA-compatible IPMMU found in the R-Mobile 371 APE6, R-Car Gen2, and R-Car Gen3 SoCs. 372 373 If unsure, say N. 374 375config SPAPR_TCE_IOMMU 376 bool "sPAPR TCE IOMMU Support" 377 depends on PPC_POWERNV || PPC_PSERIES 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 383# ARM IOMMU support 384config ARM_SMMU 385 tristate "ARM Ltd. System MMU (SMMU) Support" 386 depends on (ARM64 || ARM || (COMPILE_TEST && !GENERIC_ATOMIC64)) && MMU 387 select IOMMU_API 388 select IOMMU_IO_PGTABLE_LPAE 389 select ARM_DMA_USE_IOMMU if ARM 390 help 391 Support for implementations of the ARM System MMU architecture 392 versions 1 and 2. 393 394 Say Y here if your SoC includes an IOMMU device implementing 395 the ARM SMMU architecture. 396 397config ARM_SMMU_LEGACY_DT_BINDINGS 398 bool "Support the legacy \"mmu-masters\" devicetree bindings" 399 depends on ARM_SMMU=y && OF 400 help 401 Support for the badly designed and deprecated "mmu-masters" 402 devicetree bindings. This allows some DMA masters to attach 403 to the SMMU but does not provide any support via the DMA API. 404 If you're lucky, you might be able to get VFIO up and running. 405 406 If you say Y here then you'll make me very sad. Instead, say N 407 and move your firmware to the utopian future that was 2016. 408 409config ARM_SMMU_DISABLE_BYPASS_BY_DEFAULT 410 bool "Default to disabling bypass on ARM SMMU v1 and v2" 411 depends on ARM_SMMU 412 default y 413 help 414 Say Y here to (by default) disable bypass streams such that 415 incoming transactions from devices that are not attached to 416 an iommu domain will report an abort back to the device and 417 will not be allowed to pass through the SMMU. 418 419 Any old kernels that existed before this KConfig was 420 introduced would default to _allowing_ bypass (AKA the 421 equivalent of NO for this config). However the default for 422 this option is YES because the old behavior is insecure. 423 424 There are few reasons to allow unmatched stream bypass, and 425 even fewer good ones. If saying YES here breaks your board 426 you should work on fixing your board. This KConfig option 427 is expected to be removed in the future and we'll simply 428 hardcode the bypass disable in the code. 429 430 NOTE: the kernel command line parameter 431 'arm-smmu.disable_bypass' will continue to override this 432 config. 433 434config ARM_SMMU_V3 435 tristate "ARM Ltd. System MMU Version 3 (SMMUv3) Support" 436 depends on ARM64 437 select IOMMU_API 438 select IOMMU_IO_PGTABLE_LPAE 439 select GENERIC_MSI_IRQ_DOMAIN 440 help 441 Support for implementations of the ARM System MMU architecture 442 version 3 providing translation support to a PCIe root complex. 443 444 Say Y here if your system includes an IOMMU device implementing 445 the ARM SMMUv3 architecture. 446 447config S390_IOMMU 448 def_bool y if S390 && PCI 449 depends on S390 && PCI 450 select IOMMU_API 451 help 452 Support for the IOMMU API for s390 PCI devices. 453 454config S390_CCW_IOMMU 455 bool "S390 CCW IOMMU Support" 456 depends on S390 && CCW || COMPILE_TEST 457 select IOMMU_API 458 help 459 Enables bits of IOMMU API required by VFIO. The iommu_ops 460 is not implemented as it is not necessary for VFIO. 461 462config S390_AP_IOMMU 463 bool "S390 AP IOMMU Support" 464 depends on S390 && ZCRYPT || COMPILE_TEST 465 select IOMMU_API 466 help 467 Enables bits of IOMMU API required by VFIO. The iommu_ops 468 is not implemented as it is not necessary for VFIO. 469 470config MTK_IOMMU 471 bool "MTK IOMMU Support" 472 depends on HAS_DMA 473 depends on ARCH_MEDIATEK || COMPILE_TEST 474 select ARM_DMA_USE_IOMMU 475 select IOMMU_API 476 select IOMMU_DMA 477 select IOMMU_IO_PGTABLE_ARMV7S 478 select MEMORY 479 select MTK_SMI 480 help 481 Support for the M4U on certain Mediatek SOCs. M4U is MultiMedia 482 Memory Management Unit. This option enables remapping of DMA memory 483 accesses for the multimedia subsystem. 484 485 If unsure, say N here. 486 487config MTK_IOMMU_V1 488 bool "MTK IOMMU Version 1 (M4U gen1) Support" 489 depends on ARM 490 depends on ARCH_MEDIATEK || COMPILE_TEST 491 select ARM_DMA_USE_IOMMU 492 select IOMMU_API 493 select MEMORY 494 select MTK_SMI 495 help 496 Support for the M4U on certain Mediatek SoCs. M4U generation 1 HW is 497 Multimedia Memory Managememt Unit. This option enables remapping of 498 DMA memory accesses for the multimedia subsystem. 499 500 if unsure, say N here. 501 502config QCOM_IOMMU 503 # Note: iommu drivers cannot (yet?) be built as modules 504 bool "Qualcomm IOMMU Support" 505 depends on ARCH_QCOM || (COMPILE_TEST && !GENERIC_ATOMIC64) 506 select IOMMU_API 507 select IOMMU_IO_PGTABLE_LPAE 508 select ARM_DMA_USE_IOMMU 509 help 510 Support for IOMMU on certain Qualcomm SoCs. 511 512config HYPERV_IOMMU 513 bool "Hyper-V x2APIC IRQ Handling" 514 depends on HYPERV && X86 515 select IOMMU_API 516 default HYPERV 517 help 518 Stub IOMMU driver to handle IRQs as to allow Hyper-V Linux 519 guests to run with x2APIC mode enabled. 520 521config VIRTIO_IOMMU 522 tristate "Virtio IOMMU driver" 523 depends on VIRTIO 524 depends on ARM64 525 select IOMMU_API 526 select INTERVAL_TREE 527 help 528 Para-virtualised IOMMU driver with virtio. 529 530 Say Y here if you intend to run this kernel as a guest. 531 532endif # IOMMU_SUPPORT 533