Add bootinfo tag#536
Conversation
Previously, the ELF code treats program headers = segments. While this worked originally, it broke for cases that requires >= 2 program headers to refer to the same segment. Now, when the ELF is parsed, the code will create a 1-1 mapping of segments to program headers like before. But the allow for additional program headers to be inserted. Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
Added `pub fn phdrs_table(&self) -> Vec<(ElfProgramHeader64, usize)>` to ELF code. Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
Modified `pub fn add_segment()` to allow for an additional program header in the ELF to describe the segment with a user defined type identifier. Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
Which also required changes to how the spec is packed into the intialiser. Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
This adds the 'bootinfo' tag to map specified type of bootinfo into PD's vspace, and patch the location to the pre-declared variable. This is useful for the cases where the userland needs to access some of boot information, e.g., RSDP in ACPI driver. The example shows how TSC Frequency is mapped and read by a PD. Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>
| let bi_type = match xml_bi_type { | ||
| "vbe" => FillEntryContentBootInfoId::X86Vbe, | ||
| "mbmmap" => FillEntryContentBootInfoId::X86Mbmmap, | ||
| "rsdp" => FillEntryContentBootInfoId::X86AcpiRsdp, | ||
| "framebuffer" => FillEntryContentBootInfoId::X86FrameBuffer, | ||
| "tsc_freq" => FillEntryContentBootInfoId::X86TscFreq, | ||
| _ => return Err(format!("BootInfoMap type: '{xml_bi_type}' is not supported.")), | ||
| }; |
There was a problem hiding this comment.
This should be consistent with the naming scheme of the enum/seL4 Bootinfo items - as in keep the prefix.
There was a problem hiding this comment.
you mean the whole sel4_bootinfo_header_x86_vbe or x86_vbe?
| if existing_bi_map.bi_type == bi_map.bi_type { | ||
| let pos = xml_sdf.doc.text_pos_at(child.range().start); | ||
| return Err(format!( | ||
| "Error: duplicate {:?} in protection domain '{}' @ {}", |
There was a problem hiding this comment.
Unless rust-seL4 actively prevents this I don't really see a reason to prevent duplicates. It adds extra code that isn't useful.
There was a problem hiding this comment.
"No duplicates" assumption is used for patching the address of bootinfo into a PD via setvar? and there is no use cases that need duplicate bootinfo I think.
There was a problem hiding this comment.
Oh, is the name of the setvar implicit? I really don't like that.
no use cases that need duplicate bootinfo I think.
That doesn't mean there couldn't be one, and it's more effort to prevent it.
There was a problem hiding this comment.
yes, it is implicit. It will be solved if we use prefilled MRs.
That doesn't mean there couldn't be one, and it's more effort to prevent it.
right, so prefilled MR is indeed a better solution in this case.
There was a problem hiding this comment.
Well, we can't use "prefilled" MRs directly, but if we had a mechanism closer to it.
There was a problem hiding this comment.
Are you saying we still need a bootinfo tag outside of PDS? Can I know what's your concern of adding an optional parameter in prefilled MRs?
There was a problem hiding this comment.
Prefilled MRs means an MR prefilled from a file.
This isn't "prefilled" in the same way as other prefilled, but it's a similar mechanism.
| let mut setvars: Vec<SysSetVar> = Vec::new(); | ||
| let mut child_pds = Vec::new(); | ||
| let mut bootinfo_maps: Vec<BootInfoMap> = Vec::new(); | ||
| let mut mem_top = config.pd_map_max_vaddr(stack_size); |
There was a problem hiding this comment.
I don't link this very much. The implicit allocation adds a whole bunch of extra cases to our logic about overmapping, which makes things difficult.
Could the bootinfo not just be another <mr> that one specifies and then we can place bootinfo "inside" of it?
(You could then in theory map it in RO to multiple PDs without needing to copy it many times - for instance, if we wanted to map in the FDT it would probably be bad to copy it into every PD)
There was a problem hiding this comment.
We could make the SysMemoryRegion have the kind be User/Elf/Stack/Prefill(with a buffer)/Bootinfo (type)` and then these would all be consistently handled
There was a problem hiding this comment.
Yes, that's true. I didn't realise that we already had prefilled MR.
|
|
||
| #[repr(u64)] | ||
| #[derive(Debug, Copy, Clone, Eq, PartialEq)] | ||
| pub enum BootInfoId { |
There was a problem hiding this comment.
Isn't there already the rust-sel4 FillEntryContentBootInfoId which you use?
There was a problem hiding this comment.
uh my bad. I forgot to remove them after replacing with FillEntryContentBootInfoId.
| microkit_dbg_puts("TSC Frequency: "); | ||
| microkit_dbg_put32(bootinfo_tsc_freq->value); | ||
| microkit_dbg_puts("MHz\n"); | ||
|
|
There was a problem hiding this comment.
Can we please split this into a new example called bootinfo or something like that? That comes with the benefit of being able to target other archs as well. As this example is just meant to show x86 PIO operations.
There was a problem hiding this comment.
yes, I have added a separate example for this. Do you have any ideas of how to demonstrate the ability to read DTB on ARM?
There was a problem hiding this comment.
we can probably quite easily parae the fdt header and at the very least verify the magic bytes and print the version, without having to write an entire fdt library.
edit: although saying that, microkit loader does not pass through the dtb and always passes 0,0 for the dtb, so.
This PR is rebased on branch rust_sel4_update_to_main, which should be merged soon. The proposed feature is included in the only last commit.
This PR adds the
bootinfotag to map specified type of bootinfo into PD's vspace, and patch the address to pre-declared variablebootinfo_{bi_type}. This is useful for the cases where the userspace applications needs to consume bootinfo, e.g., RSDP in ACPI driver, TSC used as clock source, etc.The usage of
bootinfotag is added in the examplex86_64_ioport. It works with this rust-sel4 PR on x86 to show how TSC frequency is mapped and read by a PD.