Repository navigation
Description
MissingDev::from_manifest computes each claimed region's length as range.end() - range.start() + 1. For a range that spans the whole port or MMIO space (0..=0xffff, 0..=u64::MAX) the + 1 overflows, and for an empty range (start after end) the - underflows. A build with overflow checks, such as OpenVMM's dev profile, which aborts on panic, panics while the device is built. A release build registers a full-width range with length 0, so it claims nothing, and an empty range with a length near the type's maximum, which the chipset's DeviceRange::map then refuses with a panic (by reading). OpenVMM's own callers claim fixed, valid ranges, and the microVM's missing devices claim none, so only a caller that passes such a range in a MissingDevManifest or a MissingDevHandle resource reaches it.
Reproduction
The patch's tests (missing_dev) a_full_width_range_is_mapped_in_two_halves and an_empty_range_claims_nothing fail without the fix. In the dev profile both panic in from_manifest on the overflow. In release, 0..=0xffff is registered with length 0, and 5..=3 with length 0xffff. a_claimed_range_is_mapped_with_its_length passes with and without the fix.
Cause
MissingDevManifest::claim_pio and claim_mmio, and the resolver of MissingDevHandle, accept any range, and from_manifest computes the length unchecked:
// vm/devices/missing_dev/src/lib.rs
let mut control = register_pio.new_io_region(name, range.end() - range.start() + 1);
control.map(*range.start());
// ...
let mut control =
register_mmio.new_io_region(name, range.end() - range.start() + 1);A full-width range's length, 0x10000 or 2^64, does not fit in the u16 or u64 that new_io_region takes. In release, the chipset's region ignores a length of 0, and checks the region's end with expect, which the wrapped length of an empty range always fails:
// vmm_core/vmotherboard/src/chipset/backing/arc_mutex/services.rs
if self.len == 0 {
return;
}
// ...
addr.checked_add(self.len - 1).expect("overflow during addition, not possible in real hardware"),Fix
fix.patch registers each claimed range through a new helper, regions. An empty range registers no region. A full-width range registers two halves, whose lengths fit, both under the range's name: region names are used only for tracing and conflict messages, so two regions can share one. Every other range is registered as before. It adds the three tests above. The alternative is to reject such ranges with an error; that would make from_manifest and the resolver, whose error type is Infallible, fallible, so the patch does not.
Related: #1384.
Activity
tangruize commentedon Nov 9, 2026
Proposed patch
Patch against OpenVMM 881619911d1a6ec2fec7bebdad7cfe69d09018f1. Save the contents below as
fix.patchand rungit apply fix.patch.fix.patch