IOMMU的具体工作原理就不展开了,AMD IOMMU【1】与INTEL VT-D有公开的英文版文档。
总得来讲,IOMMU主要做DMA与Interrupt remapping两大类的工作
AMD IOMMU硬件功能上理解起来不算太复杂,但一旦结合Linux,复杂度就明显提高
参考了一些内容,但大多数是写IOMMU硬件功能的【4】,有少量提到IOMMU与Linux的,而大多数也只是一笔带过
Reference [3] 是以Intel IOMMU为介绍对象
Reference [2] 更加有参考价值
这一系列,主要记录:AMD IOMMU在Linux下的学习所得:
1. 先从pci_iommu_alloc()函数开始:
在执行pci_iommu_alloc()之前,内核已经通过汇编指令,将IOMMU相关的启动函数,加载到IOMMU Table中, 如下:
IOMMU_INIT_FINISH(amd_iommu_detect,
gart_iommu_hole_init,
NULL,
NULL);
amd_iommu_detect -- Early detect code. This code runs at IOMMU detection time in the DMA layer. It just looks if there is an IVRS ACPI table to detect AMD IOMMUs
针对INTEL, AMD-GART, SWIOTLB的类似启动函数还有如下:
IOMMU_INIT_POST(gart_iommu_hole_init);
IOMMU_INIT_POST(detect_intel_iommu);
IOMMU_INIT_FINISH(pci_xen_swiotlb_detect,
NULL,
pci_xen_swiotlb_init,
NULL);
IOMMU_INIT_FINISH(pci_swiotlb_detect_override,