Skip to main content

Module paging

Module paging 

Source
Expand description

A software walker for x86 guest page tables.

MacSim does its own address translation, so a MacSim trace only needs virtual addresses. We still walk the guest’s page tables because:

  1. instruction bytes live at a linear address and must be read from guest-physical memory;
  2. the extended trace records the guest-physical address of every access, for simulators that want it;
  3. a walk that fails tells us, before the instruction runs, that an access is going to fault.

The walker understands every paging mode an x86-64 guest can be in: none, 32-bit (with 4 MiB pages), PAE, 4-level and 5-level. It reads the tables the same way the CPU does, but does not set Accessed/Dirty bits and does not model the TLB: it always reflects the tables as they are in memory right now.

Structs§

Translation
The result of a successful walk.

Enums§

Intent
What kind of access a permission check is for.
PagingMode
Which page-table format is active.
WalkError
Why a walk stopped.

Functions§

permits
Would an access with this intent be allowed by t?
read_linear
Reads guest memory at a linear address, crossing page boundaries as needed. Returns the number of bytes actually read (fewer than buf.len() if a later page is not mapped).
translate
Translates one linear address using the paging structures that state points at.