Repository navigation
[DO NOT REVIEW] virt_support_apic: select a reserved DFR model by bit 31 - #5260
Merged
Pedro Henrique Penna (ppenna) merged 1 commit 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>
Pedro Henrique Penna (ppenna)
requested a review
from a team
as a code owner
November 24, 2026 11:41
This was referenced Nov 24, 2026
Merged
Merged
Pedro Henrique Penna (ppenna)
merged commit Nov 24, 2026
8c1204c
into
feature/microvm/dev
102 of 105 checks passed
This was referenced Nov 24, 2026
Merged
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
OpenVMM's local APIC emulator, which WHP's user-mode APIC and OpenHCL's SNP and TDX backends use, decoded only the flat and cluster models of the xAPIC DFR. A guest's write of one of the 14 reserved models, or a restore of a saved state that held one, reached unreachable! and aborted the VMM (microsoft#1473). Pin microsoft/openvmm 8c1204c68381d11d90e58c4ee710a879f71fb601, the head of microsoft/openvmm#5260, one commit on 9805f8984, the head of feature/microvm/dev, which NVX pins below this commit: - virt_support_apic: select a reserved DFR model by bit 31. A reserved model selects the flat model when bit 31 is set and the cluster model when it is clear, as in Hyper-V's APIC, with a rate-limited warning, for a guest's write and a restore alike, and the DFR reads back, and a save stores, the selected model. Its test panics without the fix and passes with it, on Windows, and a guest of a few bytes on WHP's in-hypervisor xAPIC read back the values that the test expects after the same writes. NVX's microVMs use the APICs of KVM, MSHV, and WHP itself, which never run this emulator, so they behave 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
… roadmap Map position 369, the commit of microsoft/openvmm#5260, which NVX now pins at 8c1204c68, 243 commits past the mapped tip: - 369, virt_support_apic: select a reserved DFR model by bit 31. cluster_mode selects the flat model for a reserved model of the xAPIC DFR whose bit 31 is set and the cluster model for one whose bit 31 is clear, as in Hyper-V's APIC, rather than reach unreachable!, for a guest's write and a restore alike, which aborted the VMM of WHP's user-mode APIC and of OpenHCL's SNP and TDX backends. Position 369 is not yet assigned to a PR. It changes lib.rs of virt_support_apic, where PR10's position 026 makes TIMER_FREQUENCY public, none of the lines that it changes. It is not a fixup: the unreachable! is upstream's. It applies to upstream main, efe0b08df, as it is, and virt_support_apic type-checks and passes its tests on the merged tree, so it can go upstream on its own. microsoft/openvmm#5247 proposes another fix of the same panic upstream, which ignores such a write; replaying the commit on it conflicts in lib.rs, which the remarks record for the next rebase. The Scope now names 9805f8984, position 368, as the head of feature/microvm/dev, since microsoft/openvmm#5254, microsoft/openvmm#5255, and microsoft/openvmm#5257 landed positions 362-368 there. 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#1473.
NVX pins the head of this branch,
8c1204c68381d11d90e58c4ee710a879f71fb601, one commit onfeature/microvm/dev(9805f8984). This pull request is therefore a prerequisite of the NVX change that pins it. It lands by fast-forwardingfeature/microvm/devto that exact commit, not with the merge button, which squashes. It is not stacked on another pull request.What and why
cluster_modeinvmm_core/virt_support_apic/src/lib.rsdecoded only the two architectural models of the xAPIC DFR, in bits 31:28: flat (0b1111) and cluster (0b0000). For the 14 values that the SDM reserves, it hitunreachable!("Unknown DFR value {value}"), which aborted the VMM.The DFR value comes from untrusted input on two paths:
write_register, whether the guest writes the whole register at0xfee000e0or only its high byte at0xfee000e3, whichis_valid_apic_accessallows;restoreof a saved DFR, throughLocalApic::restore, even in x2APIC mode.So one guest instruction such as
mov dword [0xfee000e0], 0x7fffffff, or a malformed saved state, aborted the VMM. The emulator serves:--hypervisor whp:user_mode_apicselects, as does--hvwithwhp:no_enlightenments;x2APIC mode has no DFR: its MSR stays unimplemented and faults, so nothing else reaches
cluster_mode.virt_support_apic: select a reserved DFR model by bit 31:cluster_modenow selects the flat model when bit 31 is set and the cluster model when bit 31 is clear. It logs a rate-limited warning with the value.0xffffffffor0x0fffffff, as it already does for the architectural values, andsavestores that model. A saved state therefore never holds a reserved model, which an earlier OpenVMM would fail to restore.Hyper-V's APIC, which WHP uses unless the user-mode APIC is selected, also selects the model by bit 31. microsoft/nvx#1473 measured that behavior. A scratch guest of a few bytes, run in 32-bit flat mode on WHP's in-hypervisor xAPIC, confirmed it on Windows 11 build 26300 with an Intel Core i9-12900H:
0x8fffffffin the flat model. Where the guest can read that value is presumably the virtual-APIC page of APIC-register virtualization. The host in openvmm: in virt_support_apic, a guest DFR write with a reserved model hitsunreachable!and aborts the VMM nvx#1473 read back the model for such writes too.The following alternatives were not taken:
main, would keep the previous model. After a write of0x7fffffffin the flat model, WHP's APIC switches to the cluster model, while the emulator would stay flat. A restore would also need a fallback of its own. The two changes conflict inlib.rs.The commit applies to upstream main,
efe0b08df, as it is. On the merged tree,cargo check -p virt_support_apicand its tests pass. No saved state, protocol, ABI, or format, and no version of any of them, changes.Tests
dfr_reserved_model_follows_bit_31, added to the tests inlib.rs, runs three steps:0x0fffffff,0xefffffff,0x7fffffff,0x8fffffff,0x12345678,0xffffffff, and0x00000000. Each write selects the model other than the current one, so a write that the emulator ignored would read back the wrong model.0x80and then0x70.0xefffffffand then0x7fffffff.After each write or restore, the test checks the model that the DFR reads back and the model that a save stores.
Validation
On Windows 11, local, with Rust 1.97.1:
cargo nextest run --profile agent -p virt_support_apic9805f8984, with only the new testdfr_reserved_model_follows_bit_31panics atlib.rs:171:14:entered unreachable code: Unknown DFR value 4026531839(0xefffffff)9805f8984, with scratch tests that are not committed0x70alone panics withUnknown DFR value 1879048192, and a restore of0x7fffffffalone panics withUnknown DFR value 21474836478c1204c68reserved dfr modelwarning for each reserved valueAt
8c1204c68, these checks forvirt_support_apicare clean, apart from theLNK4199linker message that every linked artifact gets on this machine:cargo check;cargo clippy --all-targets, onx86_64-pc-windows-msvcand, with-D warnings, onx86_64-unknown-linux-gnu;cargo doc --no-depswith-D warnings.cargo xtask fmt --fixchanges nothing. The change touches no platform-specific code, so this pull request's CI runs the Linux unit tests.