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 10if IOMMU_IOVA 11 12config IOMMU_LIMIT_IOVA_ALIGNMENT 13 bool "Limit IOVA alignment" 14 help 15 When the IOVA framework applies IOVA alignment it aligns all 16 IOVAs to the smallest PAGE_SIZE order which is greater than or 17 equal to the requested IOVA size. This works fine for sizes up 18 to several MiB, but for larger sizes it results in address 19 space wastage and fragmentation. For example drivers with a 4 20 GiB IOVA space might run out of IOVA space when allocating 21 buffers great than 64 MiB. 22 23 Enable this option to impose a limit on the alignment of IOVAs. 24 25 If unsure, say N. 26 27config IOMMU_IOVA_ALIGNMENT 28 int "Maximum PAGE_SIZE order of alignment for IOVAs" 29 depends on IOMMU_LIMIT_IOVA_ALIGNMENT 30 range 4 9 31 default 9 32 help 33 With this parameter you can specify the maximum PAGE_SIZE order for 34 IOVAs. Larger IOVAs will be aligned only to this specified order. 35 The order is expressed a power of two multiplied by the PAGE_SIZE. 36 37 If unsure, leave the default value "9". 38endif 39 40menuconfig IOMMU_SUPPORT 41 bool "IOMMU Hardware Support" 42 depends on MMU 43 default y 44 ---help--- 45 Say Y here if you want to compile device drivers for IO Memory 46 Management Units into the kernel. These devices usually allow to 47 remap DMA requests and/or remap interrupts from other devices on the 48 system. 49 50if IOMMU_SUPPORT 51 52menu "Generic IOMMU Pagetable Support" 53 54# Selected by the actual pagetable implementations 55config IOMMU_IO_PGTABLE 56 bool 57 58config IOMMU_IO_PGTABLE_LPAE 59 bool "ARMv7/v8 Long Descriptor Format" 60 select IOMMU_IO_PGTABLE 61 depends on ARM || ARM64 || (COMPILE_TEST && !GENERIC_ATOMIC64) 62 help 63 Enable support for the ARM long descriptor pagetable format. 64 This allocator supports 4K/2M/1G, 16K/32M and 64K/512M page 65 sizes at both stage-1 and stage-2, as well as address spaces 66 up to 48-bits in size. 67 68config IOMMU_IO_PGTABLE_LPAE_SELFTEST 69 bool "LPAE selftests" 70 depends on IOMMU_IO_PGTABLE_LPAE 71 help 72 Enable self-tests for LPAE page table allocator. This performs 73 a series of page-table consistency checks during boot. 74 75 If unsure, say N here. 76 77config IOMMU_IO_PGTABLE_ARMV7S 78 bool "ARMv7/v8 Short Descriptor Format" 79 select IOMMU_IO_PGTABLE 80 depends on ARM || ARM64 || COMPILE_TEST 81 help 82 Enable support for the ARM Short-descriptor pagetable format. 83 This supports 32-bit virtual and physical addresses mapped using 84 2-level tables with 4KB pages/1MB sections, and contiguous entries 85 for 64KB pages/16MB supersections if indicated by the IOMMU driver. 86 87config IOMMU_IO_PGTABLE_ARMV7S_SELFTEST 88 bool "ARMv7s selftests" 89 depends on IOMMU_IO_PGTABLE_ARMV7S 90 help 91 Enable self-tests for ARMv7s page table allocator. This performs 92 a series of page-table consistency checks during boot. 93 94 If unsure, say N here. 95 96endmenu 97 98config IOMMU_DEBUGFS 99 bool "Export IOMMU internals in DebugFS" 100 depends on DEBUG_FS 101 help 102 Allows exposure of IOMMU device internals. This option enables 103 the use of debugfs by IOMMU drivers as required. Devices can, 104 at initialization time, cause the IOMMU code to create a top-level 105 debug/iommu directory, and then populate a subdirectory with 106 entries as required. 107 108config IOMMU_DEFAULT_PASSTHROUGH 109 bool "IOMMU passthrough by default" 110 depends on IOMMU_API 111 help 112 Enable passthrough by default, removing the need to pass in 113 iommu.passthrough=on or iommu=pt through command line. If this 114 is enabled, you can still disable with iommu.passthrough=off 115 or iommu=nopt depending on the architecture. 116 117 If unsure, say N here. 118 119config OF_IOMMU 120 def_bool y 121 depends on OF && IOMMU_API 122 123# IOMMU-agnostic DMA-mapping layer 124config IOMMU_DMA 125 bool 126 select IOMMU_API 127 select IOMMU_IOVA 128 select IRQ_MSI_IOMMU 129 select NEED_SG_DMA_LENGTH 130 131config FSL_PAMU 132 bool "Freescale IOMMU support" 133 depends on PCI 134 depends on PHYS_64BIT 135 depends on PPC_E500MC || (COMPILE_TEST && PPC) 136 select IOMMU_API 137 select GENERIC_ALLOCATOR 138 help 139 Freescale PAMU support. PAMU is the IOMMU present on Freescale QorIQ platforms. 140 PAMU can authorize memory access, remap the memory address, and remap I/O 141 transaction types. 142 143# MSM IOMMU support 144config MSM_IOMMU 145 bool "MSM IOMMU Support" 146 depends on ARM 147 depends on ARCH_MSM8X60 || ARCH_MSM8960 || COMPILE_TEST 148 select IOMMU_API 149 select IOMMU_IO_PGTABLE_ARMV7S 150 help 151 Support for the IOMMUs found on certain Qualcomm SOCs. 152 These IOMMUs allow virtualization of the address space used by most 153 cores within the multimedia subsystem. 154 155 If unsure, say N here. 156 157config IOMMU_PGTABLES_L2 158 def_bool y 159 depends on MSM_IOMMU && MMU && SMP && CPU_DCACHE_DISABLE=n 160 161# AMD IOMMU support 162config AMD_IOMMU 163 bool "AMD IOMMU support" 164 select SWIOTLB 165 select PCI_MSI 166 select PCI_ATS 167 select PCI_PRI 168 select PCI_PASID 169 select IOMMU_API 170 select IOMMU_IOVA 171 depends on X86_64 && PCI && ACPI && HAVE_CMPXCHG_DOUBLE 172 ---help--- 173 With this option you can enable support for AMD IOMMU hardware in 174 your system. An IOMMU is a hardware component which provides 175 remapping of DMA memory accesses from devices. With an AMD IOMMU you 176 can isolate the DMA memory of different devices and protect the 177 system from misbehaving device drivers or hardware. 178 179 You can find out if your system has an AMD IOMMU if you look into 180 your BIOS for an option to enable it or if you have an IVRS ACPI 181 table. 182 183config AMD_IOMMU_V2 184 tristate "AMD IOMMU Version 2 driver" 185 depends on AMD_IOMMU 186 select MMU_NOTIFIER 187 ---help--- 188 This option enables support for the AMD IOMMUv2 features of the IOMMU 189 hardware. Select this option if you want to use devices that support 190 the PCI PRI and PASID interface. 191 192config AMD_IOMMU_DEBUGFS 193 bool "Enable AMD IOMMU internals in DebugFS" 194 depends on AMD_IOMMU && IOMMU_DEBUGFS 195 ---help--- 196 !!!WARNING!!! !!!WARNING!!! !!!WARNING!!! !!!WARNING!!! 197 198 DO NOT ENABLE THIS OPTION UNLESS YOU REALLY, -REALLY- KNOW WHAT YOU ARE DOING!!! 199 Exposes AMD IOMMU device internals in DebugFS. 200 201 This option is -NOT- intended for production environments, and should 202 not generally be enabled. 203 204# Intel IOMMU support 205config DMAR_TABLE 206 bool 207 208config INTEL_IOMMU 209 bool "Support for Intel IOMMU using DMA Remapping Devices" 210 depends on PCI_MSI && ACPI && (X86 || IA64) 211 select IOMMU_API 212 select IOMMU_IOVA 213 select NEED_DMA_MAP_STATE 214 select DMAR_TABLE 215 select SWIOTLB 216 help 217 DMA remapping (DMAR) devices support enables independent address 218 translations for Direct Memory Access (DMA) from devices. 219 These DMA remapping devices are reported via ACPI tables 220 and include PCI device scope covered by these DMA 221 remapping devices. 222 223config INTEL_IOMMU_DEBUGFS 224 bool "Export Intel IOMMU internals in Debugfs" 225 depends on INTEL_IOMMU && IOMMU_DEBUGFS 226 help 227 !!!WARNING!!! 228 229 DO NOT ENABLE THIS OPTION UNLESS YOU REALLY KNOW WHAT YOU ARE DOING!!! 230 231 Expose Intel IOMMU internals in Debugfs. 232 233 This option is -NOT- intended for production environments, and should 234 only be enabled for debugging Intel IOMMU. 235 236config INTEL_IOMMU_SVM 237 bool "Support for Shared Virtual Memory with Intel IOMMU" 238 depends on INTEL_IOMMU && X86_64 239 select PCI_PASID 240 select MMU_NOTIFIER 241 help 242 Shared Virtual Memory (SVM) provides a facility for devices 243 to access DMA resources through process address space by 244 means of a Process Address Space ID (PASID). 245 246config INTEL_IOMMU_DEFAULT_ON 247 def_bool y 248 prompt "Enable Intel DMA Remapping Devices by default" 249 depends on INTEL_IOMMU 250 help 251 Selecting this option will enable a DMAR device at boot time if 252 one is found. If this option is not selected, DMAR support can 253 be enabled by passing intel_iommu=on to the kernel. 254 255config INTEL_IOMMU_BROKEN_GFX_WA 256 bool "Workaround broken graphics drivers (going away soon)" 257 depends on INTEL_IOMMU && BROKEN && X86 258 ---help--- 259 Current Graphics drivers tend to use physical address 260 for DMA and avoid using DMA APIs. Setting this config 261 option permits the IOMMU driver to set a unity map for 262 all the OS-visible memory. Hence the driver can continue 263 to use physical addresses for DMA, at least until this 264 option is removed in the 2.6.32 kernel. 265 266config INTEL_IOMMU_FLOPPY_WA 267 def_bool y 268 depends on INTEL_IOMMU && X86 269 ---help--- 270 Floppy disk drivers are known to bypass DMA API calls 271 thereby failing to work when IOMMU is enabled. This 272 workaround will setup a 1:1 mapping for the first 273 16MiB to make floppy (an ISA device) work. 274 275config IRQ_REMAP 276 bool "Support for Interrupt Remapping" 277 depends on X86_64 && X86_IO_APIC && PCI_MSI && ACPI 278 select DMAR_TABLE 279 ---help--- 280 Supports Interrupt remapping for IO-APIC and MSI devices. 281 To use x2apic mode in the CPU's which support x2APIC enhancements or 282 to support platforms with CPU's having > 8 bit APIC ID, say Y. 283 284# OMAP IOMMU support 285config OMAP_IOMMU 286 bool "OMAP IOMMU Support" 287 depends on ARM && MMU 288 depends on ARCH_OMAP2PLUS || COMPILE_TEST 289 select IOMMU_API 290 ---help--- 291 The OMAP3 media platform drivers depend on iommu support, 292 if you need them say Y here. 293 294config OMAP_IOMMU_DEBUG 295 bool "Export OMAP IOMMU internals in DebugFS" 296 depends on OMAP_IOMMU && DEBUG_FS 297 ---help--- 298 Select this to see extensive information about 299 the internal state of OMAP IOMMU in debugfs. 300 301 Say N unless you know you need this. 302 303config ROCKCHIP_IOMMU 304 bool "Rockchip IOMMU Support" 305 depends on ARM || ARM64 306 depends on ARCH_ROCKCHIP || COMPILE_TEST 307 select IOMMU_API 308 select ARM_DMA_USE_IOMMU 309 help 310 Support for IOMMUs found on Rockchip rk32xx SOCs. 311 These IOMMUs allow virtualization of the address space used by most 312 cores within the multimedia subsystem. 313 Say Y here if you are using a Rockchip SoC that includes an IOMMU 314 device. 315 316config TEGRA_IOMMU_GART 317 bool "Tegra GART IOMMU Support" 318 depends on ARCH_TEGRA_2x_SOC 319 depends on TEGRA_MC 320 select IOMMU_API 321 help 322 Enables support for remapping discontiguous physical memory 323 shared with the operating system into contiguous I/O virtual 324 space through the GART (Graphics Address Relocation Table) 325 hardware included on Tegra SoCs. 326 327config TEGRA_IOMMU_SMMU 328 bool "NVIDIA Tegra SMMU Support" 329 depends on ARCH_TEGRA 330 depends on TEGRA_AHB 331 depends on TEGRA_MC 332 select IOMMU_API 333 help 334 This driver supports the IOMMU hardware (SMMU) found on NVIDIA Tegra 335 SoCs (Tegra30 up to Tegra210). 336 337config EXYNOS_IOMMU 338 bool "Exynos IOMMU Support" 339 depends on ARCH_EXYNOS && MMU 340 depends on !CPU_BIG_ENDIAN # revisit driver if we can enable big-endian ptes 341 select IOMMU_API 342 select ARM_DMA_USE_IOMMU 343 help 344 Support for the IOMMU (System MMU) of Samsung Exynos application 345 processor family. This enables H/W multimedia accelerators to see 346 non-linear physical memory chunks as linear memory in their 347 address space. 348 349 If unsure, say N here. 350 351config EXYNOS_IOMMU_DEBUG 352 bool "Debugging log for Exynos IOMMU" 353 depends on EXYNOS_IOMMU 354 help 355 Select this to see the detailed log message that shows what 356 happens in the IOMMU driver. 357 358 Say N unless you need kernel log message for IOMMU debugging. 359 360config IPMMU_VMSA 361 bool "Renesas VMSA-compatible IPMMU" 362 depends on ARM || IOMMU_DMA 363 depends on ARCH_RENESAS || (COMPILE_TEST && !GENERIC_ATOMIC64) 364 select IOMMU_API 365 select IOMMU_IO_PGTABLE_LPAE 366 select ARM_DMA_USE_IOMMU 367 help 368 Support for the Renesas VMSA-compatible IPMMU found in the R-Mobile 369 APE6, R-Car Gen2, and R-Car Gen3 SoCs. 370 371 If unsure, say N. 372 373config SPAPR_TCE_IOMMU 374 bool "sPAPR TCE IOMMU Support" 375 depends on PPC_POWERNV || PPC_PSERIES 376 select IOMMU_API 377 help 378 Enables bits of IOMMU API required by VFIO. The iommu_ops 379 is not implemented as it is not necessary for VFIO. 380 381# ARM IOMMU support 382config ARM_SMMU 383 tristate "ARM Ltd. System MMU (SMMU) Support" 384 depends on (ARM64 || ARM) && MMU 385 depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y 386 select IOMMU_API 387 select IOMMU_IO_PGTABLE_LPAE 388 select ARM_DMA_USE_IOMMU if ARM 389 help 390 Support for implementations of the ARM System MMU architecture 391 versions 1 and 2. 392 393 Say Y here if your SoC includes an IOMMU device implementing 394 the ARM SMMU architecture. 395 396config ARM_SMMU_LEGACY_DT_BINDINGS 397 bool "Support the legacy \"mmu-masters\" devicetree bindings" 398 depends on ARM_SMMU=y && OF 399 help 400 Support for the badly designed and deprecated "mmu-masters" 401 devicetree bindings. This allows some DMA masters to attach 402 to the SMMU but does not provide any support via the DMA API. 403 If you're lucky, you might be able to get VFIO up and running. 404 405 If you say Y here then you'll make me very sad. Instead, say N 406 and move your firmware to the utopian future that was 2016. 407 408config ARM_SMMU_DISABLE_BYPASS_BY_DEFAULT 409 bool "Default to disabling bypass on ARM SMMU v1 and v2" 410 depends on ARM_SMMU 411 default y 412 help 413 Say Y here to (by default) disable bypass streams such that 414 incoming transactions from devices that are not attached to 415 an iommu domain will report an abort back to the device and 416 will not be allowed to pass through the SMMU. 417 418 Any old kernels that existed before this KConfig was 419 introduced would default to _allowing_ bypass (AKA the 420 equivalent of NO for this config). However the default for 421 this option is YES because the old behavior is insecure. 422 423 There are few reasons to allow unmatched stream bypass, and 424 even fewer good ones. If saying YES here breaks your board 425 you should work on fixing your board. This KConfig option 426 is expected to be removed in the future and we'll simply 427 hardcode the bypass disable in the code. 428 429 NOTE: the kernel command line parameter 430 'arm-smmu.disable_bypass' will continue to override this 431 config. 432 433config ARM_SMMU_V3 434 tristate "ARM Ltd. System MMU Version 3 (SMMUv3) Support" 435 depends on ARM64 436 select IOMMU_API 437 select IOMMU_IO_PGTABLE_LPAE 438 select GENERIC_MSI_IRQ_DOMAIN 439 help 440 Support for implementations of the ARM System MMU architecture 441 version 3 providing translation support to a PCIe root complex. 442 443 Say Y here if your system includes an IOMMU device implementing 444 the ARM SMMUv3 architecture. 445 446config S390_IOMMU 447 def_bool y if S390 && PCI 448 depends on S390 && PCI 449 select IOMMU_API 450 help 451 Support for the IOMMU API for s390 PCI devices. 452 453config S390_CCW_IOMMU 454 bool "S390 CCW IOMMU Support" 455 depends on S390 && CCW 456 select IOMMU_API 457 help 458 Enables bits of IOMMU API required by VFIO. The iommu_ops 459 is not implemented as it is not necessary for VFIO. 460 461config S390_AP_IOMMU 462 bool "S390 AP IOMMU Support" 463 depends on S390 && ZCRYPT 464 select IOMMU_API 465 help 466 Enables bits of IOMMU API required by VFIO. The iommu_ops 467 is not implemented as it is not necessary for VFIO. 468 469config MTK_IOMMU 470 bool "MTK IOMMU Support" 471 depends on ARM || ARM64 472 depends on ARCH_MEDIATEK || COMPILE_TEST 473 select ARM_DMA_USE_IOMMU 474 select IOMMU_API 475 select IOMMU_DMA 476 select IOMMU_IO_PGTABLE_ARMV7S 477 select MEMORY 478 select MTK_SMI 479 help 480 Support for the M4U on certain Mediatek SOCs. M4U is MultiMedia 481 Memory Management Unit. This option enables remapping of DMA memory 482 accesses for the multimedia subsystem. 483 484 If unsure, say N here. 485 486config MTK_IOMMU_V1 487 bool "MTK IOMMU Version 1 (M4U gen1) Support" 488 depends on ARM 489 depends on ARCH_MEDIATEK || COMPILE_TEST 490 select ARM_DMA_USE_IOMMU 491 select IOMMU_API 492 select MEMORY 493 select MTK_SMI 494 help 495 Support for the M4U on certain Mediatek SoCs. M4U generation 1 HW is 496 Multimedia Memory Managememt Unit. This option enables remapping of 497 DMA memory accesses for the multimedia subsystem. 498 499 if unsure, say N here. 500 501config QCOM_IOMMU 502 # Note: iommu drivers cannot (yet?) be built as modules 503 bool "Qualcomm IOMMU Support" 504 depends on ARCH_QCOM || (COMPILE_TEST && !GENERIC_ATOMIC64) 505 depends on QCOM_SCM=y 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 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 bool "Virtio IOMMU driver" 523 depends on VIRTIO=y 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