Skip to main content

Module mem

Module mem 

Source
Expand description

Flat-buffer memory model + the Memory trait that abstracts over different memory backends (software-copy here, hardware-paged in the bare-metal Hyperlight guest).

Matches v2 javm’s flat_mem layout for perf parity: a single contiguous Vec<u8> indexed by 32-bit address. Reads/writes are bounds-checked against flat_mem.len(); on out-of-range the caller gets false/None and translates to ExitReason::PageFault.

Per-page permissions are tracked separately in flat_perms (one byte per page) so the JIT signal handler can detect ro-write faults without involving the interpreter. The interpreter itself relies on the page-protected hardware mapping for read-only enforcement; this layer just bounds-checks.

The fast-path read/write helpers use read_unaligned / write_unaligned via raw pointers — single MOV on x86.

Modules§

perm
Per-page permission byte (matches v2’s flat_perms semantics).

Structs§

CopyingMemory
Address-space mapping for one execution context.
TouchFault
A category-#3 first-touch (touch_read/touch_write) that cannot be satisfied: a write to a read-only (pinned) page, or a data access straddling outside the declared region. The caller must PageFault, charging nothing — the touch is all-or-nothing. (Accesses whose base page is not a declared data page — a code-region PIC load or a fully-unmapped address — are skipped, not faulted: they return Ok so the caller’s normal load/store path resolves them.)

Enums§

Access
Mapping permission for Memory::map_region. RO regions back perm::RO pages; RW regions back perm::RW pages.
MapError
Setup-time error for Memory::map_region.
MemAccess
Outcome of a memory access (slow path; the fast inline helpers return raw Option / bool).

Constants§

PAGE_SIZE
PVM page size: 4 KiB.

Traits§

Memory
Memory backend abstraction.

Type Aliases§

Mem
Compatibility alias for the pre-trait name. Consumers can keep writing Mem; new code should prefer CopyingMemory (when the concrete impl is wanted) or be generic over M: Memory.