-
Notifications
You must be signed in to change notification settings - Fork 0
Draft: Memory Cap Sharing #10
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,8 +5,15 @@ | |
| SPDX-License-Identifier: BSD-2-Clause | ||
| --> | ||
| <system> | ||
| <memory_region name="dma_buffer" size="0xa000" page_size="0x1000" /> | ||
|
|
||
| <io_address_space name="QEMU EDU" peripheral_id="0:4.0" domain_id="1"> | ||
| <io_page_table iovaddr="0x10_a000" size="0xa000" page_size="0x1000" /> | ||
| </io_address_space> | ||
|
|
||
| <protection_domain name="primary" priority="1"> | ||
| <program_image path="cap_sharing.elf" /> | ||
| <page_table vaddr="0x1000_1000" size="0xa000" page_size="0x1000" /> | ||
|
|
||
| <cspace> | ||
| <!-- You can have the SC or TCB of another PD --> | ||
|
|
@@ -16,10 +23,20 @@ | |
| <!-- You can also have it of yourself --> | ||
| <cap_sc slot="3" pd="primary" /> | ||
| <cap_tcb slot="4" pd="primary" /> | ||
|
|
||
| <!-- You can access your VSpace, memory-region frames, and an IOSpace. --> | ||
| <cap_vspace slot="5" pd="primary" /> | ||
| <cap_mr slot="6" mr_name="dma_buffer" perms="rw" /> | ||
| <cap_iospace slot="7" io_address_space="QEMU EDU" /> | ||
|
|
||
| <!-- You can access frames belonging to another PD. --> | ||
| <cap_stack slot="9" pd="secondary" perms="r" /> | ||
| <cap_ipcbuf slot="10" pd="secondary" perms="r" /> | ||
| <cap_elf slot="11" pd="secondary" perms="r" /> | ||
|
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. Being able to access frames of other PDs is cool, but I don't see why a PD needs to read/modify the stack/ipcbuffer of others? Regarding Maybe
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. Yeah the sdf name and grouping with the other caps is clunky? I wasn’t sure where else to put them. Reading the stack and IPC buffer was to support gdb. 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. That makes sense, though I can't think of any better solution at sdf level. How about this: Add a pair of attributes like 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. Yes, we have been following this and adding arbitrary limits when you can already dip your fingers into a PD and alter pretty much anything you want seems just that...arbitrary. I know this is a WIP but I will mention something we noticed while reviewing the design to see if it supports everything we need for gdb (and it seems to on paper): In the example the PD iterates over the frames by calling The tool already knows the frame count, so why not embed it in the metadata? Then expose it to the PD, use it internally in the library, and both layers of probing go away. 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.
I don't think this is a good idea. The Microkit should only expose generic mechanisms for users to do what they want. Rather than putting every possible use case in. 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.
Right. How about allowing PDs to bind their ipc buffer or stack to a <system>
<memory_region name="ipc_buffer_frame" size="0x1000" />
<memory_region name="stack_frame" size="0x2000" />
<protection_domain name="debugger" priority="25">
<program_image path="debugger.elf" />
<cspace>
<cap_mr slot="5" mr_name="ipc_buffer_frame" perms="r" />
<cap_mr slot="6" mr_name="stack_frame" perms="r" />
</cspace>
</protection_domain>
<protection_domain name="debuggee" priority="2" stack_size="0x2000">
<program_image path="debuggee.elf" />
<ipc_buffer mr="ipc_buffer_frame" />
<stack_frame mr="stack_frame" />
</protection_domain>
</system>The elements
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. I think that’s clean ^, one minor consideration is the stack size vs memory region size. Maybe it is cleanest to leave it up to the user to specify the stack size of a pd and use that for any stack memory regions? Would you want to bind the memory region to a protection domain ipcbuff/stack/elf as attributes on the memory region though, otherwise you allow and have to handle multiple pds trying to bind to it?
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.
Yeah I agree, thanks for the feedback too. This probably should be provided to a PD as a memory region. It seems like that is becoming the mechanism to provide tool metadata to PDs e.g. the x86 prefills & the suggestion from @ZGwtao. If a PD has access to this data directly then having a sentinel / NULL entry avoids having to provide the size all together and we could get rid of the bit packing and keep it simply the virtual address of each frame for the other pd. Which is nice since that is all a PD actually needs so shouldn't need to change later in future... in theory. This would enforce a O(n) loop to begin with but the user could establish a constant time mapping etc during init. 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.
I am not sure about the design, do you mean something like this? <system>
<memory_region name="stack_frame" size="0x2000" />
<protection_domain name="debuggee" priority="2" stack_mr="stack_frame" >
<program_image path="debuggee.elf" />
</protection_domain>
</system>
I would prefer to treat it like the above example, as Regarding multi-pds binding conflict, probably a simple way to do is letting the sdf parser enforce an implicit one-on-one relationship. Looking forward to others' ideas.
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. Yeah I agree with keeping memory regions a physical memory abstraction :) I was thinking very roughly like: <memory_region name="debugee_elf" pd_elf="debugee”/> <memory_region name="debugee_ipc_buf" pd_ipc_buf="debugee”/> <protection_domain name="debugger" priority="2"" > |
||
| </cspace> | ||
| </protection_domain> | ||
|
|
||
| <protection_domain name="secondary" priority="2"> | ||
| <protection_domain name="secondary" priority="2" stack_size="0x2000"> | ||
| <program_image path="secondary.elf" /> | ||
| </protection_domain> | ||
|
|
||
|
|
||
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.
Sample API.