RMRR & identity mapping related notes
本文将会介绍VT-d场景下,RMRR和identity mapping的相关知识点。
1 RMRR
1.1 基本概念
RMRR - Reserved Memory Region Reporting Structure.
RMRR is specified by the BIOS via ACPI tables.
1.2 motivation
There are some devices the BIOS controls, for e.g USB devices to perform PS2 emulation. The regions of memory used for these devices are marked reserved in the e820 map. When we turn on DMA translation, DMA to those regions will fail. 在VT-d环境下,DMA指DMA remapping。为了使IOMMU能访问到reserved memory regions,RMRR应运而生。
1.3 usage
- Hence BIOS uses RMRR to specify these regions along with devices that need to access these regions.
- OS is expected to setup unity mappings for these regions for these devices to access these regions.
2 identity mapping
RMRR definitions associate a physical memory region with one or more devices, so that when the IOMMU is initialized the device will continue to have access to the physical memory at the original address. In other words, the IOMMU must provide a direct one-to-one translation, or an identity mapping, for every referenced device in order to satisfy the RMRR.
翻译一下就是,何为identity mapping呢?当RMRR的HPA地址范围为1GB~2GB时,经过identity mapping后,GPA的地址范围也为1GB~2GB。也就是说,GPA和HPA的地址是identical(相同的)的,故为identity mapping。
假设在IOMMU初始化之前,我们访问的HPA为1GB,并将该地址hardcode了。IOMMU初始化之后,我们依然访问hardcode后的地址,此时的地址为GPA。在这种场景下,便需要建立identity mapping了。
参考资料: