2
2
3
3
## Objectives
4
4
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.
7
7
- Provide a clean abstraction of the VM memory such that rust-vmm components
8
8
can use it without depending on the implementation details specific to
9
9
different VMMs.
@@ -122,6 +122,29 @@ let buf = &mut [0u8; 5];
122
122
let result = guest_memory_mmap . write (buf , addr );
123
123
```
124
124
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
+
125
148
### Utilities and Helpers
126
149
127
150
The following utilities and helper traits/macros are imported from the
@@ -143,7 +166,8 @@ with minor changes:
143
166
- ` Address ` inherits ` AddressValue `
144
167
- ` GuestMemoryRegion ` inherits ` Bytes<MemoryRegionAddress, E = Error> ` . The
145
168
` 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> ` .
147
171
148
172
** Types** :
149
173
0 commit comments