IOMMU: Refactor the memory module#7
Conversation
26a6f14 to
c8c04e3
Compare
3580597 to
d543258
Compare
af71760 to
2a462da
Compare
43b0567 to
dd66aeb
Compare
4df0221 to
4121642
Compare
| #endif | ||
|
|
||
| #ifdef VTD_PT_INDEX_BITS | ||
| MICROKIT_CONSTANT(io_page_table_index_bits, VTD_PT_INDEX_BITS) |
There was a problem hiding this comment.
Oh, you seem to have changed this in PR 8.
| min_untyped_bits: seL4_MinUntypedBits | ||
| max_untyped_bits: seL4_MaxUntypedBits | ||
| vspace: seL4_VSpaceBits | ||
| #define MICROKIT_CONSTANT(name, value) microkit_constant name value |
There was a problem hiding this comment.
What's the point of these changes? I don't understand them
There was a problem hiding this comment.
Made the parsing simple when I had to dig down to get the VTD information, but with the libsel4 fix I should be able to revert
| // We expect the PD ELFs to be first and the monitor ELF last in the list of ELFs. | ||
| let mon_elf_id = elfs.len() - 1; | ||
| assert!(elfs.len() == system.protection_domains.len() + 1); | ||
| let monitor_tcb_obj_id = { |
There was a problem hiding this comment.
What's the point of this change? You just removed monitor_elf afaict.
There was a problem hiding this comment.
This just uses the new return value of add_elf_to_spec, which is both the tcb obj id and the address space
| device_regions, | ||
| normal_regions, | ||
| object_sizes, | ||
| object_sizes: Some(object_sizes_json.object_sizes), |
There was a problem hiding this comment.
I think this should be split out into object_sizes and address_space_constants, as 2 different preprocessed files or something
There was a problem hiding this comment.
yep will fix, I was just following how it was before (mixed), take it back I misinterpreted the original (asid pool index bits seems like a special case), have fixed this
|
|
||
| /* | ||
| * The Microkit tool needs to know the sizes of kernel objects. | ||
| * The Microkit tool needs to know the sizes of kernel objects and a small |
There was a problem hiding this comment.
Your third commit, 'IOMMU: Remove constants retrievable from seL4' has nothing to do with the IOMMU, and could be its own PR done standalone, which would make it easier to review.
| } | ||
|
|
||
| fn read(&self) -> bool { | ||
| matches!(self.perms, SysIOMapPerms::Read | SysIOMapPerms::ReadWrite) |
There was a problem hiding this comment.
What's the point of defininng separate SysIOMapPerms then? What do these permissions do differently than the original SysMapPerms?
There was a problem hiding this comment.
SysIOMapPerms can only represent valid perms in the type system, while the other can the anything. The better improvement would be to fix SysMapPerms too... Should I do that?
| /// Kernel object sizes, used for kernel boot emulation and untyped allocation. | ||
| pub object_sizes: Option<ObjectSizes>, | ||
| pub page_table_index_bits: u64, | ||
| /// Only emitted for aarch builds |
There was a problem hiding this comment.
emitted or omitted? If the former, I'd prefer included, and be specific that it is AArch64.
| Arch::Riscv64 => 0x0000003fffffefff, | ||
| Arch::X86_64 => 0x7fffffffefff, | ||
| } | ||
| self.user_top |
There was a problem hiding this comment.
If this is just a constant now we should have pub vspace_user_top: u64 and use that. No need for this extra function.
| /// The two remaining fields are only valid on ARM and RISC-V | ||
| pub device_regions: Option<Vec<PlatformConfigRegion>>, | ||
| pub normal_regions: Option<Vec<PlatformConfigRegion>>, | ||
| /// Emitted on all builds corresponds to seL4_UserVSpaceTop. |
| match (self.arch, self.iommu) { | ||
| (Arch::X86_64, true) => self | ||
| .io_page_table_index_bits | ||
| .expect("Error: An x86 VT-D build should have VTD_PT_INDEX_BITS defined by seL4, captured in tool/microkit/object_sizes.h"), |
There was a problem hiding this comment.
Please reformat over multiple lines.
4121642 to
6539123
Compare
6539123 to
c4643ad
Compare
c4b6467 to
fd6dab8
Compare
c4643ad to
d2d3d33
Compare
5e715bd to
dfc3853
Compare
d2d3d33 to
112cc18
Compare
dfc3853 to
7070554
Compare
112cc18 to
51f97b2
Compare
7070554 to
d13bf6b
Compare
2af2aab to
9ecdac4
Compare
d13bf6b to
ad35214
Compare
Because the tool will default to priority 0 if it is not specified. Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
No behavioural changes. Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
This is because on x86-64, the VM shares TCB with the parent PD (VMM). Rather than being distinct entities like on ARM. Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
Add tests for valid and invalid VM scenarios. Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
We recently switched to using a 2 level CSpace for cap mapping support. During the switch there was a mistake in the code that caused a child TCB object to be inserted into the wrong CNode. Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
A simple refactor that hide the different CNodes of a PD behind helper functions to make it less error prone during development. Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
As per discussions surrounding RFC25, allowing access to a PD's CSpace can violate the static nature of a Microkit system. Let's remove this feature for now for the next release and we can always rework/add it back later. It was also broken, and it did not work properly because of the guard. Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
This commit adds 'microkit_pd_resume' that resumes a PD that is stopped by 'microkit_pd_stop'. Signed-off-by: Guangtao Zhu <guangtaozhu@outlook.com>
Hex formatting. Signed-off-by: Callum <c.berry@student.unsw.edu.au>
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 will allow 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. Signed-off-by: Callum <c.berry@student.unsw.edu.au>
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. Signed-off-by: Callum <c.berry@student.unsw.edu.au>
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 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. 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. Signed-off-by: Callum <c.berry@student.unsw.edu.au>
Update the manual to include IOMMU information. Signed-off-by: Callum <c.berry@student.unsw.edu.au>
Ensure that the sel4::Config struct has the iommu flag asserted, indicating the kernel was built with IOMMU support. If not we fail parsing any io address space elements encountered in the sdf. Signed-off-by: Callum <c.berry@student.unsw.edu.au>
Address Feedback from Bill. Signed-off-by: Callum <c.berry@student.unsw.edu.au>
Fix a test that was assuming a fixed max virtual address. Instead make the memory region large enough that it will be out of bounds on any realistic max virtual address reported by seL4 via user_top(). Signed-off-by: Callum <c.berry@student.unsw.edu.au>
Add domain ids to microkit system descriptions. Signed-off-by: Callum <c.berry@student.unsw.edu.au>
Minor adjustments to the prior sdf work to do with how permissions are handled. Previously I implemented read and write functions as part of the SysIOMapPerms enum, however the old SysMapPerms did not do this. Given these types are meant to exhibit similar behaviour extracting this common logic into the Map trait provides a streamlined interface to check if a permission is set. Signed-off-by: Callum <c.berry@student.unsw.edu.au>
This commit is meant to preserve original functionality. The memory.rs file previously was a collection of functions that allowed the mapping of pages into vspaces. This commit refactors this logic into an AddressSpace type. This will allow us to simply support new variants of address spaces, including IO Address Spaces for devices. The majority of changes are made to allow the old functions to be reusued in a more generic way. The changes to the builder.rs reflect the changes to memory.rs or make use of the trait Map as trait bounds to handle both normal Mappings and IOMappings. Signed-off-by: Callum <c.berry@student.unsw.edu.au>
This commit integrates the improved config to the memory module. This commit removes some of the duplicated constants definitions that seL4 already exports. Signed-off-by: Callum <c.berry@student.unsw.edu.au>
9ecdac4 to
73853c7
Compare
This PR makes a small change to the SDF work previously completed.
It then refactors the memory.rs module in preparation for adding support for IO Address Spaces. The refactor primarily introduces an address space abstraction that can allow simpler handling of different address space variants.
It also removes the pre-existing duplicated constants that are already defined by seL4. This commit extracts those and includes them in the Config struct that the tool passes around.
This PR preserves the existing behaviour.