Registry Mirror
Skip to content

Conversation

@ppenna

@ppenna Pedro Henrique Penna (ppenna) commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1472

What does this pull request change?

It pins microsoft/openvmm#5277, which makes OpenVMM's WHP backend restore the activity of a VP whose APIC the VMM emulates without writing the hypervisor's internal activity state, which WHP denies in that mode. With --hypervisor whp:user_mode_apic, or no_enlightenments with --hv, WhpProcessor::restore_activity in vmm_core/virt_whp/src/apic.rs wrote all four Hyper-V registers of vp::Activity, InternalActivityState among them, so every restore of such a VP's activity failed with Access to the specified object was denied, a snapshot's restore included, and every INIT to an AP aborted OpenVMM, since inject_init unwraps the error of x86_init. It now writes only the pending interruption, the interrupt state, and the pending event there; the VMM keeps the VP's halt and its wait for a SIPI itself, as before. The branch of the hypervisor's APIC is unchanged.

  • virt_whp: write no internal activity state with the user-mode APIC (fa239c823) changes the user-mode APIC's branch of restore_activity, and adds four WHP contract tests in a new module of virt_backend_tests, vmm_tests/vmm_tests/tests/virt_backend_tests/user_mode_apic.rs, with a new backend whose APIC the VMM emulates, whp_user_mode_apic, in native.rs, a fixture of two VPs (Fixture::build_all and Fixture::with_vps) in fixture.rs, and a paragraph in the Guide's page on the backend contract tests, Guide/src/dev_guide/tests/vmm.md.

Commits:

This pull request is stacked on the pull request of #1379, #2116 (branch agents/issue-1379-intel-l3-sharing), which pins microsoft/openvmm#5276; review only its last two commits. Start with the user-mode APIC's branch of restore_activity in microsoft/openvmm#5277's last commit, then user_mode_apic.rs.

Left out: nothing that nvx runs changes. nvx passes only the backend's name to --hypervisor and never selects the user-mode APIC, which the WHP time ABI refuses (virt_whp::time_abi::validate_partition). Two other limitations of WHP's activity, which probes for the tests met and this change does not touch, remain: a restore of an activity whose pending interruption is an NMI fails on WHP with either APIC, and with the hypervisor's APIC, a pending interrupt restored with an interrupt shadow while RFLAGS.IF is clear reads back without the interrupt. No version is created or bumped: no ABI, machine-contract, time-ABI, snapshot, manifest, saved-state, or protocol version, in NVX or in OpenVMM, and no saved-state, snapshot, protocol, or on-disk format changes.

Why is this change needed?

With the user-mode APIC, every multiprocessor guest aborted OpenVMM when it sent its APs the INIT that starts them, and no snapshot could be restored, not even an unchanged save of a VP that never ran (#1472).

Root cause: with the APIC emulated in the VMM, WHP's partition has LocalApicEmulationMode None, and WHP then denies a write of InternalActivityState with HV_STATUS_ACCESS_DENIED (0xC0350006), even of the running state that the register already holds. Upstream's branch of restore_activity for the user-mode APIC sets the VMM's halt and wait-for-SIPI state, and then writes the whole vp::Activity, running, through set_register_state, so the write failed every time. x86_init, which makes an AP wait for a SIPI through set_activity (vmm_core/virt/src/x86/vp.rs), reached it for every INIT, and inject_init unwraps its error; hv1_emulator's set_x86_vp_context, which starts a VP for HvCallStartVirtualProcessor, failed the same way. The code is upstream's since OpenVMM's first commit; upstream main, 8d4e03132, still has it.

Rejected alternatives:

  • The issue's patch, as it is: the same change, but with debug_assert_eq! on the order of the activity's registers. OpenVMM's instructions prefer assert! for internal invariants, so the change asserts it in every build.
  • Skipping the write of InternalActivityState only when its value does not change: WHP denies even the unchanged value, which is always running here, so the user-mode APIC's branch never needs the register.
  • The issue's test file, vmm_core/virt_whp/tests/vp_state.rs: it would run in OpenVMM's unit-test jobs, whose hosts lack WHP, so the tests went into virt_backend_tests, which OpenVMM's CI runs on its WHP hosts, Intel and AMD, with a backend of their own, so that the existing WHP cases do not run twice.

How was this change validated?

Checks and results:

Check Result
The four new cases of virt_backend_tests (user_mode_apic::whp::restores_the_activity_in_each_state, restores_a_new_vp_into_a_new_partition, restores_a_new_vp_into_a_new_partition_hv1, an_init_makes_an_ap_wait_for_a_sipi), on WHP, at d44a113be and at acfaa5199 without the fix All four fail: the first three with failed to set registers: Access to the specified object was denied. (os error -1070268410), two of them at phase restore "activity", and the INIT case with the panic in inject_init that the issue reports (apic.rs:764, apic.rs:775 at acfaa5199)
The same cases with the fix, on d44a113be and rebased on acfaa5199 Pass
OpenVMM: all WHP cases of virt_backend_tests, one process each, on fa239c823 31 passed (the four new cases, and microsoft/openvmm#5272's suspend::whp::user_mode_apic_refuses_an_idle_vp_hv1 among the others), 10 ignored for capabilities that the host lacks, 0 failed
OpenVMM: cargo nextest run --profile agent -p virt_whp --run-ignored all 64 passed, before and after the rebase
OpenVMM: cargo clippy --all-targets for virt_whp and vmm_tests, cargo clippy --target x86_64-unknown-linux-gnu -p vmm_tests --test virt_backend_tests, cargo doc --no-deps -p virt_whp -p vmm_tests, and cargo xtask fmt --fix Clean, but for the LNK4199 linker messages that every linked artifact gets on this machine; after the rebase, the clippy of virt_whp and of virt_backend_tests, the docs, and fmt again
Probes of WHP, not committed, that chose the tests' activities With the user-mode APIC, WHP refuses a pending interrupt as the interruption while RFLAGS.IF is clear, as in a new VP, with HV_STATUS_INVALID_VP_STATE, so the tests restore exceptions, which it holds in every state
A code-review subagent's review of the OpenVMM commit No findings
cargo test --locked --manifest-path nvx/Cargo.toml --no-default-features --test openvmm_vectors -- --ignored 4 passed
cargo test --locked --manifest-path nvx/Cargo.toml --no-default-features --test openvmm_cpu_profiles -- --ignored 1 passed
python scripts/openvmm_pin.py source fa239c823b14bcd88abed9db7d241c89a578025b --pr 5277 Good signature; the pull request's head
python scripts/openvmm_pin.py check-branch --topic --target origin/agents/issue-1379-intel-l3-sharing, check-roadmap, and check-roadmap --worktree Pass
python scripts/nvx.py verify and python scripts/check_markdown_links.py Pass
python scripts/local_gates.py --base origin/agents/issue-1379-intel-l3-sharing --only test-changes markdown-links test-layout openvmm-vectors openvmm-cpu-profiles openvmm-ci --run --keep-going All six pass
nvx-cli gate, python scripts/local_gates.py --base origin/dev --only nvx-cli --run, on scripts that this branch and its base do not change Stopped unfinished after two hours, with the machine at 100% CPU under other builds; the same commands passed in this head's CI run 45538860462, as NVX CLI / Windows and NVX CLI / Linux
python scripts/nvx.py check-openvmm-ci --revision fa239c823b14bcd88abed9db7d241c89a578025b, through the openvmm-ci gate Passed: OpenVMM's run 45525942339 of the pin passed unit tests [x64-linux], unit tests [x64-windows], run vmm-tests [x64-linux-amd-kvm], run vmm-tests [x64-linux-intel-mshv], run vmm-tests [x64-windows-intel], and run vmm-tests [x64-windows-amd]; the last two ran the four new cases, which passed on both the Intel and the AMD host

Backend, host OS, host type, and guest: WHP on Windows 11 Enterprise build 26300, a local workstation with an Intel Core i9-12900H, without a guest: the contract tests set the VPs' state through the virt interfaces and run no guest code. No microVM ran, since nothing that nvx runs changes.

NVX's CI run 45538860462 of this head passed, Required status check, OpenVMM CI of the pinned revision, and the microVM tests on KVM, MSHV, and WHP included.

Left to CI: WHP on a virtual-machine host, which NVX's CI covered (above); KVM and MSHV, whose cases of virt_backend_tests build on the changed fixture, which OpenVMM's CI ran on its KVM and MSHV hosts (above), and which this workstation checked only with a Linux cargo clippy, since nvx-kvm-test is unreachable.

Checklist

  • Tests cover the new or fixed behavior, in the layout that
    python3 scripts/check_test_layout.py checks.
  • python3 scripts/check_test_changes.py --base origin/dev lists no change
    to an existing test, or a Changes to existing tests section below
    explains each one.
  • The documentation that the change affects is updated, including
    .github/copilot-instructions.md and the skills when a convention or
    workflow changes.
  • A change to the public API of nvx updates nvx/public-api/ with
    python3 scripts/public_api.py --update.
  • Snapshots, protocols, and on-disk formats stay compatible, or the
    description says how the change versions or migrates them.

Changes to existing tests

None: python scripts/check_test_changes.py --base origin/agents/issue-1379-intel-l3-sharing lists no change to an existing test of NVX. In OpenVMM, the commit changes no existing case: it splits the fixture's build into build_all, which builds a partition of the fixture's VPs, and build, which keeps its check of one VP and returns the same as before, has with_ram call a function that also takes the number of VPs, with one as before, and adds a backend and a module, which the existing cases do not use.

OpenVMM pin

With WHP's user-mode APIC, which --hypervisor whp:user_mode_apic
selects, as does no_enlightenments with --hv, OpenVMM's
restore_activity wrote the four Hyper-V registers of the activity, the
internal activity state among them, and WHP denies a write of that
register when it does not emulate the APIC, even of the running state
that it holds (#1472). So every restore of such a VP's activity failed,
a snapshot's included, and an INIT to an AP, which every multiprocessor
guest sends, aborted the VMM. NVX never selects the user-mode APIC,
which the WHP time ABI refuses, so nothing that NVX runs changes.

Pin fa239c823b14bcd88abed9db7d241c89a578025b, the head of
microsoft/openvmm#5277, one commit on acfaa5199, the head of
microsoft/openvmm#5276, which NVX pins below this commit:

- virt_whp: write no internal activity state with the user-mode APIC.
  restore_activity writes only the pending interruption, the interrupt
  state, and the pending event of a VP whose APIC the VMM emulates, and
  the VMM keeps the VP's halt and its wait for a SIPI itself, as
  before. Four new WHP contract tests of virt_backend_tests restore an
  activity in each state that the VMM keeps, restore the save of a new
  VP into a new partition, with Hv1 and without it, and send an AP an
  INIT and then a SIPI.

No saved state, protocol, ABI, or format, and no version of any of them,
changes. NVX needs no coordinated change: the protocol vectors, the
source excerpts, the contract versions, and the CPU profiles that nvx
copies from OpenVMM match the revision's.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…enVMM roadmap

Map position 383, the commit of microsoft/openvmm#5277, which NVX now
pins at fa239c823, 257 commits past the mapped tip, on acfaa5199,
position 382, the head of microsoft/openvmm#5276:

- 383, virt_whp: write no internal activity state with the user-mode
  APIC. restore_activity writes only the pending interruption, the
  interrupt state, and the pending event of a VP whose APIC the VMM
  emulates, since WHP then denies a write of the internal activity
  state, which failed every restore of such a VP's activity and aborted
  the VMM at an INIT to an AP. It adds WHP contract tests of
  virt_backend_tests with a backend whose APIC the VMM emulates, and a
  fixture of two VPs for them.

Positions 138, 143, 287, 288, 291, 293, 297, 299, 300, 305, and 379,
which no PR has yet, also change apic.rs. PR05's position 008, PR12's
position 036, PR17's position 072, and positions without a PR also
change the fixture of virt_backend_tests, PR05's position 008 and
positions without a PR its module list and its backends, and PR01's
position 002, PR05's position 007, and positions without a PR the
Guide's VMM-test page. The commit changes no line that a mapped PR
adds: the write of the activity is upstream's, and in the fixture it
changes only upstream's lines and position 301's. So it is no fixup,
and stays unassigned. Of positions 369-382, positions 373, 379, and 380
change other lines of its files. Replaying it on upstream main,
8d4e03132, conflicts in apic.rs, whose Activity lacks the fields of
positions 287 and 291, in the fixture and the module list of
virt_backend_tests, which lack the chain's mapped RAM and modules, and
in the Guide's VMM-test page, so it cannot go upstream on its own.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the OpenVMM pin update addressing user-mode APIC INIT failures and activity restoration.

No open issues 🎉

What changed in this PR

This PR pins OpenVMM’s fix for INIT failures and activity restoration with the user-mode APIC, addressing #1472. It also records the fix in NVX’s upstream roadmap; NVX’s normal backend selection and saved-state formats remain unchanged.

Changes:

  • Advances the OpenVMM pin to fa239c823, which avoids writing WHP’s internal activity state with the user-mode APIC.
  • Maps chain position 383 and updates the roadmap’s counts, dependency notes, and upstream applicability analysis.
File Description
doc/​openvmm-upstream-roadmap.md Records the new pin and documents position 383’s fix, tests, and upstream dependencies.

Review effort: Balanced

Base automatically changed from agents/issue-1379-intel-l3-sharing to dev November 25, 2026 04:56
@ppenna
Pedro Henrique Penna (ppenna) added this pull request to the merge queue Nov 25, 2026
Merged via the queue into dev with commit db09f30 Nov 25, 2026
51 checks passed
@ppenna
Pedro Henrique Penna (ppenna) deleted the agents/issue-1472-whp-user-apic-activity branch November 25, 2026 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openvmm: in virt_whp, with the user-mode APIC, an INIT IPI aborts the VMM and snapshot restore always fails

2 participants