Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sluck-msft
Copy link
Contributor

Start VP hypercall handling for SNP Guest VSM support.

Tested:

  • SNP + Guest VSM boots 8 VPs
  • SNP without Guest VSM boots
  • non-isolated VM still boots

@sluck-msft sluck-msft requested a review from a team as a code owner January 8, 2025 22:52
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// 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.

Copy link
Contributor Author

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?

Copy link
Contributor

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);
Copy link
Contributor

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?

Copy link
Contributor

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()
Copy link
Contributor

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?

Copy link
Contributor Author

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).
Copy link
Contributor

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?

Copy link
Contributor Author

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.

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