Skip to content

Conversation

@jaszczyk-grzegorz
Copy link
Contributor

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.

@jaszczyk-grzegorz
Copy link
Contributor Author

@qwandor Could you please take a look?

signature.to_le_bytes()
}

macro_rules! __vmcall_impl {
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

);
}
data
core::arch::asm!(
Copy link
Collaborator

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.

Copy link
Contributor Author

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.
@qwandor qwandor merged commit 2e0beb3 into rcore-os:master Nov 20, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants