1.8: CVM register validation (#3960) - #4026
Open
jennagoddard wants to merge 1 commit into
Open
Conversation
Add per-register / per-MSR validation on the SetVpRegisters and WRMSR paths to help prevent invalid VMSA state which cause failures at VMRUN
Contributor
There was a problem hiding this comment.
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
x86defsfor reuse across the codebase. - Add shared CVM MSR validation (
validate_cvm_msr_write) and SetVpRegisters per-register validation/normalization inhardware_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 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 | ||
| } |
sluck-msft
approved these changes
Jul 24, 2026
jennagoddard
enabled auto-merge (squash)
July 24, 2026 21:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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