Repository navigation
Description
On KVM, restoring a snapshot whose time-ABI host CPU profile describes huge XSAVE components (CPUID leaf 0xD) overflows u32 in XsaveCapabilities::standard_len_for and compact_len_for while the partition is built, so a debug build's VM worker panics ("attempt to add with overflow") and aborts. A release build wraps, and the restore then fails the CPU profile support check with E_PROFILE_UNSUPPORTED, before any VP runs, since no host's KVM has that layout. Only a crafted snapshot reaches this: a host profile is the snapshot's own document, and host CPUIDs never describe such components.
Reproduction
In a debug build, call X86PartitionCapabilities::from_cpuid with a CPUID whose XSAVE component 2 has offset 0xffff_ff00 and size 0x100 (this overflows offset + len), or with two components of size 0x8000_0000 (this overflows the compact sum). Expected: saturated lengths. Actual: a panic, "attempt to add with overflow". The new test from_cpuid_xsave_lengths_saturate covers both, plus an alignment that overflows.
Cause
In vmm_core/virt/src/x86/mod.rs, standard_len_for and compact_len_for add and align in unchecked u32 arithmetic. from_cpuid calls both, and KvmProtoPartition::build builds a time-ABI partition's caps from the profile's CPUID:
// vmm_core/virt/src/x86/mod.rs
pub fn standard_len_for(&self, xfem: u64) -> u32 {
// ...
len = len.max(feature.offset + feature.len);
// ...
pub fn compact_len_for(&self, xfem: u64) -> u32 {
// ...
if feature.align {
len = (len + 63) & !63;
}
len += feature.len;Fix
fix.patch saturates both sums, and makes an alignment that overflows yield u32::MAX: rounding a saturated length up and masking it would otherwise bring it back below u32::MAX. The KVM build then calls the new check_xsave_layout, so that it refuses, before any VP exists, caps whose XSAVE layout its own buffers cannot hold, which today only the later profile support check catches. It refuses a compact length below 576 or not a multiple of 8 (which Xsave::at_reset cannot build its buffer from) with XSaveLengthTooSmall, a component whose standard end is past the 4096 bytes of KVM_GET_XSAVE's buffer with the new XSaveLengthTooLarge, and a component past the compact length. A host's own CPUID passes all of these, and such a restore now fails while the partition is built, with KvmError::Capabilities. Tests: from_cpuid_xsave_lengths_saturate (virt) and check_xsave_layout_refuses_what_kvm_cannot_hold (virt_kvm).
Related: #1381.
Activity
tangruize commentedon Nov 8, 2026
Proposed patch
Patch against OpenVMM 3cf58a5234ed824435825c9f87187f5129219724. Save the contents below as
fix.patchand rungit apply fix.patch.fix.patchopenvmm: pin the XSAVE length math and KVM's layout check