Repository navigation
virtio: Fix PCI MSI-X mapping defaults and live queue routing - #4717
Anatol Belski (weltling) wants to merge 2 commits into
Conversation
|
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.
🟡 Changes recommended
The callback wrapper disables accelerated irqfd delivery for PCI vhost queues, forcing interrupts through userspace proxies.
1 open issue
What changed in this PR
This PR corrects Virtio PCI MSI-X defaults and supports live queue interrupt remapping after DRIVER_OK.
Changes:
- Initialize and reset MSI-X mappings to
NO_VECTOR. - Validate queue vectors and update active interrupt routes.
- Add reset, remapping, and save/restore regression tests.
| File | Description |
|---|---|
| vm/devices/virtio/virtio/src/transport/pci.rs | Updates PCI interrupt defaults, routing, and restoration. |
| vm/devices/virtio/virtio/src/transport/core.rs | Defines and applies the unmapped queue vector default. |
| vm/devices/virtio/virtio/src/tests.rs | Tests mapping defaults and live routing across lifecycle transitions. |
Review effort: Balanced
e600f69 to
1d4480d
Compare
1d4480d to
93081fd
Compare
93081fd to
99391cd
Compare
99391cd to
20b2629
Compare
20b2629 to
18d56c3
Compare
As the mentioned PR has been merged, I rebased on top of main and updated the feature branch. Ready for the next review round. Thanks |
475913f to
d4830b2
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Concurrent remap/reset behavior spans proxy cancellation, shared MSI-X locking, and kernel irqfd routing, requiring platform-owner review and real-backend validation beyond the mock-route tests.
No open issues 🎉
Review effort: Balanced
d4830b2 to
0aba3a4
Compare
There was a problem hiding this comment.
🟡 Changes recommended
A critical Windows race allows the eager noop poll to overwrite the device task’s cancellation waker, potentially leaving the task asleep and blocking subsequent mapping, configuration, and reset commands.
1 open issue
Review effort: Balanced
0aba3a4 to
22532f1
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Live MSI-X rerouting involves kernel IRQFD remapping and cross-platform wait cancellation, requiring backend-aware human review and runtime validation of races that mocked tests do not cover.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
|
John Starks (@jstarks) ping on this one, once you've a chance please. Thanks |
Virtio 1.2 section 4.1.5.1.2.1 requires all queue and configuration change events to be unmapped after reset. Initialize and reset queue and configuration MSI-X vectors to NO_VECTOR instead of vector zero. MMIO does not use the queue MSI-X vector field. Program the configuration vector explicitly in the PCI test setup and verify unmapped readback for every queue on construction and after guest and device resets. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
22532f1 to
4dad357
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Software-backed MSI-X events are not drained before Stop acknowledges completion, so a concurrent save can omit a pending event and lose the final completion notification after device recreation.
1 open issue
Review effort: Balanced
Virtio 1.2 sections 4.1.5.1.2.1 and 4.1.5.3.1 require event mapping, unmapping and suppression of queue interrupts for NO_VECTOR. Allow queue MSI-X mapping and unmapping after DRIVER_OK while preserving queue configuration restrictions. Validate vectors against the MSI-X table and report rejected mappings through NO_VECTOR. Keep a stable event for each queue so vhost backends retain direct irqfd delivery across mapping changes. Update routes when MSI-X table entries or masks change. Preserve pending interrupts on the old vector and drop events received while the queue is unmapped. Cancel software event waits before changing queue mappings so captured signals remain on the old vector. Defer mapping writes until asynchronous cancellation completes. Service software events in the existing virtio device task while commands await completion. Leave vmcore unchanged. Drain pending software events before acknowledging Stop so snapshots preserve final completion notifications. Save pending interrupts and rebuild routes from restored MSI-X state. Reconstruct queue mappings on activation and restore. Unmap them on reset. Preserve INTx and MMIO interrupt behavior. Add regression tests for live routing, stable events, interrupt suppression, shared vectors, queue size protection and lifecycle transitions. Cover direct irqfd delivery and software interrupts while STATUS completion is pending. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
4dad357 to
92c4bc5
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Coupled MSI-X remapping, asynchronous cancellation, and STATUS/reset/save ordering warrant human review and Windows/io_uring and real irqfd runtime validation beyond the available mock tests.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
|
Hey John Starks (@jstarks), I reworked the patch according to the previous discussion. The modifications to vmcore are removed. The fallback software events are handled alongside device commands. No additional worker task is needed anymore. Thanks |


Initialize and reset queue and configuration MSI-X mappings to
NO_VECTOR.Allow queue mapping and unmapping after
DRIVER_OK. Update active interrupt routes alongside register readback and validate vector indices against the MSI-X table. Preserve queue configuration restrictions and INTx and MMIO behavior.This addresses Virtio 1.2 sections 4.1.5.1.2.1 and 4.1.5.3.1.