Expand description
Types representing contiguous and discontiguous ranges of guest memory.
The primary type is PagedRange, which describes a single logically
contiguous byte range scattered across potentially-discontiguous guest
pages. It is used throughout the storage and virtio stacks to describe
IO buffers.
§Memory model
A PagedRange is defined by a GPN (guest page number) list, a starting
byte offset, and a length. The byte range is a contiguous window into the
flat byte space implied by concatenating the pages:
gpns: [ GPN_0 ] [ GPN_1 ] [ GPN_2 ] [ GPN_3 ]
bytes: 0 4095 4096 8191 8192 12287 12288 16383
start end
│ │
GPN_0: ░░░░░░░█████████ ◄── first page: partial (offset > 0)
GPN_1: ██████████████████ ◄── interior page: always fully covered
GPN_2: ██████████████████ ◄── interior page: always fully covered
GPN_3: █████████░░░░░░░░░ ◄── last page: partial (end < page boundary)Key constraint: only the first and last pages may be partially covered. All interior pages are implicitly fully used. There is no way to express a gap or a non-zero starting offset on an interior page.
This means you cannot combine two arbitrary guest memory regions
(e.g., two virtio descriptors with arbitrary GPAs) into a single
PagedRange unless every region boundary falls on a page boundary.
See PagedRanges for a type that can represent multiple disjoint
PagedRanges as a single logical buffer.
Structs§
- Address
Range - A range of bytes in the guest address space.
- Paged
Range - A single logically-contiguous byte range spread across guest pages.
- Paged
Range Range Iter - An iterator returned by
PagedRange::ranges(). - Paged
Range Reader - A
MemoryReadimplementation forPagedRange. - Paged
Range Writer - A
MemoryWriteimplementation forPagedRange. - Paged
Ranges - A list of
PagedRanges. - Paged
Ranges Iter - An iterator returned by
PagedRanges::paged_ranges. - Paged
Ranges Reader - A
MemoryReadimplementation forPagedRanges. - Paged
Ranges Writer - A
MemoryWriteimplementation forPagedRanges.