Commit e04a8ec
authored
vfio_assigned_device: dynamic IOMMU mapping for P2P DMA (#3367)
VFIO device assignment needs peer-to-peer DMA between assigned devices —
one device must be able to DMA into another device's BAR. The old VFIO
container manager snapshot guest RAM at creation time via
GuestMemory::full_mapping() and programmed a static set of IOMMU
identity mappings, so device BARs (which are mapped dynamically as the
guest configures them) were never visible to the IOMMU.
Introduce a DmaTarget trait in the region manager that receives
incremental sub-mapping events (map_dma / unmap_dma) as regions are
enabled, disabled, or modified. VFIO containers register themselves as
DMA mapper consumers via a new DmaMapperClient, and the region manager
replays all existing active sub-mappings on registration, then sends
live updates as the memory map evolves. This means device BAR mappings
are now programmed into every VFIO container's IOMMU as they appear,
enabling P2P DMA between assigned devices.
The region manager maintains the VaMapper lifecycle for backends that
need host VAs (VFIO type1's pin_user_pages), controlled by a needs_va
flag at registration. This also sets up the abstraction for future
iommufd support, which maps from fd+offset directly and won't need a
VaMapper at all.1 parent 29b0996 commit e04a8ec
12 files changed
Lines changed: 654 additions & 88 deletions
File tree
- openvmm
- membacking/src
- mapping_manager
- memory_manager
- openvmm_core/src/worker
- vm/devices
- pci/vfio_assigned_device
- src
- user_driver/vfio_sys/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8704 | 8704 | | |
8705 | 8705 | | |
8706 | 8706 | | |
| 8707 | + | |
8707 | 8708 | | |
8708 | 8709 | | |
8709 | 8710 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| |||
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
47 | 51 | | |
48 | 52 | | |
49 | 53 | | |
| |||
259 | 263 | | |
260 | 264 | | |
261 | 265 | | |
| 266 | + | |
262 | 267 | | |
263 | 268 | | |
264 | 269 | | |
265 | 270 | | |
| 271 | + | |
266 | 272 | | |
267 | 273 | | |
268 | 274 | | |
269 | 275 | | |
| 276 | + | |
270 | 277 | | |
271 | 278 | | |
272 | 279 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
162 | 165 | | |
163 | 166 | | |
164 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
458 | 463 | | |
459 | 464 | | |
460 | 465 | | |
| |||
0 commit comments