@@ -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
8687The VM memory consumers should only rely on traits and structs defined here to
8788access 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
127128When 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