mshv: Add SVM_EXIT_CPUID, SVM_EXIT_MSR and GHCB_MSR_TERM_REQ handlers for SEV-SNP - #7934
Merged
Merged
Conversation
Member
|
Please fix CI |
souradeep100
force-pushed
the
main
branch
3 times, most recently
from
March 31, 2026 07:42
3c902c9 to
78d429b
Compare
When booting an SEV-SNP guest VM using IGVM with -pvalidate_opt 1 (lazy
page acceptance), the guest kernel's #VC exception handler may issue
VMGEXIT with SVM_EXIT_CPUID (0x72) or SVM_EXIT_MSR (0x7c) exit codes
via the GHCB page protocol. The hypervisor had no handlers for these
exit codes, causing the guest's #VC handler to fail and trigger
sev_es_terminate(), which sends GHCB_MSR_TERM_REQ (0x100). The
hypervisor then panicked on the unhandled 0x100 operation.
Add the following handlers to the GHCB VMGEXIT processing:
- SVM_EXIT_CPUID (0x72): Read function/index/xcr0/xss from the GHCB
page and return CPUID results via get_cpuid_values().
- SVM_EXIT_MSR (0x7c): Handle MSR read (RDMSR) and write (WRMSR)
requests from the guest via the GHCB page protocol.
- GHCB_MSR_TERM_REQ (0x100): Decode reason_set and reason_val from the
GHCB MSR and return an error instead of panicking, allowing graceful
error propagation.
Testing:
Reproducer (on Azure DC16as_cc_v5, /dev/mshv):
cloud-hypervisor --cpus boot=1,nested=off --memory size=512M \
--disk path=osdisk.img path=cloudinit \
--net "tap=,mac=12:34:56:78:90:06,ip=192.168.6.1,mask=255.255.255.128" \
--serial null --console pty \
--api-socket /tmp/ch.sock \
--igvm /igvm_files/linux-ttyS0.bin \
--host-data <hash> --platform sev_snp=on -v
Before fix:
thread 'vcpu0' panicked at hypervisor/src/mshv/mod.rs:1207:30:
Unsupported VMGEXIT operation: 100
After fix: VM boots successfully to login prompt with no panics.
All virtio devices (console, rng, disks) activate normally.
No regression risk for non-SEV-SNP: all new code is within the
HVMSG_X64_SEV_VMGEXIT_INTERCEPT handler which is only reached for
SEV-SNP guests.
Signed-off-by: Souradeep Chakrabarti <[email protected]>
Author
|
ARM64 failure is a pre-existing flaky test_ovs_dpdk (stale OVS bridge) , please rerun the test. |
rbradford
approved these changes
Mar 31, 2026
rbradford
enabled auto-merge
March 31, 2026 10:54
Merged
via the queue into
cloud-hypervisor:main
with commit Mar 31, 2026
7832401
38 of 39 checks passed
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.
When booting an SEV-SNP guest VM using IGVM with -pvalidate_opt 1 (lazy page acceptance), the guest kernel's #VC exception handler may issue VMGEXIT with SVM_EXIT_CPUID (0x72) or SVM_EXIT_MSR (0x7c) exit codes via the GHCB page protocol. The hypervisor had no handlers for these exit codes, causing the guest's #VC handler to fail and trigger sev_es_terminate(), which sends GHCB_MSR_TERM_REQ (0x100). The hypervisor then panicked on the unhandled 0x100 operation.
Add the following handlers to the GHCB VMGEXIT processing:
Testing:
Reproducer (on Azure , /dev/mshv):
cloud-hypervisor --cpus boot=1,nested=off --memory size=512M \ --disk path=osdisk.img path=cloudinit \ --net "tap=,mac=12:34:56:78:90:06,ip=192.168.6.1,mask=255.255.255.128" \ --serial null --console pty \ --api-socket /tmp/ch.sock \ --igvm /igvm_files/linux-ttyS0.bin \ --host-data --platform sev_snp=on -v
Before fix:
After fix: VM boots successfully to login prompt with no panics. All virtio devices (console, rng, disks) activate normally.
No regression risk for non-SEV-SNP: all new code is within the HVMSG_X64_SEV_VMGEXIT_INTERCEPT handler which is only reached for SEV-SNP guests.