Commit Graph

9771 Commits

Author SHA1 Message Date
Souradeep Chakrabarti
7832401816 hypervisor: Add GHCB CPUID, MSR and TERM_REQ handlers
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 <schakrabarti@microsoft.com>
2026-03-31 11:32:34 +00:00
CMGS
ff20f18364 vmm: restore KVM clock before resuming vCPUs
Reorder resume() to: set_clock, device_manager.resume,
cpu_manager.resume. This matches the inverse of pause()
which correctly saves the clock before pausing vCPUs.

Signed-off-by: CMGS <ilskdw@gmail.com>
2026-03-31 08:39:20 +00:00
Wei Liu
c52e151439 github: Introduce cool down periods for non-rust-vmm crates
This gives the community more time to react to possible security chain
compromises.

We have high confidence that rust-vmm crates are trusted, and the
community is fully capable of spotting any issues. There is no need to
delay that group.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
2026-03-31 09:24:34 +01:00
dependabot[bot]
c943103f75 build(deps): bump the non-rust-vmm group across 2 directories with 7 updates
Bumps the non-rust-vmm group with 5 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [uuid](https://github.com/uuid-rs/uuid) | `1.22.0` | `1.23.0` |
| [zerocopy](https://github.com/google/zerocopy) | `0.8.47` | `0.8.48` |
| [cc](https://github.com/rust-lang/cc-rs) | `1.2.57` | `1.2.58` |
| libredox | `0.1.14` | `0.1.15` |
| [simd-adler32](https://github.com/mcountryman/simd-adler32) | `0.3.8` | `0.3.9` |

Bumps the non-rust-vmm group with 5 updates in the /fuzz directory:

| Package | From | To |
| --- | --- | --- |
| [uuid](https://github.com/uuid-rs/uuid) | `1.22.0` | `1.23.0` |
| [zerocopy](https://github.com/google/zerocopy) | `0.8.47` | `0.8.48` |
| [cc](https://github.com/rust-lang/cc-rs) | `1.2.57` | `1.2.58` |
| [simd-adler32](https://github.com/mcountryman/simd-adler32) | `0.3.8` | `0.3.9` |
| [winnow](https://github.com/winnow-rs/winnow) | `1.0.0` | `1.0.1` |



Updates `uuid` from 1.22.0 to 1.23.0
- [Release notes](https://github.com/uuid-rs/uuid/releases)
- [Commits](https://github.com/uuid-rs/uuid/compare/v1.22.0...v1.23.0)

Updates `zerocopy` from 0.8.47 to 0.8.48
- [Release notes](https://github.com/google/zerocopy/releases)
- [Changelog](https://github.com/google/zerocopy/blob/main/CHANGELOG.md)
- [Commits](https://github.com/google/zerocopy/compare/v0.8.47...v0.8.48)

Updates `cc` from 1.2.57 to 1.2.58
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Changelog](https://github.com/rust-lang/cc-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.57...cc-v1.2.58)

Updates `libredox` from 0.1.14 to 0.1.15

Updates `simd-adler32` from 0.3.8 to 0.3.9
- [Changelog](https://github.com/mcountryman/simd-adler32/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mcountryman/simd-adler32/commits/v0.3.9)

Updates `zerocopy-derive` from 0.8.47 to 0.8.48
- [Release notes](https://github.com/google/zerocopy/releases)
- [Changelog](https://github.com/google/zerocopy/blob/main/CHANGELOG.md)
- [Commits](https://github.com/google/zerocopy/compare/v0.8.47...v0.8.48)

Updates `uuid` from 1.22.0 to 1.23.0
- [Release notes](https://github.com/uuid-rs/uuid/releases)
- [Commits](https://github.com/uuid-rs/uuid/compare/v1.22.0...v1.23.0)

Updates `zerocopy` from 0.8.47 to 0.8.48
- [Release notes](https://github.com/google/zerocopy/releases)
- [Changelog](https://github.com/google/zerocopy/blob/main/CHANGELOG.md)
- [Commits](https://github.com/google/zerocopy/compare/v0.8.47...v0.8.48)

Updates `cc` from 1.2.57 to 1.2.58
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Changelog](https://github.com/rust-lang/cc-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.57...cc-v1.2.58)

Updates `simd-adler32` from 0.3.8 to 0.3.9
- [Changelog](https://github.com/mcountryman/simd-adler32/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mcountryman/simd-adler32/commits/v0.3.9)

Updates `winnow` from 1.0.0 to 1.0.1
- [Changelog](https://github.com/winnow-rs/winnow/blob/main/CHANGELOG.md)
- [Commits](https://github.com/winnow-rs/winnow/compare/v1.0.0...v1.0.1)

Updates `zerocopy-derive` from 0.8.47 to 0.8.48
- [Release notes](https://github.com/google/zerocopy/releases)
- [Changelog](https://github.com/google/zerocopy/blob/main/CHANGELOG.md)
- [Commits](https://github.com/google/zerocopy/compare/v0.8.47...v0.8.48)

---
updated-dependencies:
- dependency-name: uuid
  dependency-version: 1.23.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: non-rust-vmm
- dependency-name: zerocopy
  dependency-version: 0.8.48
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: cc
  dependency-version: 1.2.58
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: libredox
  dependency-version: 0.1.15
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: simd-adler32
  dependency-version: 0.3.9
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: zerocopy-derive
  dependency-version: 0.8.48
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: uuid
  dependency-version: 1.23.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: non-rust-vmm
- dependency-name: zerocopy
  dependency-version: 0.8.48
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: cc
  dependency-version: 1.2.58
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: simd-adler32
  dependency-version: 0.3.9
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: winnow
  dependency-version: 1.0.1
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
- dependency-name: zerocopy-derive
  dependency-version: 0.8.48
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: non-rust-vmm
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-31 01:15:56 +00:00
Anatol Belski
5ca6ff869f block: vhd: Remove legacy async_io::DiskFile impl from FixedVhdDiskSync
No remaining consumers after switching to DiskBackend::Next.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:18:09 +00:00
Anatol Belski
c90f5a9e47 vmm: Switch fixed VHD sync to DiskBackend::Next
Wire FixedVhdDiskSync through the new composable trait system.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:18:09 +00:00
Anatol Belski
cc2f878094 block: vhd: impl AsyncDiskFile for FixedVhdDiskSync
Delegate try_clone() to FixedVhd::clone() and new_async_io() to
FixedVhdSync, preserving DiskFileError::NewAsyncIo.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:18:09 +00:00
Anatol Belski
ce1592d1df block: vhd: impl DiskFile for FixedVhdDiskSync
Marker impl bundling DiskSize and Geometry supertraits.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:18:09 +00:00
Anatol Belski
60af47c99b block: vhd: impl Resizable for FixedVhdDiskSync
Fixed VHD does not support resize, return UnsupportedFeature.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:18:09 +00:00
Anatol Belski
74b0613c04 block: vhd: impl SparseCapable for FixedVhdDiskSync
Fixed VHD does not support sparse operations.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:18:09 +00:00
Anatol Belski
1a56cb3d0e block: vhd: impl Geometry for FixedVhdDiskSync
Use default DiskTopology with 512byte sectors.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:18:09 +00:00
Anatol Belski
dfa9a25fd8 block: vhd: impl DiskFd for FixedVhdDiskSync
Delegate to FixedVhd::as_raw_fd() for the backing file descriptor.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:18:09 +00:00
Anatol Belski
266c5fc241 block: vhd: impl PhysicalSize for FixedVhdDiskSync
Delegate to FixedVhd::physical_size() which calls file.metadata().
Preserve the crate::Error::GetFileMetadata variant as the BlockError
source for diagnostic chain traversal.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:18:09 +00:00
Anatol Belski
7136744549 block: vhd: impl DiskSize for FixedVhdDiskSync
Delegate to FixedVhd::logical_size() which returns the guest
visible capacity parsed from the VHD footer at construction.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:18:09 +00:00
Anatol Belski
24e9049280 block: vhd: Switch FixedVhdDiskSync::new to BlockResult
Classify the io::Error as BlockErrorKind::Io with ErrorOp::Open.
Update vmm CreateFixedVhdDiskSync to take BlockError.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:18:09 +00:00
Anatol Belski
6e36932e90 block: vhdx: Remove legacy async_io::DiskFile impl from VhdxDiskSync
All functionality now provided by composable disk_file traits.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:17:01 +00:00
Anatol Belski
b703043f77 vmm: Switch VHDX to DiskBackend::Next
Wire VhdxDiskSync through DiskBackend::Next instead of Legacy.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:17:01 +00:00
Anatol Belski
cf9496376f block: vhdx: impl AsyncDiskFile for VhdxDiskSync
try_clone() shares the Arc<Mutex<Vhdx>>. new_async_io() creates
VhdxSync with a cloned Arc (no error path, infallible).

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:17:01 +00:00
Anatol Belski
e99ad15939 block: vhdx: impl DiskFile for VhdxDiskSync
Supertrait marker, all component traits already implemented.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:17:01 +00:00
Anatol Belski
ffdc8c49d1 block: vhdx: impl Resizable for VhdxDiskSync
Returns UnsupportedFeature, VHDX resize is not supported.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:17:01 +00:00
Anatol Belski
3e904d7a27 block: vhdx: impl SparseCapable for VhdxDiskSync
VHDX does not support sparse operations.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:17:01 +00:00
Anatol Belski
62244f94da block: vhdx: impl Geometry for VhdxDiskSync
Uses default topology.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:17:01 +00:00
Anatol Belski
eca9e14ecb block: vhdx: impl DiskFd for VhdxDiskSync
Returns the raw fd from the inner Vhdx via mutex lock.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:17:01 +00:00
Anatol Belski
5578f329cf block: vhdx: impl PhysicalSize for VhdxDiskSync
Explicitly matches GetFileMetadata to preserve the original error type.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:17:01 +00:00
Anatol Belski
3164b66cb5 block: vhdx: impl DiskSize for VhdxDiskSync
Delegates to Vhdx::virtual_disk_size() which is infallible.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:17:01 +00:00
Anatol Belski
b8b32f5927 block: vhdx: Switch VhdxDiskSync::new to BlockResult
Wrap VhdxError via BlockError::new(Io, e).with_op(Open). Update VMM
CreateFixedVhdxDiskSync error variant from VhdxError to BlockError.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:17:01 +00:00
Anatol Belski
019aa52830 block: vhd: Remove legacy async_io::DiskFile impl from FixedVhdDiskAsync
No remaining consumers after switching to DiskBackend::Next.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:16:04 +00:00
Anatol Belski
b69bd219fa vmm: Switch fixed VHD async to DiskBackend::Next
Wire FixedVhdDiskAsync through the new composable trait system.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:16:04 +00:00
Anatol Belski
c0db1f61ac block: vhd: impl AsyncDiskFile for FixedVhdDiskAsync
Delegate try_clone() to FixedVhd::clone() and new_async_io() to
FixedVhdAsync, preserving DiskFileError::NewAsyncIo.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:16:04 +00:00
Anatol Belski
be6ce5b878 block: vhd: impl DiskFile for FixedVhdDiskAsync
Marker impl bundling DiskSize and Geometry supertraits.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:16:04 +00:00
Anatol Belski
df5d2d64b2 block: vhd: impl Resizable for FixedVhdDiskAsync
Fixed VHD does not support resize, return UnsupportedFeature.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:16:04 +00:00
Anatol Belski
0dece29fa8 block: vhd: impl SparseCapable for FixedVhdDiskAsync
Fixed VHD does not support sparse operations.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:16:04 +00:00
Anatol Belski
1db64f511e block: vhd: impl Geometry for FixedVhdDiskAsync
Use default DiskTopology with 512 byte sectors.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:16:04 +00:00
Anatol Belski
2973987c81 block: vhd: impl DiskFd for FixedVhdDiskAsync
Delegate to FixedVhd::as_raw_fd().

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:16:04 +00:00
Anatol Belski
42af5913d9 block: vhd: impl PhysicalSize for FixedVhdDiskAsync
Fix .unwrap() bug: use explicit GetFileMetadata match.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:16:04 +00:00
Anatol Belski
d82b1101d9 block: vhd: impl DiskSize for FixedVhdDiskAsync
Delegate to infallible FixedVhd::logical_size().

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:16:04 +00:00
Anatol Belski
15073edf08 block: vhd: Switch FixedVhdDiskAsync::new to BlockResult
Map FixedVhd::new io::Error to BlockError with ErrorOp::Open.
Update vmm CreateFixedVhdDiskAsync source type accordingly.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-30 22:16:04 +00:00
Muminul Islam
38eb10d209 block: Remove legacy DiskFile impl from RawFileDiskSync
Remove the legacy async_io::DiskFile implementation from
RawFileDiskSync now that the new disk_file trait impls are
in place.

Remove unused imports: Seek, SeekFrom, DiskFile, and
DiskFileResult.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
4f44cd9ed3 vmm: Switch RawFileDiskSync to DiskBackend::Next
Update device_manager.rs to construct DiskBackend::Next
instead of DiskBackend::Legacy for the synchronous raw
backend.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
afd018f9d1 fuzz: Switch RawFileDiskSync to DiskBackend::Next
Update fuzz/block.rs to construct DiskBackend::Next instead
of DiskBackend::Legacy for the synchronous raw backend.

Remove the unused async_io::DiskFile import.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
662d350cf9 block: Implement AsyncDiskFile trait for RawFileDiskSync
Add disk_file::AsyncDiskFile trait implementation for
RawFileDiskSync with try_clone() and new_async_io() methods.

try_clone() duplicates the underlying file descriptor and
wraps it in a new RawFileDiskSync. new_async_io() creates a
RawFileSync (synchronous fallback) backend, wrapping errors
in BlockError instead of DiskFileError.

Add DiskFileError::Clone variant in async_io.rs for the
try_clone() error path.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
da72a3abfb block: Implement DiskFile marker trait for RawFileDiskSync
Add empty disk_file::DiskFile impl for RawFileDiskSync.
This marker supertrait requires DiskSize + Geometry + Sync,
all of which are now satisfied.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
6b14d27f30 block: Implement Resizable trait for RawFileDiskSync
Add disk_file::Resizable trait implementation for
RawFileDiskSync. Calls file.set_len(size) and wraps the
I/O error in BlockError on failure.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
fe39929a2a block: Implement SparseCapable trait for RawFileDiskSync
Add disk_file::SparseCapable trait implementation for
RawFileDiskSync. Delegates to probe_sparse_support() to
detect whether the underlying file supports hole-punching.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
aa5aa6fe89 block: Implement Geometry trait for RawFileDiskSync
Add disk_file::Geometry trait implementation for
RawFileDiskSync. Probes disk topology from the file,
falling back to defaults on failure. Takes &self instead
of &mut self and uses unwrap_or_else for cleaner error
handling.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
bd026ce4cb block: Implement DiskFd trait for RawFileDiskSync
Add disk_file::DiskFd trait implementation for
RawFileDiskSync. Delegates to file.as_raw_fd() via
BorrowedDiskFd, taking &self instead of &mut self.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
744c365faa block: Implement PhysicalSize trait for RawFileDiskSync
Add disk_file::PhysicalSize trait implementation for
RawFileDiskSync. Returns metadata().len() wrapped in
BlockError on failure, consistent with the DiskSize impl.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
00a355d273 block: Implement DiskSize trait for RawFileDiskSync
Add disk_file::DiskSize trait implementation for
RawFileDiskSync using BlockError and BlockResult. Uses
metadata().len() instead of seek(SeekFrom::End(0)), taking
&self instead of &mut self.

Add BlockError, BlockErrorKind, BlockResult, and disk_file
imports needed by this and subsequent trait impls.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
98fedac77f block: Derive Debug on RawFileDiskSync
Add #[derive(Debug)] to RawFileDiskSync. This is required
by the new disk_file traits which have Send + Debug bounds.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:15:31 +00:00
Muminul Islam
573f3af77d vmm: Switch RawFileDisk to DiskBackend::Next
Update device_manager.rs to construct DiskBackend::Next
instead of DiskBackend::Legacy for the io_uring raw backend.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2026-03-30 22:14:42 +00:00