virt: add irqfd trait and implement for mshv and KVM#3206
Open
will-j-wright wants to merge 1 commit intomicrosoft:mainfrom
Open
virt: add irqfd trait and implement for mshv and KVM#3206will-j-wright wants to merge 1 commit intomicrosoft:mainfrom
will-j-wright wants to merge 1 commit intomicrosoft:mainfrom
Conversation
|
This PR modifies files containing For more on why we check whole files, instead of just diffs, check out the Rustonomicon |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces an irqfd abstraction to the virt layer and wires up backend implementations for mshv and KVM, enabling kernel-assisted MSI injection (needed for VFIO-style interrupt delivery without userspace transitions).
Changes:
- Add new
virt::irqfdmodule definingIrqFd/IrqFdRoutetraits andPartition::irqfd()capability hook. - Implement irqfd + MSI routing for mshv (GSI allocation,
MSHV_IRQFD, atomicMSHV_SET_MSI_ROUTINGupdates). - Implement irqfd support for KVM by wrapping existing
GsiRouteinfrastructure and exposing it viaPartition::irqfd()on x86_64.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| vmm_core/virt/src/lib.rs | Exposes the new irqfd module. |
| vmm_core/virt/src/irqfd.rs | Adds IrqFd / IrqFdRoute traits and semantics for MSI routing + mask/unmask behavior. |
| vmm_core/virt/src/generic.rs | Adds Partition::irqfd() optional capability entrypoint. |
| vmm_core/virt_mshv/src/lib.rs | Stores shared MshvIrqFdState in the partition and exposes it via Partition::irqfd(). |
| vmm_core/virt_mshv/src/irqfd.rs | New mshv irqfd implementation: GSI table + irqfd registration + full routing table push. |
| vmm_core/virt_mshv/Cargo.toml | Adds headervec dependency for variable-length ioctl buffer building. |
| vmm_core/virt_kvm/src/gsi.rs | Adds KvmIrqFdState/KvmIrqFdRoute wrapper implementing the new traits. |
| vmm_core/virt_kvm/src/arch/x86_64/mod.rs | Wires Partition::irqfd() for KVM x86_64 partitions. |
Add irqfd support enabling the kernel to inject MSIs directly into the guest when an eventfd is signaled, without a userspace transition. This is required for VFIO device passthrough where physical device interrupts must be delivered to the guest via the hypervisor's irqfd mechanism. New traits in virt crate: - IrqFd: allocates GSIs and registers eventfds as irqfd routes - IrqFdRoute: updates/clears MSI routing (address/data) per GSI - Partition::irqfd(): returns the irqfd interface if supported mshv implementation (virt_mshv/src/irqfd.rs): - GSI allocation table (2048 slots) - MSHV_IRQFD ioctl for register/unregister eventfds - MSHV_SET_MSI_ROUTING ioctl to push full routing table - Automatic cleanup on route drop (unregister + free GSI) - VmFd changed to Arc<VmFd> for shared ownership KVM implementation (virt_kvm/src/gsi.rs): - KvmIrqFdState wraps existing GsiRoute infrastructure - KvmIrqFdRoute delegates to GsiRoute::enable/disable - Partition::irqfd() wired in x86_64 arch module Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add irqfd support enabling the kernel to inject MSIs directly into the guest when an event is signaled, without a userspace transition. This is required for VFIO device passthrough where physical device interrupts must be delivered to the guest via the hypervisor's irqfd mechanism.
New traits
IrqFd— creates irqfd routes (GSI allocation + event registration)IrqFdRoute— manages per-vector MSI routing, masking, and pending state for PBA supportPartition::irqfd()— returns the irqfd interface if the backend supports itThe event is created by the implementation rather than provided by the caller. This accommodates backends like WHP where the hypervisor owns the event handle (
WHvCreateTrigger).mshv implementation
MSHV_IRQFDioctl for register/unregister eventfdsMSHV_SET_MSI_ROUTINGioctl to push full routing table atomicallyKVM implementation
KvmIrqFdStatewraps existingGsiRouteinfrastructureKvmIrqFdRoutedelegates toGsiRoute::enable/disableTesting
End-to-end with VFIO NVMe passthrough on mshv.