# IOMMU

**IOMMU**（input-output memory management unit，输入输出内存管理单元）是一种硬件，它把设备用于直接内存访问（DMA）的地址翻译成物理内存地址，对设备施加与 CPU 的内存管理单元对程序施加的同类地址翻译与权限检查。<sup>[1](https://stackharbor.com/en/knowledge-base/gpu-passthrough-vfio-iommu/)</sup> 设备的 DMA 一般都要经过 IOMMU 所控制的一次翻译，系统由此可以限制每台设备能触及哪些内存。<sup>[2](https://topofmind.dev/blog/2026/05/08/gpu-virtualization-part-2-iommus-and-hardware-isolation/)</sup>

| 关键事实 | 细节 |
|---|---|
| 功能 | 把设备 DMA（总线）地址翻译成 CPU 物理地址；IOMMU 与主机桥可在两者之间生成任意映射<sup>[3](https://www.kernel.org/doc/html/v6.8/core-api/dma-api-howto.html)</sup> |
| 被翻译的地址 | DMA 的目标地址被当作 I/O 虚拟地址（IOVA），翻译为物理地址<sup>[4](https://www.cs.tau.ac.il/~mad/publications/asplos2016-iommu.pdf)</sup> |
| 厂商实现 | x86 上的 Intel VT-d、AMD-Vi；ARM SMMU；已批准的 RISC-V IOMMU 规范<sup>[1](https://stackharbor.com/en/knowledge-base/gpu-passthrough-vfio-iommu/)</sup><sup> • </sup><sup>[5](https://docs.riscv.org/reference/iommu/v20260222/iommu_intro.html)</sup> |
| 地址空间收窄 | 内存与 PCI BAR 均为 64 位的系统可以使用 IOMMU，使设备只需 32 位 DMA 地址<sup>[3](https://www.kernel.org/doc/html/v6.8/core-api/dma-api-howto.html)</sup> |
| 虚拟化中的作用 | DMA 重映射让设备 DMA 能以客户机物理地址完成，中断重映射把设备中断向量翻译进虚拟机上下文，从而实现 PCI 设备直通<sup>[6](https://www.usenix.org/system/files/atc21-kwon.pdf)</sup> |
| 代价 | IOMMU 因执行 DMA 操作需要额外的内存访问而带来性能损失，由 I/O 转换后备缓冲器（IOTLB）缓解<sup>[7](https://research.ibm.com/haifa/dept/stt/pubs/iommu-performance-ols07.pdf)</sup> |
| 内核接口 | 驱动使用 dma_map_*() API，由它建立所需的 IOMMU 映射；IOMMUFD 把 IO 页表管理暴露给用户空间<sup>[3](https://www.kernel.org/doc/html/v6.8/core-api/dma-api-howto.html)</sup><sup> • </sup><sup>[8](https://cdn.kernel.org/doc/html/latest/userspace-api/iommufd.html)</sup> |

## 设备的地址翻译

运行 DMA 的系统涉及三个地址空间。内核工作在虚拟地址中，由 CPU 的虚拟内存系统翻译成物理地址。设备使用的是第三种，即总线地址：设备在读寄存器或执行 DMA 时放到总线上的地址。在某些系统上总线地址等于 CPU 物理地址，但一般而言并非如此，而 IOMMU 与主机桥可以在两者之间生成任意映射。<sup>[3](https://www.kernel.org/doc/html/v6.8/core-api/dma-api-howto.html)</sup>

当驱动用 `kmalloc()` 准备一块缓冲区时，它得到的是一个虚拟地址，虚拟内存系统把它映射到 RAM 中的某个物理地址。设备不能使用这个虚拟地址，因为 DMA 不经过 CPU 的虚拟内存系统。在简单的系统上，设备可以直接 DMA 到物理地址。而在有 IOMMU 的地方，驱动改为把虚拟地址传给 `dma_map_single()` 之类的接口，由该接口建立所需的 IOMMU 映射并返回一个 DMA 地址；驱动把这个地址写进设备，此后每次访问时由 IOMMU 把它翻译到缓冲区所在的物理位置。<sup>[3](https://www.kernel.org/doc/html/v6.8/core-api/dma-api-howto.html)</sup> IOMMU 把 DMA 目标地址当作 IOVA，通过操作系统配置的页表进行翻译，从而把设备可访问的地址限制在页表允许的范围之内。<sup>[4](https://www.cs.tau.ac.il/~mad/publications/asplos2016-iommu.pdf)</sup><sup> • </sup><sup>[5](https://docs.riscv.org/reference/iommu/v20260222/iommu_intro.html)</sup>

守规矩的驱动会在向执行 DMA 的设备发出命令之前调用 `dma_map_*()`，并在传输完成、映射不再需要之后调用 `dma_unmap_*()`。<sup>[9](https://kernel.org/doc/html/v6.1/x86/iommu.html)</sup> 同一套 API 在没有 IOMMU 的平台上同样可用，而且与总线、体系结构无关。<sup>[3](https://www.kernel.org/doc/html/v6.8/core-api/dma-api-howto.html)</sup>

并非每一笔事务都会被翻译。在 x86 上，0xfee00000 至 0xfeefffff 之类的中断区间会绕过地址翻译，点对点事务也是如此，因此内核保留若干 PCI MMIO 地址区间，使它们不会被当作 IOVA 分配出去。<sup>[9](https://kernel.org/doc/html/v6.1/x86/iommu.html)</sup>

## 厂商实现

IOMMU 这一功能以不同的名字实现。在 Intel 平台上它是 Intel VT-d（Virtualization Technology for Directed I/O，定向 I/O 虚拟化技术），见 Intel 关于 Intel 处理器与芯片组平台上 I/O 虚拟化的体系结构规范。<sup>[1](https://stackharbor.com/en/knowledge-base/gpu-passthrough-vfio-iommu/)</sup><sup> • </sup><sup>[10](https://cdrdv2-public.intel.com/831418/vt-directed-io-spec.pdf)</sup> AMD 的实现是 AMD-Vi。<sup>[1](https://stackharbor.com/en/knowledge-base/gpu-passthrough-vfio-iommu/)</sup> ARM 系统使用 SMMU，RISC-V 则批准了自己的 IOMMU 规范，其中由操作系统配置页表来翻译 IOVA，从而限制设备可访问的地址。<sup>[5](https://docs.riscv.org/reference/iommu/v20260222/iommu_intro.html)</sup>

Linux 为各厂商提供了内核参数。`intel_iommu=on` 启用 Intel VT-d，`iommu=pt` 选择 1:1 直通映射——内核文档建议在集成显卡设备出问题时一试；`intel_iommu=igfx_off` 则关闭集成显卡引擎的翻译。<sup>[9](https://kernel.org/doc/html/v6.1/x86/iommu.html)</sup>

## 隔离与安全

隔离这一角色是相对晚近才有的。许多现代 IOMMU 把隔离特性并入了原本往往只用于翻译的接口，即用于解决地址空间受限设备的寻址问题。<sup>[11](https://docs.kernel.org/driver-api/vfio.html)</sup> 剑桥大学的一份技术报告得出了更为尖锐的结论：尽管安全界的许多人以为并非如此，现代 IOMMU 的建造目的并不是把系统与怀有敌意的外设隔开，而是让虚拟机直接访问物理硬件；报告还指出，IOMMU 以 4 KiB 为单位重映射外设地址空间，并能阻止对外设本不应触及的区域的访问。<sup>[12](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-934.html)</sup>

对于可从外部接入的设备，这种隔离在实践中很重要。Linux 把 IOMMU 认定为防止隧道化的 [Thunderbolt](https://www.edgepedia.org/zh/thunderbolt) 与 USB4 设备访问其被分配区域之外内存的机制。<sup>[13](https://cdn.kernel.org/doc/html/latest/admin-guide/thunderbolt.html)</sup>

## 虚拟化与设备直通

要把一块物理 PCIe 设备直接分配给虚拟机（直通虚拟化），虚拟机监控器依赖 IOMMU 的 DMA 重映射，使被分配设备的 DMA 能以客户机物理地址完成；还依赖中断重映射，把设备的中断向量翻译进虚拟机的上下文。<sup>[6](https://www.usenix.org/system/files/atc21-kwon.pdf)</sup> VFIO 框架利用这些 IOMMU 隔离特性，把 GPU 之类的设备交给虚拟机，同时保护主机不受其 DMA 影响。<sup>[11](https://docs.kernel.org/driver-api/vfio.html)</sup><sup> • </sup><sup>[1](https://stackharbor.com/en/knowledge-base/gpu-passthrough-vfio-iommu/)</sup>

实际能否直通，取决于平台如何把设备划分成 IOMMU 组。如果一块 GPU 与主机需要的某台设备同组，那么不把那台设备一并直通，就无法直通这块 GPU——这是某台机器上无法直通的最常见原因；ACS override 补丁可以人为拆分 IOMMU 组，但会削弱隔离保证。<sup>[14](https://linuxdork.com/blog/gpu-passthrough-vfio/)</sup>

内核的用户空间接口已归拢到 IOMMUFD，这一用户 API 通过文件描述符从用户空间管理 IO 页表，从而控制 IOMMU 子系统。它的设计目标是足够通用，适用于任何想把 DMA 暴露给用户空间的驱动；它提供跨各 IOMMU 管理 I/O 地址空间与 I/O 页表的统一支持，并支持面向客户机虚拟 IOMMU 的嵌套翻译等功能；VFIO 可以透明地把 IOMMUFD 用作其容器后端。<sup>[8](https://cdn.kernel.org/doc/html/latest/userspace-api/iommufd.html)</sup><sup> • </sup><sup>[11](https://docs.kernel.org/driver-api/vfio.html)</sup>

## 性能

翻译不是免费的。IOMMU 会带来性能损失，因为 DMA 操作需要额外的内存访问来遍历翻译结构；硬件把翻译结果缓存在 IOTLB 中，而 IOTLB 与页表缓存的大小是系统构建者要权衡的设计取舍。<sup>[7](https://research.ibm.com/haifa/dept/stt/pubs/iommu-performance-ols07.pdf)</sup> 共享的翻译结构还可能造成争用：对 IOMMU 内部结构的微基准测试表明，共享组件——尤其是 IOTLB——在并发 DMA 活动下会引入可测量的延迟，这在具备 DMA 能力的设备充当独立总线主控的混合关键性系统中关系重大。<sup>[15](https://arxiv.org/abs/2508.19670)</sup>

对于翻译只增加成本、并不带来所需隔离的工作负载，可以使用直通模式（`iommu=pt`），它把地址按 1:1 映射；DPDK 文档指示用户在使用 Intel VT-d 配合 igb_uio 驱动时以该内核参数运行。<sup>[9](https://kernel.org/doc/html/v6.1/x86/iommu.html)</sup><sup> • </sup><sup>[16](https://cdrdv2-public.intel.com/777309/dpdk-getting-started-guide.pdf)</sup>

## References

1. [GPU passthrough with VFIO and IOMMU, stackharbor.com](https://stackharbor.com/en/knowledge-base/gpu-passthrough-vfio-iommu/)
2. [GPU Virtualization Part 2: IOMMUs and Hardware Isolation, topofmind.dev](https://topofmind.dev/blog/2026/05/08/gpu-virtualization-part-2-iommus-and-hardware-isolation/)
3. [Dynamic DMA mapping Guide, The Linux Kernel documentation](https://www.kernel.org/doc/html/v6.8/core-api/dma-api-howto.html)
4. [2.1 IOMMU Operation, ASPLOS 2016](https://www.cs.tau.ac.il/~mad/publications/asplos2016-iommu.pdf)
5. [Introduction, RISC-V Ratified IOMMU Specification](https://docs.riscv.org/reference/iommu/v20260222/iommu_intro.html)
6. [A Fast and Flexible Hardware-based Virtualization Mechanism for Computational Storage Devices, USENIX ATC 2021](https://www.usenix.org/system/files/atc21-kwon.pdf)
7. [The Price of Safety: Evaluating IOMMU Performance, IBM Research / OLS 2007](https://research.ibm.com/haifa/dept/stt/pubs/iommu-performance-ols07.pdf)
8. [IOMMUFD, The Linux Kernel documentation](https://cdn.kernel.org/doc/html/latest/userspace-api/iommufd.html)
9. [x86 IOMMU Support, The Linux Kernel documentation](https://kernel.org/doc/html/v6.1/x86/iommu.html)
10. [Intel Virtualization Technology for Directed I/O Architecture Specification](https://cdrdv2-public.intel.com/831418/vt-directed-io-spec.pdf)
11. [VFIO - Virtual Function I/O, The Linux Kernel documentation](https://docs.kernel.org/driver-api/vfio.html)
12. [UCAM-CL-TR-934, University of Cambridge Computer Laboratory Technical Report](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-934.html)
13. [USB4 and Thunderbolt, The Linux Kernel documentation](https://cdn.kernel.org/doc/html/latest/admin-guide/thunderbolt.html)
14. [GPU Passthrough with VFIO, Linux Dork](https://linuxdork.com/blog/gpu-passthrough-vfio/)
15. [Beyond the Bermuda Triangle of Contention: IOMMU Interference in Mixed Criticality Systems, arXiv](https://arxiv.org/abs/2508.19670)
16. [Getting Started Guide for Linux, DPDK Release 2.0.0](https://cdrdv2-public.intel.com/777309/dpdk-getting-started-guide.pdf)

---
*Initially written Oct 15, 2026 · Edited: Oct 25, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 计算机硬件 › Boards, peripherals & form factors › Peripherals & expansion hardware

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/iommu

English original: https://www.edgepedia.org/iommu
