Skip to content

Commit a6cd7cd

Browse files
committed
Emphasize GuestMemory more in the documentation
After the rename, the primary interface to vm-memory is almost completely absent in DESIGN.md. Give it more importance and remove some details of GuestMemoryBackend that are now obsolete. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 5972e82 commit a6cd7cd

File tree

2 files changed

+33
-21
lines changed

2 files changed

+33
-21
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
## Upcoming version
44

5+
### Changed
6+
7+
This release includes a major change to the `vm-memory` API in order to support
8+
memory access permissions. The previous `GuestMemory` trait is now renamed
9+
to `GuestMemoryBackend`, and `GuestMemory` has a completely new definition.
10+
However, common interfaces such as `GuestAddressSpace` and `Bytes` remain on
11+
`GuestMemory`; therefore, all callers that just use the `Bytes` interface
12+
remain completely unchanged.
13+
14+
- \[[#362](https://github.com/rust-vmm/vm-memory/pull/360)\] Rename `GuestMemory` to `GuestMemoryBackend`, `IoMemory` to `GuestMemoryBackend`
15+
516
### Added
617

718
- \[[#327](https://github.com/rust-vmm/vm-memory/pull/327)\] I/O virtual memory support via `IoMemory`, `IommuMemory`, and `Iommu`/`Iotlb`

DESIGN.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,13 @@ of the VM using the following traits:
7676
- `GuestMemoryRegion`: represents a continuous region of the VM memory.
7777
- `GuestMemoryBackend`: represents a collection of `GuestMemoryRegion` objects. The
7878
main responsibilities of the `GuestMemoryBackend` trait are:
79-
- hide the detail of accessing physical addresses (for example complex
80-
hierarchical structures).
8179
- map an address request to a `GuestMemoryRegion` object and relay the
8280
request to it.
8381
- handle cases where an access request is spanning two or more
8482
`GuestMemoryRegion` objects.
83+
- `GuestMemory`: the primary external interface; it adds permission checks
84+
to `GuestMemoryBackend`, and is more suited to implementations that
85+
have a potentially very large set of non-continuous mappings.
8586

8687
The VM memory consumers should only rely on traits and structs defined here to
8788
access VM's physical memory and not on the implementation of the traits.
@@ -125,25 +126,25 @@ let result = guest_memory_mmap.write(buf, addr);
125126
### I/O Virtual Address Space
126127

127128
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-
- `GuestMemory` replaces `GuestMemoryBackend`: 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 `GuestMemory` still has a `GuestMemoryBackend` 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 `GuestMemory`
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-
`GuestMemoryBackend` 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).
129+
address space, but instead only to I/O virtual address space. In order to
130+
support this usecase, `GuestMemory` (unlike `GuestMemoryBackend`) requires
131+
specifying the required access permissions (which are relevant for virtual
132+
memory).
133+
134+
`GuestMemory` can still use `GuestMemoryBackend` inside as the underlying
135+
address space, but if an IOMMU is used, that may not be the guest
136+
physical address space. With vhost-user, for example, it will be the
137+
VMM’s user address space instead. For compatibility, `GuestAddress`
138+
can refer to an address in any address space:
139+
- Guest physical addresses (GPAs) when no IOMMU is used,
140+
- I/O virtual addresses (IOVAs),
141+
- VMM user addresses (VUAs).
142+
143+
`vm-memory` provides an example implementation of `GuestMemory` when
144+
compiled with the `iommu` feature. `IommuMemory` uses an `Iommu`
145+
object to translate I/O virtual addresses (IOVAs) into VMM user addresses
146+
(VUAs), which are then passed to the inner `GuestMemoryBackend`
147+
implementation (like `GuestMemoryMmap`).
147148

148149
### Utilities and Helpers
149150

0 commit comments

Comments
 (0)