Skip to content

membacking: map private RAM into the IOMMU#3777

Open
jstarks wants to merge 4 commits into
microsoft:mainfrom
jstarks:dda-anon
Open

membacking: map private RAM into the IOMMU#3777
jstarks wants to merge 4 commits into
microsoft:mainfrom
jstarks:dda-anon

Conversation

@jstarks

@jstarks jstarks commented Jun 18, 2026

Copy link
Copy Markdown
Member

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.

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.
Copilot AI review requested due to automatic review settings June 18, 2026 20:53
@github-actions github-actions Bot added the unsafe Related to unsafe code label Jun 18, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Unsafe Code Detected

This PR modifies files containing unsafe Rust code. Extra scrutiny is required during review.

For more on why we check whole files, instead of just diffs, check out the Rustonomicon

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.

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_fd semantics 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 (including needs_fd rejection).

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.

Comment thread openvmm/membacking/src/region_manager.rs Outdated
Comment thread openvmm/membacking/src/region_manager.rs
Comment thread openvmm/membacking/src/region_manager.rs Outdated
Comment thread openvmm/membacking/src/region_manager.rs Outdated
Copilot AI review requested due to automatic review settings June 18, 2026 22:07

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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread openvmm/membacking/src/mapping_manager/manager.rs
@jstarks jstarks marked this pull request as ready for review June 19, 2026 18:13
@jstarks jstarks requested a review from a team as a code owner June 19, 2026 18:13
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.
@github-actions

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unsafe Related to unsafe code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants