-
Notifications
You must be signed in to change notification settings - Fork 80
Improve pKVM hypercalls #210
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
Improve pKVM hypercalls #210
Conversation
|
@qwandor Could you please take a look? |
src/transport/x86_64/hypercalls.rs
Outdated
| signature.to_le_bytes() | ||
| } | ||
|
|
||
| macro_rules! __vmcall_impl { |
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.
Can this just be a simple function rather than a macro? The caller can pass zeroes for any unused parameters, and cast everything to u64.
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.
Done - use simple function rather than a macro. I've left the macro wrapper so the caller do not have to care about zeroing not used arguments.
3705209 to
a583136
Compare
src/transport/x86_64/hypercalls.rs
Outdated
| ); | ||
| } | ||
| data | ||
| core::arch::asm!( |
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.
There's already a use statement for asm, no need to use the full path here.
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.
Yeah, thx.
The pKVM hypervisor forwards PKVM_GHC_IOWRITE and PKVM_GHC_IOWREAD to pKVM host for emulation. In such case, guest registers values in RAX, RBX, RCX, RDX and RSI might become visible to the host. To prevent potential unintended information leakage, introduce vmcall macro which zeros not used hyperacall arguments, and use it for PKVM_GHC_IOWRITE/PKVM_GHC_IOWREAD hypercall to make sure that unused RDX or RSI are set to 0.
a583136 to
2e7b9ce
Compare
The pKVM hypervisor forwards PKVM_GHC_IOWRITE and PKVM_GHC_IOWREAD to pKVM host for emulation. In such case, guest registers values in RAX, RBX, RCX, RDX and RSI might become visible to the host.
To prevent potential unintended information leakage, introduce vmcall macro which zeros not used hyperacall arguments, and use it for PKVM_GHC_IOWRITE/PKVM_GHC_IOWREAD hypercall to make sure that unused RDX or RSI are set to 0.