Add some TODOs in IOMMU initialization

This commit is contained in:
Ruihan Li 2025-05-20 13:16:31 +08:00 committed by Junyang Zhang
parent d2ff5fc1a9
commit dd9fc81a81
2 changed files with 14 additions and 0 deletions

View File

@ -74,6 +74,11 @@ pub fn init() {
// Create a Root Table instance.
let mut root_table = RootTable::new();
// For all PCI devices, use the same page table.
//
// TODO: The BIOS reserves some memory regions as DMA targets and lists them in the Reserved
// Memory Region Reporting (RMRR) structures. These regions must be mapped for the hardware or
// firmware to function properly. For more details, see Intel(R) Virtualization Technology for
// Directed I/O (Revision 5.0), 3.16 Handling Requests to Reserved System Memory.
let page_table = PageTable::<DeviceMode, PageTableEntry, PagingConsts>::empty();
for table in PciDeviceLocation::all() {
root_table.specify_device_page_table(table, unsafe { page_table.shallow_copy() })

View File

@ -258,6 +258,15 @@ impl IommuRegisters {
let base_address = dmar
.remapping_iter()
// TODO: Add support for multiple DMA remapping hardware unit definitions (DRHDs). Note
// that we use `rev()` here to select the last one, since DRHDs that control specific
// devices tend to be reported first.
//
// For example, Intel(R) Virtualization Technology for Directed I/O (Revision 5.0), 8.4
// DMA Remapping Hardware Unit Definition Structure says "If a DRHD structure with
// INCLUDE_PCI_ALL flag Set is reported for a Segment, it must be enumerated by BIOS
// after all other DRHD structures for the same Segment".
.rev()
.find_map(|remapping| match remapping {
Remapping::Drhd(drhd) => Some(drhd.register_base_addr()),
_ => None,