| 1 |
# SPDX-License-Identifier: GPL-2.0-only |
| 2 |
# The IOVA library may also be used by non-IOMMU_API users |
| 3 |
config IOMMU_IOVA |
| 4 |
tristate |
| 5 |
|
| 6 |
# IOMMU_API always gets selected by whoever wants it. |
| 7 |
config IOMMU_API |
| 8 |
bool |
| 9 |
|
| 10 |
config IOMMUFD_DRIVER |
| 11 |
bool |
| 12 |
default n |
| 13 |
|
| 14 |
menuconfig 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 |
|
| 24 |
if IOMMU_SUPPORT |
| 25 |
|
| 26 |
menu "Generic IOMMU Pagetable Support" |
| 27 |
|
| 28 |
# Selected by the actual pagetable implementations |
| 29 |
config IOMMU_IO_PGTABLE |
| 30 |
bool |
| 31 |
|
| 32 |
config IOMMU_IO_PGTABLE_LPAE |
| 33 |
bool "ARMv7/v8 Long Descriptor Format" |
| 34 |
select IOMMU_IO_PGTABLE |
| 35 |
depends on ARM || ARM64 || COMPILE_TEST |
| 36 |
depends on !GENERIC_ATOMIC64 # for cmpxchg64() |
| 37 |
help |
| 38 |
Enable support for the ARM long descriptor pagetable format. |
| 39 |
This allocator supports 4K/2M/1G, 16K/32M and 64K/512M page |
| 40 |
sizes at both stage-1 and stage-2, as well as address spaces |
| 41 |
up to 48-bits in size. |
| 42 |
|
| 43 |
config IOMMU_IO_PGTABLE_LPAE_KUNIT_TEST |
| 44 |
tristate "KUnit tests for LPAE" |
| 45 |
depends on IOMMU_IO_PGTABLE_LPAE && KUNIT |
| 46 |
default KUNIT_ALL_TESTS |
| 47 |
help |
| 48 |
Enable kunit tests for LPAE page table allocator. This performs |
| 49 |
a series of page-table consistency checks. |
| 50 |
|
| 51 |
If unsure, say N here. |
| 52 |
|
| 53 |
config IOMMU_IO_PGTABLE_ARMV7S |
| 54 |
bool "ARMv7/v8 Short Descriptor Format" |
| 55 |
select IOMMU_IO_PGTABLE |
| 56 |
depends on ARM || ARM64 || COMPILE_TEST |
| 57 |
help |
| 58 |
Enable support for the ARM Short-descriptor pagetable format. |
| 59 |
This supports 32-bit virtual and physical addresses mapped using |
| 60 |
2-level tables with 4KB pages/1MB sections, and contiguous entries |
| 61 |
for 64KB pages/16MB supersections if indicated by the IOMMU driver. |
| 62 |
|
| 63 |
config IOMMU_IO_PGTABLE_ARMV7S_SELFTEST |
| 64 |
bool "ARMv7s selftests" |
| 65 |
depends on IOMMU_IO_PGTABLE_ARMV7S |
| 66 |
help |
| 67 |
Enable self-tests for ARMv7s page table allocator. This performs |
| 68 |
a series of page-table consistency checks during boot. |
| 69 |
|
| 70 |
If unsure, say N here. |
| 71 |
|
| 72 |
config IOMMU_IO_PGTABLE_DART |
| 73 |
bool "Apple DART Formats" |
| 74 |
select IOMMU_IO_PGTABLE |
| 75 |
depends on ARM64 || COMPILE_TEST |
| 76 |
depends on !GENERIC_ATOMIC64 # for cmpxchg64() |
| 77 |
help |
| 78 |
Enable support for the Apple DART pagetable formats. These include |
| 79 |
the t8020 and t6000/t8110 DART formats used in Apple M1/M2 family |
| 80 |
SoCs. |
| 81 |
|
| 82 |
If unsure, say N here. |
| 83 |
|
| 84 |
endmenu |
| 85 |
|
| 86 |
config IOMMU_DEBUGFS |
| 87 |
bool "Export IOMMU internals in DebugFS" |
| 88 |
depends on DEBUG_FS |
| 89 |
help |
| 90 |
Allows exposure of IOMMU device internals. This option enables |
| 91 |
the use of debugfs by IOMMU drivers as required. Devices can, |
| 92 |
at initialization time, cause the IOMMU code to create a top-level |
| 93 |
debug/iommu directory, and then populate a subdirectory with |
| 94 |
entries as required. |
| 95 |
|
| 96 |
choice |
| 97 |
prompt "IOMMU default domain type" |
| 98 |
depends on IOMMU_API |
| 99 |
default IOMMU_DEFAULT_DMA_LAZY if X86 || S390 |
| 100 |
default IOMMU_DEFAULT_DMA_STRICT |
| 101 |
help |
| 102 |
Choose the type of IOMMU domain used to manage DMA API usage by |
| 103 |
device drivers. The options here typically represent different |
| 104 |
levels of tradeoff between robustness/security and performance, |
| 105 |
depending on the IOMMU driver. Not all IOMMUs support all options. |
| 106 |
This choice can be overridden at boot via the command line, and for |
| 107 |
some devices also at runtime via sysfs. |
| 108 |
|
| 109 |
If unsure, keep the default. |
| 110 |
|
| 111 |
config IOMMU_DEFAULT_DMA_STRICT |
| 112 |
bool "Translated - Strict" |
| 113 |
help |
| 114 |
Trusted devices use translation to restrict their access to only |
| 115 |
DMA-mapped pages, with strict TLB invalidation on unmap. Equivalent |
| 116 |
to passing "iommu.passthrough=0 iommu.strict=1" on the command line. |
| 117 |
|
| 118 |
Untrusted devices always use this mode, with an additional layer of |
| 119 |
bounce-buffering such that they cannot gain access to any unrelated |
| 120 |
data within a mapped page. |
| 121 |
|
| 122 |
config IOMMU_DEFAULT_DMA_LAZY |
| 123 |
bool "Translated - Lazy" |
| 124 |
help |
| 125 |
Trusted devices use translation to restrict their access to only |
| 126 |
DMA-mapped pages, but with "lazy" batched TLB invalidation. This |
| 127 |
mode allows higher performance with some IOMMUs due to reduced TLB |
| 128 |
flushing, but at the cost of reduced isolation since devices may be |
| 129 |
able to access memory for some time after it has been unmapped. |
| 130 |
Equivalent to passing "iommu.passthrough=0 iommu.strict=0" on the |
| 131 |
command line. |
| 132 |
|
| 133 |
If this mode is not supported by the IOMMU driver, the effective |
| 134 |
runtime default will fall back to IOMMU_DEFAULT_DMA_STRICT. |
| 135 |
|
| 136 |
config IOMMU_DEFAULT_PASSTHROUGH |
| 137 |
bool "Passthrough" |
| 138 |
help |
| 139 |
Trusted devices are identity-mapped, giving them unrestricted access |
| 140 |
to memory with minimal performance overhead. Equivalent to passing |
| 141 |
"iommu.passthrough=1" (historically "iommu=pt") on the command line. |
| 142 |
|
| 143 |
If this mode is not supported by the IOMMU driver, the effective |
| 144 |
runtime default will fall back to IOMMU_DEFAULT_DMA_STRICT. |
| 145 |
|
| 146 |
endchoice |
| 147 |
|
| 148 |
config OF_IOMMU |
| 149 |
def_bool y |
| 150 |
depends on OF && IOMMU_API |
| 151 |
|
| 152 |
# IOMMU-agnostic DMA-mapping layer |
| 153 |
config IOMMU_DMA |
| 154 |
def_bool ARM64 || X86 || S390 |
| 155 |
select DMA_OPS_HELPERS |
| 156 |
select IOMMU_API |
| 157 |
select IOMMU_IOVA |
| 158 |
select NEED_SG_DMA_LENGTH |
| 159 |
select NEED_SG_DMA_FLAGS if SWIOTLB |
| 160 |
|
| 161 |
# Shared Virtual Addressing |
| 162 |
config IOMMU_SVA |
| 163 |
select IOMMU_MM_DATA |
| 164 |
bool |
| 165 |
|
| 166 |
config IOMMU_IOPF |
| 167 |
bool |
| 168 |
|
| 169 |
config FSL_PAMU |
| 170 |
bool "Freescale IOMMU support" |
| 171 |
depends on PCI |
| 172 |
depends on PHYS_64BIT |
| 173 |
depends on PPC_E500MC || (COMPILE_TEST && PPC) |
| 174 |
select IOMMU_API |
| 175 |
select GENERIC_ALLOCATOR |
| 176 |
help |
| 177 |
Freescale PAMU support. PAMU is the IOMMU present on Freescale QorIQ platforms. |
| 178 |
PAMU can authorize memory access, remap the memory address, and remap I/O |
| 179 |
transaction types. |
| 180 |
|
| 181 |
# MSM IOMMU support |
| 182 |
config MSM_IOMMU |
| 183 |
bool "MSM IOMMU Support" |
| 184 |
depends on ARM |
| 185 |
depends on ARCH_QCOM || COMPILE_TEST |
| 186 |
select IOMMU_API |
| 187 |
select IOMMU_IO_PGTABLE_ARMV7S |
| 188 |
help |
| 189 |
Support for the IOMMUs found on certain Qualcomm SOCs. |
| 190 |
These IOMMUs allow virtualization of the address space used by most |
| 191 |
cores within the multimedia subsystem. |
| 192 |
|
| 193 |
If unsure, say N here. |
| 194 |
|
| 195 |
source "drivers/iommu/amd/Kconfig" |
| 196 |
source "drivers/iommu/arm/Kconfig" |
| 197 |
source "drivers/iommu/intel/Kconfig" |
| 198 |
source "drivers/iommu/iommufd/Kconfig" |
| 199 |
source "drivers/iommu/riscv/Kconfig" |
| 200 |
|
| 201 |
config IRQ_REMAP |
| 202 |
bool "Support for Interrupt Remapping" |
| 203 |
depends on X86_64 && X86_IO_APIC && PCI_MSI && ACPI |
| 204 |
select IRQ_MSI_LIB |
| 205 |
help |
| 206 |
Supports Interrupt remapping for IO-APIC and MSI devices. |
| 207 |
To use x2apic mode in the CPU's which support x2APIC enhancements or |
| 208 |
to support platforms with CPU's having > 8 bit APIC ID, say Y. |
| 209 |
|
| 210 |
# OMAP IOMMU support |
| 211 |
config OMAP_IOMMU |
| 212 |
bool "OMAP IOMMU Support" |
| 213 |
depends on ARCH_OMAP2PLUS || COMPILE_TEST |
| 214 |
select IOMMU_API |
| 215 |
help |
| 216 |
The OMAP3 media platform drivers depend on iommu support, |
| 217 |
if you need them say Y here. |
| 218 |
|
| 219 |
config OMAP_IOMMU_DEBUG |
| 220 |
bool "Export OMAP IOMMU internals in DebugFS" |
| 221 |
depends on OMAP_IOMMU && DEBUG_FS |
| 222 |
help |
| 223 |
Select this to see extensive information about |
| 224 |
the internal state of OMAP IOMMU in debugfs. |
| 225 |
|
| 226 |
Say N unless you know you need this. |
| 227 |
|
| 228 |
config ROCKCHIP_IOMMU |
| 229 |
bool "Rockchip IOMMU Support" |
| 230 |
depends on ARCH_ROCKCHIP || COMPILE_TEST |
| 231 |
select IOMMU_API |
| 232 |
select ARM_DMA_USE_IOMMU |
| 233 |
help |
| 234 |
Support for IOMMUs found on Rockchip rk32xx SOCs. |
| 235 |
These IOMMUs allow virtualization of the address space used by most |
| 236 |
cores within the multimedia subsystem. |
| 237 |
Say Y here if you are using a Rockchip SoC that includes an IOMMU |
| 238 |
device. |
| 239 |
|
| 240 |
config SUN50I_IOMMU |
| 241 |
bool "Allwinner H6 IOMMU Support" |
| 242 |
depends on HAS_DMA |
| 243 |
depends on ARCH_SUNXI || COMPILE_TEST |
| 244 |
select ARM_DMA_USE_IOMMU |
| 245 |
select IOMMU_API |
| 246 |
help |
| 247 |
Support for the IOMMU introduced in the Allwinner H6 SoCs. |
| 248 |
|
| 249 |
config TEGRA_IOMMU_SMMU |
| 250 |
bool "NVIDIA Tegra SMMU Support" |
| 251 |
depends on ARCH_TEGRA || COMPILE_TEST |
| 252 |
depends on TEGRA_AHB |
| 253 |
depends on TEGRA_MC |
| 254 |
select IOMMU_API |
| 255 |
help |
| 256 |
This driver supports the IOMMU hardware (SMMU) found on NVIDIA Tegra |
| 257 |
SoCs (Tegra30 up to Tegra210). |
| 258 |
|
| 259 |
config EXYNOS_IOMMU |
| 260 |
bool "Exynos IOMMU Support" |
| 261 |
depends on ARCH_EXYNOS || COMPILE_TEST |
| 262 |
depends on !CPU_BIG_ENDIAN # revisit driver if we can enable big-endian ptes |
| 263 |
select IOMMU_API |
| 264 |
select ARM_DMA_USE_IOMMU |
| 265 |
help |
| 266 |
Support for the IOMMU (System MMU) of Samsung Exynos application |
| 267 |
processor family. This enables H/W multimedia accelerators to see |
| 268 |
non-linear physical memory chunks as linear memory in their |
| 269 |
address space. |
| 270 |
|
| 271 |
If unsure, say N here. |
| 272 |
|
| 273 |
config EXYNOS_IOMMU_DEBUG |
| 274 |
bool "Debugging log for Exynos IOMMU" |
| 275 |
depends on EXYNOS_IOMMU |
| 276 |
help |
| 277 |
Select this to see the detailed log message that shows what |
| 278 |
happens in the IOMMU driver. |
| 279 |
|
| 280 |
Say N unless you need kernel log message for IOMMU debugging. |
| 281 |
|
| 282 |
config IPMMU_VMSA |
| 283 |
bool "Renesas VMSA-compatible IPMMU" |
| 284 |
depends on ARCH_RENESAS || COMPILE_TEST |
| 285 |
depends on ARM || ARM64 || COMPILE_TEST |
| 286 |
depends on !GENERIC_ATOMIC64 # for IOMMU_IO_PGTABLE_LPAE |
| 287 |
select IOMMU_API |
| 288 |
select IOMMU_IO_PGTABLE_LPAE |
| 289 |
select ARM_DMA_USE_IOMMU |
| 290 |
help |
| 291 |
Support for the Renesas VMSA-compatible IPMMU found in the R-Mobile |
| 292 |
APE6, R-Car Gen{2,3} and RZ/G{1,2} SoCs. |
| 293 |
|
| 294 |
If unsure, say N. |
| 295 |
|
| 296 |
config SPAPR_TCE_IOMMU |
| 297 |
bool "sPAPR TCE IOMMU Support" |
| 298 |
depends on PPC_POWERNV || PPC_PSERIES |
| 299 |
select IOMMU_API |
| 300 |
help |
| 301 |
Enables bits of IOMMU API required by VFIO. The iommu_ops |
| 302 |
is not implemented as it is not necessary for VFIO. |
| 303 |
|
| 304 |
config APPLE_DART |
| 305 |
tristate "Apple DART IOMMU Support" |
| 306 |
depends on ARCH_APPLE || COMPILE_TEST |
| 307 |
depends on !GENERIC_ATOMIC64 # for IOMMU_IO_PGTABLE_DART |
| 308 |
select IOMMU_API |
| 309 |
select IOMMU_IO_PGTABLE_DART |
| 310 |
help |
| 311 |
Support for Apple DART (Device Address Resolution Table) IOMMUs |
| 312 |
found in Apple ARM SoCs like the M1. |
| 313 |
This IOMMU is required for most peripherals using DMA to access |
| 314 |
the main memory. |
| 315 |
|
| 316 |
Say Y here if you are using an Apple SoC. |
| 317 |
|
| 318 |
config S390_IOMMU |
| 319 |
def_bool y if S390 && PCI |
| 320 |
depends on S390 && PCI |
| 321 |
select IOMMU_API |
| 322 |
help |
| 323 |
Support for the IOMMU API for s390 PCI devices. |
| 324 |
|
| 325 |
config MTK_IOMMU |
| 326 |
tristate "MediaTek IOMMU Support" |
| 327 |
depends on ARCH_MEDIATEK || COMPILE_TEST |
| 328 |
select ARM_DMA_USE_IOMMU |
| 329 |
select IOMMU_API |
| 330 |
select IOMMU_IO_PGTABLE_ARMV7S |
| 331 |
select MEMORY |
| 332 |
select MTK_SMI |
| 333 |
help |
| 334 |
Support for the M4U on certain Mediatek SOCs. M4U is MultiMedia |
| 335 |
Memory Management Unit. This option enables remapping of DMA memory |
| 336 |
accesses for the multimedia subsystem. |
| 337 |
|
| 338 |
If unsure, say N here. |
| 339 |
|
| 340 |
config MTK_IOMMU_V1 |
| 341 |
tristate "MediaTek IOMMU Version 1 (M4U gen1) Support" |
| 342 |
depends on (ARCH_MEDIATEK && ARM) || COMPILE_TEST |
| 343 |
select ARM_DMA_USE_IOMMU |
| 344 |
select IOMMU_API |
| 345 |
select MEMORY |
| 346 |
select MTK_SMI |
| 347 |
help |
| 348 |
Support for the M4U on certain Mediatek SoCs. M4U generation 1 HW is |
| 349 |
Multimedia Memory Managememt Unit. This option enables remapping of |
| 350 |
DMA memory accesses for the multimedia subsystem. |
| 351 |
|
| 352 |
if unsure, say N here. |
| 353 |
|
| 354 |
config HYPERV_IOMMU |
| 355 |
bool "Hyper-V IRQ Handling" |
| 356 |
depends on HYPERV && X86 |
| 357 |
select IOMMU_API |
| 358 |
default HYPERV |
| 359 |
help |
| 360 |
Stub IOMMU driver to handle IRQs to support Hyper-V Linux |
| 361 |
guest and root partitions. |
| 362 |
|
| 363 |
config VIRTIO_IOMMU |
| 364 |
tristate "Virtio IOMMU driver" |
| 365 |
depends on VIRTIO |
| 366 |
depends on (ARM64 || X86) |
| 367 |
select IOMMU_API |
| 368 |
select INTERVAL_TREE |
| 369 |
select ACPI_VIOT if ACPI |
| 370 |
help |
| 371 |
Para-virtualised IOMMU driver with virtio. |
| 372 |
|
| 373 |
Say Y here if you intend to run this kernel as a guest. |
| 374 |
|
| 375 |
config SPRD_IOMMU |
| 376 |
tristate "Unisoc IOMMU Support" |
| 377 |
depends on ARCH_SPRD || COMPILE_TEST |
| 378 |
select IOMMU_API |
| 379 |
help |
| 380 |
Support for IOMMU on Unisoc's SoCs, this IOMMU can be used by |
| 381 |
Unisoc's multimedia devices, such as display, Image codec(jpeg) |
| 382 |
and a few signal processors, including VSP(video), GSP(graphic), |
| 383 |
ISP(image), and CPP(camera pixel processor), etc. |
| 384 |
|
| 385 |
Say Y here if you want to use the multimedia devices listed above. |
| 386 |
|
| 387 |
config IOMMU_DEBUG_PAGEALLOC |
| 388 |
bool "Debug IOMMU mappings against page allocations" |
| 389 |
depends on DEBUG_PAGEALLOC && IOMMU_API && PAGE_EXTENSION |
| 390 |
help |
| 391 |
This enables a consistency check between the kernel page allocator and |
| 392 |
the IOMMU subsystem. It verifies that pages being allocated or freed |
| 393 |
are not currently mapped in any IOMMU domain. |
| 394 |
|
| 395 |
This helps detect DMA use-after-free bugs where a driver frees a page |
| 396 |
but forgets to unmap it from the IOMMU, potentially allowing a device |
| 397 |
to overwrite memory that the kernel has repurposed. |
| 398 |
|
| 399 |
These checks are best-effort and may not detect all problems. |
| 400 |
|
| 401 |
Due to performance overhead, this feature is disabled by default. |
| 402 |
You must enable "iommu.debug_pagealloc" from the kernel command |
| 403 |
line to activate the runtime checks. |
| 404 |
|
| 405 |
If unsure, say N. |
| 406 |
endif # IOMMU_SUPPORT |
| 407 |
|
| 408 |
source "drivers/iommu/generic_pt/Kconfig" |