Skip to content

Commit bbd0bb4

Browse files
committed
DESIGN: Document I/O virtual memory
Document in DESIGN.md how I/O virtual memory is handled. Signed-off-by: Hanna Czenczek <[email protected]>
1 parent af00ca9 commit bbd0bb4

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

DESIGN.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
## Objectives
44

5-
- Provide a set of traits for accessing and configuring the physical memory of
6-
a virtual machine.
5+
- Provide a set of traits for accessing and configuring the physical and/or
6+
I/O virtual memory of a virtual machine.
77
- Provide a clean abstraction of the VM memory such that rust-vmm components
88
can use it without depending on the implementation details specific to
99
different VMMs.
@@ -122,6 +122,29 @@ let buf = &mut [0u8; 5];
122122
let result = guest_memory_mmap.write(buf, addr);
123123
```
124124

125+
### I/O Virtual Address Space
126+
127+
When using an IOMMU, there no longer is direct access to the guest (physical)
128+
address space, but instead only to I/O virtual address space. In this case:
129+
130+
- `IoMemory` replaces `GuestMemory`: It requires specifying the required access
131+
permissions (which are relevant for virtual memory). It also removes
132+
interfaces that imply a mostly linear memory layout, because virtual memory is
133+
fragmented into many pages instead of few (large) memory regions.
134+
- Any `IoMemory` still has a `GuestMemory` inside as the underlying address
135+
space, but if an IOMMU is used, that will generally not be guest physical
136+
address space. With vhost-user, for example, it will be the VMM’s user
137+
address space instead.
138+
- `IommuMemory` as our only actually IOMMU-supporting `IoMemory`
139+
implementation uses an `Iommu` object to translate I/O virtual addresses
140+
(IOVAs) into VMM user addresses (VUAs), which are then passed to the inner
141+
`GuestMemory` implementation (like `GuestMemoryMmap`).
142+
- `GuestAddress` (for compatibility) refers to an address in any of these
143+
address spaces:
144+
- Guest physical addresses (GPAs) when no IOMMU is used,
145+
- I/O virtual addresses (IOVAs),
146+
- VMM user addresses (VUAs).
147+
125148
### Utilities and Helpers
126149

127150
The following utilities and helper traits/macros are imported from the
@@ -143,7 +166,8 @@ with minor changes:
143166
- `Address` inherits `AddressValue`
144167
- `GuestMemoryRegion` inherits `Bytes<MemoryRegionAddress, E = Error>`. The
145168
`Bytes` trait must be implemented.
146-
- `GuestMemory` has a generic implementation of `Bytes<GuestAddress>`.
169+
- `GuestMemory` has a generic implementation of `IoMemory`
170+
- `IoMemory` has a generic implementation of `Bytes<GuestAddress>`.
147171

148172
**Types**:
149173

0 commit comments

Comments
 (0)