Skip to content

Conversation

@Kswin01
Copy link
Contributor

@Kswin01 Kswin01 commented Jul 17, 2025

This PR adds support for patching a copy of a child PD's page tables into the parent.

We add an extra attribute to the protection domain xml tag, if set to true, the child page tables will be added into the parent.

We create a vector for all potential child page tables, with the length of the total amount of PDs in the system. This vector is a vector of 64 references to potential PGD's of potential child PDs. If the above tag is set to true, we will go through the current elf segments, memory regions and the ipc buffer associated with each of the child PDs, and create a copy of this paging structure and add to the above vector. At this point, the underlying frame caps haven't been allocated. We will add a blank elf segment, .table_data to the parent elf at this point, of the correct size that we have calculated from creating these paging structures.

Later on when these frame caps have been allocated, its a simple matter of filling in the already create paging structures. To make this simpler, we have added some helper structs and functions in lib.rs. I'm not sure if this is the best place for this code to live.

We then populate the elf segment we created before with these complete paging structures. Additionally we patch a struct variable into the parent containing the base address of this new segment, as well as an array of 64 pointers into this region that are the start of the PGD of each child. We haven't added this struct to the microkit header, so it is therefore up to the user to define this structure. Please let me know if we should add this to microkit.h instead. The entries in this table are pointers to the next level tables, or the frame cap. We support both large and small pages. This has been tested on aarch64, but should also work on RISCV64 provided that the address are Sv48 (48bit addressing) we don't actually use . The caps to the underlying frames are also minted into the parent's cspace.

Additionally, we extend the current elf library in the microkit tool to be able to create and populate new segments to the in-memory copy of the supplied elf's.

Please feel free to provide any feedback!

Signed-off-by: Alwin Joshy <joshyalwin@gmail.com>
@Kswin01 Kswin01 force-pushed the child_vspace branch 2 times, most recently from 096fb53 to a483c35 Compare July 21, 2025 04:39
alwin-joshy and others added 10 commits July 21, 2025 14:43
Signed-off-by: Alwin Joshy <joshyalwin@gmail.com>
Signed-off-by: Alwin Joshy <joshyalwin@gmail.com>
Signed-off-by: Krishnan Winter <krishnanwinter1@gmail.com>
The previous approach for patching the page tables
of child PD's into the parent PD was to patch two
symbols, one for the table metadata (PGD) which
points to entries in the table data array, which
is the rest of the paging structures. The drawback
of this approach is that you need to hardcode the
size of the child paging structures in the parent
PD.

This commit supports a variable size of table data
regions by appending a loadable segment to the ELF
of the parent.

Co-authored-by: Alwin Joshy <joshyalwin@gmail.com>
Co-authored-by: Szymon Duchniewicz <s.duchniewicz@unsw.edu.au>
Signed-off-by: Krishnan Winter <krishnanwinter1@gmail.com>
Co-authored-by: Alwin Joshy <joshyalwin@gmail.com>
Signed-off-by: Krishnan Winter <krishnanwinter1@gmail.com>
Cleanup how we patch child page table's as data into new elf segments.

Co-authored-by: Alwin Joshy <joshyalwin@gmail.com>
Signed-off-by: Krishnan Winter <krishnanwinter1@gmail.com>
Support for memory regions using large pages to be mapped into the
translation tables that are mapped into the parent PD's.

Signed-off-by: Krishnan Winter <krishnanwinter1@gmail.com>
Signed-off-by: Krishnan Winter <krishnanwinter1@gmail.com>
Signed-off-by: Krishnan Winter <krishnanwinter1@gmail.com>
Signed-off-by: Krishnan Winter <krishnanwinter1@gmail.com>
Signed-off-by: Krishnan Winter <krishnanwinter1@gmail.com>
Signed-off-by: Krishnan Winter <krishnanwinter1@gmail.com>
Kswin01 added 2 commits August 5, 2025 15:57
Signed-off-by: Krishnan Winter <krishnan-git@wintermail.me>
Signed-off-by: Krishnan Winter <krishnan-git@wintermail.me>
Copy link
Contributor

@midnightveil midnightveil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, forgot to post this.

}

pub fn get_segment(&mut self, segment_name: &str) -> Option<&ElfSegment> {
for segment in &self.segments {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just self.segments.find(|segment| segment.name == Some(segment_name))?


// patch the data in
let elf = &mut pd_elf_files[pd_idx];
elf.populate_segment(".table_data", &table_data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had this discussion in person but hard NACK on actually editing the ELF files directly to do this, as opposed to doing this via adding a new segment into the memory regions the tool adds directly.

Signed-off-by: Krishnan Winter <krishnan-git@wintermail.me>
Signed-off-by: Krishnan Winter <krishnan-git@wintermail.me>
Signed-off-by: Krishnan Winter <krishnan-git@wintermail.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants