Skip to content

Hypercall to let the VTL0 or VTL1 to retrieve its VMPCK so that it can communicate with the PSP#3408

Open
sunilmut wants to merge 2 commits intomicrosoft:mainfrom
sunilmut:sunilmut/lower_vtl_vmpck
Open

Hypercall to let the VTL0 or VTL1 to retrieve its VMPCK so that it can communicate with the PSP#3408
sunilmut wants to merge 2 commits intomicrosoft:mainfrom
sunilmut:sunilmut/lower_vtl_vmpck

Conversation

@sunilmut
Copy link
Copy Markdown
Member

@sunilmut sunilmut commented Apr 30, 2026

Implement the hypercall that allows the VTL0 or VTL1 retrieve the VM Platform Communication Key (VMPCK) for its own VTL, so that it can directly communicate with the PSP. The VMPCK is used to encrypt/decrypt the communication with the PSP.

Copilot AI review requested due to automatic review settings April 30, 2026 01:26
@sunilmut sunilmut requested a review from a team as a code owner April 30, 2026 01:26
@github-actions
Copy link
Copy Markdown

⚠️ Unsafe Code Detected

This PR modifies files containing unsafe Rust code. Extra scrutiny is required during review.

For more on why we check whole files, instead of just diffs, check out the Rustonomicon

@github-actions github-actions Bot added the unsafe Related to unsafe code label Apr 30, 2026
Comment thread openhcl/underhill_core/src/worker.rs
sunilmut

This comment was marked as resolved.

@sunilmut sunilmut requested a review from jstarks April 30, 2026 01:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements a new Hyper-V hypercall for lower VTL guests (VTL0/VTL1) to retrieve their SEV-SNP VMPCK so they can communicate directly with the PSP, and centralizes some host CPUID feature detection for OpenHCL.

Changes:

  • Added HvCallGetSnpVmpck hypercall definition + output struct in hvdef and dispatch plumbing in hv1_hypercall.
  • Extracted/stored VMPCKs from the SNP secrets page at partition init and exposed them via a new Underhill hypercall handler.
  • Introduced openhcl_cpuid_features crate and plumbed cached CPUID features from worker startup into Hcl.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
vm/x86/x86defs/src/snp.rs Adds SNP secrets-page VMPCK offsets/size constants.
vm/hv1/hvdef/src/lib.rs Extends enlightenment bitfield flags; adds hypercall code + VMPCK output type/size constant.
vm/hv1/hv1_hypercall/src/imp.rs Adds hypercall type alias + handler trait for HvGetSnpVmpck.
openhcl/virt_mshv_vtl/src/processor/snp/mod.rs Caches VMPCK keys from secrets page and implements the new hypercall handler.
openhcl/virt_mshv_vtl/src/lib.rs Plumbs cached CPUID features into Hcl::new on x86_64 guest builds.
openhcl/virt_mshv_vtl/Cargo.toml Adds dependency on openhcl_cpuid_features.
openhcl/underhill_core/src/worker.rs Initializes CPUID feature snapshot once and reuses it for MMIO-hypercall + x2APIC decisions.
openhcl/underhill_core/Cargo.toml Swaps direct CPUID deps for openhcl_cpuid_features.
openhcl/openhcl_cpuid_features/src/lib.rs New crate centralizing a small set of host CPUID feature queries.
openhcl/openhcl_cpuid_features/Cargo.toml New crate manifest with x86_64-only deps.
openhcl/hcl/src/ioctl.rs Adds CPUID feature caching to Hcl and changes Hcl::new signature on x86_64 guest builds.
openhcl/hcl/Cargo.toml Adds openhcl_cpuid_features dependency.
Cargo.toml Registers openhcl_cpuid_features as a workspace member dependency.
Cargo.lock Adds lock entries for the new crate and updated dependency graph.

Comment thread openhcl/virt_mshv_vtl/src/processor/snp/mod.rs
Comment thread vm/hv1/hvdef/src/lib.rs Outdated
Comment thread openhcl/hcl/Cargo.toml
Comment thread openhcl/hcl/src/ioctl.rs
Comment thread openhcl/hcl/src/ioctl.rs Outdated
Comment thread openhcl/virt_mshv_vtl/src/lib.rs
@sunilmut sunilmut changed the title Hypercall to let the VTL0 or VTL1 to retrieve its VMPCK so that it can communicate with the SNP Hypercall to let the VTL0 or VTL1 to retrieve its VMPCK so that it can communicate with the PSP Apr 30, 2026
Comment thread openhcl/virt_mshv_vtl/src/processor/snp/mod.rs
Comment thread openhcl/virt_mshv_vtl/src/processor/snp/mod.rs Outdated
Comment thread openhcl/hcl/src/ioctl.rs Outdated
Copilot AI review requested due to automatic review settings May 8, 2026 22:14
@sunilmut sunilmut force-pushed the sunilmut/lower_vtl_vmpck branch from 5592161 to 115b8d3 Compare May 8, 2026 22:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread openhcl/virt_mshv_vtl/src/processor/snp/mod.rs
Comment thread openhcl/virt_mshv_vtl/src/processor/snp/mod.rs Outdated
Comment thread openhcl/hcl/src/ioctl.rs Outdated
@sunilmut sunilmut force-pushed the sunilmut/lower_vtl_vmpck branch from 115b8d3 to 9d4917a Compare May 9, 2026 01:04
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unsafe Related to unsafe code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants