Conversation
Signed-off-by: Cheng Li <cheng.li10@unsw.edu.au>
Signed-off-by: Cheng Li <cheng.li10@unsw.edu.au>
Signed-off-by: Cheng Li <cheng.li10@unsw.edu.au>
Signed-off-by: Cheng Li <cheng.li10@unsw.edu.au>
Signed-off-by: Cheng Li <cheng.li10@unsw.edu.au>
Signed-off-by: Cheng Li <cheng.li10@unsw.edu.au>
…ure for generating spec in microkit tool. Signed-off-by: Cheng Li <cheng.li10@unsw.edu.au>
Signed-off-by: Cheng Li <cheng.li10@unsw.edu.au>
…e check unused mr and mr page size optimization logic for iomaps support. Signed-off-by: Cheng Li <cheng.li10@unsw.edu.au>
Signed-off-by: Cheng Li <cheng.li10@unsw.edu.au>
Signed-off-by: Cheng Li <cheng.li10@unsw.edu.au>
Signed-off-by: Cheng Li <cheng.li10@unsw.edu.au>
| [workspace.dependencies.sel4-capdl-initializer-types] | ||
| git = "https://github.com/seL4/rust-sel4" | ||
| rev = "7a2321f2d84310ba7a09fe7f5988e6dcecde3566" | ||
| path = "/home/cheng/system/rust-sel4/crates/sel4-capdl-initializer/types" |
There was a problem hiding this comment.
Can you update it to the commit hash that added IOMMU support to the capDL initialiser in rust-sel4 so that the CI works? On that note, you will need to rebase your branch as well, the CI doesn't run when there are conflicts.
| @@ -0,0 +1,282 @@ | |||
| use std::ops::Range; | |||
There was a problem hiding this comment.
Missing copyright here
| }), | ||
| }); | ||
|
|
||
| const PD_TO_DOMAIN_ID_OFFSET: u16 = 1; |
There was a problem hiding this comment.
You should explain why this is needed (with kernel source) for future reference.
| "Error: iomap for '{}' has address 0x{:x} which exceeds the upper limits of {} in {} '{}' @ {}", | ||
| io_map.name, | ||
| map_end, | ||
| crate::capdl::iomem::VTD_MAX_ADDR, |
There was a problem hiding this comment.
I feel like VTD_MAX_ADDR should be printed as hex.
| } | ||
|
|
||
| #[test] | ||
| fn test_iommu_valid_on_x86() { |
There was a problem hiding this comment.
This should be called test_iommu_out_of_bound or similar.
On this note, I would like to see more tests, e.g. overlapping mappings, invalid page size, trying to use IOMMU on non-x86 targets etc.
| phys_base: None, | ||
| spec_metadata: None, | ||
| log_level: LogLevel::Info, | ||
| log_level: LogLevel::Debug, |
There was a problem hiding this comment.
This shouldn't be changed.
| sel4::Config, | ||
| }; | ||
|
|
||
| // VTD Page table level is defaulted to the three-level structure even if the hardware supports four level. |
There was a problem hiding this comment.
I forgot the content of the conversation we had offline about this. But what happens when the target machine only support 3 levels VT-d page table, but we made a 4 levels one (according to VTD_PAGE_TABLE_LEVEL)?
|
Your commit history needs to be cleaned up and squashed. Some of the commits checked in code that should not be in Microkit, then other commits removed them. |
|
A nice to have would be a minimal example showing this in action on QEMU x86, like the For example, you can use QEMU's DMA-capable "educational device": https://www.qemu.org/docs/master/specs/edu.html. You copy some data from normal RAM into the device's SRAM with a DMA transaction, then read back the device's SRAM via normal MMIO to verify that the transfer succeeded. |
midnightveil
left a comment
There was a problem hiding this comment.
Misc things.
I'm not quite sure how this is supposed to be used in the SDF file.
I can only vaguely infer from the error tests you added, but you should add documentation on how to use this and what that means for the layout of the page tables for both.
| use sel4_capdl_initializer_types::{ | ||
| object, CapTableEntry, Fill, FillEntry, FillEntryContent, NamedObject, Object, ObjectId, Spec, | ||
| Word, | ||
| object::{self}, |
There was a problem hiding this comment.
Why object::{self}. What was wrong with just object?
| for frame_obj_id in frames.iter() { | ||
| // Make a cap for this frame. | ||
| let frame_cap = capdl_util_make_frame_cap(*frame_obj_id, read, write, false, false); |
There was a problem hiding this comment.
| for frame_obj_id in frames.iter() { | |
| // Make a cap for this frame. | |
| let frame_cap = capdl_util_make_frame_cap(*frame_obj_id, read, write, false, false); | |
| for &frame_obj_id in frames.iter() { | |
| // Make a cap for this frame. | |
| let frame_cap = capdl_util_make_frame_cap(frame_obj_id, read, write, /* what does this mean */ false, /* what does this mean */ false); |
| // Step 3-4 Create Scheduling Context | ||
| // Step 3-4 Create and Map IO Page Table Structure | ||
| if kernel_config.iommu { | ||
| let mut pci_to_iospace: HashMap<(u8, u8, u8), ObjectId> = HashMap::new(); |
There was a problem hiding this comment.
This is assuming x86-specificness.
Do we not have a PciDev type anyway, that would make this nicer
also what happened to the domain id from the rust-seL4 pr?
| }; | ||
|
|
||
| // VTD Page table level is defaulted to the three-level structure even if the hardware supports four level. | ||
| // Sel4 will only attempt to use the four-level structure if the hardware does not supports three level. |
There was a problem hiding this comment.
seL4.
Check the grammar.
|
|
||
| // VTD Page table level is defaulted to the three-level structure even if the hardware supports four level. | ||
| // Sel4 will only attempt to use the four-level structure if the hardware does not supports three level. | ||
| // https://github.com/seL4/seL4/blob/c406015c389decc4559fd44cb69604ddd24a0ddb/src/plat/pc99/machine/intel-vtd.c#L498 |
There was a problem hiding this comment.
Use a link to a commit tag preferably over a random commit hash, e.g. seL4/seL4/blob/15.0.0.
| pub name: String, | ||
| pub pci_bus: u8, | ||
| pub pci_dev: u8, | ||
| pub dev_func: u8, | ||
| pub ioaddr: u64, | ||
| pub perms: u8, | ||
| pub text_pos: Option<roxmltree::TextPos>, |
There was a problem hiding this comment.
Same comments as the rust-seL4 PR: the PCI stuff should be part of x86 as itis arch-speicific.
| if map_end > crate::capdl::iomem::VTD_MAX_ADDR { | ||
| return Err( | ||
| format!( | ||
| "Error: iomap for '{}' has address 0x{:x} which exceeds the upper limits of {} in {} '{}' @ {}", |
| }, | ||
| ObjectType::AsidPool => Some(object_sizes.asid_pool), | ||
| ObjectType::IOPageTable => Some(12), | ||
| // It would be best to avoid such catch all case so people might forget to add the size of new object type here. |
There was a problem hiding this comment.
Fix it or make an issue I think
| @@ -0,0 +1,15 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!-- | |||
| Copyright 2024, UNSW. | |||
| @@ -68,7 +68,7 @@ | |||
| "KernelPlatform": "pc99", | |||
| "KernelX86MicroArch": "generic", | |||
| # See https://github.com/seL4/microkit/issues/418 for details. | |||
There was a problem hiding this comment.
remove this comment if its solved
Signed-off-by: Cheng Li <cheng.li10@unsw.edu.au>
This pull request adds iommu support for Microkit and needs Rust-Sel4 with the iommu support to work.
Supported features:
Map the memory region to a device-visible memory address.
Tests done:
Blk example with iommu feature enabled on x86 qemu and hardware(vb-105).