membacking: map private RAM into the IOMMU#3777
Open
jstarks wants to merge 4 commits into
Open
Conversation
Private anonymous guest RAM was not represented in region mappings, so it was never programmed into DMA targets. The private-memory builder committed pages directly into the eager VaMapper and skipped add_mapping, while IOMMU mappings are driven from region mappings. As a result, --private-memory with an assigned device caused DMA into private RAM to fault in the IOMMU. Register private RAM as a region mapping without a backing fd. These mappings skip the mapping-manager mmap because the pages are already committed, but still provide the host VA used by DMA targets. This lets private RAM flow through the same DMA mapping machinery as shared RAM.
|
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 fixes assigned-device DMA into --private-memory by representing private/anonymous guest RAM as a region mapping (with no backing fd) so it flows through the existing region-driven DMA/IOMMU programming path.
Changes:
- Make DMA mapping requests always carry a host VA, and allow mappings to omit a backing
Mappable(mappable: None) for private RAM. - Update VFIO type1 and iommufd DMA mapper registration to reflect the new
needs_fdsemantics and rely on always-present host VAs. - Register backing-less mappings for private RAM in
GuestMemoryBuilder, and add coverage for the replay + live mapping paths (includingneeds_fdrejection).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| vm/devices/pci/vfio_assigned_device/src/manager.rs | Updates VFIO/iommufd DMA target plumbing to the new DMA-mapper registration semantics and always-present host VA. |
| openvmm/membacking/src/region_manager.rs | Core change: backing-less region mappings + needs_fd gating, always-present host_va, and tests for private-RAM DMA mapping behavior. |
| openvmm/membacking/src/memory_manager/mod.rs | Adds backing-less region mappings for private RAM so private pages participate in region-driven DMA/IOMMU programming. |
| openvmm/membacking/src/memory_manager/device_memory.rs | Adjusts device-memory mapping calls to the updated add_mapping(Option<Mappable>) API. |
The RamBacking::transparent_hugepages field is now read on all platforms when constructing MappingBacking::Private, so the non-Linux expect(dead_code) attribute is unfulfilled and breaks the Windows doc build.
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.
Private anonymous guest RAM was not represented in region mappings, so it was never programmed into DMA targets. The private-memory builder committed pages directly into the eager VaMapper and skipped add_mapping, while IOMMU mappings are driven from region mappings. As a result, --private-memory with an assigned device caused DMA into private RAM to fault in the IOMMU.
Register private RAM as a region mapping without a backing fd. These mappings skip the mapping-manager mmap because the pages are already committed, but still provide the host VA used by DMA targets. This lets private RAM flow through the same DMA mapping machinery as shared RAM.