0001 # SPDX-License-Identifier: GPL-2.0-only
0002 # The IOVA library may also be used by non-IOMMU_API users
0003 config IOMMU_IOVA
0004 tristate
0005
0006 # The IOASID library may also be used by non-IOMMU_API users
0007 config IOASID
0008 tristate
0009
0010 # IOMMU_API always gets selected by whoever wants it.
0011 config IOMMU_API
0012 bool
0013
0014 menuconfig IOMMU_SUPPORT
0015 bool "IOMMU Hardware Support"
0016 depends on MMU
0017 default y
0018 help
0019 Say Y here if you want to compile device drivers for IO Memory
0020 Management Units into the kernel. These devices usually allow to
0021 remap DMA requests and/or remap interrupts from other devices on the
0022 system.
0023
0024 if IOMMU_SUPPORT
0025
0026 menu "Generic IOMMU Pagetable Support"
0027
0028 # Selected by the actual pagetable implementations
0029 config IOMMU_IO_PGTABLE
0030 bool
0031
0032 config IOMMU_IO_PGTABLE_LPAE
0033 bool "ARMv7/v8 Long Descriptor Format"
0034 select IOMMU_IO_PGTABLE
0035 depends on ARM || ARM64 || (COMPILE_TEST && !GENERIC_ATOMIC64)
0036 help
0037 Enable support for the ARM long descriptor pagetable format.
0038 This allocator supports 4K/2M/1G, 16K/32M and 64K/512M page
0039 sizes at both stage-1 and stage-2, as well as address spaces
0040 up to 48-bits in size.
0041
0042 config IOMMU_IO_PGTABLE_LPAE_SELFTEST
0043 bool "LPAE selftests"
0044 depends on IOMMU_IO_PGTABLE_LPAE
0045 help
0046 Enable self-tests for LPAE page table allocator. This performs
0047 a series of page-table consistency checks during boot.
0048
0049 If unsure, say N here.
0050
0051 config IOMMU_IO_PGTABLE_ARMV7S
0052 bool "ARMv7/v8 Short Descriptor Format"
0053 select IOMMU_IO_PGTABLE
0054 depends on ARM || ARM64 || COMPILE_TEST
0055 help
0056 Enable support for the ARM Short-descriptor pagetable format.
0057 This supports 32-bit virtual and physical addresses mapped using
0058 2-level tables with 4KB pages/1MB sections, and contiguous entries
0059 for 64KB pages/16MB supersections if indicated by the IOMMU driver.
0060
0061 config IOMMU_IO_PGTABLE_ARMV7S_SELFTEST
0062 bool "ARMv7s selftests"
0063 depends on IOMMU_IO_PGTABLE_ARMV7S
0064 help
0065 Enable self-tests for ARMv7s page table allocator. This performs
0066 a series of page-table consistency checks during boot.
0067
0068 If unsure, say N here.
0069
0070 endmenu
0071
0072 config IOMMU_DEBUGFS
0073 bool "Export IOMMU internals in DebugFS"
0074 depends on DEBUG_FS
0075 help
0076 Allows exposure of IOMMU device internals. This option enables
0077 the use of debugfs by IOMMU drivers as required. Devices can,
0078 at initialization time, cause the IOMMU code to create a top-level
0079 debug/iommu directory, and then populate a subdirectory with
0080 entries as required.
0081
0082 choice
0083 prompt "IOMMU default domain type"
0084 depends on IOMMU_API
0085 default IOMMU_DEFAULT_DMA_LAZY if X86 || IA64
0086 default IOMMU_DEFAULT_DMA_STRICT
0087 help
0088 Choose the type of IOMMU domain used to manage DMA API usage by
0089 device drivers. The options here typically represent different
0090 levels of tradeoff between robustness/security and performance,
0091 depending on the IOMMU driver. Not all IOMMUs support all options.
0092 This choice can be overridden at boot via the command line, and for
0093 some devices also at runtime via sysfs.
0094
0095 If unsure, keep the default.
0096
0097 config IOMMU_DEFAULT_DMA_STRICT
0098 bool "Translated - Strict"
0099 help
0100 Trusted devices use translation to restrict their access to only
0101 DMA-mapped pages, with strict TLB invalidation on unmap. Equivalent
0102 to passing "iommu.passthrough=0 iommu.strict=1" on the command line.
0103
0104 Untrusted devices always use this mode, with an additional layer of
0105 bounce-buffering such that they cannot gain access to any unrelated
0106 data within a mapped page.
0107
0108 config IOMMU_DEFAULT_DMA_LAZY
0109 bool "Translated - Lazy"
0110 help
0111 Trusted devices use translation to restrict their access to only
0112 DMA-mapped pages, but with "lazy" batched TLB invalidation. This
0113 mode allows higher performance with some IOMMUs due to reduced TLB
0114 flushing, but at the cost of reduced isolation since devices may be
0115 able to access memory for some time after it has been unmapped.
0116 Equivalent to passing "iommu.passthrough=0 iommu.strict=0" on the
0117 command line.
0118
0119 If this mode is not supported by the IOMMU driver, the effective
0120 runtime default will fall back to IOMMU_DEFAULT_DMA_STRICT.
0121
0122 config IOMMU_DEFAULT_PASSTHROUGH
0123 bool "Passthrough"
0124 help
0125 Trusted devices are identity-mapped, giving them unrestricted access
0126 to memory with minimal performance overhead. Equivalent to passing
0127 "iommu.passthrough=1" (historically "iommu=pt") on the command line.
0128
0129 If this mode is not supported by the IOMMU driver, the effective
0130 runtime default will fall back to IOMMU_DEFAULT_DMA_STRICT.
0131
0132 endchoice
0133
0134 config OF_IOMMU
0135 def_bool y
0136 depends on OF && IOMMU_API
0137
0138 # IOMMU-agnostic DMA-mapping layer
0139 config IOMMU_DMA
0140 bool
0141 select DMA_OPS
0142 select IOMMU_API
0143 select IOMMU_IOVA
0144 select IRQ_MSI_IOMMU
0145 select NEED_SG_DMA_LENGTH
0146
0147 # Shared Virtual Addressing
0148 config IOMMU_SVA
0149 bool
0150 select IOASID
0151
0152 config FSL_PAMU
0153 bool "Freescale IOMMU support"
0154 depends on PCI
0155 depends on PHYS_64BIT
0156 depends on PPC_E500MC || (COMPILE_TEST && PPC)
0157 select IOMMU_API
0158 select GENERIC_ALLOCATOR
0159 help
0160 Freescale PAMU support. PAMU is the IOMMU present on Freescale QorIQ platforms.
0161 PAMU can authorize memory access, remap the memory address, and remap I/O
0162 transaction types.
0163
0164 # MSM IOMMU support
0165 config MSM_IOMMU
0166 bool "MSM IOMMU Support"
0167 depends on ARM
0168 depends on ARCH_MSM8X60 || ARCH_MSM8960 || COMPILE_TEST
0169 select IOMMU_API
0170 select IOMMU_IO_PGTABLE_ARMV7S
0171 help
0172 Support for the IOMMUs found on certain Qualcomm SOCs.
0173 These IOMMUs allow virtualization of the address space used by most
0174 cores within the multimedia subsystem.
0175
0176 If unsure, say N here.
0177
0178 source "drivers/iommu/amd/Kconfig"
0179 source "drivers/iommu/intel/Kconfig"
0180
0181 config IRQ_REMAP
0182 bool "Support for Interrupt Remapping"
0183 depends on X86_64 && X86_IO_APIC && PCI_MSI && ACPI
0184 select DMAR_TABLE
0185 help
0186 Supports Interrupt remapping for IO-APIC and MSI devices.
0187 To use x2apic mode in the CPU's which support x2APIC enhancements or
0188 to support platforms with CPU's having > 8 bit APIC ID, say Y.
0189
0190 # OMAP IOMMU support
0191 config OMAP_IOMMU
0192 bool "OMAP IOMMU Support"
0193 depends on ARCH_OMAP2PLUS || COMPILE_TEST
0194 select IOMMU_API
0195 help
0196 The OMAP3 media platform drivers depend on iommu support,
0197 if you need them say Y here.
0198
0199 config OMAP_IOMMU_DEBUG
0200 bool "Export OMAP IOMMU internals in DebugFS"
0201 depends on OMAP_IOMMU && DEBUG_FS
0202 help
0203 Select this to see extensive information about
0204 the internal state of OMAP IOMMU in debugfs.
0205
0206 Say N unless you know you need this.
0207
0208 config ROCKCHIP_IOMMU
0209 bool "Rockchip IOMMU Support"
0210 depends on ARCH_ROCKCHIP || COMPILE_TEST
0211 select IOMMU_API
0212 select ARM_DMA_USE_IOMMU
0213 help
0214 Support for IOMMUs found on Rockchip rk32xx SOCs.
0215 These IOMMUs allow virtualization of the address space used by most
0216 cores within the multimedia subsystem.
0217 Say Y here if you are using a Rockchip SoC that includes an IOMMU
0218 device.
0219
0220 config SUN50I_IOMMU
0221 bool "Allwinner H6 IOMMU Support"
0222 depends on HAS_DMA
0223 depends on ARCH_SUNXI || COMPILE_TEST
0224 select ARM_DMA_USE_IOMMU
0225 select IOMMU_API
0226 help
0227 Support for the IOMMU introduced in the Allwinner H6 SoCs.
0228
0229 config TEGRA_IOMMU_GART
0230 bool "Tegra GART IOMMU Support"
0231 depends on ARCH_TEGRA_2x_SOC
0232 depends on TEGRA_MC
0233 select IOMMU_API
0234 help
0235 Enables support for remapping discontiguous physical memory
0236 shared with the operating system into contiguous I/O virtual
0237 space through the GART (Graphics Address Relocation Table)
0238 hardware included on Tegra SoCs.
0239
0240 config TEGRA_IOMMU_SMMU
0241 bool "NVIDIA Tegra SMMU Support"
0242 depends on ARCH_TEGRA
0243 depends on TEGRA_AHB
0244 depends on TEGRA_MC
0245 select IOMMU_API
0246 help
0247 This driver supports the IOMMU hardware (SMMU) found on NVIDIA Tegra
0248 SoCs (Tegra30 up to Tegra210).
0249
0250 config EXYNOS_IOMMU
0251 bool "Exynos IOMMU Support"
0252 depends on ARCH_EXYNOS || COMPILE_TEST
0253 depends on !CPU_BIG_ENDIAN # revisit driver if we can enable big-endian ptes
0254 select IOMMU_API
0255 select ARM_DMA_USE_IOMMU
0256 help
0257 Support for the IOMMU (System MMU) of Samsung Exynos application
0258 processor family. This enables H/W multimedia accelerators to see
0259 non-linear physical memory chunks as linear memory in their
0260 address space.
0261
0262 If unsure, say N here.
0263
0264 config EXYNOS_IOMMU_DEBUG
0265 bool "Debugging log for Exynos IOMMU"
0266 depends on EXYNOS_IOMMU
0267 help
0268 Select this to see the detailed log message that shows what
0269 happens in the IOMMU driver.
0270
0271 Say N unless you need kernel log message for IOMMU debugging.
0272
0273 config IPMMU_VMSA
0274 bool "Renesas VMSA-compatible IPMMU"
0275 depends on ARCH_RENESAS || (COMPILE_TEST && !GENERIC_ATOMIC64)
0276 select IOMMU_API
0277 select IOMMU_IO_PGTABLE_LPAE
0278 select ARM_DMA_USE_IOMMU
0279 help
0280 Support for the Renesas VMSA-compatible IPMMU found in the R-Mobile
0281 APE6, R-Car Gen{2,3} and RZ/G{1,2} SoCs.
0282
0283 If unsure, say N.
0284
0285 config SPAPR_TCE_IOMMU
0286 bool "sPAPR TCE IOMMU Support"
0287 depends on PPC_POWERNV || PPC_PSERIES
0288 select IOMMU_API
0289 help
0290 Enables bits of IOMMU API required by VFIO. The iommu_ops
0291 is not implemented as it is not necessary for VFIO.
0292
0293 config APPLE_DART
0294 tristate "Apple DART IOMMU Support"
0295 depends on ARCH_APPLE || (COMPILE_TEST && !GENERIC_ATOMIC64)
0296 select IOMMU_API
0297 select IOMMU_IO_PGTABLE_LPAE
0298 default ARCH_APPLE
0299 help
0300 Support for Apple DART (Device Address Resolution Table) IOMMUs
0301 found in Apple ARM SoCs like the M1.
0302 This IOMMU is required for most peripherals using DMA to access
0303 the main memory.
0304
0305 Say Y here if you are using an Apple SoC.
0306
0307 # ARM IOMMU support
0308 config ARM_SMMU
0309 tristate "ARM Ltd. System MMU (SMMU) Support"
0310 depends on ARM64 || ARM || (COMPILE_TEST && !GENERIC_ATOMIC64)
0311 select IOMMU_API
0312 select IOMMU_IO_PGTABLE_LPAE
0313 select ARM_DMA_USE_IOMMU if ARM
0314 help
0315 Support for implementations of the ARM System MMU architecture
0316 versions 1 and 2.
0317
0318 Say Y here if your SoC includes an IOMMU device implementing
0319 the ARM SMMU architecture.
0320
0321 config ARM_SMMU_LEGACY_DT_BINDINGS
0322 bool "Support the legacy \"mmu-masters\" devicetree bindings"
0323 depends on ARM_SMMU=y && OF
0324 help
0325 Support for the badly designed and deprecated "mmu-masters"
0326 devicetree bindings. This allows some DMA masters to attach
0327 to the SMMU but does not provide any support via the DMA API.
0328 If you're lucky, you might be able to get VFIO up and running.
0329
0330 If you say Y here then you'll make me very sad. Instead, say N
0331 and move your firmware to the utopian future that was 2016.
0332
0333 config ARM_SMMU_DISABLE_BYPASS_BY_DEFAULT
0334 bool "Default to disabling bypass on ARM SMMU v1 and v2"
0335 depends on ARM_SMMU
0336 default y
0337 help
0338 Say Y here to (by default) disable bypass streams such that
0339 incoming transactions from devices that are not attached to
0340 an iommu domain will report an abort back to the device and
0341 will not be allowed to pass through the SMMU.
0342
0343 Any old kernels that existed before this KConfig was
0344 introduced would default to _allowing_ bypass (AKA the
0345 equivalent of NO for this config). However the default for
0346 this option is YES because the old behavior is insecure.
0347
0348 There are few reasons to allow unmatched stream bypass, and
0349 even fewer good ones. If saying YES here breaks your board
0350 you should work on fixing your board. This KConfig option
0351 is expected to be removed in the future and we'll simply
0352 hardcode the bypass disable in the code.
0353
0354 NOTE: the kernel command line parameter
0355 'arm-smmu.disable_bypass' will continue to override this
0356 config.
0357
0358 config ARM_SMMU_QCOM
0359 def_tristate y
0360 depends on ARM_SMMU && ARCH_QCOM
0361 select QCOM_SCM
0362 help
0363 When running on a Qualcomm platform that has the custom variant
0364 of the ARM SMMU, this needs to be built into the SMMU driver.
0365
0366 config ARM_SMMU_QCOM_DEBUG
0367 bool "ARM SMMU QCOM implementation defined debug support"
0368 depends on ARM_SMMU_QCOM
0369 help
0370 Support for implementation specific debug features in ARM SMMU
0371 hardware found in QTI platforms.
0372
0373 Say Y here to enable debug for issues such as TLB sync timeouts
0374 which requires implementation defined register dumps.
0375
0376 config ARM_SMMU_V3
0377 tristate "ARM Ltd. System MMU Version 3 (SMMUv3) Support"
0378 depends on ARM64
0379 select IOMMU_API
0380 select IOMMU_IO_PGTABLE_LPAE
0381 select GENERIC_MSI_IRQ_DOMAIN
0382 help
0383 Support for implementations of the ARM System MMU architecture
0384 version 3 providing translation support to a PCIe root complex.
0385
0386 Say Y here if your system includes an IOMMU device implementing
0387 the ARM SMMUv3 architecture.
0388
0389 config ARM_SMMU_V3_SVA
0390 bool "Shared Virtual Addressing support for the ARM SMMUv3"
0391 depends on ARM_SMMU_V3
0392 select IOMMU_SVA
0393 select MMU_NOTIFIER
0394 help
0395 Support for sharing process address spaces with devices using the
0396 SMMUv3.
0397
0398 Say Y here if your system supports SVA extensions such as PCIe PASID
0399 and PRI.
0400
0401 config S390_IOMMU
0402 def_bool y if S390 && PCI
0403 depends on S390 && PCI
0404 select IOMMU_API
0405 help
0406 Support for the IOMMU API for s390 PCI devices.
0407
0408 config S390_CCW_IOMMU
0409 bool "S390 CCW IOMMU Support"
0410 depends on S390 && CCW || COMPILE_TEST
0411 select IOMMU_API
0412 help
0413 Enables bits of IOMMU API required by VFIO. The iommu_ops
0414 is not implemented as it is not necessary for VFIO.
0415
0416 config S390_AP_IOMMU
0417 bool "S390 AP IOMMU Support"
0418 depends on S390 && ZCRYPT || COMPILE_TEST
0419 select IOMMU_API
0420 help
0421 Enables bits of IOMMU API required by VFIO. The iommu_ops
0422 is not implemented as it is not necessary for VFIO.
0423
0424 config MTK_IOMMU
0425 tristate "MediaTek IOMMU Support"
0426 depends on ARCH_MEDIATEK || COMPILE_TEST
0427 select ARM_DMA_USE_IOMMU
0428 select IOMMU_API
0429 select IOMMU_IO_PGTABLE_ARMV7S
0430 select MEMORY
0431 select MTK_SMI
0432 help
0433 Support for the M4U on certain Mediatek SOCs. M4U is MultiMedia
0434 Memory Management Unit. This option enables remapping of DMA memory
0435 accesses for the multimedia subsystem.
0436
0437 If unsure, say N here.
0438
0439 config MTK_IOMMU_V1
0440 tristate "MediaTek IOMMU Version 1 (M4U gen1) Support"
0441 depends on ARM
0442 depends on ARCH_MEDIATEK || COMPILE_TEST
0443 select ARM_DMA_USE_IOMMU
0444 select IOMMU_API
0445 select MEMORY
0446 select MTK_SMI
0447 help
0448 Support for the M4U on certain Mediatek SoCs. M4U generation 1 HW is
0449 Multimedia Memory Managememt Unit. This option enables remapping of
0450 DMA memory accesses for the multimedia subsystem.
0451
0452 if unsure, say N here.
0453
0454 config QCOM_IOMMU
0455 # Note: iommu drivers cannot (yet?) be built as modules
0456 bool "Qualcomm IOMMU Support"
0457 depends on ARCH_QCOM || (COMPILE_TEST && !GENERIC_ATOMIC64)
0458 select QCOM_SCM
0459 select IOMMU_API
0460 select IOMMU_IO_PGTABLE_LPAE
0461 select ARM_DMA_USE_IOMMU
0462 help
0463 Support for IOMMU on certain Qualcomm SoCs.
0464
0465 config HYPERV_IOMMU
0466 bool "Hyper-V x2APIC IRQ Handling"
0467 depends on HYPERV && X86
0468 select IOMMU_API
0469 default HYPERV
0470 help
0471 Stub IOMMU driver to handle IRQs as to allow Hyper-V Linux
0472 guests to run with x2APIC mode enabled.
0473
0474 config VIRTIO_IOMMU
0475 tristate "Virtio IOMMU driver"
0476 depends on VIRTIO
0477 depends on (ARM64 || X86)
0478 select IOMMU_API
0479 select IOMMU_DMA
0480 select INTERVAL_TREE
0481 select ACPI_VIOT if ACPI
0482 help
0483 Para-virtualised IOMMU driver with virtio.
0484
0485 Say Y here if you intend to run this kernel as a guest.
0486
0487 config SPRD_IOMMU
0488 tristate "Unisoc IOMMU Support"
0489 depends on ARCH_SPRD || COMPILE_TEST
0490 select IOMMU_API
0491 help
0492 Support for IOMMU on Unisoc's SoCs, this IOMMU can be used by
0493 Unisoc's multimedia devices, such as display, Image codec(jpeg)
0494 and a few signal processors, including VSP(video), GSP(graphic),
0495 ISP(image), and CPP(camera pixel processor), etc.
0496
0497 Say Y here if you want to use the multimedia devices listed above.
0498
0499 endif # IOMMU_SUPPORT