Expand description
Software MMU: page-granular mapping with per-byte permissions.
This is the process-memory model the QCode emulator’s flat
EmulatedSpace map cannot express. A flat
addr -> byte map answers “what is here”, but a VM needs to answer “may this
access happen at all”, and to answer it without aborting the run — an
unmapped read is a fault the guest may legitimately take, not an emulator
bug.
Permissions are tracked per byte rather than per page. The cost is one extra byte of bookkeeping per guest byte; the benefit is that sub-page granularity (a redzone between two heap chunks, a partially initialized stack frame) costs nothing extra to express, which is the whole point of a fuzzing-oriented memory model.
Only the RAM space is mapped through here. Register, unique and temporary
spaces keep their flat representation: permission-checking a varnode write to
RAX is meaningless, and putting it on this path would add a page lookup to
the hottest operation in the interpreter.
Modules§
- perm
- Permission bits.
MAPis what distinguishes “mapped with no access” from “not mapped at all” — the two produce different faults, and a guest can observe the difference (mprotect(PROT_NONE)succeeds on mapped memory and fails on unmapped memory).
Structs§
- MemFault
- A failed access, with the exact byte that failed rather than the start of the
access. A 8-byte read straddling a mapping boundary faults at the boundary,
and that address is what a guest fault handler would see in
CR2. - Mmu
- A sparse, page-granular guest address space.
- MmuSnapshot
- An opaque point-in-time copy of an
Mmu. - Page
Data - One guest page: its bytes, and one permission bitset per byte.
Enums§
- Fault
Kind - Why an access could not be performed.
Constants§
- PAGE_
PERM_ OFFSET - Distance from a page’s first data byte to its first permission byte.
- PAGE_
SIZE - Guest page size. Chosen to match the x86-64 base page so that guest
mmapgranularity and MMU granularity agree; nothing here depends on the value.
Type Aliases§
- Perm
- A permission bitset, one per guest byte.