-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sev/ghcb: introduce GHCB interior mutability
At the moment, a mutable reference may be acquired into the GHCB from any point in code via the `current_ghcb()` function. This function returns a `GHCBRef`, which implements `DerefMut<Target=GHCB>`. Since mutable references must be exclusive, this can cause undefined behavior, as a function may acquire a mutable reference to the GHCB while another one is held in a function up the call stack. Aliased mutable references are always undefined behavior, so we must give out shared references from GHCBRef. In order to be able to use the GHCB, we must mutate it though. Thus, introduce interior mutability in the GHCB through the use of the Cell type. This informs the compiler that the type may be mutated even through `&self`, and allows for sound nested references to the GHCB. In preparation for future additional safety changes when giving out reentrant references to the GHCB, introduce the Nestable trait, which allows snapshotting and restoring the state of the GHCB. Add a testing method as well to fill the GHCB with data through a shared reference. Signed-off-by: Carlos López <[email protected]>
- Loading branch information
Showing
6 changed files
with
151 additions
and
108 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
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
Oops, something went wrong.