Skip to content

Switch to two level cnodes#538

Draft
terryzbai wants to merge 7 commits into
seL4:mainfrom
au-ts:switch-to-two-level-cnodes
Draft

Switch to two level cnodes#538
terryzbai wants to merge 7 commits into
seL4:mainfrom
au-ts:switch-to-two-level-cnodes

Conversation

@terryzbai

Copy link
Copy Markdown

This PR makes the CSpace of each PD as a two-level CNodes, which brings more flexibility for cspace management. This is useful for capability sharing.

Now each PD has a smaller root CNode having 64 slots in total. The original Microkit CNode is moved to the root CNode's slot 0 to make sure all existing stuff work. All shared capabilities are moved to the root CNode and addressed by shifting the slot index.

This PR also fixes the capability creation for shared VSpace and CSpace, and adds rules for quick QEMU tests in cap_sharing example.

This PR is also based on the branch rust_sel4_update_to_main, and should be cherry-picked when being merged.

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>

@midnightveil midnightveil left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You need to also add the check to prevent people from placing extra caps in the Microkit CNode, yeah? (not permitted slot 0?)

Comment thread example/cap_sharing/Makefile
Comment thread tool/microkit/src/capdl/builder.rs Outdated
This adds a smaller CNode as PD's cspace and moves
the original Microkit resource CNode to the root's
first slot, as this makes the CSpace management more
flexible. The changes are:
- size of root CNode: 64
- size of Microkit CNode: 1024 -> 512
- guard size of root CNode: 0
- guard size of Microkit CNode: seL4_WordBits - 6 - 9

This also fixes the capability creation for shared
VSpace and CSpace.

Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>
This adds rules for QEMU tests on x86 and enables the
'capdl_spec.json' file generation for analysis.

Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>
This checks if people try to place extra caps in slot 0,
which is reserved for Microkit CNode, and adds a test
case for it.

Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>
@terryzbai terryzbai force-pushed the switch-to-two-level-cnodes branch from 6061f18 to 04bef0b Compare June 26, 2026 06:38
@terryzbai

Copy link
Copy Markdown
Author

yes, I have added the check and a test case for it.

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.

3 participants