DMA 重映射
iommu 作用
- 安全性, 防止恶意访问
In the absence of an IOMMU, a device driver must program devices with Physical Addresses, which implies that DMA from a device could be used to access any memory, such as privileged memory,and cause malicious or unintended corruptions. This may be caused by hardware bugs, devicedriver bugs, or by malicious software/hardware. 013
在没有IOMMU的情况下,设备驱动程序必须用物理地址对设备进行编程,这意味着来自设备的DMA可以被用来访问任何内存,如特权内存,并造成恶意或意外的损坏。这可能是由硬件错误、设备驱动程序错误或恶意软件/硬件造成的。
使传统的32位外设可以访问超过4G的内存区间, 不再需要软件做 bounce buffers, 提高性能
Legacy 32-bit devices cannot access the memory above 4 GiB. 013
The integration of the IOMMU,through its address remapping capability, offers a simple mechanism for the DMA to directly accessany address in the system 013
Without an IOMMU, the OS must resort to copying data through buffers (also known as bounce buffers) allocated in memory below 4GiB. 013
The IOMMU can be useful as it permits to allocate large regions of memory without the need to becontiguous in physical memory 013
可以使用连续物理内存
中断重映射
MSI 重映射
To handle MSIs from a device controlled by a guest OS, the hypervisor configures an IOMMU toredirect those MSIs to a guest interrupt file in an IMSIC (see Figure 3) or to a memory-residentinterrupt file. The IOMMU is responsible to use the MSI address-translation data structures suppliedby the hypervisor to perform the MSI redirection. Because every interrupt file, real or virtual,occupies a naturally aligned 4-KiB page of address space, the required address translation is from avirtual (guest) page address to a physical page address, 015
hypervisor配置了一个IOMMU,将这些guest 的MSI (GPA) 重定向到IMSIC中的guest interrupt file (HPA)
利用 iommu 重定向能力 使的 guest msi的GPA地址访问直接映射为 HPA的msi的地址访问, 从而让guest 可以直接读写物理msi mmio, 实现中断重映射能力, 中断直通给vcpu.