indicogniBuild a VMM

Contents

Chapter 25 · Part XI

Hardening: threat model, fuzzing and sandboxing

Needs a Mac Runs in browser ~6 h Lab: Hostile-ring fuzzer
26 of 26

Course progress: chapter 25 is 26 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 13: Loading kernels: arm64 Image, initramfs and ELF

    The eight bytes at offset 0x10 of an Image header are 00 00 2a 02 00 00 00 00, and text_offset is 0. Where does the kernel's memory start and end in our plan?

    Show answer

    The field is image_size, little-endian: 0x022a0000. The kernel starts at the 2 MiB-aligned base 0x4020_0000 plus text_offset 0, so it owns 0x4020_0000..0x424a_0000 (start plus image_size, end exclusive).

  2. From chapter 09: A device is a state machine: the bus, PL011 and PL031

    A guest reads the PL011's flag register FR and gets 0x90. May it write a byte to DR now, and is there a byte for it to read?

    Show answer

    0x90 is bit 7 (TXFE, transmit FIFO empty) plus bit 4 (RXFE, receive FIFO empty). It may send: the transmit side is empty, so TXFF (full) is clear. There is nothing to read: RXFE says the receive FIFO is empty, and a DR read now would return 0.

  3. From chapter 04: Guest memory: the only safe access is a copy

    A guest asks the VMM to read 8 bytes at address 0xFFFF_FFFF_FFFF_FFFC. Guest RAM is 0x4000_0000..0x4400_0000. Compute addr + len in 64-bit wrapping arithmetic, and say whether the check addr >= 0x4000_0000 && addr + len <= 0x4400_0000 accepts the access.

    Show answer

    The true sum is 0x1_0000_0000_0000_0004, which needs 65 bits; wrapped to 64 bits it is 0x4. Both halves of the check pass (0xFFFF_FFFF_FFFF_FFFC is above the base, 0x4 is below the end), so a wrapping check accepts an access that starts 4 bytes below the top of the address space. checked_add returns None instead, and the access is refused.

Concepts you'll need

Chapters before this one: chapter 16, Split virtqueues: shared memory with an adversary.

  • Core, taught here: the trust boundaries of a virtual machine monitor (VMM) and a threat model; terminal injection in full; fuzzing (a seeded pseudo-random number generator, structure-aware mutation, a corpus, invariants, minimisation); the hostile guest; confining the VMM process after set-up.
  • Core, from earlier: the guest as an adversary (chapter 04); virtqueues, the hop budget, TOCTOU and copy-then-validate (chapter 16); the output filter (chapter 09); containment and the opt-in ,learn peer (chapter 19); UNDEF injection and exit codes (chapter 08); the reset limit and PSCI, the power state coordination interface (chapters 08, 14); DEVICE_NEEDS_RESET (chapter 15); CPU_ON (chapter 20); accesses whose instruction syndrome is not valid (ISV=0) and the injected abort (chapter 21).
  • Primers (read first): macos-sandbox (Seatbelt, SBPL profiles, sandbox_init, the "checked when a resource is acquired" rule, rlimits and core dumps, umask, O_CLOEXEC, why the run path never forks).
  • Primers (review): tty-termios (escape sequences, the terminal attack strings); codesign-entitlements (its "going deeper" parts: an entitlement is a permission, not a fence; the hardened runtime).
  • Pointers: STRIDE and docs/security/threat-model.md (an Aside); cargo fuzz and coverage-guided fuzzing (an Aside); the confused deputy (one sentence and a link).
  • Forward definitions: none.

Outside two quarantined places (the hvf crate, which holds the hypervisor calls and a few host calls such as the sandbox, and the guest-memory mapping), our VMM forbids unsafe code. Now delete one line from chapter 16's descriptor-chain walker, the hop budget, and point a program that invents hostile virtqueues at it. Then plant a subtler bug that fires only when a chain holds three buffers and the first and third share an address. How long does an automatic search need for each?

Predict For the missing hop budget, and then for the three-buffer bug: will a fuzzer find it in about 10 seconds, about 10 minutes, or never?

Write both guesses, with one sentence of reasoning each, under ## Predict in your journal. Sitting A runs both plants with the reference's fuzzer; then you time your own fuzzer on the same two.

Chapter 00's problem ledger listed what a kernel assumes it owns. Every row is now closed, and each mechanism that closed one (exits, memory-mapped I/O (MMIO), rings, the console) is also a door the guest can push on. This chapter adds no row; it reads the ledger the other way round: every row is also an input the guest controls, so what can a guest that is trying to hurt us do with each one? Sitting A (about 3.5 hours) is the threat model, the reference's fuzzer, and your own fuzzer; sitting B (about 2.5 hours, at your Mac) is the hostile guest and the sandbox.

Objectives: by the end you can

  • (Sitting A) Write a threat model for your VMM in STRIDE style (a six-letter checklist of threat kinds, below): assets, every trust boundary, what each attacker can do. Cross-check it against the reference's docs/security/threat-model.md.
  • (Sitting A) Build a dependency-free fuzz harness (a seeded generator, structure-aware mutation of descriptor chains, invariants checked after every input) that runs device models on the host, find each planted bug in the queue code, and minimise each reproducer.
  • (Sitting B) Run the hostile guest's eight attack phases (MMIO, ISV=0, system registers, SMCCC (SMC calling convention, where SMC is the Secure Monitor Call instruction) calls, virtqueues with a live time-of-check-to-time-of-use (TOCTOU) race, terminal strings, a reset storm, an output flood) and explain each expected exit code.
  • (Sitting B) Confine the process after set-up with a sandbox that is on by default (--no-sandbox opts out), set RLIMIT_CORE to 0, and measure what the sandbox denies.

Before you start. From the repository root, run scripts/learner start 25; it copies this chapter's journal to learner/journal/25.md, "your journal" below. There is no starter code: you create learner/crates/fuzz/ and learner/crates/macvmm/src/sandbox.rs in Your turn.

Memory-safe is not the same as safe

The tempting belief is "Rust is memory safe, so a Rust VMM is secure". forbid(unsafe_code) rules out reading past a buffer, using freed memory, a race that tears a value in half. It cannot rule out a program that is memory safe and wrong. Five classes survive, each with a candidate in our VMM:

ClassWhat the guest controlsAn instance in our VMM
logic bugthe numbers we checka range check that adds addr + len with wrapping arithmetic (chapter 04)
resource exhaustionhow much work it asks fora --trace file the guest could grow without bound, had it no size cap
infinite loopthe shape of a data structurea descriptor whose next points at itself (chapter 16)
TOCTOU (time of check to time of use)the bytes between our two readsa descriptor len read once to check and again to use (chapter 16)
confused deputya name we act on with our rightsa --serial file: path (chapter 09) that names the guest's own disk image

A confused deputy is a privileged program tricked into using its rights for someone else (Hardy, 1988). Our VMM can open any file you can, so a path handed over for one purpose must never serve another.

None of these is a crash. The worst return Ok with a wrong answer, so a test that only asks "did it panic?" finds none of them.

A threat model on one page

Before hunting bugs, decide what you are protecting and from whom. Writing that down is a threat model. It has three parts.

Assets, what an attacker wants: your user account (files, keys, shell), your terminal, the VMM process itself (it holds guest RAM and open disk images), the disk images and the files near them, and the Mac's CPU, memory and disk space.

Trust boundaries, where data crosses from someone you trust less to someone you trust more:

 guest (hostile)            macvmm process (your rights)              host+--------------+ traps into +--------------------------+ writes to +---------------+| guest kernel | ---------> | exit decode, devices,    | --------> | your terminal || and its apps |            | GuestMemory copies,      |           +---------------+|              | =========> | loaders, CLI             | <-------- | your files,   |+--------------+ shares RAM +--------------------------+   reads   | .cache/macvmm |                    with                 ^                         +---------------+                                         | plant links for,                ^                                         | connect to                      | downloads into                               +-------------------+               +---------------+                               | other local users |               |   internet    |                               +-------------------+               +---------------+

Each row below is an arrow; the guest has two, because it reaches us by trapping and through shared RAM.

BoundaryWho is distrustedWhat crosses
guest to VMMthe guest, fullyevery register on an exit, every MMIO value, every byte of guest RAM, at any moment
VMM to terminalthe guest's outputserial and console bytes, which can be escape sequences: terminal injection
host files to VMMthe file's contentImage, ELF, initramfs and disk bytes (you chose the path, not what is inside)
internet to cachethe downloadanything until its sha256 matches the pinned value
other users to VMMother accounts on the Macplanted symlinks, world-readable outputs, connections to sockets

Attackers and their capabilities. The malicious guest runs any code at exception level 1 (EL1, the guest kernel's level) on every virtual CPU (vCPU) at once, rewrites RAM while we read it, traps as often as it likes and chooses every value it hands us; stage 2 keeps it out of host memory. A malicious file can be any bytes. Another local user can create files and symbolic links in shared directories such as /tmp before macvmm does, and connect to any socket macvmm leaves open to everyone; the umask 077 below and opens that never follow a symbolic link answer that (see the next paragraph). A network attacker on the download path can serve any bytes; the pinned sha256 answers that. A compromised VMM is what you get if any of them succeeds: code running as you, with the hypervisor entitlement and every file descriptor macvmm holds. Sitting B shrinks that last one.

Chapter 10 promised to explain why the reference's open_output (in crates/vmm/src/backend/hostio.rs), which opens every file macvmm writes, checks more than "no symbolic link". Each check answers one of the attackers above. It resolves the directory you named once (a link you typed, such as /tmp, is your intent), then opens the file with a flag that refuses a symbolic link anywhere in that path, so a link planted as the file's name, or swapped in afterwards, is refused. It requires a regular file owned by you, so a file another user planted at the name is refused rather than written. It requires a link count of 1, because macOS lets any user make a hard link (a second name for the same file) to a file they do not own: a hard link to one of your files, planted in /tmp, passes the owner check, and writing through it would empty the original. It refuses a file that is already open as an input or output, the confused-deputy row of the table above: --serial file: naming the guest's own disk image. Only after every check passes does it empty the file.

STRIDE is a checklist so no kind of threat is forgotten. Each letter is a kind of threat: Spoofing (pretending to be someone else), Tampering (changing data you rely on), Repudiation (doing something and denying it), Information disclosure (reading what you should not), Denial of service (making the VMM stop or crawl), Elevation of privilege (gaining rights you were not given). Walk each boundary through the six letters and write the mitigation, or "n/a", next to each. One row, worked:

guest to VMM  S  n/a: the guest is the only party on this boundary  T  rewrites descriptors mid-walk         -> copy-then-validate (chapter 16)  R  n/a: we do not hold the guest to account  I  reads past its buffer                 -> bounds-checked GuestMemory (chapter 04)  D  a descriptor chain that loops         -> the hop budget (chapter 16)  E  runs code inside macvmm               -> the sandbox, on by default (sitting B)

Aside

STRIDE comes from Microsoft (their description). The reference's docs/security/threat-model.md has a STRIDE table naming each surface and mitigation; its row tags (VQ-5, MEM-7, SBX-2 and so on) reappear in the reference's code and messages below.

Write yours now in learner/docs/security/threat-model.md: the assets, the boundary table, five attackers with one paragraph each, and a STRIDE row for each of the other four boundaries. It is the evidence for journal question 2.

Let a program write the hostile inputs

Chapter 16's hostile tests are cases someone thought of; the bugs that survive are the ones nobody did. So let a program build millions of slightly wrong inputs, run the real code on each, and check that nothing went wrong. That is fuzzing. Five decisions turn the idea into a tool; the reference's crates/fuzz/ depends only on the workspace's own crates (vmm and xtask).

Randomness you can replay. A bug found once and never again is useless, so inputs come from a seeded PRNG (pseudo-random number generator): arithmetic that turns a starting number, the seed, into a random-looking stream, identical on every run. Ours is xorshift64*, three shifts and a multiply:

crates/fuzz/src/rng.rslines 37-45
/// The next 64 random bits.pub fn next_u64(&mut self) -> u64 {    let mut x = self.0;    x ^= x >> 12;    x ^= x << 25;    x ^= x >> 27;    self.0 = x;    x.wrapping_mul(0x2545_f491_4f6c_dd1d)}

Iteration i derives its own generator from the seed and i, so iteration 23,338,941 could be regenerated from those two numbers alone, without the 23 million before it. In practice the saved input replays it (below); a --start N flag would be a small addition to your own fuzzer:

crates/fuzz/src/rng.rslines 26-33
/// A generator derived from `(seed, stream)`, so iteration `n` of a run can be regenerated/// without replaying iterations `0..n`. SplitMix64's finalizer decorrelates the two.pub fn derive(seed: u64, stream: u64) -> Rng {    let mut z = seed ^ stream.wrapping_mul(0x9e37_79b9_7f4a_7c15);    z = (z ^ (z >> 30)).wrapping_mul(0xbf58_476d_1ce4_e5b9);    z = (z ^ (z >> 27)).wrapping_mul(0x94d0_49bb_1331_11eb);    Rng::new(z ^ (z >> 31))}

A target is a function of bytes. Each fuzz target decodes bytes into an input for one parser or device model, runs the real code against test doubles (chapter 04's VecMemory RAM, a fake interrupt line), and reports a verdict. It also knows how to build a well-formed input and how to damage one:

crates/fuzz/src/lib.rslines 31-46
/// `Ok` if every invariant held, else a description of the first violation.pub type Verdict = Result<(), String>;/// One fuzz target.pub struct Target {    /// The name on the command line (`cargo run -p fuzz -- <name>`).    pub name: &'static str,    /// Run one input and check the invariants.    pub run: fn(&[u8]) -> Verdict,    /// A random *well-formed* input: the starting point the mutators corrupt.    pub seed: fn(&mut rng::Rng) -> Vec<u8>,    /// Target-specific structural mutation (descriptor shapes, MMIO op fields, ...).    pub mutate: fn(&mut rng::Rng, &mut Vec<u8>),    /// Inputs are truncated to this length.    pub max_len: usize,}

No Hypervisor.framework: the virtqueue target drives the device worker's own Queue::pop, into_validated and add_used on the host.

Invariants, not only panics. The invariants are the test oracle, the part that decides pass or fail: properties that must hold after every input. The virtqueue target checks five:

  1. No panic, and a ring error marks the queue broken.
  2. Bounded work: at most 2N + 1 descriptor reads per pop, for a queue of N entries. The hop budget allows N reads in the main table and restarts for one indirect table of at most N entries; the + 1 is one read of slack.
  3. Each descriptor of a validated chain was read once; a second read is a double fetch.
  4. Every validated buffer lies inside one RAM region, and each direction's total is within the cap.
  5. The device writes only into the chain's writable buffers and the used ring.

Messages carry the tag of a row of the reference's threat model: invariant 2 reports as VQ-5, 3 as MEM-7, 4 as VQ-4 and 5 as VQ-9. Here are invariants 3 and 4. Invariant 4 adds address and length in 128-bit arithmetic, so the check itself cannot overflow:

crates/fuzz/src/targets/virtqueue.rslines 176-187
/// Invariant 3: no address appears twice.pub fn read_once(reads: &[u64]) -> Result<(), String> {    let mut seen = reads.to_vec();    seen.sort_unstable();    match seen.windows(2).find(|w| w.first() == w.get(1)) {        Some(w) => Err(format!(            "descriptor at {:#x} read twice in one pop (double fetch, MEM-7)",            w.first().copied().unwrap_or(0)        )),        None => Ok(()),    }}
crates/fuzz/src/targets/mod.rslines 139-147
/// True if `[addr, addr + len)` lies inside a single region, computed in `u128` so that the/// check itself cannot overflow (the reference model the code under test is compared with).pub fn in_one_region(addr: u64, len: u64) -> bool {    let (a, l) = (u128::from(addr), u128::from(len));    REGIONS.iter().any(|&(b, s)| {        let (b, s) = (u128::from(b), u128::from(s));        l > 0 && a >= b && a + l <= b + s    })}

The fuzz RAM has two regions and a hole on purpose: "inside one region" can only fail, and so be tested, when there are two. We write a buffer as address+length, so 0x40008000+16 means 16 bytes starting at 0x40008000:

0x4000_0000  region A, 256 KiB: descriptor table 0x4000_1000, avail ring 0x4000_2000,             used ring 0x4000_3000, indirect table 0x4000_4000, buffers from 0x4000_80000x4004_0000  the hole, 256 KiB of not-RAM0x4008_0000  region B, 64 KiB: more buffers0x4009_0000  end of RAM

How do bytes become a ring? The input has fixed offsets, so the mutations below know where each descriptor sits:

crates/fuzz/src/targets/virtqueue.rslines 5-15
//! **Input** (fixed offsets, so the structural mutators know where descriptors are)://!//! | Bytes | Field |//! |---|---|//! | 0 | queue size: `1 << (b % 9)`, 1..=256 |//! | 1 | bit 0 `INDIRECT_DESC` negotiated, bit 1 rings packed at the end of region B, bit 2 `avail.flags = NO_INTERRUPT` |//! | 2..4 | avail entries published per round (more than the size is an index jump, which must reset the queue) |//! | 4 | `max_total` (the per-direction byte cap): 64 KiB, 4 KiB, 1 MiB or 4 GiB |//! | 5 | rounds: the driver republishes `1 + b % 4` times, so `used.idx` wraps the ring |//! | 8..520 | the 256 avail-ring entries |//! | 520.. | the descriptor table (256 × 16 bytes), then a 64-entry indirect table |

Byte 0 picks the queue size, byte 1 the options, bytes 8 onwards are the avail-ring entries (the heads of the chains the driver offers), and from byte 520 come 16-byte descriptors, each laid out as chapter 16's descriptor (address, length, flags, next). When you design your own target, choose your own layout or copy this one. The target writes those bytes into the fuzz RAM as rings, then runs them:

crates/fuzz/src/targets/virtqueue.rslines 215-257
/// Run one ring (module docs for the input and the invariants).pub fn run(data: &[u8]) -> crate::Verdict {    let spec = Spec::decode(data);    let mem = ram()?;    write_rings(&spec, data, &mem)?;    let mut q = spec.queue();    // Invariant 2: the hop budget is N per table, and an indirect table has at most N entries.    let max_reads = 2 * usize::from(spec.size) + 1;    let mut completed: u16 = 0;    for round in 0..spec.rounds {        let idx = spec.per_round.wrapping_mul(round.wrapping_add(1));        mem.write_u16(GuestAddress(spec.avail + 2), idx)            .map_err(|e| format!("avail.idx: {e:?}"))?;        for _ in 0..=spec.size {            mem.enable_log(); // the access log of this one pop            let chain = match q.pop(&*mem) {                Ok(None) => break,                Ok(Some(c)) => c,                Err(_) if q.is_broken() && q.pop(&*mem).is_err() => return Ok(()), // latched: stays broken until reset                Err(_) => return Err("a ring error did not latch the queue as broken".into()),            };            let validated = chain.into_validated(spec.max_total);            let reads = descriptor_reads(&mem.log());            if reads.len() > max_reads {                return Err(format!(                    "{} descriptor reads for one pop of a size-{} queue (VQ-5 hop budget)",                    reads.len(),                    spec.size                ));            }            let Ok(v) = validated else {                return Ok(()); // the device would set NEEDS_RESET here            };            read_once(&reads)?; // invariant 3: each descriptor read once            chain_in_ram(&v, spec.max_total)?; // invariant 4: in RAM, under the cap            match complete(&spec, &mem, &mut q, &v, completed)? {                Some(c) => completed = c,                None => return Ok(()),            }        }    }    Ok(())}

Mutation that knows the shape. Random bit flips mostly give chains that die at the first check (next out of range). The structure-aware mutation knows where the 16-byte descriptors are and damages them as an attacker would: next pointing back, or a length that ends a few bytes into a region, often the other one. rec is the byte offset of descriptor i; ADDR, LEN, FLAGS and NEXT are field offsets, and F_NEXT is the NEXT flag:

crates/fuzz/src/mutate.rslines 183-206
1 => {    // A back edge: next = some j <= i, with NEXT set.    let j = rng.index(i + 1);    put_le(buf, rec + NEXT, 2, j as u64);    let flags = get_le(buf, rec + FLAGS, 2) | F_NEXT;    put_le(buf, rec + FLAGS, 2, flags);}2 => {    let addr = get_le(buf, rec + ADDR, 8);    let len = match rng.below(4) {        0 => 0,        1 => u64::from(u32::MAX),        2 => 0x8000_0000,        // End a few bytes into another region (crossing the hole between them).        _ => {            let target = ram                .regions                .get(rng.index(ram.regions.len()))                .map_or(0, |&(b, s)| b.wrapping_add(rng.below(s.clamp(1, 64))));            target.wrapping_sub(addr).wrapping_add(1) & 0xffff_ffff        }    };    put_le(buf, rec + LEN, 4, len);}

Another move aims the address at the edges, the "specials": the last bytes of a region, the hole, a device window, the rings themselves:

crates/fuzz/src/mutate.rslines 209-231
3 => {    let addr = match rng.below(4) {        // The last few bytes of a region.        0 => ram            .regions            .get(rng.index(ram.regions.len()))            .map_or(0, |&(b, s)| {                b.wrapping_add(s).wrapping_sub(1 + rng.below(32))            }),        // Just past a region's end (the hole, or beyond RAM).        1 => ram            .regions            .get(rng.index(ram.regions.len()))            .map_or(0, |&(b, s)| b.wrapping_add(s).wrapping_add(rng.below(16))),        2 => ram            .specials            .get(rng.index(ram.specials.len()))            .copied()            .unwrap_or(0),        _ => rng.pick(&INTERESTING_U64).unwrap_or(0),    };    put_le(buf, rec + ADDR, 8, addr);}

An input generator instead of a stored corpus. Fuzzers usually damage a corpus, a set of good inputs. Ours draws a fresh well-formed ring each iteration (one to four buffers per chain, readable before writable, some indirect; the target's seed function, not the PRNG's seed), then damages it up to eight times, each step, by coin toss, a structure-aware move or a byte-level mutation (a bit flip, a random byte, a boundary integer such as 0xffff_ffff):

crates/fuzz/src/main.rslines 184-231
/// Fuzz one target; returns the number of failures (0 or 1: the run stops at the first).fn fuzz(t: &'static Target, o: &Opts, watch: &Watch, epoch: Instant) -> u64 {    let deadline = Instant::now() + Duration::from_secs(o.seconds);    if let Ok(mut n) = watch.name.lock() {        *n = t.name;    }    let mut iters = 0u64;    while iters < o.iters && Instant::now() < deadline {        let mut rng = Rng::derive(o.seed, iters);        let mut input = (t.seed)(&mut rng);        let rounds = rng.below(9);        for _ in 0..rounds {            if rng.coin() {                (t.mutate)(&mut rng, &mut input);            } else {                fuzz::mutate::bytes(&mut rng, &mut input, t.max_len);            }        }        input.truncate(t.max_len);        if let Ok(mut w) = watch.input.lock() {            w.clone_from(&input);        }        watch.iter.store(iters, Ordering::SeqCst);        watch.started_ms.store(now_ms(epoch), Ordering::SeqCst);        let r = run_one(t, &input);        watch.started_ms.store(u64::MAX, Ordering::SeqCst);        iters += 1;        if let Err(e) = r {            let saved = save(t.name, o.seed, iters - 1, &input);            say(&format!(                "fuzz {}: FAILURE at iteration {} (seed {}): {e}",                t.name,                iters - 1,                o.seed            ));            say(&format!(                "fuzz {}: input saved to {} (replay: cargo run -p fuzz --release -- {} --replay FILE)",                t.name,                saved.map_or("<not saved>".into(), |p| p.display().to_string()),                t.name            ));            say(&format!("fuzz {}: {iters} iterations, 1 failures", t.name));            return 1;        }    }    say(&format!("fuzz {}: {iters} iterations, 0 failures", t.name));    0}

A failing input is saved (mode 0600, never overwriting) and becomes a regression test. Safe Rust cannot interrupt a hang, so a watchdog thread saves any input that runs over two seconds and exits with HANG.

Aside

Our fuzzer is blind: it never learns which inputs reached new code. A coverage-guided fuzzer does, and keeps mutating those. cargo fuzz drives one, libFuzzer (the Rust Fuzz Book); it needs a nightly compiler, so it stays optional here, and every target is exported as fuzz_<target>(&[u8]) for it.

The lab brings the fuzzer to your browser:

Lab

Hostile-ring fuzzer

Patch one of chapter 25's planted bugs into chapter 16's queue code, let a seeded fuzzer invent hostile descriptor rings, and see which invariant catches the first failing input.

Runs in browserOpen full page: Hostile-ring fuzzer

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

If it does not load, nothing is lost: it mutates chains for chapter 16's queue model and stops at the first input that breaks an invariant.

Ten seconds, or never?

The plants are patches in crates/fuzz/planted/, written against the reference's chain.rs and queue.rs, so they will not apply to your own walker. To run one, copy the reference, patch the copy, and fuzz it. Use one fresh copy per plant, and never patch a copy twice: a second patch either fails or stacks two bugs. From the repository root:

Shell
P=02-chain-no-hop-budgetrsync -a --exclude /target --exclude /.cache --exclude /.git --exclude /learner ./ "$TMPDIR/$P/"cd "$TMPDIR/$P" && patch -p1 < "crates/fuzz/planted/$P.patch"cargo run -q --release -p fuzz -- virtqueue --seconds 600cd -

The leading / makes each --exclude skip only the top-level directory of that name; without it, rsync also drops the course tooling's own learner module, and the copy does not build. The first run in a copy builds the workspace in release mode before fuzzing, so judge the fuzzer by its iteration count, not your stopwatch. cd - returns you to the repository root.

This plant deletes the hop-budget decrement. With the default seed, 1, you should see our iteration numbers on any Mac; the seconds depend on the machine, and --seed 2 gives other numbers. (Most of our runs used --seconds 590 so they fit our recording tool's ten-minute limit; use 600. /usr/bin/time -p adds the real/user/sys lines.) Check your Predict entry, then our run:

TerminalReal output
/usr/bin/time -p cargo run -q --release -p fuzz -- virtqueue --seconds 590exit: 1--- stdout ---fuzz virtqueue: FAILURE at iteration 7 (seed 1): 2838 descriptor reads for one pop of a size-2 queue (VQ-5 hop budget)fuzz virtqueue: input saved to <tree>/crates/fuzz/../../target/fuzz/crashes/virtqueue-seed1-iter7-0.bin (replay: cargo run -p fuzz --release -- virtqueue --replay FILE)fuzz virtqueue: 8 iterations, 1 failures--- stderr ---real 0.30user 0.02sys 0.02
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • Predict fork, first plant: crates/fuzz/planted/02-chain-no-hop-budget.patch applied to a copy of the reference (the hop budget in chain.rs removed); the fuzzer built in that copy. /usr/bin/time -p adds the real/user/sys lines on stderr.
course/captures/25-predict-hop.txt

Iteration 7, under a second, and not a hang. The saved input is a two-entry queue whose second descriptor points at itself. The walk went round it until the chain's total passed its 64 KiB cap and the walker gave up by itself; only invariant 2 noticed that 2,838 reads for a two-entry queue is a loop. One check (the byte cap) covering for a missing one (the hop budget) is defence in depth, and here it hid the bug from everything except the invariant.

The second plant, 05-chain-verdict-cache.patch, adds a "verdict cache": a buffer at the same address as the buffer two hops earlier skips the RAM check, whatever its length:

TerminalReal output
/usr/bin/time -p cargo run -q --release -p fuzz -- virtqueue --seconds 590exit: 1--- stdout ---fuzz virtqueue: FAILURE at iteration 23338941 (seed 1): validated buffer 0x40003000+0x80000000 is not inside one RAM region (VQ-4)fuzz virtqueue: input saved to <tree>/crates/fuzz/../../target/fuzz/crashes/virtqueue-seed1-iter23338941-0.bin (replay: cargo run -p fuzz --release -- virtqueue --replay FILE)fuzz virtqueue: 23338942 iterations, 1 failures--- stderr ---real 128.07user 67.37sys 58.07
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • Predict fork, second plant: crates/fuzz/planted/05-chain-verdict-cache.patch applied to a copy of the reference (step() skips the RAM check for a buffer whose address equals the buffer two hops earlier, a 'verdict cache' that ignores the new length); the fuzzer built in that copy. --seconds 590 keeps the run inside the capture's 600 s limit. /usr/bin/time -p adds the real/user/sys lines on stderr.
course/captures/25-predict-seq3.txt

Iteration 23,338,941, after 128 seconds. The failing buffer, 0x40003000+0x80000000, starts at the used ring, one of the specials. Two descriptors two hops apart had to receive the same special address; drawn from all 2^64 addresses, they would essentially never match. Structure made the search possible. Would coverage guidance make it shorter? We did not measure that; it is worth asking which new code path a coverage-guided fuzzer would see first. Write our two times in your journal; you add your own fuzzer's times in Your turn.

The saved input replays, as it must:

TerminalReal output
cargo run -q --release -p fuzz -- virtqueue --replay target/fuzz/crashes/virtqueue-seed1-iter23338941-0.binexit: 1--- stdout ---fuzz virtqueue: replay FAILED: validated buffer 0x40003000+0x80000000 is not inside one RAM region (VQ-4)
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • The second plant's copy (05-chain-verdict-cache.patch applied): replaying the input the fuzzer saved, before any minimisation.
course/captures/25-replay-saved.txt

It is 5,640 bytes, of which 162 are not zero (wc -c, before and after deleting the zero bytes with tr -d '\000'), and most of those are unrelated to the bug. Minimising a reproducer means finding the smallest input that still fails, so a human can read the cause: repeatedly zero or delete a chunk (halves, then quarters, down to single bytes), keep each change after which the replay still fails, and stop when none does.

You write the minimiser in Your turn; the reference has none yet. So we built by hand what one aims for, from the input layout above: one chain of three buffers, readable 0x40008000+16, writable 0x40009000+16, writable 0x40008000+0x40000, which runs off the end of region A. It ships as crates/fuzz/planted/05-three-buffers.bin: 568 bytes (the header, the avail entries and three descriptors), 17 of them not zero. It fails against the planted copy, and passes against the unmodified reference:

TerminalReal output
cargo run -q --release -p fuzz -- virtqueue --replay crates/fuzz/planted/05-three-buffers.binexit: 1--- stdout ---fuzz virtqueue: replay FAILED: validated buffer 0x40008000+0x40000 is not inside one RAM region (VQ-4)
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • The second plant's copy (05-chain-verdict-cache.patch applied) replaying the hand-built three-buffer input. Its layout: a size-4 queue, one chain of three buffers (readable 0x40008000+16, writable 0x40009000+16, writable 0x40008000+0x40000).
course/captures/25-replay-seq3.txt
TerminalReal output
cargo run -q --release -p fuzz -- virtqueue --replay crates/fuzz/planted/05-three-buffers.binexit: 0--- stdout ---fuzz virtqueue: replay OK
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • The hand-built three-buffer input (crates/fuzz/planted/05-three-buffers.bin) against an unmodified copy of the reference.
course/captures/25-replay-ref.txt

Breaking it on purpose

The other plants are the chapter's mandatory breaks. Run each in its own fresh copy, with the recipe above and P set to the plant's name.

Deliberate breakage 1: drop the checked_add. 01-chain-range-no-checked-add.patch checks a buffer's first and last byte separately, computed with wrapping arithmetic, instead of the span. Predict: which invariant fires, and does any single byte of the buffer lie outside RAM?

TerminalReal output
cargo run -q --release -p fuzz -- virtqueue --seconds 600exit: 1--- stdout ---fuzz virtqueue: FAILURE at iteration 250 (seed 1): validated buffer 0x4002e6e9+0x5193a is not inside one RAM region (VQ-4)fuzz virtqueue: input saved to <tree>/crates/fuzz/../../target/fuzz/crashes/virtqueue-seed1-iter250-0.bin (replay: cargo run -p fuzz --release -- virtqueue --replay FILE)fuzz virtqueue: 251 iterations, 1 failures
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • Deliberate breakage 1: crates/fuzz/planted/01-chain-range-no-checked-add.patch applied to a copy (chain.rs judges a buffer by its first and last byte, computed with wrapping arithmetic).
course/captures/25-break-checked-add.txt

0x4002e6e9+0x5193a ends at 0x40080023: first byte in region A, last in region B, the hole between them not RAM. Each endpoint passed; the span did not. The plant removes two checks, the checked_add and the span check, and the fuzzer hit the second. In this machine it can only ever hit the second. A length is 32 bits and all RAM lies below 0x4009_0000, so a sum that wraps past 2^64 must start above 2^64 − 2^32. No RAM is there, and the first-byte check refuses it. Predict, then check it in your patched copy: a descriptor at 0xffff_ffff_ffff_fff0 with length 0x40000020 wraps to 0x40000010, inside RAM, yet it is refused at its first byte. The checked_add earns its place when RAM sits near the top of the address space, or when a length is 64 bits wide. The misconception: "checking both ends checks the range". The tool: invariant 4, computed independently in wider arithmetic.

Deliberate breakage 2: an off-by-one in the ring index. 03-used-idx-off-by-one.patch computes the used-ring slot as next_used % (N + 1) instead of % N. Predict: what does the device write, and where?

TerminalReal output
cargo run -q --release -p fuzz -- virtqueue --seconds 590exit: 1--- stdout ---fuzz virtqueue: FAILURE at iteration 22 (seed 1): device wrote 0x40003014+8 outside the writable buffers and the used ring (used ring 0x40003000+0x16; VQ-9)fuzz virtqueue: input saved to <tree>/crates/fuzz/../../target/fuzz/crashes/virtqueue-seed1-iter22-0.bin (replay: cargo run -p fuzz --release -- virtqueue --replay FILE)fuzz virtqueue: 23 iterations, 1 failures
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • Deliberate breakage 2: crates/fuzz/planted/03-used-idx-off-by-one.patch applied to a copy of the reference (queue.rs computes the used-ring slot as next_used % (N + 1)).
course/captures/25-break-ring-index.txt

A two-entry used ring at 0x40003000 is 0x16 bytes: flags, index, 8-byte elements at +4 and +12, and the 2-byte avail_event at +0x14 (chapter 16). Slot 2 lands at +0x14: over avail_event and six bytes past the ring's end. The misconception: "an index bug only corrupts the guest's own ring". The tool: invariant 5, the audit of every device write.

Try it

04-desc-len-double-fetch.patch re-reads a descriptor after validating it and keeps the second len. The plain target catches it from the access log (invariant 3). The hidden virtqueue_race_only variant has no log, only a second thread rewriting lengths during the walk, so it finds the bug only by winning the race. Run it twice with the same seed: ours failed once at iteration 87,420 and once, in the self-test below, at 2,025. A race does not replay from a seed.

The reference's self-test, scripts/bughunt-selftest.sh, runs plants 1 to 4, each in a private copy, and requires each to be found within the time limit (ten minutes by default; two in this run). It counts the double fetch too, so it ends with 4/4:

TerminalReal output
scripts/bughunt-selftest.sh --minutes 2 --allow-concurrent-editsexit: 0--- stdout ---bughunt-selftest: bug 1 (01-chain-range-no-checked-add.patch): building the fuzzer against the planted copybughunt-selftest: bug 1: fuzzing 'virtqueue' for up to 2 min (seed 1)bughunt-selftest: bug 1 FOUND by virtqueue after 0s:    fuzz virtqueue: FAILURE at iteration 250 (seed 1): validated buffer 0x4002e6e9+0x5193a is not inside one RAM region (VQ-4)bughunt-selftest: bug 2 (02-chain-no-hop-budget.patch): building the fuzzer against the planted copybughunt-selftest: bug 2: fuzzing 'virtqueue' for up to 2 min (seed 1)bughunt-selftest: bug 2 FOUND by virtqueue after 0s:    fuzz virtqueue: FAILURE at iteration 7 (seed 1): 2838 descriptor reads for one pop of a size-2 queue (VQ-5 hop budget)bughunt-selftest: bug 3 (03-used-idx-off-by-one.patch): building the fuzzer against the planted copybughunt-selftest: bug 3: fuzzing 'virtqueue' for up to 2 min (seed 1)bughunt-selftest: bug 3 FOUND by virtqueue after 0s:    fuzz virtqueue: FAILURE at iteration 22 (seed 1): device wrote 0x40003014+8 outside the writable buffers and the used ring (used ring 0x40003000+0x16; VQ-9)bughunt-selftest: bug 4 (04-desc-len-double-fetch.patch): building the fuzzer against the planted copybughunt-selftest: bug 4: fuzzing 'virtqueue' for up to 2 min (seed 1)bughunt-selftest: bug 4 FOUND by virtqueue after 0s:    fuzz virtqueue: FAILURE at iteration 4 (seed 1): descriptor at 0x4008ff80 read twice in one pop (double fetch, MEM-7)bughunt-selftest: bug 4: fuzzing 'virtqueue_race_only' for up to 2 min (seed 1)bughunt-selftest: bug 4 FOUND by virtqueue_race_only after 0s:    fuzz virtqueue_race_only: FAILURE at iteration 2025 (seed 1): validated buffer 0x400095e0+0xffffffff is not inside one RAM region (VQ-4)bughunt-selftest: working tree unchanged (git status --porcelain identical)bughunt: 4/4 planted bugs found
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • The reference's planted-bug self-test: plants 1 to 4 of crates/fuzz/planted/, each patched into a private scratch copy (the working tree is never touched), each fuzzed for up to 2 minutes (the default is 10). --allow-concurrent-edits: other files in this checkout were being edited during the run; the script still checks that the files it patches are unchanged.
course/captures/25-bughunt-selftest.txt

Descriptor chains are one hostile input; the reference has 21 more targets: the MMIO register files, the Image, ELF and initramfs loaders, the blk device and the output filter among them (scripts/fuzz.sh all --seconds 2 runs each for a two-second smoke test; all 22 passed on our Mac). The virtio-mmio target decodes its bytes as a sequence of guest register accesses, 11 bytes each, and checks after every write that no queue register changed while the queue was ready:

crates/fuzz/src/targets/virtio_mmio.rslines 192-215
let mut input = Input::new(data);let mut steps = 0;while !input.is_empty() && steps < 256 {    steps += 1;    let kind = input.u8();    let offset = u64::from(input.u16()) % 0x200;    let value = input.u64();    let size = size_of(kind);    let before = [snapshot(&t, 0), snapshot(&t, 1)];    if kind & 1 == 1 {        t.write(offset, size, value);        for (i, b) in before.iter().enumerate() {            if let (Some(b), Some(a)) = (b, snapshot(&t, i))                && *b != a            {                return Err(format!(                    "queue {i} changed while ready ({b:?} -> {a:?}) by a write of {value:#x} \                     at {offset:#x} (VQ-14)"                ));            }        }    } else {        let _ = t.read(offset, size);    }

Before you stop, do Your turn items 1 to 4 (the crate, the virtqueue target, the minimiser, the plants), and check that cargo run -q --release -p fuzz -- virtqueue --seconds 20 --seed 1 exits 0 from inside learner/.

Good place to stop. Sitting B needs your Mac and about 2.5 hours.

The hostile guest

Since chapter 00, "a hostile guest" has meant any guest that misbehaves on purpose, the malicious guest above. Here it is also a program you run. The hostile guest suite attacks the real VMM from inside a virtual machine: bare-metal guests in guests/hostile-*, each a phase with an exit code the VMM must end with. A VMM survives by turning every misdeed into a guest-visible answer (an exception, -1 in x0, DEVICE_NEEDS_RESET) or a defined stop; exit code 1, a VMM error, caused by a guest is always a bug.

Phase (guest)The attackExpected outcome
MMIO sweep (hostile-mmio)every device window, width and byte offset, then 20,000 random accessesexit 0 with --unhandled-mmio log; unknown registers read as zero
ISV=0 garbage (hostile-isv0)load and store pairs across a device boundary, SIMD (single instruction, multiple data: vector-register) storesexit 0; an abort injected each time
system registers (hostile-sysreg)all 16,384 S3_* encodings read; each whose read was UNDEF is then written (the Generic Interrupt Controller (GIC) CPU-interface block is skipped)exit 0; a value or an UNDEF each time
SMCCC garbage (hostile-smp, 4 vCPUs)12,000 random calls, then a CPU_ON stormexit 0; -1 for every unknown call
virtqueues (hostile-vq, hostile-smp)loops, rings at the end of RAM, index jumps, a second vCPU rewriting descriptorsexit 0; DEVICE_NEEDS_RESET, then recovery
terminal strings (hostile-tty)22 attack strings: title, clipboard, queriesexit 0; no escape sequence reaches stdout
reset storm (hostile-reset)SYSTEM_RESET on every bootexit 3 (guest fatal) within 10 s
output flood (hostile-flood)4 MiB into --serial file:F,max=1M, a file capped at 1 MiBexit 0; the file holds exactly 1 MiB

The phases exercise chapters 17 (virtio-rng), 18 (a read-only virtio-blk disk), 20 (several vCPUs) and 21 (accesses with ISV=0); if your VMM lacks one, that phase cannot pass. As a reminder: an UNDEF is an undefined-instruction exception, CPU_ON starts another vCPU, and the abort (a synchronous external abort) is what a real bus gives for an access the VMM will not decode: errors the guest can handle.

Run the phases from inside learner/, so cargo run builds your VMM, with G set as in chapter 09. Our captures ran from the repository root, so their paths start at target/; from learner/, prefix them with ../. Each phase is one guest run, and each capture shows its flags:

Shell
G=../target/guests/aarch64-unknown-none/releasecargo run -q -p macvmm -- run --mem 64M --testdev --kernel $G/hostile-isv0 --timeout 10
TerminalReal output
cargo run -q -p macvmm -- run --mem 64M --testdev --kernel target/guests/aarch64-unknown-none/release/hostile-isv0 --timeout 10exit: 0--- stdout ---hostile-isv0: 15/15 external abortshostile-isv0: device state intacthostile-isv0: phase 2 ok--- stderr ---macvmm: warn: [vcpu0] guest: vcpu0: ISV=0 write at 0xb000ff8 pc 0x400811c8 not emulated (pair is not inside one device window (first 0xb000000, second none)): injecting a synchronous external abortmacvmm: warn: [vcpu0] guest: vcpu0: ISV=0 read at 0xb000ff8 pc 0x4008128c not emulated (pair is not inside one device window (first 0xb000000, second none)): injecting a synchronous external abortmacvmm: warn: [vcpu0] guest: vcpu0: ISV=0 write at 0xb000ffc pc 0x40081364 not emulated (pair is not inside one device window (first 0xb000000, second none)): injecting a synchronous external abortmacvmm: warn: [vcpu0] guest: vcpu0: ISV=0 write at 0xa0001f8 pc 0x400813fc not emulated (pair is not inside one device window (first 0xa000000, second 0xa000200)): injecting a synchronous external abortmacvmm: warn: [vcpu0] guest: vcpu0: ISV=0 read at 0xa0001f8 pc 0x40081498 not emulated (pair is not inside one device window (first 0xa000000, second 0xa000200)): injecting a synchronous external abortmacvmm: warn: [vcpu0] guest: vcpu0: ISV=0 write at 0xa0001fc pc 0x40081568 not emulated (pair is not inside one device window (first 0xa000000, second 0xa000200)): injecting a synchronous external abortmacvmm: warn: [vcpu0] guest: vcpu0: ISV=0 write at 0xb000ff8 pc 0x4008160c not emulated (second element at 0x9000000, expected 0xb001000): injecting a synchronous external abortmacvmm: warn: [vcpu0] guest: vcpu0: ISV=0 read at 0xb000ff8 pc 0x400816a0 not emulated (second element at 0x9000000, expected 0xb001000): injecting a synchronous external abortmacvmm: warn: [vcpu0] guest: vcpu0: ISV=0 write at 0xb000fe0 pc 0x40081770 not emulated (unsupported: simd-fp): injecting a synchronous external abortmacvmm: warn: [vcpu0] guest: vcpu0: ISV=0 write at 0xb000fe8 pc 0x40081808 not emulated (unsupported: simd-fp): injecting a synchronous external abort
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20course/captures/25-hostile-isv0.txt

All 15 attempts came back as aborts, and the device kept its state. The MMIO sweep needs --unhandled-mmio log, because it probes addresses where no device lives; under the default policy, fatal, the first such access ends the run with exit 3. The stray characters are bytes written into the data register of the UART (the universal asynchronous receiver-transmitter, our PL011):

TerminalReal output
cargo run -q -p macvmm -- run --mem 64M --testdev --unhandled-mmio log --kernel target/guests/aarch64-unknown-none/release/hostile-mmio --timeout 60exit: 0--- stdout ---lOhostile-mmio: swept pl011 (0x1000 bytes)hostile-mmio: swept pl031 (0x1000 bytes)hostile-mmio: swept virtio-mmio (0x4000 bytes)hostile-mmio: swept testdev (0x1000 bytes)hostile-mmio: swept gicr-unused (0x1000 bytes)hostile-mmio: swept probe-hole (0x100 bytes)��hostile-mmio: 284192 accesses, 150926 alignment faults, 0 other data abortshostile-mmio: survived--- stderr ---macvmm: warn: [vcpu0] guest: pl011: 8-byte read at offset 0x0 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl011: 8-byte write at offset 0x0 names no register (ignored)macvmm: warn: [vcpu0] guest: pl011: 1-byte read at offset 0x1 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl011: 1-byte write at offset 0x1 names no register (ignored)macvmm: warn: [vcpu0] guest: pl011: 1-byte read at offset 0x2 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl011: 1-byte write at offset 0x2 names no register (ignored)macvmm: warn: [vcpu0] guest: pl011: 2-byte read at offset 0x2 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl011: 2-byte write at offset 0x2 names no register (ignored)macvmm: warn: [vcpu0] guest: pl011: 1-byte read at offset 0x3 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl011: 1-byte write at offset 0x3 names no register (ignored)macvmm: warn: [vcpu0] guest: pl011: 1-byte read at offset 0x5 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl011: 1-byte write at offset 0x5 names no register (ignored)macvmm: warn: [vcpu0] guest: pl011: 1-byte read at offset 0x6 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl011: 1-byte write at offset 0x6 names no register (ignored)macvmm: warn: [vcpu0] guest: pl011: 2-byte read at offset 0x6 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl011: 2-byte write at offset 0x6 names no register (ignored)macvmm: warn: [vcpu0] guest: pl011: 1-byte read at offset 0x7 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl011: 1-byte write at offset 0x7 names no register (ignored)macvmm: warn: [vcpu0] guest: pl011: 1-byte read at offset 0x8 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl011: 1-byte write at offset 0x8 names no register (ignored)macvmm: warn: [vcpu0] guest: pl011: 2-byte read at offset 0x22a names no register (read as zero) (989 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl011: 2-byte write at offset 0x22a names no register (ignored) (989 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl011: 2-byte read at offset 0x440 names no register (read as zero) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl011: 2-byte write at offset 0x440 names no register (ignored) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl011: 1-byte read at offset 0x655 names no register (read as zero) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl011: 1-byte write at offset 0x655 names no register (ignored) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl011: 2-byte read at offset 0x86a names no register (read as zero) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl011: 2-byte write at offset 0x86a names no register (ignored) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl011: 2-byte read at offset 0xa80 names no register (read as zero) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl011: 2-byte write at offset 0xa80 names no register (ignored) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl011: 1-byte read at offset 0xc95 names no register (read as zero) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl011: 1-byte write at offset 0xc95 names no register (ignored) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl011: 2-byte read at offset 0xeaa names no register (read as zero) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl011: 2-byte write at offset 0xeaa names no register (ignored) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl031: 8-byte read at offset 0x0 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl031: 8-byte write at offset 0x0 names no register (ignored)macvmm: warn: [vcpu0] guest: pl031: 1-byte read at offset 0x1 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl031: 1-byte write at offset 0x1 names no register (ignored)macvmm: warn: [vcpu0] guest: pl031: 1-byte read at offset 0x2 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl031: 1-byte write at offset 0x2 names no register (ignored)macvmm: warn: [vcpu0] guest: pl031: 2-byte read at offset 0x2 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl031: 2-byte write at offset 0x2 names no register (ignored)macvmm: warn: [vcpu0] guest: pl031: 1-byte read at offset 0x3 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl031: 1-byte write at offset 0x3 names no register (ignored)macvmm: warn: [vcpu0] guest: pl031: 1-byte read at offset 0x5 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl031: 1-byte write at offset 0x5 names no register (ignored)macvmm: warn: [vcpu0] guest: pl031: 1-byte read at offset 0x6 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl031: 1-byte write at offset 0x6 names no register (ignored)macvmm: warn: [vcpu0] guest: pl031: 2-byte read at offset 0x6 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl031: 2-byte write at offset 0x6 names no register (ignored)macvmm: warn: [vcpu0] guest: pl031: 1-byte read at offset 0x7 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl031: 1-byte write at offset 0x7 names no register (ignored)macvmm: warn: [vcpu0] guest: pl031: 8-byte read at offset 0x8 names no register (read as zero)macvmm: warn: [vcpu0] guest: pl031: 8-byte write at offset 0x8 names no register (ignored)macvmm: warn: [vcpu0] guest: pl031: 8-byte read at offset 0x220 names no register (read as zero) (989 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl031: 8-byte write at offset 0x220 names no register (ignored) (989 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl031: 2-byte read at offset 0x436 names no register (read as zero) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl031: 2-byte write at offset 0x436 names no register (ignored) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl031: 1-byte read at offset 0x64c names no register (read as zero) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl031: 1-byte write at offset 0x64c names no register (ignored) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl031: 8-byte read at offset 0x860 names no register (read as zero) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl031: 8-byte write at offset 0x860 names no register (ignored) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl031: 2-byte read at offset 0xa76 names no register (read as zero) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl031: 2-byte write at offset 0xa76 names no register (ignored) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl031: 1-byte read at offset 0xc8c names no register (read as zero) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl031: 1-byte write at offset 0xc8c names no register (ignored) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl031: 8-byte read at offset 0xea0 names no register (read as zero) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl031: 8-byte write at offset 0xea0 names no register (ignored) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte read at 0x0 is not an aligned 32-bit access (RAZ)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte write at 0x0 is not an aligned 32-bit access (WI)macvmm: warn: [vcpu0] guest: virtio-mmio: 2-byte read at 0x0 is not an aligned 32-bit access (RAZ)macvmm: warn: [vcpu0] guest: virtio-mmio: 2-byte write at 0x0 is not an aligned 32-bit access (WI)macvmm: warn: [vcpu0] guest: virtio-mmio: 8-byte read at 0x0 is not an aligned 32-bit access (RAZ)macvmm: warn: [vcpu0] guest: virtio-mmio: 8-byte write at 0x0 is not an aligned 32-bit access (WI)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte read at 0x1 is not an aligned 32-bit access (RAZ)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte write at 0x1 is not an aligned 32-bit access (WI)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte read at 0x2 is not an aligned 32-bit access (RAZ)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte write at 0x2 is not an aligned 32-bit access (WI)macvmm: warn: [vcpu0] guest: virtio-mmio: 2-byte read at 0x2 is not an aligned 32-bit access (RAZ)macvmm: warn: [vcpu0] guest: virtio-mmio: 2-byte write at 0x2 is not an aligned 32-bit access (WI)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte read at 0x3 is not an aligned 32-bit access (RAZ)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte write at 0x3 is not an aligned 32-bit access (WI)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte read at 0x4 is not an aligned 32-bit access (RAZ)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte write at 0x4 is not an aligned 32-bit access (WI)macvmm: warn: [vcpu0] guest: virtio-mmio: 2-byte read at 0x4 is not an aligned 32-bit access (RAZ)macvmm: warn: [vcpu0] guest: virtio-mmio: 2-byte write at 0x4 is not an aligned 32-bit access (WI)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte read at 0x5 is not an aligned 32-bit access (RAZ)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte write at 0x5 is not an aligned 32-bit access (WI)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x0 outside the 0-byte config space (RAZ/WI)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x0 outside the 0-byte config space (RAZ/WI)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 2 bytes at 0x0 outside the 0-byte config space (RAZ/WI)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 2 bytes at 0x0 outside the 0-byte config space (RAZ/WI)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 4 bytes at 0x0 outside the 0-byte config space (RAZ/WI)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 4 bytes at 0x0 outside the 0-byte config space (RAZ/WI)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 8 bytes at 0x0 outside the 0-byte config space (RAZ/WI)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 8 bytes at 0x0 outside the 0-byte config space (RAZ/WI)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x1 outside the 0-byte config space (RAZ/WI)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x1 outside the 0-byte config space (RAZ/WI)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x9 outside the 0-byte config space (RAZ/WI) (989 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 2-byte read at 0x66 is not an aligned 32-bit access (RAZ) (989 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 2-byte write at 0x66 is not an aligned 32-bit access (WI) (989 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 2 bytes at 0x14 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x1f outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte read at 0xce is not an aligned 32-bit access (RAZ) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte write at 0xce is not an aligned 32-bit access (WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x29 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 2 bytes at 0x34 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x3f outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte read at 0x35 is not an aligned 32-bit access (RAZ) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte write at 0x35 is not an aligned 32-bit access (WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x49 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 2 bytes at 0x54 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 2-byte read at 0x9c is not an aligned 32-bit access (RAZ) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 2-byte write at 0x9c is not an aligned 32-bit access (WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x5f outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x69 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 2 bytes at 0x74 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte read at 0x4 is not an aligned 32-bit access (RAZ) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte write at 0x4 is not an aligned 32-bit access (WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x7f outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x89 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte read at 0x6b is not an aligned 32-bit access (RAZ) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte write at 0x6b is not an aligned 32-bit access (WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 2 bytes at 0x94 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x9f outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 2-byte read at 0xd2 is not an aligned 32-bit access (RAZ) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 2-byte write at 0xd2 is not an aligned 32-bit access (WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0xa9 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 2 bytes at 0xb4 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0xbf outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte read at 0x3a is not an aligned 32-bit access (RAZ) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte write at 0x3a is not an aligned 32-bit access (WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0xc9 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 2 bytes at 0xd4 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte read at 0xa1 is not an aligned 32-bit access (RAZ) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte write at 0xa1 is not an aligned 32-bit access (WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0xdf outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0xe9 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 2 bytes at 0xf4 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 8-byte read at 0x8 is not an aligned 32-bit access (RAZ) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 8-byte write at 0x8 is not an aligned 32-bit access (WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0xff outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 2-byte read at 0x70 is not an aligned 32-bit access (RAZ) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 2-byte write at 0x70 is not an aligned 32-bit access (WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x9 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 2 bytes at 0x14 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte read at 0xd8 is not an aligned 32-bit access (RAZ) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte write at 0xd8 is not an aligned 32-bit access (WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x1f outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x29 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 2 bytes at 0x34 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte read at 0x3f is not an aligned 32-bit access (RAZ) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: 1-byte write at 0x3f is not an aligned 32-bit access (WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x3f outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: unhandled MMIO read at 0xc000000 size 1 pc 0x40081120 (ignored: --unhandled-mmio log)macvmm: warn: [vcpu0] guest: unhandled MMIO write at 0xc000000 size 1 pc 0x40081068 (ignored: --unhandled-mmio log)macvmm: warn: [vcpu0] guest: unhandled MMIO read at 0xc000000 size 2 pc 0x40081118 (ignored: --unhandled-mmio log)macvmm: warn: [vcpu0] guest: unhandled MMIO write at 0xc000000 size 2 pc 0x40081060 (ignored: --unhandled-mmio log)macvmm: warn: [vcpu0] guest: unhandled MMIO read at 0xc000000 size 4 pc 0x40081110 (ignored: --unhandled-mmio log)macvmm: warn: [vcpu0] guest: unhandled MMIO write at 0xc000000 size 4 pc 0x40081058 (ignored: --unhandled-mmio log)macvmm: warn: [vcpu0] guest: unhandled MMIO read at 0xc000000 size 8 pc 0x40081128 (ignored: --unhandled-mmio log)macvmm: warn: [vcpu0] guest: unhandled MMIO write at 0xc000000 size 8 pc 0x40081070 (ignored: --unhandled-mmio log)macvmm: warn: [vcpu0] guest: unhandled MMIO read at 0xc000001 size 1 pc 0x40081120 (ignored: --unhandled-mmio log)macvmm: warn: [vcpu0] guest: unhandled MMIO write at 0xc000001 size 1 pc 0x40081068 (ignored: --unhandled-mmio log)macvmm: warn: [vcpu0] guest: unhandled MMIO read at 0xc00001a size 1 pc 0x4008125c (ignored: --unhandled-mmio log) (989 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: config access of 1 bytes at 0x73 outside the 0-byte config space (RAZ/WI) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl031: 1-byte write at offset 0x945 names no register (ignored) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl031: 1-byte read at offset 0x4da names no register (read as zero) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl011: 4-byte read at offset 0xc48 names no register (read as zero) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: pl011: 1-byte write at offset 0x450 names no register (ignored) (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: unhandled MMIO write at 0xc0000c8 size 4 pc 0x40081058 (ignored: --unhandled-mmio log) (999 similar messages suppressed)
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20course/captures/25-hostile-mmio.txt

The 150,926 alignment faults are the guest's own. It runs with its memory management unit (MMU) off, so every access is to Device memory, where an unaligned access faults inside the guest (chapter 06) before it could reach us; the guest counts them and moves on. What matters is 0 other data aborts and exit 0.

The live TOCTOU phase is the one Rust cannot help with. vCPU 1 scribbles over the descriptor table while vCPU 0 rings the doorbell. Before and after, the guest hashes 16 MiB of its own RAM that no descriptor names, a canary region. The VMM's device writes land in guest RAM, so a stray write would change the hash, and the guest would see it. It needs chapter 18's test disk, opened read-only. As in chapter 18, the disk tool runs at the repository root; make it once:

Shell
cargo xtask mkdisk --size 64M --seed 1 --out learner/disk.img

Then, back in learner/, the run uses --disk disk.img,ro; our capture, from the root, names learner/disk.img:

TerminalReal output
cargo run -q -p macvmm -- run --cpus 2 --mem 64M --rng --disk learner/disk.img,ro --stats --kernel target/guests/aarch64-unknown-none/release/hostile-smp --timeout 60 && shasum -a 256 learner/disk.imgexit: 0--- stdout ---hostile-smp: 2 cpus, 2 virtio devices, RAM ends at 0x44000000hostile-smp: canary 0x42e00000+0x1000000 hash 0x6300ec9a4c71f456hostile-smp: live toctou blk slot 0: notifies=121736 served=4672 resets=83758 scribbles=365302878 recoveredhostile-smp: canary intact after blkhostile-smp: live toctou rng slot 1: notifies=114425 served=5895 resets=103139 scribbles=377087318 recoveredhostile-smp: canary intact after rnghostile-smp: survived4ae50b0ecaa3f91bdcfe84f5a2e20706045ea6f3387c6c45238200cf50ea7859  learner/disk.img--- stderr ---macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 16, size: 16 }macvmm: warn: [vcpu0] guest: virtio-mmio: QueueNotify 0 ignored in status 79macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiatedmacvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 19, size: 16 }macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 17, size: 16 }macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiatedmacvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 19, size: 16 }macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 16, size: 16 }macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: Overflow { addr: 18446744073709551608, len: 65537 }macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiatedmacvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiatedmacvmm: warn: [vcpu0] guest: virtio-mmio: QueueNotify 0 ignored in status 79macvmm: warn: [vcpu0] guest: virtio-mmio: QueueNotify 0 ignored in status 79macvmm: warn: [vcpu0] guest: virtio-mmio: QueueNotify 0 ignored in status 79macvmm: warn: [vcpu0] guest: virtio-mmio: QueueNotify 0 ignored in status 79macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 1140850688, len: 1 } (989 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: QueueNotify 0 ignored in status 79macvmm: warn: [vcpu0] guest: virtio-mmio: QueueNotify 0 ignored in status 79macvmm: warn: [vcpu0] guest: virtio-mmio: QueueNotify 0 ignored in status 79macvmm: warn: [vcpu0] guest: virtio-mmio: QueueNotify 0 ignored in status 79macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: device: blk request without a writable status byte (999 similar messages suppressed)macvmm: warn: [vcpu0] guest: virtio-mmio: QueueNotify 0 ignored in status 79macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: NextOutOfRange { next: 16, table_len: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: device: blk request without a writable status byte (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 17, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 19, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 19, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: Overflow { addr: 18446744073709551608, len: 65537 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 134217728, len: 44704 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 134217728, len: 281445 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: device: blk request without a writable status byte (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: ZeroLength { index: 7 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 19, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 16, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 1140850688, len: 1 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 17, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: Overflow { addr: 18446744073709551608, len: 1085292 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 17, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 1140850688, len: 4096 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 1140850688, len: 65537 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 1140850688, len: 512 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: Overflow { addr: 18446744073709551608, len: 65537 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 1140850688, len: 4096 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: Overflow { addr: 18446744073709551608, len: 512 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 16, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 134217728, len: 65537 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: device: blk request without a writable status byte (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 18, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 16, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: device: blk request without a writable status byte (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: device: blk request without a writable status byte (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: NextOutOfRange { next: 17, table_len: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: device: blk request without a writable status byte (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: ZeroLength { index: 11 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 16, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: device: blk request without a writable status byte (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: Overflow { addr: 18446744073709551608, len: 920728 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 134217728, len: 512 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 17, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 16, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: device: blk request without a writable status byte (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: NextOutOfRange { next: 16, table_len: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: ZeroLength { index: 5 } (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-blk-0] guest: virtio: queue 0 failed, device needs reset: virtqueue: ZeroLength { index: 0 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 134217728, len: 753987 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: NextOutOfRange { next: 17, table_len: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 19, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 19, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 1138773032, len: 4294967295 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 134217728, len: 4294967295 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: ZeroLength { index: 4 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 16, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 134217728, len: 657212 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 17, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 150994944, len: 4096 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 134217728, len: 4096 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: ZeroLength { index: 8 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 18, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 18, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: NextOutOfRange { next: 17, table_len: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: NextOutOfRange { next: 19, table_len: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: TooLarge { total: 1445678, max: 65536 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 1139845984, len: 2059959 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 19, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 18, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: ReadableAfterWritable (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 134217728, len: 4294967295 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: ZeroLength { index: 14 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: TooLarge { total: 687923, max: 65536 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 134217728, len: 1 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: NextOutOfRange { next: 17, table_len: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 1140850688, len: 4294967295 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: NextOutOfRange { next: 17, table_len: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 18, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: ZeroLength { index: 9 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: ZeroLength { index: 7 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 17, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: TooLarge { total: 1092291, max: 65536 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 18, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 19, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 1140850688, len: 771100 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: TooLarge { total: 65537, max: 65536 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 1140850688, len: 218071 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 1140850688, len: 1 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 134217728, len: 1807325 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: ZeroLength { index: 10 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 18, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: ZeroLength { index: 13 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 16, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 18, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 1140618464, len: 4294967295 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: AvailIdxJump { avail_idx: 24, next_avail: 0, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 16, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: Overflow { addr: 18446744073709551608, len: 4096 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: IndirectNotNegotiated (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: BufferOutOfRam { addr: 150994944, len: 669149 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: NextOutOfRange { next: 16, table_len: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 16, size: 16 } (999 similar messages suppressed)macvmm: warn: [virtio-rng-1] guest: virtio: queue 0 failed, device needs reset: virtqueue: HeadOutOfRange { head: 18, size: 16 } (999 similar messages suppressed)macvmm: stats: serial_input_dropped=0 serial_input_queued=0 serial_written=440 serial_sink_dropped=0 serial_capped=0 serial_lost=0 serial_filtered=0macvmm: stats: vcpu0 exits: vtimer 0, wfx 0, total 4397722: hvc 445, data abort 4397277macvmm: stats: vcpu0 time: exec 13.414 s, wfi 0.000 smacvmm: stats: vcpu1 exits: vtimer 0, wfx 0, total 1: canceled 1macvmm: stats: vcpu1 time: exec 19.796 s, wfi 0.000 smacvmm: stats: host cpu 41.020 s over 20.246 s wall (203%)macvmm: stats: rlimit core=0 nofile=1048576
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • learner/disk.img made with: cargo xtask mkdisk --size 64M --seed 1 --out learner/disk.img; its sha256 before the run was 4ae50b0ecaa3f91bdcfe84f5a2e20706045ea6f3387c6c45238200cf50ea7859.
course/captures/25-hostile-toctou.txt

About 10,600 requests served, about 187,000 attacks ended in a device reset, the canary intact, the image unchanged. Each refusal is the walker's own copy of a descriptor failing a check, whatever vCPU 1 wrote afterwards.

The terminal phase writes the forbidden list to the UART:

TerminalReal output
cargo run -q -p macvmm -- run --mem 64M --stats --kernel target/guests/aarch64-unknown-none/release/hostile-tty --timeout 10exit: 0--- stdout ---hostile-tty: beginlink6n52;c;AAAA\x076nhostile-tty: 22 attack strings senthostile-tty: end--- stderr ---macvmm: stats: serial_input_dropped=0 serial_input_queued=0 serial_written=91 serial_sink_dropped=0 serial_capped=0 serial_lost=0 serial_filtered=160macvmm: stats: vcpu0 exits: vtimer 0, wfx 0, total 610: hvc 1, data abort 609macvmm: stats: vcpu0 time: exec 0.000 s, wfi 0.000 smacvmm: stats: host cpu 0.001 s over 0.001 s wall (115%)macvmm: stats: rlimit core=0 nofile=1048576
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20course/captures/25-hostile-tty.txt

The odd middle line is all that is left of 22 attack strings: link is a hyperlink's text. 6n and 52;c;AAAA are the tails of a status query and a clipboard write sent with a one-byte introducer (0x9B, 0x9D): the filter drops that byte, so the rest is inert text. (0x9D is the one-byte form of ESC ], which starts an operating system command, OSC.) \x07 is how the capture shows one BEL (bell) byte, 0x07, allowed at most once a second. The final 6n is the same status query again, its introducer encoded as UTF-8 (U+009B, bytes C2 9B), dropped the same way. Nothing left can make a terminal act. The reset storm is the one phase whose correct ending is a fatal stop:

TerminalReal output
cargo run -q -p macvmm -- run --mem 64M --kernel target/guests/aarch64-unknown-none/release/hostile-reset --timeout 30exit: 3--- stdout ---hostile-reset: boot 0hostile-reset: boot 1hostile-reset: boot 2hostile-reset: boot 3hostile-reset: boot 4hostile-reset: boot 5hostile-reset: boot 6hostile-reset: boot 7hostile-reset: boot 8hostile-reset: boot 9hostile-reset: boot 10--- stderr ---macvmm: guest fatal: reset storm: more than 10 resets within 10 s
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20course/captures/25-hostile-reset.txt

Tying our own hands: the sandbox

Suppose a bug survives all that and a guest runs code inside macvmm. Our one entitlement is a permission, not a fence (the codesign-entitlements primer): the process can still read ~/.ssh, open sockets and start a shell. Chapter 19 named what we want instead, containment. The fence is a sandbox, rules the kernel enforces on a process: sandbox_init (the macos-sandbox primer), applied once, irrevocably, with a profile. macvmm's base profile is (deny default) with almost nothing allowed:

crates/macvmm/src/sandbox.rslines 177-191
/// The lockdown profile (module docs). SBPL, the Scheme dialect of macOS's Seatbelt./// Rules are matched last-to-first with `deny default` as the fallback; the explicit denials/// restate the policy for the reader (and keep it if a later edit adds a broad `allow`).pub const PROFILE: &str = r#"(version 1)(deny default)(allow sysctl-read)(allow file-ioctl       (ioctl-command TIOCSETA)       (ioctl-command TIOCSETAW)       (ioctl-command TIOCSETAF)       (ioctl-command TIOCFLUSH))(deny file-read* file-write* file-write-create)(deny network*)(deny process-exec* process-fork)"#;

Four ioctls (device commands, here to the terminal) are allowed so the exit path can restore your terminal settings; TIOCSTI, which fakes typed input, stays denied. There is no mach-lookup and no iokit-open: Hypervisor.framework needs neither to create, run, destroy and re-create a virtual machine (VM). One thing is added per run: for each --net ...,peer=PATH (chapter 19), profile_for appends an allow network-outbound rule for exactly that Unix socket, plus metadata reads of the symbolic links on its path. --net ...,learn is refused while the sandbox is on, because its peer is not known when the profile is written: it is a usage error (exit code 2) that tells you to use peer=PATH or --no-sandbox. Three tests checked this on a real Mac: four vCPUs created after the lockdown, an in-process reboot that builds a new VM under it, and the limits line:

TerminalReal output
cargo test -p macvmm --features hvf-tests --test e2e_sandbox -- sandbox_smp sandbox_reboot rlimit_stats --test-threads=1exit: 0--- stdout ---running 3 teststest rlimit_stats ... oktest sandbox_reboot ... oktest sandbox_smp ... oktest result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 10 filtered out; finished in 1.84s--- stderr ---   Compiling libc v0.2.191   Compiling hvf v0.1.0 (<tree>/crates/hvf)   Compiling xtask v0.1.0 (<tree>/crates/xtask)   Compiling vmm v0.1.0 (<tree>/crates/vmm)   Compiling fuzz v0.1.0 (<tree>/crates/fuzz)   Compiling macvmm v0.1.0 (<tree>/crates/macvmm)    Finished `test` profile [unoptimized + debuginfo] target(s) in 2.63s     Running tests/e2e_sandbox.rs (target/debug/deps/e2e_sandbox-de903fff9661cc90)
captured: real output, Apple M5 Pro, macOS 27.2.1, commit 64871bd, 2026-11-20
  • Run in an rsync copy of the reference with its own target directory. Three tests of the sandbox suite: four vCPUs created after the lockdown (sandbox_smp), an in-process reboot under it, a new VM with its memory and its GIC created while sandboxed (sandbox_reboot), and the rlimit line (rlimit_stats).
course/captures/25-sandbox-reboot.txt

When matters as much as what. The sandbox checks a resource when it is acquired, so run first opens every file and starts every host thread (the terminal, the signal thread, the stdin thread):

crates/macvmm/src/cli.rslines 730-742
let interactive = host.stdin != StdinBinding::Unbound;let mut terminal = term::Terminal::setup(interactive);if terminal.is_raw() {    err("macvmm: console attached; Ctrl-A x quits, Ctrl-A h lists the escapes");}if let Err(e) = signals::spawn(Arc::clone(&host)) {    err(&format!("macvmm: cannot install the signal handlers: {e}"));    return ExitCode::from(1);}if interactive && let Err(e) = term::spawn_stdin(Arc::clone(&host)) {    err(&format!("macvmm: cannot start the stdin thread: {e}"));    return ExitCode::from(1);}

and only then locks down, before the first guest instruction:

crates/macvmm/src/cli.rslines 747-755
if let Err(line) = confine(sandbox, &cfg) {    // Fail closed: only `--no-sandbox` runs unconfined, never a failed lockdown. Nothing ran    // yet; undo the terminal and stop.    host.close_sinks(&[]);    terminal.restore();    err(&line);    return ExitCode::from(1);}let result = vmm::run(&cfg, &host);

This runs on every macvmm run: the sandbox is on by default. A protection you have to remember to ask for protects nobody on the day you forget, and the list of what it costs is short: everything a VM does after the lockdown works under it (the e2e suites all pass with it on), and only ,learn needs it off. --no-sandbox turns it off, for debugging; --sandbox is still accepted and changes nothing, so older scripts keep working; giving both is a usage error (exit code 2), because one of them must be a mistake. confine, above it, fails closed: if the lockdown fails, macvmm exits 1 and names --no-sandbox; only --sandbox=best-effort warns and runs without it. The lockdown first drops the file-descriptor limit (RLIMIT_NOFILE, nofile= in --stats) to one past the highest descriptor in use, plus 16. The profile still lets the process create descriptors that need no path, so the cap bounds how many a compromised macvmm could hoard; the 16 spare cover what later work opens without a path, such as vCPU threads and the new VM of a reboot:

crates/macvmm/src/sandbox.rslines 292-309
/// Lower `RLIMIT_NOFILE`, then apply the profile (module docs: timing)./// Irrevocable. `Err` is the reason; the caller decides between exit 1 and a warning.pub fn lockdown(cfg: &VmConfig) -> Result<Lockdown, String> {    let profile = profile_for(cfg)?;    let (soft, _) = hvf::host::get_rlimit(hvf::host::RLIMIT_NOFILE)        .map_err(|e| format!("getrlimit(RLIMIT_NOFILE): {e}"))?;    let scan = i32::try_from(soft.min(1 << 16)).unwrap_or(1 << 16);    let highest = hvf::host::highest_open_fd(scan).unwrap_or(2);    let nofile = u64::try_from(highest)        .unwrap_or(2)        .saturating_add(1)        .saturating_add(NOFILE_SLACK)        .min(soft);    hvf::host::set_rlimit(hvf::host::RLIMIT_NOFILE, nofile)        .map_err(|e| format!("setrlimit(RLIMIT_NOFILE, {nofile}): {e}"))?;    hvf::host::sandbox_init_profile(&profile).map_err(|e| format!("sandbox_init: {e}"))?;    Ok(Lockdown { nofile })}

The sandbox_init call is one of the few unsafe blocks, in the hvf crate. Its header declares it deprecated, and passing profile text rather than a built-in profile name is undocumented. Deprecated means Apple may stop honouring it in a future macOS. If the call ever started failing, a silent fallback would run the guest unconfined while you believed otherwise, so the sandbox treats any failure as fatal:

crates/hvf/src/host.rslines 807-844
unsafe extern "C" {    fn sandbox_init(        profile: *const libc::c_char,        flags: u64,        errorbuf: *mut *mut libc::c_char,    ) -> libc::c_int;    fn sandbox_free_error(errorbuf: *mut libc::c_char);}/// Apply the SBPL `profile` to this process, irrevocably (`sandbox_init(profile, 0, &err)`)./// `Err` carries libsandbox's message (for example a profile syntax error, or "already in a/// sandbox"). Threads that exist keep running under the new profile.pub fn sandbox_init_profile(profile: &str) -> Result<(), String> {    let c = std::ffi::CString::new(profile).map_err(|_| "the profile contains a NUL byte")?;    let mut err: *mut libc::c_char = core::ptr::null_mut();    // SAFETY: `c` is a NUL-terminated string that outlives the call; `err` is a live, writable    // `char *` slot that `sandbox_init` sets to NULL or to a string it allocated.    let rc = unsafe { sandbox_init(c.as_ptr(), 0, &mut err) };    let msg = if err.is_null() {        None    } else {        // SAFETY: on error `sandbox_init` stored a NUL-terminated string it owns in `err`; we        // copy it before freeing it below.        let m = unsafe { std::ffi::CStr::from_ptr(err) }            .to_string_lossy()            .into_owned();        // SAFETY: `err` came from `sandbox_init` and is freed exactly once, as `sandbox.h`        // requires; it is not used afterwards.        unsafe { sandbox_free_error(err) };        Some(m)    };    match (rc, msg) {        (0, _) => Ok(()),        (_, Some(m)) => Err(m),        (rc, None) => Err(format!("sandbox_init returned {rc}")),    }}

Two smaller defences run first in main, sandbox or not. RLIMIT_CORE goes to 0, soft and hard: no core dumps (a core would be a file full of guest RAM). That one is a one-way door, since an unprivileged process cannot raise its hard limit again. The umask of 077 is only a default, which any code in the process could change, but it makes sure that only you can read what macvmm creates during set-up:

crates/macvmm/src/main.rslines 174-177
fn harden_process() -> std::io::Result<()> {    hvf::host::set_umask(0o077);    hvf::host::set_rlimit(hvf::host::RLIMIT_CORE, 0)}

The hidden --sandbox-selftest flag tries three things after the lockdown and requires each to be refused:

crates/macvmm/src/sandbox.rslines 340-363
pub fn selftest() -> Result<String, String> {    let mut bad = Vec::new();    if let Err(e) = denied("open", hvf::host::probe_open("/etc/hosts"), &[]) {        bad.push(e);    }    match hvf::host::probe_connect_loopback() {        Err(e) if e.raw_os_error() == Some(ECONNREFUSED) => {            bad.push("socket connect ALLOWED (ECONNREFUSED: it reached the network stack)".into())        }        r => {            if let Err(e) = denied("socket connect", r, &[]) {                bad.push(e);            }        }    }    if let Err(e) = denied("spawn", hvf::host::probe_spawn("/usr/bin/true"), &[]) {        bad.push(e);    }    if bad.is_empty() {        Ok("sandbox: open denied, socket denied, spawn denied".into())    } else {        Err(format!("sandbox: self-test FAILED: {}", bad.join(", ")))    }}
Shell
cargo run -q -p macvmm -- run --mem 64M --sandbox-selftest --stats --kernel target/guests/aarch64-unknown-none/release/hello --timeout 10
TerminalReal output
cargo run -q -p macvmm -- run --mem 64M --sandbox-selftest --stats --kernel target/guests/aarch64-unknown-none/release/hello --timeout 10exit: 0--- stdout ---hello from guest, x0=0x40000000guest done--- stderr ---macvmm: sandbox: open denied, socket denied, spawn deniedmacvmm: stats: serial_input_dropped=0 serial_input_queued=0 serial_written=43 serial_sink_dropped=0 serial_capped=0 serial_lost=0 serial_filtered=0macvmm: stats: vcpu0 exits: vtimer 0, wfx 0, total 44: hvc 44macvmm: stats: vcpu0 time: exec 0.000 s, wfi 0.000 smacvmm: stats: host cpu 0.000 s over 0.000 s wall (116%)macvmm: stats: rlimit core=0 nofile=21
captured: real output, Apple M5 Pro, macOS 27.2.1, commit 64871bd, 2026-11-20course/captures/25-sandbox-selftest.txt

No sandbox flag was needed: the default run locked down, and the guest ran to completion under the profile. With --no-sandbox:

TerminalReal output
cargo run -q -p macvmm -- run --mem 64M --no-sandbox --stats --kernel target/guests/aarch64-unknown-none/release/hello --timeout 10exit: 0--- stdout ---hello from guest, x0=0x40000000guest done--- stderr ---macvmm: stats: serial_input_dropped=0 serial_input_queued=0 serial_written=43 serial_sink_dropped=0 serial_capped=0 serial_lost=0 serial_filtered=0macvmm: stats: vcpu0 exits: vtimer 0, wfx 0, total 44: hvc 44macvmm: stats: vcpu0 time: exec 0.000 s, wfi 0.000 smacvmm: stats: host cpu 0.000 s over 0.000 s wall (119%)macvmm: stats: rlimit core=0 nofile=1048576
captured: real output, Apple M5 Pro, macOS 27.2.1, commit 64871bd, 2026-11-20course/captures/25-stats-unsandboxed.txt

core=0 in both, and the file-descriptor limit is 21 under the sandbox against 1,048,576 without it (the unsandboxed number is inherited from your shell). The kernel also reports each denial to the unified log, as the primer showed. --last 10s only covers the last ten seconds, so run log show within ten seconds of the self-test, or widen it to --last 1m:

TerminalReal output
log show --last 10s --style compact --predicate 'eventMessage BEGINSWITH "Sandbox: macvmm"'exit: 0--- stdout ---Timestamp               Ty Process[PID:TID]2026-11-20 01:14:37.977 E  kernel[0:73ca05c] (Sandbox) Sandbox: macvmm(84685) deny(1) file-read-metadata /etc2026-11-20 01:14:37.977 E  kernel[0:73ca05c] (Sandbox) Sandbox: macvmm(84685) deny(1) network-outbound remote:*:12026-11-20 01:14:37.977 E  kernel[0:73ca05c] (Sandbox) Sandbox: macvmm(84685) deny(1) process-fork
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • Run right after a sandboxed self-test run (cargo run -q -p macvmm -- run --mem 64M --sandbox --sandbox-selftest --kernel <hello> --timeout 10), in the same shell command, so the 10-second window holds only that run.
course/captures/25-sandbox-log.txt

The open of /etc/hosts died resolving the symbolic link /etc (on macOS, /etc is a link to /private/etc, the macos-sandbox primer), the connect as network-outbound, the spawn at process-fork. The socket itself was created: only its use was refused.

Production note

Inside the sandbox the process keeps what it holds: guest RAM, the opened disks, the hypervisor. Production VMMs such as crosvm also confine each device in its own process.

Security

The fuzzer asks "is there a bug in the parsers?", the hostile guest "does the whole VMM survive a guest that misbehaves on purpose?", the sandbox "if both missed one, what does the attacker get?". Rely on only one and you fail the day it misses.

Your turn

The reference shows the finished harness; yours goes in learner/crates/fuzz/. Items 1 to 4 belong to sitting A, before the stopping point; items 5 to 7 to sitting B.

  1. Create the crate: package and binary both named fuzz, a workspace member depending on vmm as { path = "../vmm", features = ["test-util"] } and on nothing outside the workspace. Write rng.rs, the Target struct and the loop. The checkpoint runs fuzz virtqueue --seconds S --seed 1 and reads two things: a finding prints a line containing FAILURE (or HANG) and exits 1; a clean run exits 0. Add --replay FILE; check that one seed always gives the same iteration numbers. One trap: the checkpoint builds your fuzzer against the reference's vmm, not yours, so use only the names the reference exports: vmm::virtio::Queue (its pop and add_used), vmm::virtio::DescriptorChain::into_validated, vmm::virtio::ValidatedChain and Descriptor, vmm::memory::VecMemory (behind the test-util feature) and vmm::memory::prelude::*. If your own walker uses other names, add aliases in your vmm with the reference's names.
  2. Write the virtqueue target through those functions (pop, into_validated, add_used); choose your own input layout, or copy the one above. Start with invariants 2 and 4, then add 3 and 5.
  3. Add --minimise FILE, the chunk-zeroing loop above, writing the smallest failing input next to the original. Minimise each planted bug's reproducer and note its non-zero byte count.
  4. Plant each bug by hand in a copy of your own tree: delete the hop-budget decrement; check a buffer's first and last byte separately with wrapping addition; take the used slot modulo N + 1; re-read a descriptor after validating it; and the verdict cache, skipping the RAM check when a buffer's address equals the one two hops earlier. Record how long your fuzzer takes on each, and write its times for the hop budget and the verdict cache under your journal's Predict entry, next to ours.
  5. Optional: write a second target, for the virtio-mmio register file or the Image header, with one invariant each.
  6. Run each hostile phase in the table on your VMM, from learner/, with the flags in its capture. Every phase must end with its exit code; fix what does not.
  7. Write sandbox.rs (the profile, profile_for with its --net peers, lockdown, the self-test) and call harden_process first in main. Make the lockdown the default, with --no-sandbox to opt out, --sandbox accepted as a no-op and --sandbox=best-effort; --sandbox together with --no-sandbox is a usage error (exit code 2). Add the hidden --sandbox-selftest, and the --stats line macvmm: stats: rlimit core=0 nofile=N. Call the lockdown after every file is open and every thread exists, as run does above. The self-test must print exactly sandbox: open denied, socket denied, spawn denied on stderr (after the macvmm: prefix), the line the checkpoint matches.
  8. Finish your threat model, then compare it with the reference's, row by row.

Stuck? scripts/learner hint 25 gives a ladder of hints, from the concept to the reference file to read. Read the matching reference file only after a real attempt.

Checkpoint

Back at the repository root, run:

Checkpoint

Needs a Mac

Run this from the repository root:

scripts/checkpoint.sh 25

You should see, as the last line:

CHECKPOINT 25 PASS

The plants cannot apply to your walker, so the checkpoint brings your fuzzer to them: it copies the reference's crates, puts your crates/fuzz in place of ours, applies one plant, builds, and runs fuzz virtqueue --seed 1. If it reports that the fuzzer "does not build against the reference", your fuzzer uses a name the reference's vmm lacks (Your turn, item 1). It checks:

  • a 20-second control on the unplanted reference finds nothing (a fuzzer that reports everything proves nothing);
  • plants 1 to 3 (the missing checked_add, the missing hop budget, the ring-index off-by-one) are each found within ten minutes, build included, each printing a line such as bughunt: plant 2 (missing hop budget) found after 0s;
  • the sandbox self-test with hello, with no sandbox flag, prints the three denials and exits 0, and --stats shows rlimit core=0 both then and with --no-sandbox;
  • each hostile phase on your VMM ends with its exit code and the guest's lines; no forbidden escape sequence in stdout, a flood file of exactly 1 MiB, an unchanged read-only disk, every TOCTOU-phase MMIO access in the virtio window;
  • your journal answers every question.

Against a copy of the reference:

TerminalReal output
scripts/checkpoint.sh 25exit: 0--- stdout ---[INFO] contract tests   none for this chapter[PASS] runs on your Mac bughunt-control: 1/1 serial markers, exit 0 in 24.11s[PASS] runs on your Mac bughunt-1: 1/1 serial markers, exit 0 in 3.95s[PASS] runs on your Mac bughunt-2: 1/1 serial markers, exit 0 in 3.71s[PASS] runs on your Mac bughunt-3: 1/1 serial markers, exit 0 in 3.64s[PASS] runs on your Mac sandbox-check: 4/4 serial markers, exit 0 in 0.07s[PASS] runs on your Mac rlimit-check: 3/3 serial markers, exit 0 in 0.01s[PASS] runs on your Mac phase-mmio: 9/9 serial markers, exit 0 in 0.25s[PASS] runs on your Mac phase-isv0: 3/3 serial markers, exit 0 in 0.01s[PASS] runs on your Mac phase-sysreg: 4/4 serial markers, exit 0 in 0.03s[PASS] runs on your Mac phase-smccc: 4/4 serial markers, exit 0 in 0.06s[PASS] runs on your Mac phase-vq-empty: 3/3 serial markers, exit 0 in 0.10s[PASS] runs on your Mac phase-vq-rng: 5/5 serial markers, exit 0 in 0.11s[PASS] runs on your Mac phase-vq-blk: 7/7 serial markers, exit 0 in 0.45s[PASS] runs on your Mac phase-toctou: 10/10 serial markers, exit 0 in 25.35s[PASS] runs on your Mac phase-tty: 4/4 serial markers, exit 0 in 0.03s[PASS] runs on your Mac phase-reset: 3/3 serial markers, exit 3 in 0.02s[PASS] runs on your Mac phase-flood: 1/1 serial markers, exit 0 in 7.57s[INFO] journal          not checked (not a learner tree)CHECKPOINT 25 PASS
captured: real output, Apple M5 Pro, macOS 27.2.1, commit dad6c99, 2026-11-20
  • The chapter's checkpoint, run against the reference (scripts/checkpoint.sh 25 --ref): what a finished chapter 25 looks like. The bughunt runs put crates/fuzz into a planted copy of the reference.
  • The journal line reports "not a learner tree" here; in your own learner/ workspace it checks your journal.
course/captures/25-checkpoint.txt

What now works:

  • a threat model naming the mechanism that guards each asset;
  • a dependency-free fuzzer whose invariants find bugs that never panic, with replayable, minimised reproducers;
  • a VMM that survives a guest attacking it on purpose;
  • a process that, after set-up, can open no file, reach no network except the configured virtio-net peer socket, start no process, and never dumps core.

The next chapter starts from this state (the reference at the end of chapter 25).

What's next

Chapter 26, planned for after the course's first release, freezes a running VM to a file and brings it back in a fresh process. A snapshot is not a memory dump: the Generic Interrupt Controller (GIC), the timers and in-flight disk requests hold state that RAM does not, and the file itself is hostile input the moment it touches disk.

Open question

Your fuzzer is structure-aware: its input generator and mutations encode what you believe a ring looks like. Which input shape does it never generate, and what bug could hide there?

Spec hunt

  • virtio 1.2, section 2.7.5.3.1 "Driver Requirements: Indirect Descriptors": which combinations of INDIRECT and NEXT may a driver not send, and which of them does your fuzzer's flag-flip mutation produce?
  • man 2 setrlimit, the RLIMIT_CORE entry and the paragraph on hard limits: why does macvmm set both the soft and the hard value to 0, and what could a compromised macvmm do if only the soft value were 0?
  • ECMA-48, section 5.6 "Control strings": which introducers start an operating system command and a device control string, and how does a filter know where such a string ends?
Progress is stored only in this browser.