-
Notifications
You must be signed in to change notification settings - Fork 98
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
SNP Guest VSM: Start VP hypercall handling #634
base: main
Are you sure you want to change the base?
Conversation
@@ -231,6 +231,17 @@ mod private { | |||
/// This is used for hypervisor-managed and untrusted SINTs. | |||
fn request_untrusted_sint_readiness(this: &mut UhProcessor<'_, Self>, sints: u16); | |||
|
|||
/// Copies shared registers (per VSM TLFS spec) from the source VTL to |
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.
/// Copies shared registers (per VSM TLFS spec) from the source VTL to | |
/// Copies shared registers (per VSM TLFS spec) from the source_vtl to |
Also lets remove the default 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.
Hmm how do you decide when to have a default 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.
Usually when there's something actually functional that can be provided in terms of other trait fns.
{ | ||
// If VTL 1 has been enabled, switch to it (the | ||
// highest enabled VTL should run first). | ||
T::switch_vtl(self, GuestVtl::Vtl0, GuestVtl::Vtl1); |
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.
We should try to avoid hardcoded vtls wherever we can. Can we use vtl
and vtl +/- 1
or something?
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.
Or maybe make this a match on vtl instead of an if/else?
} else { | ||
if self.partition.isolation.is_hardware_isolated() | ||
&& start_enable_vtl_state.is_start | ||
&& *self.inner.hcvm_vtl1_enabled.lock() |
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.
Why check for hardware isolated?
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.
A couple reasons. For a non-hardware-isolated VM, the hypervisor should still be the one making sure that the highest runnable VTL runs when it enters back into the guest and making that VTL switch, so we don't need to do the switch here (and in general I want to leave that mangement to the hypervisor). Second, since openhcl is not involved in enabling the vp on the vtl, it doesn't actually know if the VTL is enabled (although I think we can query the hypervisor for this value if we think it's appropriate).
&& *self.inner.hcvm_vtl1_enabled.lock() | ||
{ | ||
// If VTL 1 has been enabled, switch to it (the | ||
// highest enabled VTL should run first). |
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.
Do we actually need to do the full switch_vtl, seeing as the vp hasn't run before? Can we just set exit_vtl?
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.
My understanding is that the guest can call start vp whenever it wants so it's not necessarily true that the vp hasn't run before, but I'm also not convinced that we should be copying the register state in all cases so I'll need to confirm this.
Start VP hypercall handling for SNP Guest VSM support.
Tested: