-
Notifications
You must be signed in to change notification settings - Fork 49
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
kernel/cpu: add safety comments #584
Conversation
Both of these GHCB operations can cause physical memory to be remapped (one may cause the GHCB data to appear in a different place, and one may cause memory to be remapped with a different encryption attribute). Because both of these operations can cause mapped memory to change contents, they are technically unsafe. |
Thanks for your input on this Jon, and sorry for the massively delayed update. I entered a busy relocation mode and will start working on this again in a couple of weeks hopefully. |
stac and clac instructions don't break memory safety. Signed-off-by: Thomas Leroy <[email protected]>
fae85db
to
fdcc08d
Compare
Thanks for the initial review @msft-jlange. I addressed the comments and this is open again for review |
Writing to some MSRs can break memory safety. Therefore, write_msr() should be unsafe. Signed-off-by: Thomas Leroy <[email protected]>
Missing safety comments were missing in GDT code. Adding a couple of checks to validate the safety requirements. Also, to ensure we call `ltr` instruction with a tss that has a valid lifetime, we can set `load_tss()` to take a static tss reference. Signed-off-by: Thomas Leroy <[email protected]>
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.
Thanks for returning to this PR! These changes look good.
Safety comments for:
stac
andclac
instructionswrite_msr()
should be unsafe since it can break memory safety. This part is still missing two comments here and here in the GHCB MSR protocol where I have doubt if the MSR request is subject to breaking memory safety or not, specificallySNP_REG_GHCB_GPA_REQ
andSNP_STATE_CHANGE_REQ
GHCB requests. My guess is a garbage request parameter can break the platform, but does it still count as memory safety?