Skip to main content

Module memmap

Module memmap 

Source
Expand description

s9vm : guest memory map (GPA).

Pure module: it holds the set of guest physical address ranges reserved for a world (overlaps, alignment, quotas, page accounting) without touching frames or translation tables. The kernel layer (s9vm::vm) binds these ranges to pinned frames and second-level tables.

It also owns the granularity plan used by that binding: a reservation whose base is 2 MiB aligned and whose length is a multiple of 2 MiB is split into 2 MiB leaves, while a partial head or tail stays on 4 KiB pages. plan_map performs the split; the caller installs the segments (2 MiB needs a 2 MiB-aligned, physically contiguous frame block).

Testable on the host (L2 tests).

Re-exports§

use alloc::collections::BTreeMap; 🔒
use alloc::vec::Vec; 🔒

Structs§

GuestMap
Guest memory map of a world.
MapPerms
Permissions decoded from the ABI (1 = read, 2 = write, 4 = execute).
MapSegment
One contiguous piece of a guest mapping plan.
Region
Reserved range.

Enums§

MapError
Reservation errors.
PageSize
Granularity of one mapping-plan segment.

Constants§

LARGE_PAGE_FRAMES
Number of 4 KiB frames covered by one 2 MiB leaf.
LARGE_PAGE_SIZE
Size of a large second-level page (2 MiB).
MAX_GPA
Maximum guest physical address width covered (48 bits).
MAX_REGIONS
Maximum number of distinct ranges per world (safety bound).
PAGE_SIZE
Size of a base page (4 KiB).

Functions§

contiguous_2m_aligned
Checks that hp_as is exactly the set of frames of one 2 MiB-aligned block.
perms_from_abi
Converts ABI permissions (1 = R, 2 = W, 4 = X; 0 = read) into MapPerms.
plan_map
Plans the 2 MiB/4 KiB split of [gpa, gpa + len).