Repository navigation
[DO NOT REVIEW] missing_dev: claim a full-width or empty range without overflow - #5261
Merged
Pedro Henrique Penna (ppenna) merged 2 commits intoNov 24, 2026
Conversation
A guest that wrote the xAPIC DFR with a reserved model, as with mov dword [0xfee000e0], 0x7fffffff or a byte of 0x70 at 0xfee000e3, aborted the VMM with "entered unreachable code: Unknown DFR value", and so did a restore of a saved state whose DFR held one, as microsoft/nvx#1473 reports. The emulator serves WHP's user-mode APIC, which --hypervisor whp:user_mode_apic selects, as --hv does with whp:no_enlightenments, and OpenHCL's SNP and TDX backends. The DFR's model field, bits 31:28, is 0b1111 for the flat model and 0b0000 for the cluster model, and the SDM reserves its other 14 values. cluster_mode decoded only the two, and both write_register, for every xAPIC write of the DFR, whole or of its high byte, and restore, for the saved DFR, call it. x2APIC mode has no DFR: its MSR stays unimplemented and faults, so nothing else reaches cluster_mode. For a reserved model, cluster_mode now selects the flat model when bit 31 is set and the cluster model when it is clear, and logs a rate-limited warning with the value. Hyper-V's APIC, which WHP uses unless the user-mode APIC is selected, selects the model by bit 31 too. A guest of a few bytes on WHP's in-hypervisor xAPIC, on Windows 11 build 26300 on an Intel Core i9-12900H, read back after each write of the new test, each of which switches the model, what the test expects: 0xffffffff after 0xefffffff, 0x8fffffff, 0xffffffff, or a high byte of 0x80, and 0x0fffffff after 0x0fffffff, 0x7fffffff, 0x12345678, 0x00000000, or a high byte of 0x70. A write that keeps the model, such as 0x8fffffff in the flat model, read back as written there, presumably from the virtual-APIC page of APIC-register virtualization, whereas the host of microsoft/nvx#1473 read back the model. The emulator stores only the model, so the DFR reads back, and a save stores, 0xffffffff or 0x0fffffff, as for the architectural models, and a saved state never holds a reserved model, which an earlier OpenVMM would fail to restore. A restore decodes a saved DFR as a write does, and still succeeds. Ignoring the write, as #5247 proposes upstream, would keep the previous model, so a guest would read back, and route its logical interrupts by, another model with the user-mode APIC than with WHP's own, and a restore would need a fallback of its own. dfr_reserved_model_follows_bit_31 writes reserved models whole and by the high byte, each selecting the model other than the current one, and restores saved states that hold them, and checks the model that the DFR reads back and that a save stores. Without the fix, it panics at its first reserved model, 0xefffffff, and a write of the high byte alone or a restore alone panics the same way; with it, every test of virt_support_apic passes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
MissingDev::from_manifest, which builds a missing device from a MissingDevManifest or, through its resolver, from a MissingDevHandle, registered each claimed range as one I/O region of length end - start + 1 (microsoft/nvx#1409). For a range that spans its whole address space, 0..=0xffff for port I/O or 0..=u64::MAX for MMIO, that length does not fit the u16 or u64 that new_io_region takes, and for an empty range, whose start lies past its end, the subtraction underflows. Where overflow checks are on, as in debug builds, building such a device panicked with "attempt to add with overflow" or "attempt to subtract with overflow". Otherwise the length wrapped: a full-width range, and an empty range whose start lies just past its end, were registered with length 0, which the chipset maps as nothing, and any other empty range with a length that runs past the top of its address space, which the chipset's DeviceRange::map refuses with the panic "overflow during addition, not possible in real hardware". The defect is latent. OpenVMM's own callers claim fixed, valid ranges, the microVM chipset attaches no missing device, and the chipset's fallback device for unclaimed addresses claims nothing. Register each claimed range through a helper, regions, that returns the regions that claim exactly its addresses: none for an empty range, as an empty RangeInclusive holds no address; two halves for a full-width range, whose lengths fit, both under the range's name, since the chipset uses region names only for tracing, inspection, and conflict messages; and the range itself, as before, for every other range. Rejecting such ranges instead would make from_manifest and the resolver, whose error type is Infallible, fallible for every caller, while both kinds of range have a clear meaning. Tests, in missing_dev's new tests module, check the regions that from_manifest registers and maps, by name, address, and length. a_full_width_range_is_mapped_in_two_halves claims 0..=0xffff and 0..=u64::MAX, and an_empty_range_claims_nothing claims 5..=3 and 4..=3 as ports and 5..=3 and u64::MAX..=0 as MMIO. At feature/microvm/dev 9805f89, both fail in the dev profile, with "attempt to add with overflow" and "attempt to subtract with overflow", and, with overflow checks off, as in release builds, with one region of length 0 at port 0 and one of length 0xffff at port 5. Both pass with the fix, with and without overflow checks. a_claimed_range_is_mapped_with_its_length checks ranges at the edge of the split, such as 0..=0xfffe, 1..=0xffff, and 1..=u64::MAX, which keep one region; it passes before and after the fix. A scratch test, not committed, built these devices on vmotherboard's chipset. With the fix, both halves of each full-width range occupy their first and last addresses, and the empty range 5..=3 occupies none. At 9805f89, with overflow checks off in missing_dev, the full-width port range occupied nothing, and the empty range panicked in DeviceRange::map. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pedro Henrique Penna (ppenna)
requested a review
from a team
as a code owner
November 24, 2026 11:52
This was referenced Nov 24, 2026
Merged
Merged
Pedro Henrique Penna (ppenna)
merged commit Nov 24, 2026
aa145af
into
feature/microvm/dev
104 of 105 checks passed
5 tasks done
Pedro Henrique Penna (ppenna)
added a commit
to microsoft/nvx
that referenced
this pull request
Nov 24, 2026
…n the OpenVMM roadmap Map positions 374 and 375, the commits of microsoft/openvmm#5265, which NVX now pins at d44a113be, 249 commits past the mapped tip, stacked on microsoft/openvmm#5264, #5263, and #5262, and name aa145aff9 as the head of feature/microvm/dev, where microsoft/openvmm#5260 and microsoft/openvmm#5261 have landed positions 369 and 370: - 374, petri: let a microVM test arm the post-restore input gate. PetriVmConfigOpenVmm::with_microvm_restore_gate hands the VM worker the gate's timeout, which petri left unset, and the worker gates the first start of a cold boot as it gates a restore's. - 375, openvmm_core: stop a gated restore's deadline at its acknowledgement. SnapshotRestore::restore_acknowledged clears the gate's deadline when the acknowledgement comes in time and keeps host input gated, so the snapshot boundary of the acknowledgement holds the VM until the snapshot controller releases it, however long after the deadline; an acknowledgement after the deadline stops the VM as the deadline does. Position 374 is not yet assigned to a PR: it replaces the empty gate timeout in the line of Worker::launch that PR20's position 090 adds, but fixes no defect of it. Position 375 fixes a defect of position 090, which arms the deadline at the VM's start and clears it only at the release of the acknowledgement's boundary, so it is a PR20 fixup: fold it into position 090, its changes of restore_acknowledged and its unit tests into position 134, which adds that method and next_event, and its VMM test into position 374. Positions 369-373 change none of their files. Replaying either commit on upstream main, efe0b08df, conflicts in all of its files, which upstream main lacks or which change what the chain adds there, so position 374 follows PR20 and position 234 upstream, and position 375 follows PR20. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pedro Henrique Penna (ppenna)
added a commit
to microsoft/nvx
that referenced
this pull request
Nov 24, 2026
…n the OpenVMM roadmap Map positions 374 and 375, the commits of microsoft/openvmm#5265, which NVX now pins at d44a113be, 249 commits past the mapped tip, stacked on microsoft/openvmm#5264, #5263, and #5262, and name aa145aff9 as the head of feature/microvm/dev, where microsoft/openvmm#5260 and microsoft/openvmm#5261 have landed positions 369 and 370: - 374, petri: let a microVM test arm the post-restore input gate. PetriVmConfigOpenVmm::with_microvm_restore_gate hands the VM worker the gate's timeout, which petri left unset, and the worker gates the first start of a cold boot as it gates a restore's. - 375, openvmm_core: stop a gated restore's deadline at its acknowledgement. SnapshotRestore::restore_acknowledged clears the gate's deadline when the acknowledgement comes in time and keeps host input gated, so the snapshot boundary of the acknowledgement holds the VM until the snapshot controller releases it, however long after the deadline; an acknowledgement after the deadline stops the VM as the deadline does. Position 374 is not yet assigned to a PR: it replaces the empty gate timeout in the line of Worker::launch that PR20's position 090 adds, but fixes no defect of it. Position 375 fixes a defect of position 090, which arms the deadline at the VM's start and clears it only at the release of the acknowledgement's boundary, so it is a PR20 fixup: fold it into position 090, its changes of restore_acknowledged and its unit tests into position 134, which adds that method and next_event, and its VMM test into position 374. Positions 369-373 change none of their files. Replaying either commit on upstream main, efe0b08df, conflicts in all of its files, which upstream main lacks or which change what the chain adds there, so position 374 follows PR20 and position 234 upstream, and position 375 follows PR20. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pedro Henrique Penna (ppenna)
added a commit
to microsoft/nvx
that referenced
this pull request
Nov 24, 2026
…n the OpenVMM roadmap Map positions 374 and 375, the commits of microsoft/openvmm#5265, which NVX now pins at d44a113be, 249 commits past the mapped tip, stacked on microsoft/openvmm#5264, #5263, and #5262, and name aa145aff9 as the head of feature/microvm/dev, where microsoft/openvmm#5260 and microsoft/openvmm#5261 have landed positions 369 and 370: - 374, petri: let a microVM test arm the post-restore input gate. PetriVmConfigOpenVmm::with_microvm_restore_gate hands the VM worker the gate's timeout, which petri left unset, and the worker gates the first start of a cold boot as it gates a restore's. - 375, openvmm_core: stop a gated restore's deadline at its acknowledgement. SnapshotRestore::restore_acknowledged clears the gate's deadline when the acknowledgement comes in time and keeps host input gated, so the snapshot boundary of the acknowledgement holds the VM until the snapshot controller releases it, however long after the deadline; an acknowledgement after the deadline stops the VM as the deadline does. Position 374 is not yet assigned to a PR: it replaces the empty gate timeout in the line of Worker::launch that PR20's position 090 adds, but fixes no defect of it. Position 375 fixes a defect of position 090, which arms the deadline at the VM's start and clears it only at the release of the acknowledgement's boundary, so it is a PR20 fixup: fold it into position 090, its changes of restore_acknowledged and its unit tests into position 134, which adds that method and next_event, and its VMM test into position 374. Positions 369-373 change none of their files. Replaying either commit on upstream main, efe0b08df, conflicts in all of its files, which upstream main lacks or which change what the chain adds there, so position 374 follows PR20 and position 234 upstream, and position 375 follows PR20. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pedro Henrique Penna (ppenna)
added a commit
to microsoft/nvx
that referenced
this pull request
Nov 24, 2026
…n the OpenVMM roadmap Map positions 374 and 375, the commits of microsoft/openvmm#5265, which NVX now pins at d44a113be, 249 commits past the mapped tip, stacked on microsoft/openvmm#5264, #5263, and #5262, and name aa145aff9 as the head of feature/microvm/dev, where microsoft/openvmm#5260 and microsoft/openvmm#5261 have landed positions 369 and 370: - 374, petri: let a microVM test arm the post-restore input gate. PetriVmConfigOpenVmm::with_microvm_restore_gate hands the VM worker the gate's timeout, which petri left unset, and the worker gates the first start of a cold boot as it gates a restore's. - 375, openvmm_core: stop a gated restore's deadline at its acknowledgement. SnapshotRestore::restore_acknowledged clears the gate's deadline when the acknowledgement comes in time and keeps host input gated, so the snapshot boundary of the acknowledgement holds the VM until the snapshot controller releases it, however long after the deadline; an acknowledgement after the deadline stops the VM as the deadline does. Position 374 is not yet assigned to a PR: it replaces the empty gate timeout in the line of Worker::launch that PR20's position 090 adds, but fixes no defect of it. Position 375 fixes a defect of position 090, which arms the deadline at the VM's start and clears it only at the release of the acknowledgement's boundary, so it is a PR20 fixup: fold it into position 090, its changes of restore_acknowledged and its unit tests into position 134, which adds that method and next_event, and its VMM test into position 374. Positions 369-373 change none of their files. Replaying either commit on upstream main, efe0b08df, conflicts in all of its files, which upstream main lacks or which change what the chain adds there, so position 374 follows PR20 and position 234 upstream, and position 375 follows PR20. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Aaqibhafeez Khan (Aaqibhafeezkhan)
pushed a commit
to Aaqib-OSS/nvx
that referenced
this pull request
Nov 24, 2026
MissingDev::from_manifest, which builds OpenVMM's missing devices from a MissingDevManifest or a MissingDevHandle, registered each claimed port I/O or MMIO range as one region of length end - start + 1 (microsoft#1409). For a range that spans its whole address space, 0..=0xffff or 0..=u64::MAX, that length does not fit the address type, and for an empty range, whose start lies past its end, the subtraction underflows. Building such a device panicked where overflow checks are on, as in debug builds. Otherwise it claimed nothing for a full-width range or for an empty range whose start lies just past its end, and panicked in the chipset's DeviceRange::map for any other empty range. Pin microsoft/openvmm aa145aff9868866881c55f87305edc82f0f01602, the head of microsoft/openvmm#5261, one commit on 8c1204c68, the head of microsoft/openvmm#5260, which NVX pinned before this commit: - missing_dev: claim a full-width or empty range without overflow. An empty range claims nothing, a full-width range is registered as two halves under its name, and every other range as before; three new tests check the regions that from_manifest registers and maps. The new tests of full-width and empty ranges fail without the fix, with an overflow panic in the dev profile and with the wrong regions with overflow checks off, as in release builds, and pass with it, on Windows. NVX's microVMs attach no missing device, and the chipset's fallback device for unclaimed addresses claims nothing, so they build and run as before. No saved-state, protocol, or ABI format, and no version of any of them, changes. The protocol vectors and CPU profiles that nvx copies are unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Aaqibhafeez Khan (Aaqibhafeezkhan)
pushed a commit
to Aaqib-OSS/nvx
that referenced
this pull request
Nov 24, 2026
…OpenVMM roadmap Map position 370, the commit of microsoft/openvmm#5261, which NVX now pins at aa145aff9, 244 commits past the mapped tip: - 370, missing_dev: claim a full-width or empty range without overflow. MissingDev::from_manifest registers no region for an empty range and two halves, both under the range's name, for a range that spans its whole address space, whose length, end - start + 1, did not fit the address type, and every other range as before. Position 370 is not yet assigned to a PR. microsoft/openvmm#5261 is stacked on microsoft/openvmm#5260, whose position 369 the previous pin mapped, so the Scope now names it as the pull request that position 370 follows. No earlier chain commit changes missing_dev, and the 40 that change Cargo.lock change none of its entry, to which it adds test_with_tracing, a new dev-dependency. It changes nothing that a mapped PR adds, so it is no fixup. Upstream main, efe0b08df, has the code that it changes; replaying it there applies without conflicts, and missing_dev type-checks there with its tests, which pass, so it can go upstream on its own. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Aaqibhafeez Khan (Aaqibhafeezkhan)
pushed a commit
to Aaqib-OSS/nvx
that referenced
this pull request
Nov 24, 2026
On a Windows host, a microVM's virtio-fs guest listed at most 64 entries of any host directory besides `.` and `..`: FUSE_READDIR and FUSE_READDIRPLUS reported the end of the directory after the 64th entry, so `ls`, `find`, `tar`, and build tools saw an incomplete directory, although a lookup by name still found the rest, and a snapshot saved the truncated listing of each open handle (microsoft#1923). The first read of a handle lists its directory with one LxFile::read_dir call, which on Windows returns one cached enumeration window of up to 64 entries at most, so that a READDIR reply never spans two windows, and the microVM's listing never read on. Pin microsoft/openvmm 2bb009b01fbe15b2132b615e9ce78e1277d1793d, the head of microsoft/openvmm#5262, one commit on aa145aff9, the head of microsoft/openvmm#5261, which NVX pins below this commit: - virtiofs: read microVM directory listings to the end on Windows. The listing reads on from the offset of the last entry that a call returned until a call returns none, counting the entries that the access policy hides, so the per-handle bounds of 4,096 entries and 64 KiB of names, and E2BIG beyond them, cover the whole directory on Windows too. LxFile::read_dir's documentation now says that a call can end before the directory does, as on Windows. Its two tests and the issue's reproducer fail without the fix, listing 12, 66, and 66 entries, and pass with it, on Windows, where the 311 tests of the virtiofs and lxutil packages pass at the pin. In an Alpine guest of release v0.1.0-dev.af15015fa19c on WHP, whose OpenVMM CI built from 9805f8984, `ls -a` of a share of 254 files printed 66 names and `find` 64 files, and a directory of 10 shown, 128 denied, and 10 more shown files listed only the first 10. With OpenVMM built from afec63476, the same commit on 9805f8984 before its rebase onto microsoft/openvmm#5260 and microsoft/openvmm#5261, which touch none of its files, they printed 256 names, 254 files, and all 20 shown files, and the filesystem-shares, filesystem-snapshot, filesystem-policy, denied-filesystem-paths, filesystem-comma-paths, platform-filesystem, and platform-aggregate-export scenarios passed on WHP. The non-microVM READDIR, whose guest reads on itself, and lxutil's enumeration are unchanged: making LxFile::read_dir continue through the windows instead would let a READDIR reply span them, so that a guest that removes the entries that it reads would skip others. No saved-state, protocol, or ABI format, and no version of any of them, changes. The protocol vectors and CPU profiles that nvx copies are unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Aaqibhafeez Khan (Aaqibhafeezkhan)
pushed a commit
to Aaqib-OSS/nvx
that referenced
this pull request
Nov 24, 2026
…M roadmap Map position 371, the commit of microsoft/openvmm#5262, which NVX now pins at 2bb009b01, 245 commits past the mapped tip: - 371, virtiofs: read microVM directory listings to the end on Windows. The listing that the first read of a microVM directory handle takes reads on from the offset of the last entry that LxFile::read_dir returned until a call returns none, since on Windows a call returns one cached enumeration window of up to 64 entries at most, where the listing ended (microsoft#1923). Position 371 is not yet assigned to a PR. It fixes a defect of PR18's position 083, whose build_microvm_directory_snapshot it changes as position 160 filters it by the access policy, but its tests need positions 160, 164, and 335, so it is not a PR18 fixup. Positions 330, 346, 349, 354, and 355 also change the microVM's file.rs, and positions 125, 158, 344, and 351 lxutil's lib.rs, but not the documentation of LxFile::read_dir, which is upstream's; positions 369 and 370, the commits of microsoft/openvmm#5260 and microsoft/openvmm#5261 that it follows, change none of its files. Upstream main, efe0b08df, lacks the defect, since it lacks the microVM's listings, and replaying the commit there conflicts in the microVM's file.rs and fs_tests.rs, which upstream main lacks, so it cannot go upstream on its own. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Aaqibhafeez Khan (Aaqibhafeezkhan)
pushed a commit
to Aaqib-OSS/nvx
that referenced
this pull request
Nov 24, 2026
…hanged in the OpenVMM roadmap Map position 372, the commit of microsoft/openvmm#5263, which NVX now pins at 6ace73360, 246 commits past the mapped tip, after positions 369-371 of microsoft/openvmm#5260, microsoft/openvmm#5261, and microsoft/openvmm#5262, on which it is stacked: - 372, vmm_core: keep a debugger break into a paused VM out of its saved state. A gdb stub break into a stopped partition unit without a halt reports the stop at once, and holds the VPs stopped for the debugger, without a halt reason, until it resumes them or detaches, or the client clears the halt, so a save, which carries the halt reason that position 150 saves, no longer changes although the VM never ran. A break into a running unit halts it as before. The debug worker sends no Detach when GDB disconnects (microsoft#2094), so a hold, as a recorded debugger break before it, lasts until a debugger resumes the VM or the halt is cleared. Position 372 is not yet assigned to a PR. In partition_unit.rs, it changes upstream's try_start, clear_halt, and power-state inspection, none of the lines that positions 027, 065, 091, 134, 150, and 246 add, and adds its tests to position 150's save and restore tests; in partition_unit/debug.rs, it changes upstream's handling of Break, Resume, and Detach, not the stop reasons that position 054 maps. Positions 369-371 change none of its files. It is not a fixup: the break that halts stopped VPs is upstream's, and position 150 is not yet assigned to a PR. Upstream main, efe0b08df, saves no halt state, and replaying the commit there conflicts in partition_unit.rs, whose tests of position 150 it lacks, so it cannot go upstream on its own. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Refs microsoft/nvx#1409.
Stacked on #5260 (
8c1204c68); only the top commit belongs to this pull request.NVX pins the head of this branch,
aa145aff9868866881c55f87305edc82f0f01602, one commit on8c1204c68, the head of #5260, which is one commit onfeature/microvm/dev(9805f8984). This pull request is therefore a prerequisite of the NVX change that pins it. It lands after #5260, by fast-forwardingfeature/microvm/devto that exact commit, not with the merge button, which squashes.What and why
MissingDev::from_manifestinvm/devices/missing_dev/src/lib.rsbuilds a missing device from aMissingDevManifestor, throughMissingDevResolver, from aMissingDevHandle. It registered each claimed port I/O or MMIO range as one I/O region of lengthend - start + 1:0..=0xfffffor port I/O or0..=u64::MAXfor MMIO, that length,0x10000or 2^64, does not fit theu16oru64thatnew_io_regiontakes.Where overflow checks are on, as in debug builds, building such a device panicked with
attempt to add with overfloworattempt to subtract with overflow. Otherwise the length wrapped:vmotherboard'sDeviceRange::mapmaps as nothing.DeviceRange::maprefuses with the panicoverflow during addition, not possible in real hardware.The defect is latent. OpenVMM's own callers,
vm_manifest_builderandopenvmm_core's dispatch, claim fixed, valid ranges, the microVM chipset attaches no missing device, and the chipset's fallback device for unclaimed addresses claims nothing. Only a caller that passes such a range in aMissingDevManifest, or in aMissingDevHandle, whose fields are public, reaches it.missing_dev: claim a full-width or empty range without overflowregisters each claimed range through a new helper,regions, which returns the regions that claim exactly its addresses:RangeInclusive::is_empty);0..=0x7fffand0x8000..=0xffff, or0..=2^63-1and2^63..=u64::MAX, whose lengths fit. Both are registered under the range's name: the chipset uses region names only for tracing, inspection, and conflict messages, and revokes a region by its address;The device keeps the claimed ranges as they were given, so its inspection output does not change. Rejecting such ranges instead would make
from_manifestandMissingDevResolver, whose error type isInfallible, fallible for every caller, while both kinds of range have a clear meaning, so this pull request does not.No saved state, protocol, ABI, or format, and no version of any of them, changes.
Tests
A new
testsmodule inmissing_dev, withtest_with_tracingas a new dev-dependency (one line inCargo.lock), builds devices on a recorder that implements both registration traits, and checks the regions thatfrom_manifestregisters and maps, by name, address, and length:a_full_width_range_is_mapped_in_two_halves:0..=0xffffand0..=u64::MAX.an_empty_range_claims_nothing:5..=3and4..=3as ports, and5..=3andu64::MAX..=0as MMIO.a_claimed_range_is_mapped_with_its_length: ranges at the edge of the split, such as0xffff..=0xffff,0..=0xfffe,1..=0xffff, and1..=u64::MAX, each of which keeps one region.Validation
On Windows 11, local, with Rust 1.97.1, at
feature/microvm/dev9805f8984, with the tests and without the fix, and with the fix:cargo nextest run --profile agent -p missing_dev(dev profile, overflow checks on)attempt to add with overflowandattempt to subtract with overflowcargo test -p missing_dev --config "profile.test.package.missing_dev.overflow-checks=false"(overflow checks off, as in release builds)left: [(Some(0), 0)]for0..=0xffffandleft: [(Some(5), 65535)]for5..=3a_claimed_range_is_mapped_with_its_lengthpasses with and without the fix.A scratch test, not committed, built these devices on
vmotherboard's chipset, aDeviceRangeMapperoverIoRanges. Without the fix, and with overflow checks off inmissing_dev, the full-width port range occupied no port, and5..=3panicked inDeviceRange::mapwithoverflow during addition, not possible in real hardware. With the fix, with and without overflow checks, both halves of each full-width range occupy their first and last addresses, and5..=3occupies none.With the same patch on
9805f8984:cargo check,cargo clippy --all-targets, andcargo doc --no-depsformissing_dev, the last withRUSTDOCFLAGS=-D warnings, with and without--document-private-items, are clean, but for theLNK4199linker message that every linked artifact gets on this machine, andcargo xtask fmt --fixpasses, after it reflowed one line of the tests before the commit. At this head, rebased on #5260, whose commit changes onlyvirt_support_apic(git range-diffshows the patch unchanged),cargo nextest run --profile agent -p missing_devand the run without overflow checks pass all 3 tests, andcargo clippy --all-targets -p missing_devis clean.Replayed on upstream main,
efe0b08df, the commit applies without conflicts, andmissing_devtype-checks there with its tests (cargo check --locked -p missing_dev --tests), which pass (cargo test --locked -p missing_dev), so it can go upstream on its own.The change touches no platform-specific code.