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