Repository navigation
openvmm: pin the reserved DFR models of the user-mode APIC - #2092
Merged
Pedro Henrique Penna (ppenna) merged 2 commits intoNov 24, 2026
Merged
Pedro Henrique Penna (ppenna) merged 2 commits into
Pedro Henrique Penna (ppenna) merged 2 commits into
Conversation
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 (#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>
… 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>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the OpenVMM pin and roadmap update.
No open issues 🎉
What changed in this PR
This PR pins an OpenVMM fix for #1473 that handles reserved xAPIC DFR models without panicking. It affects the user-mode APIC emulator, not NVX’s normal microVM backends.
Changes:
- Advances the OpenVMM pin to
8c1204c68, which selects reserved DFR models using bit 31. - Maps the commit at roadmap position 369 and updates chain counts and references.
- Documents register readback, saved-state behavior, and the conflict with the alternative upstream fix in microsoft/openvmm#5247.
| File | Description |
|---|---|
doc/openvmm-upstream-roadmap.md |
Records the new pin, position 369, APIC behavior, and rebase considerations. |
Review effort: Balanced
This was referenced Nov 24, 2026
Pedro Henrique Penna (ppenna)
deleted the
agents/issue-1473-apic-dfr-reserved-model
branch
November 24, 2026 13:23
5 tasks done
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.
Fixes #1473
What does this pull request change?
It pins microsoft/openvmm
8c1204c68381d11d90e58c4ee710a879f71fb601(microsoft/openvmm#5260), one commit on
feature/microvm/dev, whichmakes OpenVMM's local APIC emulator,
virt_support_apic, select the model of areserved xAPIC DFR value by bit 31 instead of reaching
unreachable!andaborting the VMM, and maps that commit in the OpenVMM roadmap as position 369.
0b1111or0b0000) panicked withentered unreachable code: Unknown DFR value, which aborted the VMM. Examples aremov dword [0xfee000e0], 0x7fffffffand a one-byte write of0x70at0xfee000e3. A restore of a saved state whose DFR held a reserved modelpanicked in the same way.
cluster model when bit 31 is clear, and the emulator logs a rate-limited
warning. The DFR reads back the selected model (
0xffffffffor0x0fffffff), and a save stores that model, so no saved state holds areserved model. A restore decodes a saved DFR in the same way.
Start the review at
cluster_modeinopenvmm/vmm_core/virt_support_apic/src/lib.rs, then read the new test,dfr_reserved_model_follows_bit_31, at the end of that file.Commits:
openvmm: pin the reserved DFR models of the user-mode APICchanges only thegitlink.
doc: map the reserved DFR models of the user-mode APIC in the OpenVMM roadmapchanges onlydoc/openvmm-upstream-roadmap.md.Scope and limitations:
emulator, so their behavior does not change.
nvx, the guest, or the scripts changes.The user-mode APIC is selected by
--hypervisor whp:user_mode_apicor by--hvwithwhp:no_enlightenments. This pull request tests the emulator'sbehavior with unit tests, and does not boot a guest in those configurations.
Why is this change needed?
The root cause is in
cluster_mode. It decoded only the two architecturalmodels and called
unreachable!for the 14 reserved models. Every xAPIC writeof the DFR, whether of the whole register or of the high byte that
is_valid_apic_accessallows, reaches it unfiltered. Everyrestorereaches ittoo, even in x2APIC mode. x2APIC mode has no DFR, and a write of MSR
0x80estays unimplemented and faults. OpenVMM's rules say that it must never panic on
guest input. The
unreachable!comes from upstream, and no chain committouched it.
Design: for a reserved model, bit 31 selects the model, as the issue asks.
Hyper-V's APIC, which WHP uses unless the user-mode APIC is selected, does the
same. The issue measured it, and a scratch guest of a few bytes confirmed it on
WHP's in-hypervisor xAPIC. That guest wrote the DFR and read it back in 32-bit
flat mode, on a local Windows 11 build 26300 host with an Intel Core i9-12900H.
After the writes of the new test, each of which switches the model, that APIC
read back exactly what the test expects:
0xefffffff,0x8fffffff,0xffffffff, high byte0x800xffffffff0x0fffffff,0x7fffffff,0x12345678,0x00000000, high byte0x700x0fffffffEvery switch of the model followed bit 31. On this host, a write that keeps the
model reads back as written, presumably from the virtual-APIC page of
APIC-register virtualization. Examples are
0x8fffffffin the flat model and0x00000000in the cluster model. The issue's host read back the model forsuch writes too.
The emulator stores only the model. Its DFR therefore reads back
0xffffffffor0x0fffffff, as it already does for the architectural values,and a save stores that model. As a result, no saved state holds a reserved
model, which an earlier OpenVMM would fail to restore.
OpenVMM documents
user_mode_apicas using the user-mode APIC emulator insteadof WHP's in-hypervisor APIC. With this change, a guest selects the same model
with either APIC. The same rule covers guest writes and restores.
Alternatives considered and not taken:
2026-11-23. It ignores a write of a reserved model, so the APIC keeps its
current model, and it restores a reserved DFR as the flat model. A guest
would then keep the previous model, unlike with WHP's APIC. For example,
after a write of
0x7fffffffin the flat model, WHP's APIC switches to thecluster model and reads back
0x0fffffff, while #5247 stays flat and readsback
0xffffffff. The restore would also need a fallback of its own. The twochanges conflict in
lib.rs:git merge-treeof #5247's heada61c5f421with
8c1204c68conflicts there, and with9805f8984it does not. Theroadmap records that the next chain rebase must keep one of them once #5247
lands.
model, as the APICs of KVM and QEMU do. Logical interrupts would then reach
no APIC, unlike with WHP's APIC, the routing code would need to change, and
saved states could carry reserved models, which earlier OpenVMMs fail to
restore.
savenever produces a reserved model, and failing thewhole restore over one register helps no one.
How was this change validated?
Checks and results:
9805f8984, NVXdev's pin, on alocal Windows 11 x64 host, with no hypervisor needed. With the new test and
without the fix,
cargo nextest run --profile agent -p virt_support_apicfailed
dfr_reserved_model_follows_bit_31withpanicked at vmm_core\virt_support_apic\src\lib.rs:171:14: internal error: entered unreachable code: Unknown DFR value 4026531839(0xefffffff). Twoscratch tests, which are not committed, showed that the other paths panic in
the same way:
0x70at0xfee000e3:Unknown DFR value 1879048192;0x7fffffffalone:Unknown DFR value 2147483647.8c1204c68:cargo nextest run --profile agent -p virt_support_apicran 9 tests, and 9passed. The new test logs one
reserved dfr modelwarning for each reservedvalue.
virt_support_apicall passed:cargo check;cargo clippy --all-targetsonx86_64-pc-windows-msvc;cargo clippy --all-targetswith-D warningsonx86_64-unknown-linux-gnu;cargo doc --no-depswithRUSTDOCFLAGS=-D warnings;cargo xtask fmt --fix, which changed nothing.efe0b08dfwith the commit applied (merged tree666bfe1af).cargo check -p virt_support_apicpassed, and all 9 testspassed.
used OpenVMM's
whpcrate to run guest code of a few bytes in 32-bit flatmode. It ran on the local host: Windows 11 build 26300 on an Intel Core
i9-12900H. The program wrote the DFR, read it back, and exited
through an I/O port. From reset, the unit test's sequence of writes read back
exactly the test's expected values, as tabulated above. The issue's sequence
read back
0x00000000,0x8fffffff, and0x12345678for the writes thatkeep the model. Every switch of the model followed bit 31.
python scripts\openvmm_pin.py check-branch --topic --target origin/dev:passed on
986ca2c7c.python scripts\openvmm_pin.py check-roadmap: passed.python scripts\nvx.py verify: passed.cargo test --locked --manifest-path nvx/Cargo.toml --no-default-features --test openvmm_vectors --test openvmm_cpu_profiles -- --ignored: all 5tests passed, so the vectors, contract versions, excerpts, and CPU profiles
are unchanged.
python scripts\local_gates.py --base origin/dev --run:On the head of this pull request,
test-changes,markdown-links,test-layout,openvmm-vectors, andopenvmm-cpu-profilespassed.openvmm-ci, which runsnvx.py check-openvmm-ci, reports the pin's sixrequired OpenVMM jobs as pending in microsoft/openvmm's run
45386438885.
The
openvmm-cijob of this pull request waits for them.Before the rebase onto
986ca2c7c,nvx-cliran 2,314 tests in 2.9 hourson a heavily shared host. 1 test failed and 8 errored, all on timing in
tests that this change does not touch, since it leaves
scripts/asdevhas it:
The private-network-ingress timeout recurs at
devon the same host.The guest-init test passes alone. CI's
nvx-clijobs run them again.Backend, host OS, host type, and guest: the crate is platform-independent, and
its tests need no hypervisor. They ran on a local Windows 11 x64 host. The WHP
probe ran on WHP's in-hypervisor xAPIC on the same Intel host, with
its own guest code and no NVX guest. No NVX microVM was booted, because NVX's
microVMs never run this emulator.
Left to CI:
microVMs do not run the emulator.
openvmm-cijob checks.nvx-clijobs.Checklist
python3 scripts/check_test_layout.pychecks.python3 scripts/check_test_changes.py --base origin/devlists no changeto an existing test, or a Changes to existing tests section below
explains each one.
.github/copilot-instructions.mdand the skills when a convention orworkflow changes.
nvxupdatesnvx/public-api/withpython3 scripts/public_api.py --update.description says how the change versions or migrates them.
OpenVMM pin
pinned revision are
8c1204c68381d11d90e58c4ee710a879f71fb601, one commit on9805f89843ee01890f19d47d2f04f6460bd22024, the head offeature/microvm/dev. It is not stacked on another pull request, and thispull request targets
devdirectly.feature/microvm/dev.replacement.
mapped tip. The commit applies to upstream main and can go upstream on its
own. The roadmap records the conflict with virt_support_apic: ignore DFR writes with a reserved model openvmm#5247 for the next
chain rebase.
fast-forwarding
feature/microvm/devto the exact pinned revision. OpenVMM'smerge button squashes, which would leave the pin off the branch. Then merge
this pull request.