Repository navigation
virt_whp: reset the assigned PCI device - #5076
Robert Nowotny (bitranox) wants to merge 2 commits into
Conversation
AssignedPciDevice::reset was a TODO, so a VM reset left the device's MMIO mapped and its command register, power state and BARs as the guest had set them. Clear the command register through the normal config write path, which unmaps MMIO, then put the power state and BARs back to their initial values. disable_mmio() never cleared mmio_enabled, so once MMIO had been turned off, enable_mmio() returned early and never mapped it again. Clear the flag.
|
This PR modifies files containing For more on why we check whole files, instead of just diffs, check out the Rustonomicon |
There was a problem hiding this comment.
🔵 Needs a closer look
The reset changes physical-device power state and WHP MMIO mappings, but Windows assigned-device hardware validation is still needed to verify BAR reprogramming, D0 transition, and MMIO re-enablement.
No open issues 🎉
What changed in this PR
Implements assigned PCI device reset in WHP, supporting #5075’s change to let device reset handle cleanup when VPCI channel close skips a device.
Changes:
- Clears the command register through the PCI configuration write path to disable MMIO, then restores power state and BARs to their initial values.
- Clears
mmio_enabledafter unmapping so MMIO can be enabled again.
| File | Description |
|---|---|
vmm_core/virt_whp/src/device.rs |
Implements reset cleanup and fixes MMIO enable-state tracking. |
Review effort: Balanced
Replace the raw power state numbers, the 0b11 mask and the power management capability id in the assigned device with named constants.
There was a problem hiding this comment.
🔵 Needs a closer look
WHP power transitions and MMIO teardown/remapping require reset/re-enable validation on a Windows host with an assigned PCI device, as cross-compilation alone does not verify hardware recovery.
No open issues 🎉
Review effort: Balanced
AssignedPciDevice::resetwas a TODO, so after a VM reset the device kept its MMIO mapped and its command register, power state and BARs as the guest had left them. The reset now clears the command register throughpci_cfg_write, which unmaps MMIO and, on a device without a power management capability, moves it to D3. It then puts the power state and BARs back to whatnew()sets.disable_mmio()never setmmio_enabledback to false, so once MMIO had been turned off,enable_mmio()returned early and never mapped the BARs again. The reset above depends on that, and so does any guest that turns MMIO off and on again.In #5075 the VPCI channel's close skips a device whose state unit is resetting it, and leaves turning the device off to that reset. This is the third device that PR names.
Testing
cargo fmt, andcargo checkpluscargo clippy -p virt_whp --target x86_64-pc-windows-msvc --all-targets -- -D warnings, cross-compiled from Linux.