-
Notifications
You must be signed in to change notification settings - Fork 158
openhcl_boot: dynamic page table construction for TDX #2286
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?
Conversation
e1cefb9 to
205cc44
Compare
|
This PR modifies files containing For more on why we check whole files, instead of just diffs, check out the Rustonomicon |
205cc44 to
fd77d22
Compare
|
Pulling this out of draft mode so we can see CI results - we should not merge this until after Chris has reviewed and merged #2062 |
| unsafe { | ||
| core::ptr::copy_nonoverlapping( | ||
| page_tables.as_ptr(), | ||
| page_table_region.range.start() as *mut u8, |
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.
I'm not sure it's guaranteed that page_table_region is valid to be accessed. In most cases, we are probably allocating from memory that is in the initial identity mapped region, but it's possible that the address space manager could choose to give you some other block of memory where we don't have a valid identity mapping for.
I think this leaves you with two options:
a) prereserve a region at load time that we may shrink to fit to return memory to the kernel (or just waste 20 pages and put a TODO there)
b) use the local_map to map this region on-the-fly, and then you don't need to use unsafe.
If possible, we could use b?
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.
I think also using the local_map gives you a &mut [u8] which you can also then save another copy and allocation of the flattened page table, and you can pass that to the builder itself, right?
This PR builds on the the loader refactor in #2062 to dynamically construct R+X page tables for AP startup in the boot shim.
The context for these changes can be found in issue #1563