Skip to content

virt_support_apic: ignore DFR writes with a reserved model - #5247

Open
Sunil Muthuswamy (sunilmut) wants to merge 2 commits into
microsoft:mainfrom
sunilmut:user/sunilmut/apic-dfr-reserved-model
Open

Sunil Muthuswamy (sunilmut) wants to merge 2 commits into
microsoft:mainfrom
sunilmut:user/sunilmut/apic-dfr-reserved-model

Conversation

@sunilmut

Copy link
Copy Markdown
Member

cluster_mode() accepted only the flat (0xF) and cluster (0x0) DFR model
values and hit unreachable! for the other 14. The DFR value comes straight
from a guest xAPIC MMIO write, so a VTL0 guest could panic OpenHCL on SNP/TDX,
or OpenVMM using the WHP software APIC, with one write to 0xFEE000E0 (or a
one-byte write to 0xFEE000E3). Restoring a saved state with such a DFR
panicked the same way.

The SDM reserves those model values. This change:

  • Ignores a guest DFR write with a reserved model and logs a rate-limited
    warning, so the APIC keeps its current mode.
  • Restores a reserved model as flat, the architectural reset value, with a
    rate-limited warning. save() never produces such a value, so this only
    affects malformed saved state, and it avoids failing the whole restore over
    one register.

Adds dfr_with_reserved_model_is_ignored, which covers reserved writes in flat
and cluster mode (full and high-byte writes) and the restore fallback. It fails
without the fix.

@sunilmut
Sunil Muthuswamy (sunilmut) requested a review from a team as a code owner November 23, 2026 17:17
Copilot AI balanced review requested due to automatic review settings November 23, 2026 17:17

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 recorded for the reserved-DFR handling changes.

No open issues 🎉

What changed in this PR

This PR hardens the software APIC against reserved DFR model values, preventing guest writes or malformed saved state from panicking OpenVMM or OpenHCL.

Changes:

  • Ignores reserved-model DFR writes, preserving the current mode and logging a rate-limited warning.
  • Falls back to flat mode when restoring a reserved DFR model.
  • Adds regression coverage for full-register and high-byte writes in both modes, plus restore fallback.
File Description
vmm_core/​virt_support_apic/​src/​lib.rs Handles reserved DFR models without panicking and adds regression tests.

Review effort: Balanced

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>
A guest DFR write with a model other than flat or cluster hit
unreachable!, letting a VTL0 guest panic OpenHCL (or OpenVMM on WHP)
with a single xAPIC MMIO write. Ignore such writes with a rate-limited
warning, and restore a saved DFR with a reserved model as flat.
@sunilmut
Sunil Muthuswamy (sunilmut) force-pushed the user/sunilmut/apic-dfr-reserved-model branch from a61c5f4 to 041e195 Compare November 26, 2026 21:49
Copilot AI balanced review requested due to automatic review settings November 26, 2026 21:49
@github-actions github-actions Bot added the unsafe Related to unsafe code label Nov 26, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Unsafe Code Detected

This PR modifies files containing unsafe Rust code. Extra scrutiny is required during review.

For more on why we check whole files, instead of just diffs, check out the Rustonomicon

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.

🔵 Needs a closer look

Security-sensitive VTL0 input handling requires human review of reserved-DFR and malformed-state restore policies, especially given the source-only review without backend runtime validation.

No open issues 🎉

Review effort: Balanced

@sunilmut

Copy link
Copy Markdown
Member Author

Hi John Starks (@jstarks), thanks for your earlier approval. We have now rebased this PR onto main. Could you please take another look at the rebased changes when you have a chance? Thanks!

Copilot AI balanced review requested due to automatic review settings November 26, 2026 22:54

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.

🔵 Needs a closer look

Changes to guest-controlled APIC handling at OpenHCL’s VTL0 trust boundary require human security review, and SNP/TDX and WHP guest-path behavior was not runtime-validated.

No open issues 🎉

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unsafe Related to unsafe code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants