Skip to content

x86: enable guest-managed Intel VT-d on Windows - #5143

Merged
John Starks (jstarks) merged 3 commits into
microsoft:mainfrom
jeffbromberger:user/jbromberger/windows-vtd-dma-control
Nov 23, 2026
Merged

John Starks (jstarks) merged 3 commits into
microsoft:mainfrom
jeffbromberger:user/jbromberger/windows-vtd-dma-control

Conversation

@jeffbromberger

Copy link
Copy Markdown
Contributor

Summary

  • set the DMAR DMA-control platform opt-in flag for Intel VT-d guests
  • mask only the Hyper-V hardware-feature bits that claim DMA and interrupt remapping are hypervisor-managed
  • apply that CPUID override only when an Intel VT-d unit is configured
  • add focused DMAR and CPUID tests

Motivation

When OpenVMM runs on WHP, the underlying Hyper-V CPUID hardware-features leaf can report that DMA and interrupt remapping are already managed by the hypervisor. A Windows guest then does not take control of the emulated VT-d unit. Separately, Windows requires the DMAR DMA-control platform opt-in flag before enabling DMA remapping.

The CPUID override is masked, so all unrelated hardware-feature bits continue to come from the underlying hypervisor.

Validation

  • cargo xtask fmt --fix --only-diffed
  • cargo test -p vmm_core guest_managed_iommu_leaf_clears_only_iommu_bits
  • cargo test -p vmm_core test_dmar_basic
  • cargo clippy -p acpi_spec -p vmm_core -p openvmm_core --all-targets
  • cargo doc --no-deps -p acpi_spec -p vmm_core -p openvmm_core
  • cargo build --release -p openvmm

The resulting current-main binary was boot-smoked with a Windows guest on WHP using emulated NVMe and Intel VT-d. Windows reported the DMAR opt-in, selected native IOMMU policy, configured four-level IOMMU page tables, and started the NVMe controller and disk.

Set the DMAR DMA-control platform opt-in flag and mask the Hyper-V hardware-feature bits that claim DMA and interrupt remapping are hypervisor-managed when Intel VT-d is configured.

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

Copilot-Session: bec97463-419f-4fb3-a9ae-e8d73e3257dc
@jeffbromberger
jeffbromberger requested a review from a team as a code owner November 18, 2026 16:09
Copilot AI balanced review requested due to automatic review settings November 18, 2026 16:09

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 remain for the ACPI and CPUID changes supporting guest-managed Intel VT-d.

No open issues 🎉

What changed in this PR

This PR enables Windows guests to manage emulated Intel VT-d by updating OpenVMM’s ACPI and Hyper-V CPUID reporting.

Changes:

  • Set the DMAR DMA-control platform opt-in flag.
  • Clear only the CPUID bits indicating hypervisor-managed DMA and interrupt remapping when Intel VT-d is configured, preserving unrelated bits.
  • Add a focused CPUID masking test and update the DMAR flag assertion.
File Description
vmm_core/​src/​cpuid/​mod.rs Add the masked CPUID override and its unit test.
vmm_core/​src/​acpi_builder.rs Set the DMAR opt-in flag and update the existing test.
vm/​acpi_spec/​src/​dmar.rs Define the DMA-control platform opt-in flag constant.
openvmm/​openvmm_core/​src/​worker/​dispatch.rs Apply the CPUID override when Intel VT-d is configured.

Review effort: Balanced

Use the simplified complement expression expected by clippy::identity-op.

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

Copilot-Session: bec97463-419f-4fb3-a9ae-e8d73e3257dc
Copilot AI balanced review requested due to automatic review settings November 18, 2026 18:16

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 remain for the changes enabling Windows guests to manage the emulated Intel VT-d unit.

No open issues 🎉

Review effort: Balanced

@chris-oo

Copy link
Copy Markdown
Member

is there a way we can test this in a vmm_test (nested one?)

@jeffbromberger

Copy link
Copy Markdown
Contributor Author

CI follow-up: the original Linux Clippy failure was fixed in 9a25a35, and the replacement quick check now passes. The three remaining failed VMM jobs appear unrelated to this change: both Windows AMD jobs failed downloading x64-openhcl-igvm with GitHub HTTP 503 (egress account limit), and the Linux AMD KVM job timed out in the virtio-net KDNET Windows test after 600 seconds; that test's logged VM config has iommu: None, so the IntelVtd-only CPUID override is not applied. I do not have upstream permission to rerun failed jobs.

@jeffbromberger

jeffbromberger commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Chris Oo (@chris-oo)

I prototyped this in vmm_test, first by strengthening the existing Windows nested test and then with a focused Windows Server 2025 PCIe-NVMe/VT-d test. Both versions inspected OpenVMM state for active translation, interrupt remapping, queued invalidation, a nonzero root table, and no faults.

Unfortunately, the available Windows test images do not distinguish this change:

  • The existing nested Server 2022 test passed with the assertions, but also passed when I suppressed the new CPUID override and when I removed the DMAR DMA-control opt-in.
  • A focused Server 2025 (26100) test also passed with the PR code, but still passed when the DMAR opt-in was removed.

So those images program VT-d without enforcing the newer Windows platform-opt-in policy. Landing either test would be green before and after this PR and would provide false regression confidence.

The current coverage is therefore:

  • unit tests for the exact DMAR flag (0x05) and CPUID mask semantics;
  • the existing x64-Windows-Intel nested test, which passed in this PR's CI;
  • manual end-to-end validation with a current Windows build that does enforce the policy (translation_enabled=true, nonzero root table, NVMe healthy).

I did not keep the non-discriminating test changes. If there is a newer Windows artifact available to vmm_tests that enforces the DMA-control opt-in policy, I can wire the state assertions to that image.

@chris-oo

Copy link
Copy Markdown
Member

maybe perhaps now i'm wondering what it woudl take to onboard a test for this, does it need a new windows image?

Comment thread vmm_core/src/cpuid/mod.rs Outdated
use x86defs::cpuid::CpuidFunction;

// EAX bits 4 and 5 report hypervisor-managed DMA and interrupt remapping.
const HYPERV_HARDWARE_FEATURES_IOMMU_IN_USE_MASK: u32 = (1 << 4) | (1 << 5);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please derive this mask from hvdef::HvHardwareFeatures's dma_remapping_in_use and interrupt_remapping_in_use fields instead of hard-coding their bit positions here. Those fields already define bits 4 and 5 in vm/hv1/hvdef/src/lib.rs; the guest-managed-IOMMU override policy can remain in vmm_core.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in c83621f. The mask is now derived from the named dma_remapping_in_use and interrupt_remapping_in_use fields on HvHardwareFeatures, while the override policy remains in vmm_core. The existing test independently checks the architectural 0x30 EAX mask and verifies that unrelated bits and registers are preserved.

@jstarks John Starks (jstarks) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See comments

Copilot AI balanced review requested due to automatic review settings November 23, 2026 17:55

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 changes enabling Windows guests to manage emulated Intel VT-d.

No open issues 🎉

Review effort: Balanced

Use the canonical DMA and interrupt remapping fields while retaining the
masked override policy in vmm_core. Assert the architectural mask
independently in the existing behavioral test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ae062255-030e-4c06-861c-055fa337171c
@jeffbromberger
jeffbromberger force-pushed the user/jbromberger/windows-vtd-dma-control branch from 70157be to c83621f Compare November 23, 2026 18:36
@jstarks
John Starks (jstarks) merged commit 5d6ab1c into microsoft:main Nov 23, 2026
108 of 109 checks passed
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.

4 participants