-
Notifications
You must be signed in to change notification settings - Fork 74
tool: create IPC buffer in the tool, not the ELF #532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
midnightveil
wants to merge
2
commits into
seL4:main
Choose a base branch
from
au-ts:julia/ipc-buffer-patched
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -310,19 +310,21 @@ pub struct Config { | |
| } | ||
|
|
||
| impl Config { | ||
| /// Refers to 'seL4_UserTop' | ||
| /// Refers to 'seL4_UserTop'. Is inclusive. | ||
| // TODO: Resolve https://github.com/seL4/seL4/issues/1693 (RISC-V/X86) | ||
| // TODO: We should auto-extract this from libsel4 headers. | ||
| pub fn user_top(&self) -> u64 { | ||
| match self.arch { | ||
| Arch::Aarch64 => match self.hypervisor { | ||
| true => match self.arm_pa_size_bits.unwrap() { | ||
| 40 => 0x10000000000, | ||
| 44 => 0x100000000000, | ||
| 40 => 0x00ffffffffff, | ||
| 44 => 0x0fffffffffff, | ||
| _ => panic!("Unknown ARM physical address size bits"), | ||
| }, | ||
| false => 0x800000000000, | ||
| false => 0x7fffffffffff, | ||
| }, | ||
| Arch::Riscv64 => 0x0000003ffffff000, | ||
| Arch::X86_64 => 0x7ffffffff000, | ||
| Arch::Riscv64 => 0x0000003ffffff000 - 1, | ||
| Arch::X86_64 => 0x7ffffffff000 - 1, | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -346,30 +348,39 @@ impl Config { | |
| } | ||
| } | ||
|
|
||
| /// IPC Buffer is located at the highest possible virtual memory page | ||
| pub fn pd_ipc_buffer(&self) -> u64 { | ||
| // user_top is inclusive, so we mask off the bits inside the page. | ||
| // self.user_top() & !util::mask(PageSize::Small.fixed_size_bits(self)) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just realised this should use IPCBufferBits. It's the same but its qhat we want. |
||
| self.user_top() & !(PageSize::Small as u64 - 1) | ||
| } | ||
|
|
||
| /// The stack is located in the third highest possible virtual memory pages, | ||
| /// as the IPC buffer lives in the top, and we add a guard page inbetween. | ||
| pub fn pd_stack_top(&self) -> u64 { | ||
| self.user_top() | ||
| // Subtract off the guard page. | ||
| self.pd_ipc_buffer() - PageSize::Small as u64 | ||
| } | ||
|
|
||
| pub fn pd_stack_bottom(&self, stack_size: u64) -> u64 { | ||
| self.pd_stack_top() - stack_size | ||
| } | ||
|
|
||
| /// For simplicity and consistency, the stack of each PD occupies the highest | ||
| /// possible virtual memory region. That means that the highest possible address | ||
| /// for a user to be able to create a mapping at is below the stack region. | ||
| /// For simplicity and consistency, the stack & IPC buffers of each PD | ||
| /// occupy the highest memory regions near seL4_UserTop. | ||
| /// So the maximum vaddr allowed for mapping is the stack bottom. | ||
| /// Value is exclusive ..max) | ||
| pub fn pd_map_max_vaddr(&self, stack_size: u64) -> u64 { | ||
| // This function depends on the invariant that the stack of a PD | ||
| // consumes the highest possible address of the virtual address space. | ||
| assert!(self.pd_stack_top() == self.user_top()); | ||
|
|
||
| self.pd_stack_bottom(stack_size) | ||
| } | ||
|
|
||
| /// Unlike PDs, virtual machines do not have a stack and so the max virtual | ||
| /// address of a mapping is whatever seL4 chooses as the maximum virtual address | ||
| /// in a VSpace. | ||
| /// Unlike PDs, virtual machines do not have a stack or IPC buffer and so | ||
| /// the max virtual address of a mapping is whatever seL4 chooses as the | ||
| /// maximum virtual address in a VSpace. | ||
| /// Value is exclusive ..max) | ||
| pub fn vm_map_max_vaddr(&self) -> u64 { | ||
| self.user_top() | ||
| // Add 1, because user_top is inclusive. Note this assumes no overflow. | ||
| self.user_top() + 1 | ||
| } | ||
|
|
||
| pub fn paddr_to_kernel_vaddr(&self, paddr: u64) -> u64 { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: can we fix this in the kernel first? I dislike having workarounds like this, because then we have to go back and fix it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends on proof updates to seL4, as the values are used inside seL4 implementation.
I suppose @lsf37 can comment if it would be possible to fix seL4/seL4#1693 before the next release.
We could do something hacky where we export a different value than what seL4 uses in the code, and so we make userspace consistent whilst leaving the checks the same. I don't suppose the semantics extraction is clever enough to do constant folding, would it?
e.g. if we changed a seL4_UserTop that is 0x800000000 to 0x7fffffffffff and then made the check inside the vspace map functions do
(>= (seL4_UserTop + 1)). Whether it's smart enough to constant fold and not affect the proofs?But I don't know if it's worth doing that as opposed to just fixing it... (it's surely just changing
<to<=in a few places?).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The semantics extraction does not do constant folding as such, but a lot of the times it is done implicitly in the proofs, so it would be possible to be lucky on that one.
I currently don't have it on the list for the release, because I wanted to focus on bugs, but it would not be hard to add once we have decided what to do. The tricky part is social: technically this changes the API and is a breaking change. I don't really want to write an entire RFC for this, but a few more opinions would be good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the code, yes. In the proofs it's slightly more than that, because one version needs a proof of absence of overflow and the other does not. It's small, but it's not automatic.