Thanks to visit codestin.com
Credit goes to github.com

Skip to content

mshv: Add SVM_EXIT_CPUID, SVM_EXIT_MSR and GHCB_MSR_TERM_REQ handlers for SEV-SNP - #7934

Merged
rbradford merged 1 commit into
cloud-hypervisor:mainfrom
souradeep100:main
Mar 31, 2026
Merged

rbradford merged 1 commit into
cloud-hypervisor:mainfrom
souradeep100:main

Conversation

@souradeep100

Copy link
Copy Markdown

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 , /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:

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.

@souradeep100
souradeep100 requested a review from a team as a code owner March 31, 2026 06:46
@phip1611

Copy link
Copy Markdown
Member

Please fix CI

@souradeep100
souradeep100 force-pushed the main branch 3 times, most recently from 3c902c9 to 78d429b Compare March 31, 2026 07:42
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]>
@souradeep100

Copy link
Copy Markdown
Author

ARM64 failure is a pre-existing flaky test_ovs_dpdk (stale OVS bridge) , please rerun the test.

@rbradford
rbradford enabled auto-merge March 31, 2026 10:54
@rbradford
rbradford added this pull request to the merge queue Mar 31, 2026
Merged via the queue into cloud-hypervisor:main with commit 7832401 Mar 31, 2026
38 of 39 checks passed
@rbradford rbradford moved this to ✅ Done in Cloud Hypervisor Roadmap Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants