Skip to content

Commit dc2bb15

Browse files
committed
IOMMU: Add SDF Support
This commit adds iommu support to microkit sdfs. Define a constant to represent the a tool enforced limitation on the maximum virtual address suported for an IO address space. This is due to current x86 IOMMU behaviour in the kernel which dynamically detects the maximum virtual address for an IO address space. For more info read: BOOT_CODE bool_t vtd_init_num_iopts(uint32_t num_drhu) in seL4/src/plat/pc99/machine/intel-vtd.c. Add PciDevice struct and PCIDeviceParseError enum. This types allow us to implement the Display trait which gives a consistent way to output PCI information. The FromStr trait implemented for PCIDevice avoid duplicating logic required to parse the PCI identifier from the xml. When combined with the display trait on the PCIDeviceParseError, we get consistent error messages and avoid repeating code. Add IOMMUDeviceIdentifier and IOMMUDeviceIdentifierParseError to support parsing the sdf based on the current architecture. This allows the sdf parsing to easily support ARM SMMU and RISCV IOMMU. The Display traits again remove repeated code when outputting IOMMUDeviceIdentifer or IOMMUDeviceIdentifierParseError, particularly useful for error messages. Add SysIOMapPerms. Representing the perms in an enum completely removes the existence of invalid IOMapPerms once we parse the sdf. Add SysIOMap. The dual to SysMap, used to represent a mapping in a devices IO virtual address space. Replace ExecutionContext trait with a Map trait. The previous trait was primarily used in the check_maps function to handle memory regions in virtual machines and normal pds. This Map trait allowed the one check_maps function to handle both SysIOMaps and SysMaps uniformly. The additional information that was provided by the polymorhpic ExecutionContext is just passed as a string to be used in the respective error message. This is because outside of the check_maps function a protection_domain and a virtual_machine are handled as distinct types. Add error checking cases to check_maps. If the map_start + mr.size overflows alot of the pre-exisiting logic breaks so check for it. Also check that we don't overflow the top of user_virtual memory accouting for the differences between protection_domains, virtual_machines and io address spaces. Add check_io_maps adapter. Required because check_maps is designed to error check within one address space. Therefore we collect all the mappings that have been made on a per IO address space basis. capdl/irq.rs waas using the old pci_bus,pci_dev,pci_func form. Since we have a real type now, we updated the expected match form. Signed-off-by: Callum <c.berry@student.unsw.edu.au>
1 parent b5cd889 commit dc2bb15

24 files changed

Lines changed: 1063 additions & 194 deletions
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright 2026, UNSW
4+
5+
SPDX-License-Identifier: BSD-2-Clause
6+
-->
7+
<system>
8+
<memory_region name="edu_mmio_window" size="0x10_0000" page_size="0x1000" phys_addr="0xfe00_0000" />
9+
<memory_region name="dma_buffer" size="0x1000" page_size="0x1000" />
10+
<io_address_space name="QEMU EDU" identifier="0:4.0">
11+
<iomap mr="dma_buffer" iovaddr="0x10_0000" />
12+
</io_address_space>
13+
14+
<protection_domain name="x86_64_iommu_dma_test" priority="100">
15+
<program_image path="x86_64_iommu_dma_test.elf" />
16+
<map mr="edu_mmio_window" vaddr="0x2000_0000" perms="rw" cached="false" setvar_vaddr="edu_mmio_window_vaddr" />
17+
<map mr="dma_buffer" vaddr="0x3000_0000" perms="rw" cached="true" setvar_vaddr="dma_buffer_vaddr" />
18+
<ioport id="0" addr="0xcf8" size="8" setvar_id="pci_config_ioport_id" />
19+
</protection_domain>
20+
</system>

tool/microkit/src/capdl/irq.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,14 @@ fn create_irq_obj(
8686
}),
8787
}),
8888
SysIrqKind::MSI {
89-
pci_bus,
90-
pci_dev,
91-
pci_func,
92-
handle,
93-
..
89+
pci_device, handle, ..
9490
} => Object::IrqMsi(object::IrqMsi {
9591
slots: [].to_vec(),
9692
extra: Box::new(object::IrqMsiExtraInfo {
9793
handle: Word(handle),
98-
pci_bus: Word(pci_bus),
99-
pci_dev: Word(pci_dev),
100-
pci_func: Word(pci_func),
94+
pci_bus: Word(pci_device.bus as u64),
95+
pci_dev: Word(pci_device.device as u64),
96+
pci_func: Word(pci_device.function as u64),
10197
}),
10298
}),
10399
};

0 commit comments

Comments
 (0)