Skip to main content

Module minivm

Module minivm 

Source
Expand description

A tiny 64-bit virtual machine, for tests and for learning.

Real guests are big. To see exactly what the tracer does, it helps to have a guest small enough to read in full: a few hundred bytes of machine code, no firmware, no devices. MiniVm creates such a guest directly in 64-bit long mode:

guest-physicalcontents
0x0500GDT: null, 64-bit code (0x08), data (0x10)
0x1000PML4
0x2000PDPT
0x3000page directory: 2 MiB pages, except the second
0x4000page table for 0x20_0000..0x40_0000 (4 KiB pages)
0x6000IDT (256 × 16 bytes)
0x1_0000MiniVm::CODE: where your program goes
0x8_0000top of vCPU 0’s stack (each vCPU gets 64 KiB)

Linear addresses equal physical addresses (identity mapping), and the second 2 MiB is mapped with 4 KiB pages so tests can unmap single pages and provoke page faults.

Structs§

MiniVm
A minimal long-mode VM.