indicogniBuild a VMM

Contents

Chapter 24 · Part X

macOS guests, the low road: vmapple and AVPBooter (capstone)

Needs a Mac Runs in browser ~10 h Stretch goal Lab: vmapple map
25 of 26

Course progress: chapter 24 is 25 of the 26 chapters written so far (numbering starts at 00)

Warm-up: three questions from earlier chapters

Answer each one in your head or on paper before you open its answer. They change on each visit.

  1. From chapter 21: Firmware: a stricter guest (U-Boot, flash, ISV=0)

    U-Boot's word 0xa9010d22 faults with ISV = 0 and the exit reports IPA 0x12c678. Which accesses must the VMM perform, at which addresses, and which registers change afterwards?

    Show answer

    Bits 31:30 are 10 (8-byte elements), mode 10 (plain offset), L = 0 (store), imm7 = 2 (times 8 = 16), Rt2 = 3, Rn = 9, Rt = 2: stp x2, x3, [x9, #16]. Two 8-byte stores, x2 at the exit IPA 0x12c678 and x3 at 0x12c680 (exit IPA plus the element size). No register changes except the PC, which advances by 4: offset mode has no writeback. In flash, both stores are ignored.

  2. From chapter 12: Why an interrupt controller, and why in the kernel

    A device tree node says interrupts = <0 5 4> under a GICv3. Which INTID will the device's interrupt arrive as, and how is it triggered?

    Show answer

    INTID 37. The first cell 0 means SPI (shared peripheral interrupt), and SPI n is INTID 32 + n, so SPI 5 is INTID 37. The third cell 4 means level-sensitive, active high.

  3. From chapter 05: Two stages, one map: holes in stage 2 on purpose

    A guest stores a byte to 0x0900_0000, where its UART should be, but your VMM has mapped an ordinary page of RAM there. What does the guest see, and what does your VMM see?

    Show answer

    The guest sees a store that worked: the byte sits in RAM, and a load from the same address returns it. Nothing is printed. Your VMM sees nothing at all: a mapped address never causes a VM exit, so the VMM never learns the store happened. A device register needs a stage-2 hole, so each access stops the guest.

Concepts you'll need

Chapters before this one: chapter 21, Firmware: a stricter guest (U-Boot, flash, ISV=0); chapter 23, macOS guests, the high road: Virtualization.framework.

  • Core, taught here: the vmapple board, a second memory map beside virt; the unknown-MMIO logger as a measuring instrument; the device-access trace, summarised by counts only; observed, inferred and unknown; a controlled-variable experiment on an undocumented machine; "load from the host, never copy"; the design record.
  • Core, from earlier: the exit trace, --timeout and --stats (chapters 03 and 11); the unhandled MMIO (memory-mapped I/O) policy (chapter 05); MMIO decode and ISV (instruction syndrome valid) (chapter 07); PSCI (power state coordination interface) and system reset (chapter 08); the in-kernel GICv3 and WFI (wait for interrupt) (chapter 12); firmware in a ROM, the ISV=0 path and architecture decision records (chapter 21); Virtualization.framework, its XPC helper and its entitlement, and a macOS bundle's machine identifier (chapter 23).
  • Primers (review): codesign-entitlements (restricted entitlements); smccc (PSCI calls in a trace); reading-arm-specs (RAZ/WI).
  • Pointers: QEMU's hw/vmapple/ sources and vmapple documentation at v10.0.0; ParavirtualizedGraphics.framework; Apple's boot chain, in an Aside; the macOS software licence agreement, cited, never legal advice; the QEMU mailing-list patch series that reports the private CPU mode.
  • Forward definitions: none. The few new names (cfg, bdif, pvpanic, ECID (exclusive chip ID), iBoot, the private CPU mode) are defined where they first appear.

On your Mac, inside Virtualization.framework, sits a file of 335,096 bytes called AVPBooter.vmapple2.bin: AVPBooter, the boot ROM (read-only memory) a macOS virtual machine runs first. Point the virtual machine monitor (VMM) you built at it, and within half a millisecond it makes 34 accesses to device registers we never built. Then, for the remaining twenty seconds, it makes no VM exit at all, while one of your CPU cores runs flat out.

Is the ROM waiting for us to answer something, or has it given up? And how would you find out without reading a single one of its instructions, which, as you will see, you may not do?

Every row of chapter 00's problem ledger is closed for Linux and FreeBSD. This chapter goes beyond the ledger: real boot chains are stricter guests, and this one has no published contract at all. The deliverable is an honest trace and a design record, not a boot: macOS does not boot in macvmm, and nothing on this page says it does.

Objectives: by the end you can

  • (Sitting A) Summarise, citing QEMU's hw/vmapple/ at v10.0.0, how QEMU's vmapple machine boots macOS on Hypervisor.framework: AVPBooter loaded from the host, its cfg, bdif, AES and graphics devices, and disks from a Virtualization.framework install.
  • (Sitting A) Sort claims about the macOS boot chain into observed, inferred and unknown, and state the rule that keeps our tracing within the licence.
  • (Sitting B) Build macvmm with experimental-vmapple, run AVPBooter, and summarise its device-access trace with counts only.
  • (Sitting B) Predict, then measure, how many distinct addresses AVPBooter touches when unknown reads return 0 and when they return all ones, explain why neither trace is "right", and narrow the experiment to one register of the next device the trace asks for (cfg).
  • (Sitting B) Diagnose from the trace and --stats whether stalled firmware is polling, waiting for an interrupt, or running without exits; then write a design record with stop criteria set in advance.

Before you start. From the repository root, run scripts/learner start 24 --level open; a capstone has no scaffold, so this copies only the journal to learner/journal/24.md. Sitting A is reading (about 3 hours); sitting B is at your Mac (7 hours or more).

Two roads to the same guest

Chapter 23 took the high road: Virtualization.framework (VZ) is built to boot macOS from a configuration you fill in (chapter 23's vz-mac does that, with an optional install), because Apple wrote the whole machine, including a helper process with a restricted entitlement, one only Apple's own code may hold. The low road is ours: an empty machine, every device by hand. The inventory you wrote at the end of chapter 23 is the list of what that road must supply; this chapter checks its first rows against a real trace.

Somebody has walked it: QEMU, the open-source machine emulator, has a board called vmapple that boots macOS on Hypervisor.framework, shipped in QEMU 10.0 in 2025. Its documentation is blunt: "newer versions than 12.x are currently NOT supported on the guest side".

Its workflow has three steps. First, install macOS 12 with a VZ-based tool and take the machine's identity number, the ECID: a 64-bit number held inside the bundle's machine identifier from chapter 23. QEMU needs it because its board hands it to the ROM in the cfg block below. QEMU's documentation never says "ECID": it calls the same value uuid, passes it as -M vmapple,uuid=, and pulls it out of the machine identifier with its script contrib/vmapple/uuid.sh. vz-mac has a subcommand that prints it, tools/vz-mac/run.sh ecid --bundle .cache/macvmm/macos-vm, which works only if you installed macOS in chapter 23. Second, strip the first 0x4000 bytes of the bundle's auxiliary storage image: VZ keeps 16 KiB of its own metadata at the front, which QEMU does not expect (vz-mac's trim-aux subcommand does this). Third, start QEMU with -bios pointing at AVPBooter.vmapple2.bin. Even QEMU needs Virtualization.framework to install macOS; only the later boots run on QEMU's own board.

QEMU is licensed under the GNU General Public License (GPL), so we read it for facts (addresses, sizes, field lists), never copying its code or prose. They come from hw/vmapple/vmapple.c, cfg.c, bdif.c and docs/system/arm/vmapple.rst at the tag v10.0.0, checked on 2026-11-20.

What the machine is, according to QEMU

QEMU's board is a table of regions, like our virt map from chapter 05, and none of it is where virt puts things. GIC is the Generic Interrupt Controller; UART, the serial port (universal asynchronous receiver-transmitter); SPI, a shared peripheral interrupt; RTC, a real-time clock; GPIO, general-purpose input/output pins:

RegionBaseSizeWhat it is
firmware0x0010_00001 MiBAVPBooter
cfg0x0040_000064 KiBconfiguration block
GIC distributor0x1000_000064 KiBinterrupt controller (chapter 12)
GIC redistributors0x1001_00004 MiBone frame per CPU
PL011 UART0x2001_000064 KiBserial console, SPI 1
PL031 RTC0x2005_00004 KiBclock, SPI 2
PL061 GPIO0x2006_00004 KiBpower button, SPI 5
pvpanic0x2007_00002 byteswritten by a panicking guest
bdif0x3000_00002 MiB"backdoor" disk interface
apple-gfx, IOSurface mapper0x3020_0000, 0x3021_000064 KiB eachgraphics bridged to the host (an IOSurface is a macOS shared graphics buffer)
AES engine0x3022_0000, 0x3023_000016 KiB eachAES (Advanced Encryption Standard) cryptography
PCIe ECAM, MMIO window0x4000_0000, 0x5000_0000256 MiB, about 512 MiBPCI Express (PCIe): ECAM (Enhanced Configuration Access Mechanism, chapter 23's configuration window), then devices
RAM0x7000_0000as configured

QEMU's vmapple map at v10.0.0. Notice 0x4000_0000: RAM on our virt board, PCI Express configuration space here.

So vmapple is a second board with its own map, not a variant of virt. The CPU side is familiar (chapters 08 and 20): PSCI over hvc, secondaries powered off. QEMU passes no device tree; that a later stage builds one for the kernel is inferred from how physical Macs boot, not shown.

The work is in the devices. cfg is a page the booter reads to learn about its machine: a version (2), the CPU count, the ECID, the RAM size, two "run the installer" flags, a random seed, network addresses, a serial "1234", a model "VM0001", a chip name "Apple M1 (Virtual)", and fields QEMU's own source names unk1 to unk10: its authors did not know every field either.

bdif (backdoor block interface) is how the booter reads disks before any driver exists. The guest writes, to a command register, the guest-physical address of a three-entry descriptor: where the sector number is, where to put the data, where to write a status byte. The device copies 512-byte sectors of the root or auxiliary disk into guest memory; QEMU's version only reads.

Security

In bdif the guest controls three addresses, a sector number and a length, all in memory a second virtual CPU (vCPU) can rewrite while the device works: chapter 16's virtqueue lesson with no ring around it. Copy the descriptor once, check every address with checked_add, cap the length, and write nothing until all of it checks out.

The rest arrives once a kernel runs: the AES engine, which the guest asks to encrypt or decrypt buffers (its built-in keys are Apple's; QEMU uses placeholders), PCI Express with virtio devices, and apple-gfx, which hands two register windows to ParavirtualizedGraphics.framework, Apple's library that draws a guest's display on the host with Metal, Apple's programming interface for the graphics processor (GPU).

Lab

vmapple map

Browse the vmapple board's memory map and device inventory, each row cited and tagged observed, inferred or unknown, and switch evidence off to see which claims rest on it.

Runs in browserOpen full page: vmapple map

Loading the lab. If nothing appears, your browser may have JavaScript turned off or the lab failed to load.

If the lab does not load, here is what it shows when it opens: the map above with each row tagged by its column (defined in the next section) and by what backs it, from QEMU's sources and the first probe of sitting B. The lab keeps sitting B's second run hidden until you ask for it.

row                    column                    seen in the reference runs    source of the rowavpbooter 0x100000     observed                  first exit at pc=0x103478     QEMU vmapple.c, our runcfg       0x400000     observed                  33 accesses, all unmodelled   QEMU vmapple.c, cfg.c, our rungicd/gicr 0x10000000   observed (accepted)       hv_gic_create accepts them    QEMU vmapple.c, our runpl011     0x20010000   inferred                  no access seen                QEMU vmapple.cpvpanic   0x20070000   observed                  1 access                      QEMU vmapple.c, our runbdif      0x30000000   inferred                  no access seen                QEMU vmapple.c, bdif.cpcie, aes, apple-gfx   unknown                   never reached                 QEMU vmapple.c

Observed, inferred, unknown

From here on every sentence you write about this machine goes into one of three columns. Observed: you ran it on your Mac and have the output. Inferred: it follows from observations plus a public source you can name. Unknown: nobody has shown it, or the only way to show it is closed to you. The skill is refusing to let a plausible sentence drift from the third column into the first.

Aside

Apple's Platform Security Guide describes how a physical Apple-silicon Mac boots: a boot ROM, then iBoot (Apple's boot loader, the stages after the boot ROM), then the kernelcache (the macOS kernel linked with its drivers), each checking the next one's signature. The guide is about hardware and never mentions AVPBooter: use it to generate hypotheses, and keep them inferred or unknown until a trace of yours moves them.

Here are the first claims, sorted:

ClaimColumnWhy
AVPBooter.vmapple2.bin is 335,096 bytesobservedls -l
the CPU starts at its first byte, at exception level 1 (EL1), with the memory management unit (MMU) offinferredQEMU's board does this; our first exit lies inside the ROM
its first device access is to cfgobserved, on our boardthe first probe below
it reads disks through bdifinferredQEMU documents it; sitting B tests whether our runs reach it
later stages are iBoot-family loaders that load a kernelcacheunknownphysical Macs suggest it; nothing here shows it
a modern macOS guest needs a private CPU mode (a CPU setting only Apple's own helper process may switch on)observed in part, inferred in partrefused to us: observed by sitting B's probe; needed by guests: inferred from a named QEMU patch series, sitting B

The line you do not cross

AVPBooter is Apple software, licensed to you with macOS. Read the licence at /System/Library/CoreServices/Setup Assistant.app/Contents/Resources/en.lproj/OSXSoftwareLicense.rtf; nothing here is legal advice. Section 2B(iii) permits up to two additional copies of macOS in virtual machines on each Apple computer you own or control that already runs it, for listed purposes. Section 2K says Apple boot ROM code and firmware may not be copied, modified or redistributed. Section 2N forbids copying, decompiling, reverse engineering or disassembling the software.

A VMM cannot avoid observing the code it runs: every exit shows a program counter (PC), an address, a size and a value. So macvmm draws its line:

  • Loaded in place. The ROM is read from the system path at run time; no code path writes it to a file.
  • Only device accesses, in two instruments. The logger prints the device-access trace: each access to an address with no device, as (pc, ipa, size, direction, value), at most 256 per boot (the IPA, intermediate physical address, is chapter 05's guest-physical address). The optional exit trace (--trace exits:FILE) has one line per exit with the same fields, capped only by file size; it is your private file under .cache/.
  • No disassembly or decompilation of the ROM's instructions.
  • No memory dumps. Once the ROM has copied itself or its data into guest RAM, a dump of that RAM is a copy of the ROM by another route.
  • Not published: the per-access lines, the values written, guesses about what the code is for. This page shows counts and how runs ended; your trace stays in your workspace.

The two-copy limit becomes code too, as sitting B shows. Limiting concurrent runs to two is our conservative reading of section 2B(iii), not legal advice.

Before you stop, set yourself the sitting's exercise. Read, at tag v10.0.0, the memory map in hw/vmapple/vmapple.c, the field list in hw/vmapple/cfg.c and docs/system/arm/vmapple.rst. Start a draft of your design record (Your turn, at the end of the page) with five claims of your own about the machine, each with its column and its source. The Spec hunt's first item is a good sixth.

Good place to stop. Sitting B needs your Mac, about 7 hours, and a terminal in the repository.

Building the board

The vmapple board is behind a cargo feature, experimental-vmapple, off by default; a default build refuses it before creating anything:

TerminalReal output
scripts/sign-and-run.sh target/debug/macvmm run --machine vmapple --bios /System/Library/Frameworks/Virtualization.framework/Versions/A/Resources/AVPBooter.vmapple2.binexit: 2--- stderr ---macvmm: --machine vmapple: built without experimental-vmapple (rebuild with `--features experimental-vmapple`)usage: macvmm run [options]options:  --mem SIZE               guest RAM, e.g. 64M, 2G (default 512M; 64M..255G, a multiple of 2M)  --cpus N                 number of vCPUs, 1..64 and at most what this Mac allows (default 1);                           vCPU 0 boots, the others wait for PSCI CPU_ON  --kernel FILE            an ELF test guest or an arm64 Linux Image (detected from its                           bytes; an EFI zboot vmlinuz is refused: run scripts/fetch.sh linux)  --initrd FILE            an initramfs for an Image kernel, placed above the kernel  --cmdline STRING         the kernel command line for an Image (at most 2047 bytes; default                           console=ttyAMA0 earlycon=pl011,<the PL011 address>)  --machine BOARD          virt (default) or vmapple (experimental: AVPBooter's first device                           accesses, needs a build with --features experimental-vmapple;                           it does not boot macOS; at most two per user, an advisory lock                           in $HOME/.cache/macvmm/vmapple-slots)  --bios FILE              a firmware ROM image, at most 64 MiB (virt: U-Boot in flash                           bank 0, entered at 0x0 instead of --kernel; vmapple: default the                           system AVPBooter, read in place and never copied)  --dry-run                print the boot plan, memory map and device-tree summary, then exit                           0 without creating a VM (needs no entitlement)  --raw FILE@0xADDR        load FILE's bytes at guest-physical ADDR (repeatable); the first                           one is the entry point when there is no --kernel  --timeout SECS           stop the guest after SECS seconds (exit code 5)  --unhandled-mmio POLICY  fatal (default: exit code 3) or log (read as zero, ignore writes)  --trace exits:FILE[:CATS][,max=SIZE]                           write one JSON line per VM exit to FILE (created 0600; never a                           symlink). CATS: comma-separated mmio,hvc,sysreg,psci,cancel,all                           (default all). SIZE caps the file (default 1G)  --testdev                map the 512-register test device at 0x0b000000  --disk FILE[,ro]         add a virtio-blk disk backed by the raw image FILE (repeatable;                           the first is /dev/vda). ,ro opens it read-only. The image is                           locked (flock) while macvmm runs; a locked image is refused  --rng                    add a virtio-rng device fed by the host CSPRNG (getentropy)  --net unixgram:LOCAL,peer=REMOTE[,mac=XX:XX:XX:XX:XX:XX]                           add a virtio-net NIC whose wire is a Unix datagram socket bound                           at LOCAL; frames go to, and are accepted only from, the socket at                           REMOTE (another macvmm's LOCAL). Both must be in a directory you                           own that is not group- or world-writable. A stale socket of yours                           at LOCAL is replaced; anything else there is refused. Repeatable                           (at most 4). Default MAC 02:6d:76 plus 3 random bytes.                           unixgram:LOCAL,learn instead locks the peer to the first sender                           (logged). No host network access and no entitlement  --on-reset ACTION        reboot (default: rebuild the VM in-process) or exit (exit code 4)                           when the guest calls PSCI SYSTEM_RESET  --debug-hvc, --no-debug-hvc                           force the macvmm debug hypercalls on or off (default: on for ELF                           and --raw test guests, off for kernels and firmware)  --dtb-out FILE           write the generated device tree to FILE (created 0600; never a                           symlink), with its rng-seed and kaslr-seed zeroed  --serial SINK[,strict|,raw][,max=SIZE]                           where the PL011 console goes: stdio (default; also gets stdin, with                           Ctrl-A x quit, Ctrl-A t trace ring, Ctrl-A s stats), file:FILE                           (created 0600, never a symlink, capped at SIZE, default 1G) or none.                           Guest output is filtered for terminal safety; strict shows every                           control visibly, raw disables the filter (not recommended)  --console SINK[,strict|,raw][,max=SIZE]                           add a virtio-console (Linux /dev/hvc0) whose output goes to stdio                           or file:FILE, filtered like --serial. At most one of --serial and                           --console may be stdio, and that one gets stdin: --console stdio                           needs --serial file:FILE or --serial none  --stats                  print the console I/O counters, the exit counts, the vCPU exec and                           WFI time and the host CPU time when the VM stops  --log LEVEL              error|warn|info|debug|trace (default warn; also MACVMM_LOG)  --no-sandbox             run unconfined. By default, after opening every file, macvmm                           confines itself: no file opened by path, no network, no new process                           (macOS sandbox, threat model SBX-2), and exits 1 if the sandbox                           cannot be applied. Needed for --net ...,learn  --sandbox[=best-effort]  --sandbox is the default and changes nothing; best-effort warns                           and runs unconfined if the sandbox cannot be applied. Not together                           with --no-sandbox
captured: real output, Apple M5 Pro, macOS 27.2.1, commit 64871bd, 2026-11-20
  • Run with the default build (no experimental-vmapple feature).
course/captures/24-default-refuses.txt

Exit code 2 is a usage error; no virtual machine was created.

Now ask a feature build for the boot plan; cargo run builds it, and --dry-run creates no virtual machine. This replaces target/debug/macvmm: run a plain cargo build -q -p macvmm before returning to other chapters.

Shell
cargo run -q -p macvmm --features experimental-vmapple -- run --machine vmapple --bios /System/Library/Frameworks/Virtualization.framework/Versions/A/Resources/AVPBooter.vmapple2.bin --mem 4G --unhandled-mmio log --dry-run
TerminalReal output
cargo run -q -p macvmm --features experimental-vmapple -- run --machine vmapple --bios /System/Library/Frameworks/Virtualization.framework/Versions/A/Resources/AVPBooter.vmapple2.bin --mem 4G --unhandled-mmio log --dry-runexit: 0--- stdout ---macvmm vmapple board (dry run, no VM created; experimental, does not boot macOS)entry    pc=0x100000 x0=0 cpsr=0x3c5 (EL1h, MMU off, no DTB)rom      335096 bytes of --bios in a 1048576-byte read+execute ROMmemory map (VmApple):  0x00100000..0x00200000  avpbooter  rom  0x00400000..0x00410000  cfg        unknown-MMIO logger  0x10000000..0x10010000  gicd       in-kernel GIC  0x10010000..0x10410000  gicr       in-kernel GIC (one 128 KiB frame; the rest: unknown-MMIO logger)  0x20010000..0x20020000  pl011      pl011  0x20050000..0x20051000  pl031      unknown-MMIO logger  0x20060000..0x20061000  pl061      unknown-MMIO logger  0x20070000..0x20070002  pvpanic    unknown-MMIO logger  0x30000000..0x30200000  bdif       unknown-MMIO logger  0x70000000..0x170000000  ram        ramunknown MMIO: logged, read as zero (cap 256); debug hypercalls: off
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • The reference tree built with: cargo build -q -p macvmm --features experimental-vmapple.
course/captures/24-dry-run.txt

Besides RAM, four rows have a model behind them: the ROM, the GIC distributor, the first 128 KiB redistributor frame and the PL011. Everything else goes to the unknown-MMIO logger. --bios defaults to the system path:

crates/vmm/src/loader/firmware.rslines 49-51
/// Where macOS keeps the vmapple boot ROM (Virtualization.framework, macOS 12 and later). The/// `--machine vmapple` default for `--bios`. Read in place; never copied (module docs).pub const AVPBOOTER_VMAPPLE2: &str = "/System/Library/Frameworks/Virtualization.framework/Versions/A/Resources/AVPBooter.vmapple2.bin";

The map follows QEMU's up to bdif; the graphics, AES and PCI Express rows are left out, so an access there is logged as a bare address. A Reserved row only names an address for the logger ("cfg"). The comments on ROM_BASE and BDIF_BASE state as fact what our claims table keeps inferred and unknown; read them as QEMU's documentation, not our observation:

crates/vmm/src/machine/vmapple/layout.rslines 30-65
/// AVPBooter's load and entry address. The CPU starts here, at EL1, with the MMU off.pub const ROM_BASE: u64 = 0x0010_0000;/// The ROM window: 1 MiB (AVPBooter.vmapple2.bin is about 335 KB on macOS 27.2).pub const ROM_SIZE: u64 = 0x0010_0000;/// The configuration block VZ fills in (ECID, serial, RAM size, ...): not modelled yet.pub const CFG_BASE: u64 = 0x0040_0000;pub const GICD_BASE: u64 = 0x1000_0000;pub const GICD_SIZE: u64 = 0x0001_0000;pub const GICR_BASE: u64 = 0x1001_0000;/// Room for the redistributor frames; HVF implements one 128 KiB frame per vCPU at the base.pub const GICR_WINDOW: u64 = 0x0040_0000;pub const PL011_BASE: u64 = 0x2001_0000;/// SPI 1 → INTID 33, as on `virt`.pub const PL011_INTID: u32 = 33;pub const PL031_BASE: u64 = 0x2005_0000;pub const PL061_BASE: u64 = 0x2006_0000;pub const PVPANIC_BASE: u64 = 0x2007_0000;/// The "backdoor" block interface iBoot reads its disks through (not modelled yet).pub const BDIF_BASE: u64 = 0x3000_0000;/// RAM. AVPBooter is told nothing about its size here (no DTB, no cfg block).pub const RAM_BASE: u64 = 0x7000_0000;use RegionKind::*;/// Every non-RAM row of the vmapple board, sorted by base.#[rustfmt::skip]pub const VMAPPLE_REGIONS: &[Region] = &[    Region { name: "avpbooter", base: ROM_BASE,     size: ROM_SIZE,    kind: Rom,       intid: None },    Region { name: "cfg",       base: CFG_BASE,     size: 0x0001_0000, kind: Reserved,  intid: None },    Region { name: "gicd",      base: GICD_BASE,    size: GICD_SIZE,   kind: GicDist,   intid: None },    Region { name: "gicr",      base: GICR_BASE,    size: GICR_WINDOW, kind: GicRedist, intid: None },    Region { name: "pl011",     base: PL011_BASE,   size: 0x0001_0000, kind: Mmio,      intid: Some(PL011_INTID) },    Region { name: "pl031",     base: PL031_BASE,   size: 0x1000,      kind: Reserved,  intid: Some(34) },    Region { name: "pl061",     base: PL061_BASE,   size: 0x1000,      kind: Reserved,  intid: Some(37) },    Region { name: "pvpanic",   base: PVPANIC_BASE, size: 0x2,         kind: Reserved,  intid: None },    Region { name: "bdif",      base: BDIF_BASE,    size: 0x0020_0000, kind: Reserved,  intid: None },];

The CPU starts like a real core leaving reset: PC at the ROM's first byte, argument registers zero (no device tree), and PSTATE 0x3c5, EL1h with everything masked, as in chapter 02:

crates/vmm/src/machine/vmapple/mod.rslines 392-396
let boot = BootParams {    pc: layout::ROM_BASE,    x: [0; 4],    cpsr: CPSR_EL1H_DAIF_MASKED,};

And the two-copy rule: before any Hypervisor.framework call, the run takes one of two lock files, 0.lock and 1.lock, in a directory under your home directory. Each is held with flock, an advisory lock the kernel drops when the file closes, so a crashed macvmm never keeps its slot. First the function checks the directory: it must be yours, mode 0700, and not a symbolic link, so nobody else can take your slots. Then it tries each slot in turn:

crates/vmm/src/backend/hostio.rslines 493-513
for slot in 0..slots {    let path = dir.join(format!("{slot}.lock"));    let (file, _) = open_output(&path, &[])?;    match file.try_lock() {        Ok(()) => {            return Ok(SlotLock {                slot,                path,                _file: file,            });        }        Err(std::fs::TryLockError::WouldBlock) => continue,        Err(std::fs::TryLockError::Error(err)) => {            return Err(InputError::SlotLock { path, err });        }    }}Err(InputError::SlotsBusy {    dir: dir.to_path_buf(),    slots,})

The lock counts only macvmm's vmapple runs, not VZ machines beside them.

Every unknown access, written down

On virt, an access to no device is a guest bug, and the default unhandled-MMIO policy stops at the first one with exit code 3. A ROM written for another board will touch devices we lack, and the question is "which ones, in what order?". So the logger answers each the way an empty bus would, RAZ/WI (read as zero, writes ignored), and records it.

Where does that answer come from? A board needs to see accesses no device claims, and some exits, before the generic run loop decides what to do with them. So each machine profile may install a watcher: a hook called before each exit is handled and for each unclaimed access, which may take over the decision. virt installs none; vmapple installs one. Chapter 07's MMIO path offers an unclaimed access to the watcher first, then to the policy:

crates/vmm/src/vcpu/mmio.rslines 235-258
Err(BusError::Unmapped { .. } | BusError::Straddle { .. }) => {    // A machine profile's watch may take the access instead of the policy.    let unclaimed = UnclaimedAccess {        pc,        ipa,        size: rec.size.unwrap_or(0),        write: access.write,    };    let verdict = env.watch.and_then(|w| w.unclaimed_mmio(&unclaimed));    match verdict.unwrap_or_else(|| unhandled_mmio_policy(env.unhandled_mmio, ipa, da, pc))    {        MmioVerdict::Fatal(why) => {            rec.action = None;            Ok(MmioOutcome::Fatal(why))        }        MmioVerdict::RazWi => {            if access.write.is_none() {                regs.set_x(access.reg, 0)?;            }            rec.value = Some(access.write.unwrap_or(0));            Ok(MmioOutcome::Done)        }    }}

RazWi writes 0 into the destination register for a read. Remember that line; the experiment below changes it. The logger itself pushes one entry, prints one line, and turns into a stop at the cap:

crates/vmm/src/machine/vmapple/unknown.rslines 109-149
/// Record `a` and say what the guest sees: RAZ/WI, or (from the cap on) a stop.pub fn record(&self, a: &UnclaimedAccess) -> MmioVerdict {    let dir = match a.write {        Some(v) => Dir::Write(v),        None => Dir::Read,    };    self.push(a.pc, a.ipa, a.size, dir)}/// Record an ISV = 0 access that was not emulated (module docs). The caller stops the VM/// either way; the verdict only says whether this entry was the one that hit the cap.pub fn record_undecoded(&self, pc: u64, ipa: u64, write: bool) -> MmioVerdict {    self.push(pc, ipa, 0, Dir::Undecoded { write })}fn push(&self, pc: u64, ipa: u64, size: u8, dir: Dir) -> MmioVerdict {    let mut g = crate::sync::lock(&self.inner);    if g.entries.len() >= UNKNOWN_MMIO_CAP {        g.over_cap = g.over_cap.saturating_add(1);        return MmioVerdict::Fatal(summary_line(g.entries.len(), true));    }    let entry = UnknownAccess {        pc,        ipa,        size,        dir,        region: layout::vmapple().find(ipa).map(|r| r.name),    };    g.entries.push(entry);    let n = g.entries.len();    let line = entry.line(n);    // `warn`, the default level: the summary below counts lines the user can see.    crate::warn!("{line}");    g.lines.push(line);    if n < UNKNOWN_MMIO_CAP {        return MmioVerdict::RazWi;    }    let summary = summary_line(n, true);    emit_summary(&mut g, &summary);    MmioVerdict::Fatal(summary)}

Why a cap? A ROM polling a register we lack spins forever, and every spin is an access: the guest decides how often, the VMM decides how much it writes down. The watcher adds three rules: print the first exit, stop on any hypercall macvmm has no designed answer for, and stop on an ISV=0 access:

crates/vmm/src/machine/vmapple/mod.rslines 147-188
impl ExitWatch for Watch {    fn before_exit(&self, regs: &dyn VcpuRegs, exit: &Exit) -> Result<Option<String>> {        let pc = regs.pc()?;        if self.first_exit.set(pc).is_ok() {            crate::warn!("vmapple: first exit at pc={pc:#x}: {exit}");        }        let (conduit, imm) = match *exit {            Exit::Hvc { imm } => ("HVC", imm),            Exit::Smc { imm } => ("SMC", imm),            _ => return Ok(None),        };        let x0 = regs.x(0)?;        if imm != 0 || !hvc_supported(x0) {            return Ok(Some(format!(                "vmapple: stopped at unsupported {conduit} {x0:#x} (imm {imm:#x}) at pc {pc:#x}"            )));        }        Ok(None)    }    fn unclaimed_mmio(&self, access: &UnclaimedAccess) -> Option<MmioVerdict> {        let verdict = self.unknown.record(access);        // `fatal`: the access is logged, then the usual unhandled-MMIO stop applies.        self.keep_going.then_some(verdict)    }    fn refused_isv0(&self, access: &RefusedAccess) -> Option<String> {        // Counted like any access to no device (a device-backed one is not "unknown"), then a        // stop under either policy: no abort is injected into the ROM (module docs).        if access.unclaimed {            self.unknown                .record_undecoded(access.pc, access.ipa, access.write);        }        Some(format!(            "vmapple: ISV=0 {} at {:#x} pc {:#x} not emulated; stopping instead of injecting \             an abort",            if access.write { "write" } else { "read" },            access.ipa,            access.pc        ))    }}

Under the hood

Chapter 21 handled an ISV=0 access by fetching and decoding the faulting instruction, even from flash. Here the board deliberately leaves that ROM-fetch path off: decoding AVPBooter's instructions is disassembly, which the licence section above rules out. Injecting an abort is out too: the ROM would never see one under VZ, so it would turn the rest of the trace into a record of our behaviour. So the board counts the access and stops.

The first probe

Now run it for twenty seconds, with the logger, an exit trace under .cache/ (which git ignores) and the statistics:

Shell
mkdir -p .cache/vmapplecargo run -q -p macvmm --features experimental-vmapple -- run --machine vmapple --bios /System/Library/Frameworks/Virtualization.framework/Versions/A/Resources/AVPBooter.vmapple2.bin --mem 4G --unhandled-mmio log --trace exits:.cache/vmapple/avp.jsonl --timeout 20 --stats

Your terminal also shows one vmapple: unknown MMIO #n line per logged access; our capture removed them:

TerminalReal output
cargo run -q -p macvmm --features experimental-vmapple -- run --machine vmapple --bios /System/Library/Frameworks/Virtualization.framework/Versions/A/Resources/AVPBooter.vmapple2.bin --mem 4G --unhandled-mmio log --trace exits:.cache/vmapple/avp.jsonl --timeout 20 --statsexit: 5--- stdout ---macvmm: warn: [vcpu0] vmapple: first exit at pc=0x103478: data abort (EC 0x24): ISV=1 SAS=2 (4 bytes) SSE=0 SRT=27 SF=0 AR=0 FnV=0 S1PTW=0 WnR=1 DFSC=0x7 (translation fault)macvmm: warn: [main] vmapple: 34 unknown MMIO accesses loggedmacvmm: warn: [main] vmapple:   33 in cfgmacvmm: warn: [main] vmapple:   1 in pvpanicmacvmm: timeout: the guest was still running after --timeout 20smacvmm: stats: serial_input_dropped=0 serial_input_queued=0 serial_written=0 serial_sink_dropped=0 serial_capped=0 serial_lost=0 serial_filtered=0macvmm: stats: vcpu0 exits: vtimer 0, wfx 0, total 35: canceled 1, data abort 34macvmm: stats: vcpu0 time: exec 19.027 s, wfi 0.000 smacvmm: stats: host cpu 19.174 s over 20.004 s wall (96%)macvmm: stats: rlimit core=0 nofile=1048576
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • The per-access lines (vmapple: unknown MMIO #n: ...) were removed with grep -v before recording: your terminal shows them, but this course does not publish a trace of Apple's ROM. stderr is merged into stdout by that filter.
course/captures/24-first-probe.txt

Your times will differ; the first-exit PC, the 34 accesses and their split by region should match if your AVPBooter is also 335,096 bytes. The first exit, at pc=0x103478 inside the ROM window, is a 4-byte store (WnR=1, a write, and SAS=2, 4 bytes: chapter 07's syndrome fields) to an address with no stage-2 mapping (DFSC=0x7, the fault status code for a translation fault: neither RAM nor a device sits behind cfg). It is the first of 34 accesses to no device, 33 in cfg and 1 in pvpanic; no hypercall or ISV=0 stop; --timeout ended it, exit code 5. --stats adds the strangest line: 19.0 of the 20 seconds spent executing guest instructions, none in WFI.

Reading a stall

Three jq commands (jq ships with recent macOS) turn the trace into numbers you can publish. The kinds of exit:

TerminalReal output
jq -r '.fn // .action // .reason' .cache/vmapple/avp.jsonl | sort | uniq -cexit: 0--- stdout ---   1 canceled  34 mmio
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20course/captures/24-kinds-zero.txt

How many distinct IPAs the ROM touched:

TerminalReal output
jq -r 'select(.ipa) | .ipa' .cache/vmapple/avp.jsonl | sort -u | wc -lexit: 0--- stdout ---      14
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20course/captures/24-ipas-zero.txt

And when, in milliseconds, with the exits of the last 10 ms:

TerminalReal output
jq -s '(.[-1].t_ns) as $end | {first_ms: (.[0].t_ns / 1e6), last_mmio_ms: ([.[] | select(.action == "mmio") | .t_ns] | max / 1e6), end_ms: ($end / 1e6), exits_in_last_10ms: ([.[] | select(.t_ns > $end - 1e7)] | length)}' .cache/vmapple/avp.jsonlexit: 0--- stdout ---{  "first_ms": 0.185166,  "last_mmio_ms": 0.491,  "end_ms": 20003.9185,  "exits_in_last_10ms": 1}
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20course/captures/24-timing-zero.txt

Fourteen addresses, 34 accesses, all between 0.19 ms and 0.49 ms; then nothing until --timeout cancelled the vCPU at 20,004 ms (the one exit in the last 10 ms). A stalled guest can look three ways:

ShapeExits near the endexec timeWFI timeExample
polling a devicemany, at the same IPAhighlowa driver spinning on a status bit
waiting for an interruptnone (in-kernel WFI, chapter 12)lowhighchapter 12's timer guest sleeping: exec 0.000 s, wfi 1.048 s
running without exitsnone, or very fewhighlow or nonechapter 12's no-drain run (a million interrupts, 164 exits, exec up from 0.000 s to 0.396 s); this run, exec 19.0 s of 20

Three stalls, three fingerprints. Only the first is visibly "waiting for a device".

On this board a loop polling a register we lack would hit the logger's 256-entry cap and stop with its summary: a capped run, not a timeout, is the polling fingerprint here. Polling something that never exits, such as an in-kernel GIC register, lands in the third row.

Back to the question from the top of the page: waiting, or given up? Observed: after its last device access, at 0.49 ms, the ROM ran for the rest of the 20 seconds (19.0 s of it executing guest instructions, by --stats) without one exit or WFI. Inferred: it touches only things that never exit to us: its ROM and RAM, the in-kernel GIC, the generic timer and the system registers Hypervisor.framework handles itself (chapter 12). Unknown: which of those it touches and why; a GIC or timer poll and a deliberate halt look the same from here.

Try it

One of the 34 accesses went to pvpanic. Read QEMU's docs/specs/pvpanic.rst (tag v10.0.0): what does a guest mean by writing there? Which column does "AVPBooter gave up" belong in, and what experiment would move it? Answer at the end of your Q1 answer in your journal.

Breaking it on purpose: what an unknown register says

Our logger's 0 is not neutral. To the ROM, a register that reads 0 says something: a status bit clear, a count of zero, a version that does not exist. On an undocumented machine, the experiment is to change one controlled variable, keep everything else fixed, and compare traces.

Deliberate breakage 1: unknown reads return all ones. Copy the tree outside the repository and make the trace directory the copy lacks:

Shell
rsync -a --exclude target --exclude .cache --exclude .git ./ ../vmapple-ones/cd ../vmapple-ones && mkdir -p .cache/vmapple

Then make one edit, in the copy only:

  1. Open crates/vmm/src/vcpu/mmio.rs and find the MmioVerdict::RazWi arm shown above, with its regs.set_x(access.reg, 0) for reads.
  2. Immediately before that call, compute all ones of the access size. unclaimed.size is the size in bytes (a u8): for 8 bytes the answer is u64::MAX; otherwise it is (1 << 8*size) - 1, computed in u64.
  3. Pass that value to regs.set_x instead of 0.

The trace's value field still records 0 for reads; ignore it here. Rerun the first probe's command in the copy; its first build starts from nothing and takes a few minutes.

Predict With every unknown read returning all ones (0xff for a byte, 0xffff_ffff for a word) instead of 0, will AVPBooter touch more distinct addresses than the 14 it touched with zeros, fewer, or the same, before the run stops making progress or ends? Will it reach any row it did not reach before, and how will the run end: a timeout, the logger's cap, a stop, a reset?

Write a number and a sentence of reasoning under ## Predict in your journal. "I cannot know" is allowed, if you say which outcome would surprise you.

TerminalReal output
cargo run -q -p macvmm --features experimental-vmapple -- run --machine vmapple --bios /System/Library/Frameworks/Virtualization.framework/Versions/A/Resources/AVPBooter.vmapple2.bin --mem 4G --unhandled-mmio log --trace exits:.cache/vmapple/avp.jsonl --timeout 20 --statsexit: 3--- stdout ---macvmm: warn: [vcpu0] vmapple: first exit at pc=0x103478: data abort (EC 0x24): ISV=1 SAS=2 (4 bytes) SSE=0 SRT=27 SF=0 AR=0 FnV=0 S1PTW=0 WnR=1 DFSC=0x7 (translation fault)macvmm: warn: [main] vmapple: 63 unknown MMIO accesses loggedmacvmm: warn: [main] vmapple:   60 in cfgmacvmm: warn: [main] vmapple:   1 in pvpanicmacvmm: warn: [main] vmapple:   2 in bdifmacvmm: warn: [vcpu0] vmapple: first exit at pc=0x103478: data abort (EC 0x24): ISV=1 SAS=2 (4 bytes) SSE=0 SRT=27 SF=0 AR=0 FnV=0 S1PTW=0 WnR=1 DFSC=0x7 (translation fault)macvmm: warn: [main] vmapple: 63 unknown MMIO accesses loggedmacvmm: warn: [main] vmapple:   60 in cfgmacvmm: warn: [main] vmapple:   1 in pvpanicmacvmm: warn: [main] vmapple:   2 in bdifmacvmm: warn: [vcpu0] vmapple: first exit at pc=0x103478: data abort (EC 0x24): ISV=1 SAS=2 (4 bytes) SSE=0 SRT=27 SF=0 AR=0 FnV=0 S1PTW=0 WnR=1 DFSC=0x7 (translation fault)macvmm: warn: [main] vmapple: 63 unknown MMIO accesses loggedmacvmm: warn: [main] vmapple:   60 in cfgmacvmm: warn: [main] vmapple:   1 in pvpanicmacvmm: warn: [main] vmapple:   2 in bdifmacvmm: warn: [vcpu0] vmapple: first exit at pc=0x103478: data abort (EC 0x24): ISV=1 SAS=2 (4 bytes) SSE=0 SRT=27 SF=0 AR=0 FnV=0 S1PTW=0 WnR=1 DFSC=0x7 (translation fault)macvmm: warn: [main] vmapple: 63 unknown MMIO accesses loggedmacvmm: warn: [main] vmapple:   60 in cfgmacvmm: warn: [main] vmapple:   1 in pvpanicmacvmm: warn: [main] vmapple:   2 in bdifmacvmm: warn: [vcpu0] vmapple: first exit at pc=0x103478: data abort (EC 0x24): ISV=1 SAS=2 (4 bytes) SSE=0 SRT=27 SF=0 AR=0 FnV=0 S1PTW=0 WnR=1 DFSC=0x7 (translation fault)macvmm: warn: [main] vmapple: 63 unknown MMIO accesses loggedmacvmm: warn: [main] vmapple:   60 in cfgmacvmm: warn: [main] vmapple:   1 in pvpanicmacvmm: warn: [main] vmapple:   2 in bdifmacvmm: warn: [vcpu0] vmapple: first exit at pc=0x103478: data abort (EC 0x24): ISV=1 SAS=2 (4 bytes) SSE=0 SRT=27 SF=0 AR=0 FnV=0 S1PTW=0 WnR=1 DFSC=0x7 (translation fault)macvmm: warn: [main] vmapple: 63 unknown MMIO accesses loggedmacvmm: warn: [main] vmapple:   60 in cfgmacvmm: warn: [main] vmapple:   1 in pvpanicmacvmm: warn: [main] vmapple:   2 in bdifmacvmm: warn: [vcpu0] vmapple: first exit at pc=0x103478: data abort (EC 0x24): ISV=1 SAS=2 (4 bytes) SSE=0 SRT=27 SF=0 AR=0 FnV=0 S1PTW=0 WnR=1 DFSC=0x7 (translation fault)macvmm: warn: [main] vmapple: 63 unknown MMIO accesses loggedmacvmm: warn: [main] vmapple:   60 in cfgmacvmm: warn: [main] vmapple:   1 in pvpanicmacvmm: warn: [main] vmapple:   2 in bdifmacvmm: warn: [vcpu0] vmapple: first exit at pc=0x103478: data abort (EC 0x24): ISV=1 SAS=2 (4 bytes) SSE=0 SRT=27 SF=0 AR=0 FnV=0 S1PTW=0 WnR=1 DFSC=0x7 (translation fault)macvmm: warn: [main] vmapple: 63 unknown MMIO accesses loggedmacvmm: warn: [main] vmapple:   60 in cfgmacvmm: warn: [main] vmapple:   1 in pvpanicmacvmm: warn: [main] vmapple:   2 in bdifmacvmm: warn: [vcpu0] vmapple: first exit at pc=0x103478: data abort (EC 0x24): ISV=1 SAS=2 (4 bytes) SSE=0 SRT=27 SF=0 AR=0 FnV=0 S1PTW=0 WnR=1 DFSC=0x7 (translation fault)macvmm: warn: [main] vmapple: 63 unknown MMIO accesses loggedmacvmm: warn: [main] vmapple:   60 in cfgmacvmm: warn: [main] vmapple:   1 in pvpanicmacvmm: warn: [main] vmapple:   2 in bdifmacvmm: warn: [vcpu0] vmapple: first exit at pc=0x103478: data abort (EC 0x24): ISV=1 SAS=2 (4 bytes) SSE=0 SRT=27 SF=0 AR=0 FnV=0 S1PTW=0 WnR=1 DFSC=0x7 (translation fault)macvmm: warn: [main] vmapple: 63 unknown MMIO accesses loggedmacvmm: warn: [main] vmapple:   60 in cfgmacvmm: warn: [main] vmapple:   1 in pvpanicmacvmm: warn: [main] vmapple:   2 in bdifmacvmm: warn: [vcpu0] vmapple: first exit at pc=0x103478: data abort (EC 0x24): ISV=1 SAS=2 (4 bytes) SSE=0 SRT=27 SF=0 AR=0 FnV=0 S1PTW=0 WnR=1 DFSC=0x7 (translation fault)macvmm: warn: [main] vmapple: 63 unknown MMIO accesses loggedmacvmm: warn: [main] vmapple:   60 in cfgmacvmm: warn: [main] vmapple:   1 in pvpanicmacvmm: warn: [main] vmapple:   2 in bdifmacvmm: guest fatal: reset storm: more than 10 resets within 10 smacvmm: stats: serial_input_dropped=0 serial_input_queued=0 serial_written=0 serial_sink_dropped=0 serial_capped=0 serial_lost=0 serial_filtered=0macvmm: stats: vcpu0 exits: vtimer 0, wfx 0, total 65: hvc 2, data abort 63macvmm: stats: vcpu0 time: exec 0.000 s, wfi 0.000 smacvmm: stats: host cpu 0.000 s over 0.000 s wall (132%)macvmm: stats: rlimit core=0 nofile=1048576
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • Deliberate breakage: in crates/vmm/src/vcpu/mmio.rs, the read-as-zero branch for an access to no device writes all ones of the access size (0xff..ff) into the destination register instead of 0; nothing else changed.
  • The per-access lines (vmapple: unknown MMIO #n: ...) were removed with grep -v before recording, as in 24-first-probe.txt; stderr is merged into stdout by that filter.
course/captures/24-all-ones.txt

Then, still in the copy where the new trace is, the same two summaries:

TerminalReal output
jq -r '.fn // .action // .reason' .cache/vmapple/avp.jsonl | sort | uniq -cexit: 0--- stdout --- 693 mmio  11 PSCI_SYSTEM_RESET  11 PSCI_VERSION
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • The trace of the all-ones run (24-all-ones.txt).
course/captures/24-kinds-ones.txt
TerminalReal output
jq -r 'select(.ipa) | .ipa' .cache/vmapple/avp.jsonl | sort -u | wc -lexit: 0--- stdout ---      16
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • The trace of the all-ones run (24-all-ones.txt).
course/captures/24-ipas-ones.txt

One changed value, a different machine. Each boot made 63 logged accesses, 60 in cfg, 1 in pvpanic and, for the first time, 2 in bdif; across the whole trace they hit 16 distinct addresses. Then two hypercalls: PSCI PSCI_VERSION, then SYSTEM_RESET. macvmm answers a system reset by rebuilding the machine, so all of it repeated 11 times (693 = 11 x 63) until chapter 08's cap on resets stopped it with exit code 3. Each rebuilt machine starts with a fresh logger, so the 256-entry cap never filled: 63 per boot, 693 in the file. --stats describes only the last boot, which lasted under a millisecond, so its times round to 0.000 and its percentage is noise.

Zero gave a silent spin after 14 addresses; all ones gave a path into bdif and then a reset, every time. The all-ones run never stalled: it ended in a reset storm, and that is itself an observation.

The misconception it exposes: "the run that gets further is the right one". All ones handed the ROM a different wrong machine; neither value is what VZ's cfg holds, so both traces describe our machine as much as Apple's ROM. The tool: a controlled variable and a counts-only summary, recorded as observed, never as "the fix".

A global change shows that the answers matter, not which one. The finer experiment changes one register. In the copy's RazWi arm, pass regs.set_x a candidate value when unclaimed.ipa equals one cfg address from your own trace, and 0 for every other address. To separate hypotheses about it (a flag, a count, a version), run once per candidate value (0, all ones, cfg's version 2) and compare the counts. We have not run it, so we show no results.

Return to the repository with cd - (or cd to your repository's path). Keep ../vmapple-ones for Your turn, and delete it when you are done.

The CPU mode you cannot have

Suppose you modelled every device: would a current macOS boot? A patch series posted to QEMU's mailing list, and not merged, reports that recent macOS guests need a private "Apple ISA" CPU mode (ISA, instruction set architecture), switched on by a Hypervisor.framework function no header declares: Mohamed Mediouni's "[RFC PATCH v7 0/7] vmapple: making it work on the latest macOS host releases", March 2026, whose patch 7/7, "hvf: do not merge: enable private ISA" calls that function with the value 3 and swaps the public entitlement for a private one. We have not been able to check that a guest needs the mode; we can check whether we may have it. The probe in tools/hv-denied-probe/, signed like macvmm, asks for the mode once, finding that function by name at run time with dlsym, the C call that looks up a symbol in the loaded libraries:

tools/hv-denied-probe/probe.clines 13-25
int main(void) {  /* Mach-O symbol `__hv_vm_config_set_isa`; dlsym takes the C name (one underscore fewer). */  set_isa_fn set_isa = (set_isa_fn)dlsym(RTLD_DEFAULT, "_hv_vm_config_set_isa");  if (set_isa == NULL) { puts("hv_vm_config_set_isa: symbol not present on this macOS"); return 2; }  hv_vm_config_t cfg = hv_vm_config_create();  hv_return_t set = set_isa(cfg, 3); /* 3: the value QEMU's out-of-tree vmapple RFC uses */  hv_return_t ret = hv_vm_create(cfg);  printf("hv_vm_config_set_isa(3): 0x%08x\n", (unsigned)set);  printf("hv_vm_create with private ISA 3: %s (0x%08x)\n",         ret == HV_DENIED ? "HV_DENIED" : ret == HV_SUCCESS ? "HV_SUCCESS" : "other", (unsigned)ret);  if (ret == HV_SUCCESS) hv_vm_destroy();  return ret == HV_DENIED ? 0 : 1;}
Shell
tools/hv-denied-probe/run.sh
TerminalReal output
tools/hv-denied-probe/run.shexit: 0--- stdout ---hv_vm_config_set_isa(3): 0x00000000hv_vm_create with private ISA 3: HV_DENIED (0xfae94007)
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20course/captures/24-hv-denied.txt

Observed: the configuration call returned 0, then the virtual machine was refused, HV_DENIED, the correct answer on a normally configured Mac. Read that 0 with care: the function's signature and the value 3 are guesses taken from the patch, so a 0 does not prove the mode was set. The solid observation is the pair: hv_vm_create succeeds without the call (every macvmm run in this course) and returns HV_DENIED with it. Also observed: VZ's helper process for each virtual machine (chapter 23's XPC service) carries com.apple.private.hypervisor, one of the restricted entitlements no ad-hoc signature can carry (the codesign-entitlements primer):

Shell
XPC=/System/Library/Frameworks/Virtualization.framework/Versions/A/XPCServices/com.apple.Virtualization.VirtualMachine.xpccodesign -d --entitlements - "$XPC" 2>&1 | grep -A1 private.hypervisor
TerminalReal output
codesign -d --entitlements - "$XPC" 2>&1 | grep -A1 private.hypervisorexit: 0--- stdout ---	[Key] com.apple.private.hypervisor	[Value]
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • XPC=/System/Library/Frameworks/Virtualization.framework/Versions/A/XPCServices/com.apple.Virtualization.VirtualMachine.xpc, the helper process Virtualization.framework starts for each virtual machine.
course/captures/24-vz-helper-entitlement.txt

Inferred, from our two observations plus that patch, which asks for exactly this entitlement: the entitlement unlocks the mode, and the mode is what is refused to us. Testing that patch means switching off macOS's system protections; this course never asks you to.

Production note

This is why VZ is the product and vmapple is research: VZ's helper has the private mode, the graphics bridge and the keys, and Apple can change any of them. A tempting belief is "if QEMU can do it, it is a few days of porting". But QEMU's own cfg block has fields named unk1 to unk10, the keys are Apple's, and the CPU mode is refused to us: each device is an investigation, and an honest progress report is part of the engineering.

Never copied

Before you write anything up, check that no file in your tree is AVPBooter. Only files of exactly the ROM's size are hashed, so it is fast:

Shell
AVP=/System/Library/Frameworks/Virtualization.framework/Versions/A/Resources/AVPBooter.vmapple2.binfind . -type f -size "$(stat -f %z "$AVP")c" -not -path './.git/*' -exec shasum -a 256 {} + | grep -c "$(shasum -a 256 "$AVP" | cut -c1-64)"
TerminalReal output
find . -type f -size "$(stat -f %z "$AVP")c" -not -path './.git/*' -exec shasum -a 256 {} + | grep -c "$(shasum -a 256 "$AVP" | cut -c1-64)"exit: 1--- stdout ---0
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • Run at the repository root (build outputs and .cache included) with AVP set to the system AVPBooter path; grep -c prints 0 and exits 1 when nothing matches.
course/captures/24-never-copied.txt

Zero matches; grep -c exits 1 when it counts nothing, so exit 1 is the good answer.

Your turn

This is the capstone; there is no scaffolding. In your workspace:

  1. Your own trace. Run the first probe and the summaries. Record your AVPBooter's size (stat -f %z "$AVP") and the first 16 hex digits of its sha256 (shasum -a 256 "$AVP" | cut -c1-16), never the file.
  2. The controlled experiment. Run zero and all ones, changing nothing else. The all-ones edit lives in ../vmapple-ones; run the zero case in the repository.
  3. The design record. Write learner/docs/macos/design.md with the sections Question, Setup (Mac, macOS build, ROM size and hash prefix, commit), Observed, Inferred (with sources), Unknown, Experiments run, Next experiment, Stop criteria. Then write learner/docs/adr/0002-avpbooter-tracing.md, an architecture decision record titled "How far we trace AVPBooter". As in chapter 21, an ADR is a short record of one decision, its context and its consequences (Michael Nygard's original post).
  4. The next device, planned. The trace asks for cfg. From QEMU's field list, write which fields you would fill and with what. If you installed macOS in chapter 23, take the ECID from tools/vz-mac/run.sh ecid --bundle .cache/macvmm/macos-vm; no bundle? Write the fields with a placeholder ECID and say so in Setup. Then run one per-register experiment, editing ../vmapple-ones, and record what changed. Building the whole device is optional: the reference stops at the unmodelled cfg block, and nobody knows whether a filled one gets further.

Stuck? A capstone has no hint ladder. The lab's fallback table and the "What now works" list below show how far the reference got.

Checkpoint

The default build must refuse --machine vmapple (exit code 2), and no file in your tree or caches may have AVPBooter's sha256. A feature build, made in target/vmapple-feature so target/debug/macvmm is untouched, runs the first probe for 20 seconds: the first exit must be inside the ROM and the unknown-MMIO summary must appear (the reference's milestone). Per-access lines and the trace stay in the run's scratch directory. Last, the private-mode probe must get HV_DENIED. The first run compiles for a few minutes.

Checkpoint

Needs a Mac

Run this from the repository root:

scripts/checkpoint.sh 24

You should see, as the last line:

CHECKPOINT 24 PASS

TerminalReal output
scripts/checkpoint.sh 24exit: 0--- stdout ---checkpoint: implementation <tree>[INFO] contract tests   none for this chapter[PASS] runs on your Mac refusal: 1/1 serial markers, exit 2 in 0.06s[PASS] runs on your Mac no-copy: 1/1 serial markers, exit 0 in 0.15s[PASS] runs on your Mac rom-probe: 4/4 serial markers, exit 5 in 20.34s[PASS] runs on your Mac isa-denied: 1/1 serial markers, exit 0 in 0.27s[INFO] journal          not checked (not a learner tree)CHECKPOINT 24 PASS
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • The chapter's checkpoint, run against an unmodified copy of the reference (scripts/checkpoint.sh 24 --impl <tree>): what a finished chapter 24 looks like.
  • The journal line reports "not a learner tree" here; in your own learner/ workspace it checks your journal.
course/captures/24-checkpoint.txt

The end-to-end tests also check exit code 3 under the default fatal policy and a refused third concurrent run. Default build:

Shell
cargo test -q -p macvmm --features hvf-tests --test e2e_vmapple -- --test-threads=1
TerminalReal output
cargo test -q -p macvmm --features hvf-tests --test e2e_vmapple -- --test-threads=1exit: 0--- stdout ---running 3 tests...test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.39s
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • Run in a copy of the reference tree (the repository without .git, target and .cache).
course/captures/24-e2e-default.txt

With the feature:

Shell
cargo test -q -p macvmm --features hvf-tests,experimental-vmapple --test e2e_vmapple -- --test-threads=1
TerminalReal output
cargo test -q -p macvmm --features hvf-tests,experimental-vmapple --test e2e_vmapple -- --test-threads=1exit: 0--- stdout ---running 6 tests......test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 20.50s
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • Run in a copy of the reference tree (the repository without .git, target and .cache), so the never-copied scan walked that copy; 24-never-copied.txt scans the real repository.
course/captures/24-e2e-feature.txt

The checkpoint checks that your journal answers every question; check your design record against Your turn yourself. Nothing checks for "macOS booted", because it did not.

What now works:

  • macvmm runs Apple's boot ROM, read in place, on a second board, and records every access to a device it lacks;
  • you can tell polling, waiting and running stalls apart from --stats and the trace;
  • you can change one variable on an undocumented machine and report the result as observed, inferred and unknown;
  • you know the three gates on the low road: undocumented devices, a CPU mode reserved for Apple, and a licence that forbids reading the code.

The next chapter starts from the reference at the end of chapter 24.

What's next

Part XI turns the VMM into something you could hand to someone else. Chapter 25 writes the threat model of everything you built, fuzzes the queue code that reads guest data (the discipline bdif's guest-controlled addresses demanded above), turns a hostile guest loose on your VMM, and confines the process with a sandbox.

Open question

After the first five devices, what would convince you to stop and write "not feasible in the time we have"? Set the criteria now, before spending the time, and say what each would look like in a trace.

Spec hunt

  • QEMU hw/vmapple/bdif.c at tag v10.0.0: which register offset does the guest write to start a read, what length must the first descriptor entry have, and what is the largest request QEMU accepts?
  • The macOS software licence agreement on your Mac, sections 2K and 2N: which sentence makes "load from the host, never copy" a requirement rather than good manners?
Progress is stored only in this browser.