Skip to content

1.8: CVM register validation (#3960) - #4026

Open
jennagoddard wants to merge 1 commit into
microsoft:release/1.8.2607from
jennagoddard:regcherrypick
Open

1.8: CVM register validation (#3960)#4026
jennagoddard wants to merge 1 commit into
microsoft:release/1.8.2607from
jennagoddard:regcherrypick

Conversation

@jennagoddard

Copy link
Copy Markdown
Contributor

Add per-register / per-MSR validation on the SetVpRegisters and WRMSR paths to help prevent invalid VMSA state which cause failures at VMRUN

cherry-pick: #3960

Add per-register / per-MSR validation on the SetVpRegisters and WRMSR
paths to help prevent invalid VMSA state which cause failures at VMRUN
@jennagoddard
jennagoddard requested a review from a team as a code owner July 24, 2026 21:10
Copilot AI review requested due to automatic review settings July 24, 2026 21:10
@github-actions github-actions Bot added the release_1.8.2607 Targets the release/1.8.2607 branch. label Jul 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds centralized validation for CVM guest register and MSR writes to reduce the chance of constructing architecturally-invalid guest state that can fail at VMRUN/entry.

Changes:

  • Move canonical-address checking into x86defs for reuse across the codebase.
  • Add shared CVM MSR validation (validate_cvm_msr_write) and SetVpRegisters per-register validation/normalization in hardware_cvm.
  • Wire MSR validation into both TDX and SNP MSR-write paths; add SNP-specific FS/GS base canonical checks; add unit tests for the new validation logic.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vmm_core/virt_support_x86emu/src/translate.rs Switches to the shared x86defs::is_canonical_address helper and updates tests accordingly.
vm/x86/x86defs/src/lib.rs Adds new x86defs constants and exports is_canonical_address for reuse.
openhcl/virt_mshv_vtl/src/processor/tdx/mod.rs Adds CVM MSR-write validation before applying TDX MSR updates.
openhcl/virt_mshv_vtl/src/processor/snp/mod.rs Adds CVM MSR-write validation and enforces canonical FS/GS base values in the guest’s current paging mode.
openhcl/virt_mshv_vtl/src/processor/hardware_cvm/mod.rs Introduces shared validation helpers for MSRs and SetVpRegisters (including CR0 normalization), plus unit tests.

Comment thread vm/x86/x86defs/src/lib.rs
Comment on lines +79 to +82
pub fn is_canonical_address(v: u64, bits: u32) -> bool {
let high = (v as i64) >> (bits - 1);
high == 0 || high == -1
}
@jennagoddard
jennagoddard enabled auto-merge (squash) July 24, 2026 21:55
@github-actions

Copy link
Copy Markdown

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

Labels

release_1.8.2607 Targets the release/1.8.2607 branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants