-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure page tables are properly pinned into memory
When we load the page tables into memory, we need to guarantee that they stay valid at the same address, as the processor cares little about Rust and its memory model. The Rust way to do it is to `Pin` the pointers into memory. This guarantees that the value will not move. Note that _overwriting_ the value is safe: instead of `zero()` we now call `Pin::set`, which overwrites the contents in-place, guaranteeing that the contents of the memory at that address are always a valid page table. We do need to resort to unsafe code to get a mutable reference for setting the page table entries, though. This is because Rust can't guarantee we don't call `mem::replace` on it. This fixes one issue around the page tables; there's also the question of lifetimes themselves (we don't want a `Box` containing a page table to go out of scope while it's still refrerenced by other page tables), but fixing that will be a separate exercise. Bug: 377899703 Change-Id: I10559eda2c8a60f77201c3cc3cedabdac864f26f
- Loading branch information
Showing
3 changed files
with
35 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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 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 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