Commit Graph
70 Commits
Author SHA1 Message Date
Anees Iqbal ccbcdabd6d 🆕 Make pages blocks of memory a process maps read-only
A no-copy buffer over memory its process maps read-only cannot lie over its
own pages today: the kext refuses the pages block, and the host would lay a
buffer over it that takes the GPU's writes. So the bundle syncs a slab copy
of it at every commit that uses it. macOS 12's WindowServer wraps clients'
Core Animation backing stores, mapped read-only into it (8-30 MB each), that
way, and spent 14.1 s of a 451 s walk syncing them (appwalk14, 12.7.6 on the
Iris Xe). This makes the device and the kext ready to keep them in place; the
bundle takes the route in the next commit.

What changes on the wire:
- A new feature bit, RGFX_FEATURE_READ_ONLY_PAGES (bit 45, FEATURES_HI bit
  13), offered wherever PAGES_BUFFERS is, and taken by the kext.
- A new SURFACE_PAGES flag, RGFX_SURFACE_PAGES_READ_ONLY (1 << 5), meaningful
  with RGFX_SURFACE_PAGES_PRIVATE alone (else INVALID_ARGUMENT): the pages
  block holds pages its process maps read-only.
- BUFFER_OVER_PAGES needs no new field: its options already carry
  MTLResourceOptions bit 24 to the host, which hands it to the runtime as
  memory whose GPU writes it drops (accuracy-ledger.md,
  read-only-pages-written).

The host keeps every object over a read-only block from writing its pages: a
BUFFER_OVER_PAGES without bit 24, a HEAP_OVER_PAGES, an ICB_SLOTS_IN_PAGES
and a MANAGED_BUFFER_CREATE or MANAGED_TEXTURE_CREATE whose CPU copy lies over
one are refused, each logged as the guest error it is. The block's view stays
the writable mapping of guest RAM.

Where the kext took the bit, PagesBlock makes a block of read-only memory too:
it wires the pages with kIODirectionOut, which asks the VM system only for
read access, completes them for that direction at the unwire, and marks the
block read-only (rgfxPagesWiring). Without the bit it refuses read-only
memory as before.

Why a feature bit, though reims-ctl ships the host and the x86 set together:
the mark is where the host holds the line, not a hint. A process can post any
message on its rings, so a forged BUFFER_OVER_PAGES without bit 24 over a
read-only block would let the GPU write pages the process maps read-only, a
file's page cache among them. A host older than the mark ignores it, so the
kext makes such a block only where the host took the bit. The arm64e set also
reaches VMs through Ambrosia's config bundle, apart from the host. Old guest
sets never ask, and change nothing; a new set on an older host gets no block
and keeps its copy.

The header is regenerated, and the option ROM's record takes the header's
new hash (the ROM's bytes are unchanged); both guest sets are rebuilt with
the bundle's change, in the 📦 commit after it. Tests: the
header test, the peer and offer tests, a decoder test of what a read-only
block admits and refuses
(a_read_only_pages_block_holds_only_buffers_that_drop_their_writes), and the
kext's features and pages-block tests.
2026-11-14 03:39:14 -08:00
Anees Iqbal 14c2c18e8c 🆕 Stamp each command buffer with the guest's clock (GUEST_TIMES)
The host sees a command buffer only once a queue's thread takes it off its
ring, so the app's encode and the buffer's way to the host show as one span
with nothing pending on the host. This adds the guest's stamps that split it,
a diagnostic.

What changes for the guest:
- The device offers a new feature bit, RGFX_FEATURE_GUEST_TIMES (bit 44,
  FEATURES_HI bit 12), and DRIVER_FEATURES takes it. The kext carries it.
- Where the device's word holds it, the bundle starts each command buffer's
  stream with a new op, RGFX_OP_GUEST_TIMES (0x000e, 32 bytes): the guest's
  clock as the buffer was made, as its commit was entered, and as its message
  went on its ring. The last is written under the ring's lock, after the copy
  and before producer is published; for a buffer in a block, into the block.
- After each VBLANK's reading of HOST_TIME the kext writes ring 0's new header
  fields: guest_clock_offset_ns (0x18), then guest_clock_bound_ns (0x20) with
  release, split out of reserved bytes. The host zeroes both as it initialises
  a ring.
- The decoder walks the op as a no-op, so it changes nothing a buffer does,
  and a host that did not offer the bit never sees it. Old guest sets carry
  no bit, send no op and leave the fields 0.

The header is regenerated, both guest sets are rebuilt from the same sources,
and the option ROM's record takes the header's new hash; the ROM's bytes are
unchanged. The tests cover the op's and fields' layout (the header test, the
kext's vblank clock test), the bit's negotiation (the kext's features test,
the peer and memory-map tests), the stamps (the bundle's serializer and shell
tests) and the walk (a cmdbuf test, and the fuzz's streams). The host's
reading of the stamps is the next commit.
2026-11-13 21:25:12 -08:00
Anees Iqbal abbed9b096 📦 Rebuild both guest sets and the ROM's record for DOORBELL_ASKS
The kext carries DOORBELL_ASKS and the bundle rings an asking buffer's
doorbell apart, so both sets are rebuilt from the guest's sources, and the
wire header's new constants change the ROM's record of its sources; the
ROM's bytes are unchanged. Built on m3-max (m3-max-25849) with
make -C guest prebuilt, prebuilt-arm64e and make -C firmware prebuilt;
make -C guest test and both prebuilt checks passed there.
2026-11-13 09:50:12 -08:00
Anees Iqbal ebfa1a516d 📦 Rebuild both guest sets and the ROM record for this branch
The x86-64 and arm64e kext sets are rebuilt from this branch's guest/ on
development 788d82edd (make -C guest prebuilt, prebuilt-arm64e; m3-max job
25263, which also ran make -C guest test), and the option ROM's record from
its wire.h, whose LIBRARY_LOOKUP comment moved with the v2 library key; the
ROM's bytes are the same. prebuilt-check passes on this tree.
2026-11-13 04:02:31 -08:00
Anees Iqbal 785c4d0bbf 📦 Rebuild both guest sets for the walking mark
The bundle rings a walking queue's doorbell only for a buffer that asks, and
the wire header gained the two consumer_idle values, so guest/prebuilt and
guest/prebuilt-arm64e are built again from their sources, and the option
ROM's record names the header's new hash; the ROM's bytes are unchanged.
2026-11-12 19:06:13 -08:00
Anees Iqbal 8383d772ca 📦 Rebuild the guest sets and ROM record for ICB slots in pages
The bundle and the kexts take ICB_SLOTS_IN_PAGES, so guest/prebuilt and
guest/prebuilt-arm64e are built again from their sources. The wire header
gained the message's record, so the option ROM's record names its new hash;
the ROM's bytes are unchanged.
2026-11-12 15:33:37 -08:00
Anees Iqbal 3804f3edc7 📦 Rebuild both guest sets and the ROM's record for pipeline keys
The x86 set and the arm64e set carry the kext and the bundle as built from
6e6a80dd9: equal pipeline creates of any process answered from the kext's
kept answers, and functions' AIR read without their bodies until asked (make
-C guest prebuilt and prebuilt-arm64e on the M3 Max, job m3-max-22490). The
option ROM's record follows the wire header, which gained PIPELINE_KEYS; the
ROM's bytes are unchanged (make -C firmware prebuilt, the same job).
2026-11-12 13:28:15 -08:00
Anees Iqbal 5e1dad9a61 📦 Rebuild both guest sets and the ROM record for this branch
RgfxGate's Metal bundle answers each format's own linear alignment, and the
wire header the bundle and the option ROM compile names the format answers'
last two bytes. make -C guest prebuilt and prebuilt-arm64e rewrote RgfxGate in
both sets with their records, and make -C firmware prebuilt the ROM's record:
the ROM's bytes are unchanged.
2026-11-12 09:19:28 -08:00
Anees Iqbal 467cce8dae 📦 Rebuild both guest sets and the ROM record for this branch
The x86-64 and arm64e sets carry the kext and bundle with this branch's
commits: rasterization rate maps and their descriptor's mutability, the
residency set create's nil error out, a compute pipeline's function handles
and visible function tables, and its dynamic libraries. The wire header
changed (RATE_MAPS, FUNCTION_POINTERS and DYNAMIC_LIBRARIES, their messages,
and library_count where reserved_5c was), so the option ROM's record names
the new header; the ROM's bytes are unchanged. Built on the Mac with make -C
guest prebuilt and prebuilt-arm64e and make -C firmware prebuilt (job
m3-max-21410); prebuilt-check passes for the sets and the ROM.
2026-11-12 08:14:18 -08:00
Anees Iqbal b3fa81fa6b 📦 Rebuild guest sets and ROM record for the linear alignment
Regenerate the prebuilt x86 and arm64e guest sets and their records from the
sources of the commits before, on pin 50's tree with Graft 0.3.0: the kext
has IOSurface align the bytes per row and the plane offsets it works out to the
host GPU's linear alignment, which every host that offers the surfaces' pages
answers now. Only ReimsGraphics changes in each set. The option ROM's bytes
are unchanged; its record moves with the wire header's comments. Built on
m3-max by job m3-max-20375, which also ran make -C guest test and both prebuilt
checks.
2026-11-12 03:39:50 -08:00
Anees Iqbal a379a5a459 📦 Rebuild guest sets and ROM record for batch 18
Regenerate the prebuilt x86 and arm64e guest sets, their records and the
option ROM's source record from the combined sources of batch 18 (x86
display-sleep, sampler LOD bias + reduction mode, guest-class Mac present).
The ROM bytes are unchanged (749434f8); the C header cbindgen writes was
already the combined one from the cherry-picks.
2026-11-12 00:10:55 -08:00
Anees Iqbal fab4be5201 🆕 Show black while the guest's display sleeps
A Mac's display goes dark when the OS puts it to sleep (Energy Saver's timer,
pmset displaysleepnow) and lights with the desktop at its wake. The device kept
showing the last frame instead, so a sleeping guest looked frozen.

What changes for the guest: the device offers DISPLAY_POWER (FEATURES bit 37)
on every host, and a guest that takes it sends SET_DISPLAY_POWER (command 8,
a 24-byte RgfxSetDisplayPower of display and on, answered COMPLETE), a display
command the control thread carries out. A reset turns the panel on. Nothing
else the guest sees changes: presents are taken and answered, VBLANKs go on,
and modes and the cursor's image stay.

What changes for the host: while the panel is off, the device's window and
rvg_graphics_device_read_display (QEMU's console and screendump) show black,
and cursor_show tells the host the cursor does not show; at the wake both show
what the guest shows again. The display callbacks' order now covers the
display power commands (docs/api.md). QEMU's reims-graphics-pci needs no
change: its console reads the display through read_display.

The tests that pinned the offered feature words and the backlog's display
command range take the new bit and command. The option ROM is built from the
wire header, so its record takes the header's new hash; the ROM's bytes are
unchanged (sha256 749434f8...).
2026-11-12 00:04:27 -08:00
Anees Iqbal 22c30f2522 🐛 Take check-boot's GPU from MESA_VK_DEVICE_SELECT, else a lone lease
An --exclusive potluck job holds every GPU of its node, and its lease lists
them all, homelab-um870-1's RTX 3090 first. Taking the lease's first GPU put
three exclusive TCG runs on the 3090 in place of the 780M they were meant for
(m3-max-17679, 17862, 17863). The script now keeps a MESA_VK_DEVICE_SELECT
the run gives, names the GPU of a lease that holds one, and stops on a lease
of several, so an exclusive run must name its card.
2026-11-11 17:05:46 -08:00
Anees Iqbal cc36035eb4 🐛 Wait for the probe's window before check-boot counts its frames
Under TCG on a quiet homelab-um870-1, arm64 macOS 14.6.1's full-screen
probe window was first shown 2.1, 4.4 and 8.1 s after it was ordered front
in three boots, and not within the probe's 11 s in a fourth, which dropped
all 245 frames and failed metal-app (m3-max-17482). The probe ran 3 to 4
minutes after QEMU started, while the guest's post-login launches kept over
200 processes runnable on its 4 vCPUs. Counting frames over a fixed time
from the window's start read that delay as a device that shows nothing.

present_probe -v SECONDS now renders while it waits up to SECONDS for its
window to be shown (its occlusion state turning visible, or a frame's
nonzero presentedTime), then warms up a second and measures. Its line gives
the wait as visible_s, or none. check-boot runs it with -v 60, and fails a
window not shown in that time as such. Without -v the probe measures as
before, so the lane gate's runs are unchanged but for the new key.
2026-11-11 17:05:46 -08:00
Anees Iqbal 167ba0be50 🐛 Run check-boot's TCG device on the leased GPU, and say host load
A TCG run left the device to the library's own pick of the host's GPUs, so
on homelab-um870-1 one ran on the RTX 3090 the job did not hold (m3-max-17037).
The script now names the lease's first GPU in MESA_VK_DEVICE_SELECT and
stops where neither a lease nor a selection is given.

metal-app under TCG passes only on frames shown within the probe's 10 s, so
CPU taken by other work on the host can fail it, as a build did for 14.6.1 in
m3-max-17111. Its line now gives the host's pressure over the probe (PSI for
CPU, memory and IO, direct compactions and reclaims), and docs/qemu.md says a
gating TCG run takes the whole machine (--exclusive --hold-line).

docs/lessons.md records why the probe stays full-screen at the status level:
a titled probe window started over SSH was never shown, and every frame
dropped, while WindowServer denied the probe the right to be in front.
2026-11-11 17:05:46 -08:00
Anees Iqbal 3592ec74c9 📦 Build both kext sets and the ROM record again
Both kext sets carry the bundle that makes a no-copy Managed buffer over app
pages a Managed buffer over the Shared one over them, and the ROM's record
takes the wire header's new hash after its CB_SUBMITTED comment (the two
commits before; the ROM's bytes are unchanged). Built by make -C guest
prebuilt and prebuilt-arm64e and make -C firmware prebuilt on the M3 Max;
make -C guest test and both prebuilt checks pass.
2026-11-11 12:20:36 -08:00
Anees Iqbal e208d1a6b0 📦 Build both kext sets again with TEXTURE_DID_MODIFY_DATA
The guest's x86-64 and arm64e sets, built by make -C guest prebuilt and make
-C guest prebuilt-arm64e from the tree with the feature (bit 36) and the
bundle's messages, beside the no-copy buffers' joined pages blocks, and the
option ROM's record, whose wire header changed; the ROM's bytes are unchanged
(make -C firmware prebuilt). Built on the M3 (m3-max-16888), whose make -C
guest test passed first.
2026-11-11 11:52:38 -08:00
Anees Iqbal 4115904fb2 🆕 Tell the guest the scale of its display's host screen
The guest's kexts state the display's density from its native width alone
(220 pixels per inch from 2880 pixels wide, else 110), so a window
narrowed below 2880 pixels on a HiDPI host screen made the arm64 guest's
desktop half size, and a wide window on a 1x screen could start HiDPI.
The host knows the screen: the window's drawable is drawn at the screen's
backing scale.

DISPLAY_SCALE (feature bit 35, FEATURES_HI bit 3) carries it. Where the
guest took it, each display's record in DISPLAYS is followed by an
RgfxDisplayScale: the screen's pixels a point in 120ths, 0 until the
window first draws. The scale is part of the display's mode, so a window
moved to a screen of another scale is told with DISPLAY_CHANGED. A guest
that does not take the bit reads DISPLAYS as before; the option ROM and
Ambrosia's module never take it. The wire header gains the bit and the
record, and the option ROM's record its hash (the ROM's bytes are
unchanged).

What the guest observes changes: FEATURES_HI offers bit 3 on every host,
and DISPLAYS carries the record to a guest that took it. The tests of the
features offered change with it.
2026-11-11 10:19:26 -08:00
Anees Iqbal 2f05367316 ✅ Make check-boot's log checks match what they claim
amfi-map counted every line naming the bundle that held "amfi", "not valid"
or "code signature", and kept none of them. Read for real, each boot has
two such lines and both are notes, not denials: AMFI's "is adhoc signed" and
amfid's "not valid" for the ad hoc signed bundle, while WindowServer maps it
and Metal runs (measured on arm64 27.0.1, gate cblog2). Match denials alone
(library validation failed, rejecting, denying, denied), return the lines
into guest.log and quote the first in the verdict. page-count's dmesg read
counts as read only where the buffer holds some line of our kexts (17 in
that boot), so an empty or failed read no longer passes as "the kext logged
no count".
2026-11-11 04:58:42 -08:00
Anees Iqbal b7e6ab2cc2 🐛 Read the guest's logs where check-boot's checks look for them
Over ssh the guest user's shell is zsh, whose log builtin takes the name and
fails on log show's arguments; with its stderr thrown away, grep -c counted 0,
so amfi-map's AMFI half and ax-matrix passed on every boot without reading a
line. Name /usr/bin/log in those reads. page-count's kext lines are not in
the unified log at all (our IOLog lines reach the kernel's message buffer
alone), so read them with sudo dmesg. Record the trap in docs/lessons.md.
2026-11-11 04:57:55 -08:00
Anees Iqbal ce9285804a ✅ Fail check-boot on a screen of one colour
check-boot passed a boot whose screen was black: under KVM the runtime
refused FramebufferFetch and HostMemory, so CoreAnimation's composites
came out empty, while metal-app, which measures presentation and not
pixels, still counted 59.9 fps and every other check passed.

The new check, screen, reads the screendump check-boot already takes
(screen.png, else screen.ppm) with the standard library alone, and fails
when its commonest colour covers more than 90% of it or it has fewer than
1024 distinct colours. The bounds sit well clear of the screendumps of the
69 passing boots under HVF of 2026-11-11 (14.6.1 to 27.2.1, clean and
white-widget desktops among them): the commonest colour on 3.7% to 21.0%
of the screen and 240,414 to 404,446 colours. Of the 71 boots with a
screendump it fails one, a 27.2 control whose windowserver-metal and
metal-app failed too (15 colours, 95.0%). An all-black frame, and a black
one with a menu bar (97.8%), fail; a missing or unreadable screendump
fails as such. The header's check list and docs/qemu.md describe it.
2026-11-11 03:44:57 -08:00
Anees Iqbal f754939907 🔇 Move the library's per-event info lines to debug
No line at info may fire per present, frame, ring message or other
per-event path. Measured on development: an arm64 macOS 27.0.1 boot
logged 1326 lines, 867 of them the display's change of IOSurface at
WindowServer's presents and 396 library lookups; an x86 macOS 26.7.2 boot
on the 780M logged 3248, 1296 and 349.

- The display's change between IOSurfaces, each library lookup, each
  shared event named or made from another process's, and each queue made
  unshared are debug lines, the first, second and last under targets of
  their own that the lane gate's and check-boot's runs name at debug:
  reims_vgpu::graphics::shown (msi-drag.py times composites by it),
  ::library (msi-boot.sh's launch gaps) and ::queues (its count). The
  display's change between the scanout and a surface stays at info.
- reims-vgpu-graphics' lines of a reset and a context's close, which
  reims-vgpu's own repeat with what they let go of, are debug; its line of
  completion records handed over, once a second, is info the first time.
- The surface order's and the IOSurface views' summaries come at most
  once a minute, not at every 4096th command buffer or 256th
  SURFACE_PAGES; check-boot.sh reads the caches' count up to a minute old.
- A long wait's end, a CPU wait's end or its cut at a reset, and a
  newLibraryWithData: of bytes Metal refuses too are debug; the CPU wait's
  lines lose the runs of spaces their strings held.
- A fold at the views' budget, and the video arms' first picture of each
  way, frame of each outcome and reason of each fallback, are info once
  per process (their kind), not once per session.
2026-11-11 03:44:57 -08:00
Anees Iqbal ef65f4edd8 📦 Build both kext sets again with the cached blocks' layouts
The kext forwards the surface's layout with its cached and deferred blocks'
SURFACE_PAGES, so both sets are rebuilt (make -C guest prebuilt, make -C
guest prebuilt-arm64e): ReimsGraphics' binaries, their hashes in set.toml
and the sources' records. The wire header's docs changed with it, so the
option ROM's record takes the header's new hash (make -C firmware
prebuilt); the ROM's bytes are the same.

Built on the M3 Max (Xcode 27.2, 27B52) in potluck job m3-max-14709, which
ran make -C guest test first and both prebuilt checks after.
2026-11-11 03:27:14 -08:00
Anees Iqbal 8e7e0aa713 🎨 Write arm64 device accesses out as plain loads and stores
A volatile access fixes an access's size and count, not its instruction, and
clang picks writeback forms: the Ambrosia module's BarSize read ECAM with a
pre-indexed LDR. A hypervisor decodes an access to emulated device memory from
its abort's syndrome, which an arm64 CPU gives only for a single load or store
without writeback. A pre- or post-indexed, pair or SIMD&FP access aborts with
ISV 0, and KVM hands it to QEMU, which decodes it only with its own instruction
emulator (vendor/qemu 89e32906, 3892a92f). Ambrosia's own firmware made the same
change.

The module's Read16, Write16, Read32, Write32, Read64 and Write64 become inline
asm: one LDRH, STRH, LDR or STR at [Xn], with a "memory" clobber; the barriers
stay as they are. In the arm64e kext, the only accesses to BAR 0 are
ReimsGraphics' and RgfxAccelerator's readRegister and writeRegister. They now
go through rgfxRegisterRead32 and rgfxRegisterWrite32, which on arm64 are one
LDR or STR of a W register at [Xn]. RgfxGate makes no device access. BAR 2, the
region, is RAM to QEMU (memory_region_init_ram_ptr), so the rings' accesses
never reach it. x86-64 has no such limit and keeps the volatile accesses.

No behaviour changes for the device: each access keeps its size, its count and
its order.

Checked on m3-max (m3-max-14564, Apple clang 21.0.0), before and after:
- `clang -S` of each translation unit with its Makefile's flags, listing every
  inline-asm instruction (between `//APP` and `//NO_APP`, or `; InlineAsm
  Start` and `End`);
- `llvm-objdump -d` of the module's ELF, listing its loads and stores whose
  base is not sp that write back, pair or move a SIMD&FP register;
- `llvm-objdump -d --disassemble-symbols=` of the kext's four accessors.
Module before: `ldr w9, [x8, #0x10]!` (BarSize's ECAM read) is among the
ELF's 20 such forms. After: its 34 device accesses are all inline asm, each
`ldrh`, `strh`, `ldr` or `str` at `[xN]`. None of the ELF's 16 remaining such
forms is one of them. Kext after: ReimsGraphics.cpp's 27 and
RgfxAccelerator.cpp's 13 register accesses are each `ldr wN, [xM]` or
`str wN, [xM]`. The accessors
built `ldr w0, [x8, w1, uxtw]` and `str w2, [x8, w1, uxtw]` before, and
`ldr w0, [x8]` and `str w2, [x8]` after. x86-64: ReimsGraphics.o and
RgfxAccelerator.o disassemble the same before and after, and the rebuilt
x86-64 set's three binaries are byte for byte the committed ones.
2026-11-11 03:01:04 -08:00
Anees Iqbal 2283610452 ✅ Keep Graft's registry-root state in check-boot's guest log
check-boot read only RgfxGate's GraftClient value, and the guest is gone once
it ends, so a boot that failed into Graft left nothing to say why: Graft's
own state, its reason, its log and ReimsGraphics' bind state were never read.
It now keeps GraftState, GraftReason, GraftLog and every GraftClient.* line of
the registry root in guest.log, beside the commands' other output. No verdict
reads them, so the checks and their count are unchanged.
2026-11-10 00:35:01 -08:00
Anees Iqbal 76a7ad4d7b ⬆️ Take Graft 0.1.0, its first public release
Graft 0.1.0 (commit bb884fe, release zip sha256 2bea380e) is Graft's first
public release: bundle id ai.aneesiqbal.graft, serving only
ai.aneesiqbal.ReimsGraphics and ai.aneesiqbal.RgfxGate, with a C++17 SDK tool,
graft-kext, that consumer.mk builds from source with Xcode's clang++ in place
of the Python SDK. Its zip, copied by its own tools/vendor.py with the record
of all 156 files, puts Graft's source tree, the two kexts and the SDK in
guest/graft; the kexts sit at guest/graft/Graft.kext and Graft-arm64e.kext,
with no built/ any more, so the set's staging, its Graft check and the lane
gate read them there. The only binaries are the two kexts. AGENTS.md now says
guest/graft is Graft's release as vendor.py copies it.

RgfxGate depends on ai.aneesiqbal.graft 0.1.0, Graft's compatible version.
Graft hands an arm64e route's original back as a void * holds a function
pointer, discriminator 0, so RgfxGate keeps each AMFI original in a void * and
converts it to its mpo type at the call, which re-signs it; a typed variable
written through a void ** would authenticate with the type's discriminator and
fault. The static_asserts on the wrappers' discriminators stay. Graft's kernel
side refuses by name where it could have panicked, among them an arm64e AMFI
slot not signed with its operation's discriminator and a donor table that
differs from the live vtable.

set-check checks the prelinked collection with graft-kext check-prelinked,
which takes prelink.py's arguments and exit codes. Graft reports a bound
consumer as "bound: imports and vtables committed;" and either waiting for the
device or "activation gate open on the device nub"; the lane gate's graft-bind
passes only on the open gate, since only then does IOKit start ReimsGraphics.
Graft's own id moves in stage-config.py and docs/qemu.md, check-boot marks a
panic report naming ai.aneesiqbal as ours, and msi-appload posts its
measurement notification under the new prefix.

The prebuilt sets are rebuilt from these sources in their own commit.
2026-11-10 00:35:01 -08:00
Anees Iqbal f2d97498df 🎨 Name our kexts and Metal bundle under ai.aneesiqbal
The owner moves our reverse-DNS names from com.steelbrain to ai.aneesiqbal,
keeping each name's last part: ReimsGraphics, RgfxGate and the Metal bundle
(reims-graphics) take the new prefix. Graft 0.1.0 pins these new consumer ids
and refuses the old ones, so this lands with its adoption. What the guest sees
changes with it: the kexts' bundle ids, the Graft gate property
(ai.aneesiqbal.ReimsGraphics.graft-bound) and the registry root's
GraftClient.ai.aneesiqbal.* keys. The boot checks match the new names.

The prebuilt sets are rebuilt in the adoption batch, on Graft 0.1.0.
2026-11-10 00:34:34 -08:00
Anees Iqbal 1b2ee5e33f ✅ Check AMFI's refusals and the accessibility matrix at boot
check-boot gains two checks. amfi-refuse runs a copy of /usr/bin/true signed
ad hoc with com.apple.rootless.install, which AMFI must kill (exit 137) with the
guest up: its kern.bootsessionuuid read 5 s later is the login's. The refusal
passes through RgfxGate's signature hook, whose wrong prototype panicked a
26.6.2 guest on exactly this run until 618f3644d, so this is that fix's test.
ax-matrix fails on any "not able to set accessibility matrix" line in the
boot's log, which ReimsGraphics' colour filter scale (041af6766) took from 2 a
boot to 0 on all four releases. Both ran as a gate step by hand until now.
amfi-refuse runs last of the guest's checks, after every read of the boot's
log, since a failure can take the guest down.
2026-11-09 22:16:46 -08:00
Anees Iqbal 16c2054362 📝 Point at Ambrosia's public tree: its image and driver guides
Ambrosia's development is now its public tree (0.1.0). Its image is
target/ambrosia.bin after `make` (built/ is gone), and the graphics driver
interface's guides are docs/graphics-drivers.md and
docs/how-to/write-a-graphics-driver.md (notes/ is gone). check-boot.sh's
usage, its missing-image message, the interface header's comment and
docs/qemu.md name the new paths.
2026-11-09 21:55:32 -08:00
Anees Iqbal 576fa7502d 🐛 Tell a reboot by the boot session, not kern.boottime
page-count failed a 15.6.1 boot under TCG on homelab-um870-1 as "booted
again": its kern.boottime read { sec = 1794272590, usec = 959702 } at the
login and the same second with usec 294291 after the Metal work. macOS
corrects its boot time as its clock settles, more so under TCG, so one boot
can read two. kern.bootsessionuuid is set once each boot and changes only
then, so check-boot compares it instead and no longer reads kern.boottime.
2026-11-09 17:13:39 -08:00
Anees Iqbal c3b35bae83 🐛 Give the desktop under TCG 5 times its HVF wait
check-boot waited 180 s for the desktop under TCG, 3 times HVF's 60 s,
while SSH and every guest command get 5 times their HVF limits. On
homelab-um870-1 a 27.0.1 boot with our configuration took its SSH login at
105.6 s, then showed WindowServer and Dock but not yet Finder when the 180 s
ran out, and its end screendump shows the whole desktop with Finder's menu
bar. A guest busy after its login is slow to start Finder under TCG as it is
slow to answer SSH, so the desktop gets 300 s, the same 5 times.
2026-11-09 16:57:47 -08:00
Anees Iqbal 42ecd32c2f 🐛 Give each SSH login under TCG 5 times its HVF limit
check-boot waited on the guest's SSH with logins limited to a 5 s connect
and 10 s in all, at either speed. Under TCG a guest busy after its login can
take longer than that to send sshd's banner and finish the key exchange, so
27.0.1 on a Linux member sat at its desktop with no login landing in 300 s.
Each login's limits are now slowed as every guest command already is.
2026-11-09 16:57:47 -08:00
Anees Iqbal e2517c59a0 🐛 Judge metal-app under TCG on presents, not pacing
Under TCG the emulated CPU sets the rate WindowServer composites at:
27.0.1 on a Linux member submits about 14 frames a second and drops 63 of
142, which report.py's bar of a tenth lost reads as a failure of our device.
Pacing is judged under HVF only. Under TCG metal-app now passes on an OK
probe with frames presented and at most 3 answers missing; its drops and
rates stay in the line, unjudged.

So those drops can be read, every metal-app line now also gives the host's
display flips during the probe's call and their rate: WindowServer's own
presents, the rate the probe's frames can reach the display at. A probe that
drops while WindowServer composites as fast as it submits is ours to look at.
2026-11-09 16:57:47 -08:00
Anees Iqbal 9e7d8a8fa3 📦 Rebuild both kext sets and the ROM record with whole 16 KiB pages
The arm64e set now carries development's colour matrix and frame times with
the kext naming whole 16 KiB pages of guest RAM (PAGES_16K), so a Mac host
lays an arm64 guest's surfaces in place. The x86 binaries, plists and
set.toml are byte-identical (the x86 kext never takes PAGES_16K), and so is
the option ROM: their records change only by the sources' hashes. Built on
the M3 Max, job m3-max-12485, with the guest's native tests passing.
2026-11-09 15:18:35 -08:00
Anees Iqbal 47f010c149 🐛 Fail metal-app as unread while Setup Assistant covers the session
27.0.1's guest runs Setup Assistant after its login, and its full-screen
window covers present_probe's: the probe's frames are never shown, so it
reports presented=0 with every frame dropped, which read as our device
failing to present. check-boot now reads, just before the probe, whether a
Setup Assistant process runs; a probe that then falls short fails as unread,
naming the process and its pids, with the probe's line kept beside it. A
probe that passes still passes. A covered fixture no longer looks like a
device failure.
2026-11-09 13:42:07 -08:00
Anees Iqbal f0ac11ef2f 🐛 Fail check-boot's checks on unread guest readings, slower on TCG
A TCG boot on a Linux member passed windowserver-metal with "WindowServer
none, Dock none, Finder none": every desktop poll ran out of time and
printed nothing, and the check took the empty reading for a desktop with
no "none" in it. A reading of two pids and a trailing "none" passed too.
The desktop is now up only once all three read as pids, and no poll that
answered is "unread". The same empty-reading pass hid in amfi-map (a log
query that timed out counted as no denial) and page-count (panic reports
and the kext's count lines unread read as none, and kern.boottime unread
at the login passed): each now fails as unread.

Under TCG `kmutil showloaded` was cut off at 120 s and every desktop poll
at 20 s, so each command in the guest, and the probes' own alarms and
copies, now gets 5 times its HVF limit there.
2026-11-09 13:07:58 -08:00
Anees Iqbal d4bfd26d07 🐛 Give check-boot's network device no option ROM
An uninstalled QEMU build has no efi-virtio.rom, and virtio-net-pci refuses to
realize without the option ROM it names by default, so check-boot.sh could not
boot a guest on such a build (Ambrosia's TCG pre-check on a Linux host). The
arm64 guest's firmware runs no option ROM, so the device names none, as
Ambrosia's own run-guest.sh does.
2026-11-09 12:56:15 -08:00
Anees Iqbal e91c159484 🆕 Have Ambrosia place display 0's node in the device tree
IOMobileFramebuffer.framework counts an arm64 guest's displays from the
display-subsystem children of /arm-io once in a process, and WindowServer
counts before our kexts load from the auxiliary kernel collection, so it
counted none and ran headless. Ambrosia's Graphics > DisplayNode places
/arm-io/<name>, with only its name and that device_type, where the module
drives a display, before the kernel starts.

Our configuration's bundle now names reims-display0, the node ReimsGraphics
uses as display 0's. stage-config.py adds the key with the kexts' entries, not
config.plist, so the module's bundle alone gives no node and no process waits
30 seconds for a framebuffer service that nothing publishes.
2026-11-09 09:41:26 -08:00
Anees Iqbal 22ec2795ff 🐛 Hand Graft the discriminators of Legacy's superclasses too
The arm64 display's guests panicked when WindowServer first asked for the
frame info. IOMobileFramebufferUserClient::s_supported_frame_info calls
supported_frame_info through IOMobileFramebuffer and authenticates the slot
with IOMobileFramebuffer's discriminator, 0xbd70. Our synthesized vtable's
slot was signed with Legacy's, 0x7dc3: Legacy's own table signs the four
pure methods IOMobileFramebuffer declares (set_notify_tag_mask_gated,
supported_frame_info, factory_portal, executeFactoryConfigurations_gated)
with its own redeclaration's discriminators. Those four slots are the only
ones where Legacy's table and its bases' differ, on 14, 15, 26 and 27.

Graft 1.3.2 signs each synthesized slot with the discriminator of the most
base handed table that covers it, and refuses the display bind unless every
superclass's table is handed. Ambrosia now exports IOMobileFramebufferService's
and IOMobileFramebuffer's vtables beside Legacy's; each is defined in
IOMobileGraphicsFamily in every arm64 Boot KC from 12 to 27.0. Graft 1.3.0
and 1.3.1 look up only Legacy's table by its symbol, and ignore the others.
2026-11-09 09:41:26 -08:00
Anees Iqbal ecfa6bcb47 🐛 Read check-boot's guest answers as they stand when checked
Ambrosia's boots of 30170dc5a showed three of check-boot.sh's readings wrong:

- amfi-map looked up the WindowServer pid the desktop wait saw, so a
  WindowServer that died and came back was counted by its dead pid. The
  check now reads the pid when it runs, and names the old one beside it.
- On 14.6.1 the guest's perl printed five locale warnings for the
  host's LANG=C.UTF-8, which macOS's ssh sends and macOS 14 lacks, and
  bench -l's first five lines were only those, so the device line was
  never read and present_probe never ran. The guest's commands now run
  with LANG and LC_ALL set to C, and the device is read from bench -l's
  "bench: device" lines.
- The verdict's release came from the first sw_vers in guest.log, the
  answer of a try sshd refused. It is now the answer G returned, read
  again after the desktop wait where it was not a version.
2026-11-09 09:41:26 -08:00
Anees Iqbal 6a10f9f2d3 📦 Rebuild both kext sets and the ROM's record for the ask
The x86-64 and arm64e sets' ReimsGraphics and RgfxGate (with the Metal bundle)
are rebuilt from the scheduled ask's sources: the kext takes SCHEDULED_ASK and
the bundle asks from waitUntilScheduled. The option ROM's bytes are unchanged;
its record names the wire header the ask's message joined.

Built on the M3 Max (potluck m3-max-11864, the 25G241 KDK): make -C guest
test, prebuilt, prebuilt-arm64e, prebuilt-check, make -C firmware prebuilt and
prebuilt-check, and set-check of the x86-64 set against the 11.7.11, 12.7.6,
13.7.8, 14.8.9, 15.8.2 and 26.7.2 Boot collections all passed.
2026-11-09 08:32:26 -08:00
Anees Iqbal f4c78a91da 🐛 Have Ambrosia hand over IOMobileFramebufferLegacy's discriminators
Graft 1.3.0 signs each inherited slot of the arm64e display's synthesized
vtable with the live parent's pointer-authentication discriminator. Our
arm64 firmware, Ambrosia, measures those discriminators from the Boot
kernel collection and hands them over in the device tree, but only for
the vtables its configuration names. Without that, Graft refuses the bind.
Our config.plist named none, so every boot that bound ReimsGraphics ran on
a local configuration that named the vtable.

Our configuration now names __ZTV25IOMobileFramebufferLegacy under
Kernel > ExportVtableDiscriminators. stage-config.py keeps every Kernel
key but Add, so make config-bundle carries the key into Config.cpio, and
make bundle carries it as well.
2026-11-09 05:29:20 -08:00
Anees Iqbal 909727f72b 🐛 Probe a booting arm64 guest's SSH with no shared connection
check-boot.sh missed the SSH login on every -v boot (6 of 6), while
run-guest.sh's -v boot logged in after 10 s. Its boot probe ran `timeout 10
ssh true` every second with ControlMaster=auto and ControlPersist=yes, so a
probe the timeout cut off while it was the master could leave one behind
for every later probe to wait on. The probe now opens no master
(ControlMaster=no, ControlPath=none); the first guest command after the
login opens the shared connection as before.

The wait also re-read the whole serial log, 190 KB and more under -v, two
or three times a second. It now reads only what the log gained since the
last pass, keeping a line the guest was part way through for the next.
2026-11-09 05:06:42 -08:00
Anees Iqbal ab56ca1f44 🆕 Read the pageable-map page count's path in arm64 boots
bf7d61a94's ReimsGraphics counts a surface's pages through mach_vm_region over
kernel_map and, inside IOKit's pageable maps, IOIteratePageableMaps: strong
imports whose arm64e path has never run. check-boot.sh gains page-count, read
after the boot's Metal work: it fails where the guest booted again during the
run (kern.boottime moved since the login), wrote a panic report in it (marked
where it names our kexts or the count's calls), or stopped answering. Its line
carries the host's last count of IOSurface device caches (made, deferred,
carrying pages, refused) and the kext's own count lines (counted, not counted).

Zero deferred while caches get made, no count line, or no count that counted
is printed as a check-boot: finding: line under the verdict, not a failure:
each is a result to report, not a fault in the path.
2026-11-09 02:19:03 -08:00
Anees Iqbal 0fa19e6b00 🆕 Check RgfxGate's install and AMFI's admission in arm64 boots
The arm64 boot check read Metal enumeration and an on-screen app, but not
the two steps RgfxGate owns, so a boot with an empty /Library/GPUBundles or
an AMFI refusal of the bundle failed only downstream, with no reason. Add
bundle-install (RgfxGate's Graft client state reads installed, tagged or
present; the bundle carries the restricted flag and the
KernelExtensionManagement rootless class) and amfi-map (WindowServer maps
the bundle's executable, read with sudo lsof, which SIP allows; and the
boot's log names it in no AMFI or library-validation denial).
2026-11-09 01:46:27 -08:00
Anees Iqbal 082c30e6b1 🆕 Let a deferral carry its surface's few resident pages
VTDecoderXPCService writes page 0 of each new decoder output before its first
decode, the output's other pages not resident (measured on the 780M in a macOS
26 guest: all 208 pool surfaces of a 4K HEVC session in Safari). A deferral
takes only a surface none of whose pages is resident, so each decoder output
had its 12 MiB wired and filled with zeros at its first ask: 5 to 7 ms of the
guest's on the 780M and about 3 ms on the 5080, for each of the seventeen or
more surfaces a 4K60 playback's start makes.

The host now offers SURFACE_DEFERRED_CARRY (FEATURES_HI bit 0, feature bit 32)
where it offers either deferral. A guest that takes it may defer such a
surface carrying its resident pages: the deferral's runs are the surface's
bytes in order, each run of pages not resident RGFX_PAGE_RUN_ZEROS. The host
makes the cache of zeros as for any deferral and owes a first fill of the
carried pages, as a new cache owes one of its pages: copied in through a
staging buffer after the zeros on the transfer queue, before what reads the
cache next, or taken as met where a decode writes the planes whole first. The
carried pages are watched until the block's pages are named.

A deferral with runs is refused as INVALID_ARGUMENT where the guest did not
take the bit, or where its runs are not whole guest pages summing to the
surface's bytes, lie outside the guest's RAM, or carry none.

What the guest reads changes: FEATURES_HI offers bit 32 where either deferral
is offered, and the test that held the feature words changes with it. The
wire header's new constants move the option ROM's and both guest sets' records
of their sources; their bytes stay.
2026-11-08 23:17:07 -08:00
Anees Iqbal b6e6f33cd2 🆕 Defer fresh surfaces that need a device cache on unified memory
On a GPU that shares the CPU's memory the host keeps a device cache only of
the surfaces whose pages its textures cannot use in place
(SURFACE_CACHE_REFUSED), and it offered no deferral there. So a fresh surface
that needs one had its pages wired and zero-filled by the kext at its first
texture, and copied into the cache once, though the CPU never touched them.

The host now offers SURFACE_DEFERRED_ASK (FEATURES_LO bit 30) beside it,
with the budget a host of a GPU of its own memory gives (DEFERRED_BUDGET, a
quarter of the device-local heap's budget). A deferral then asks with the
surface's layout (DEFERRED with ASK_CACHE and no runs), and the host defers
the block only where the surface would need a cache whatever its pages
(GpuDevice::fresh_surface_never_in_place). Every other is refused with
nothing made and counted, as is one past the budget, so the kext names its
pages asking, as without the feature: a full budget fails safe to today's
wire and ASK_CACHE path.

This is inside the rule that surfaces are used in place, cost and all, only
because these surfaces genuinely cannot be placed in place: their layout
needs a device cache either way (on the Iris, rows ending inside the GPU's
64-byte lines; on the 780M, runs exceeding one udmabuf). So it does not
choose a copy over in place; it only stops eagerly wiring and zero-filling
guest pages the CPU never touches.

What the guest reads changes on a unified-memory host: FEATURES_LO gains
bit 30 and DEFERRED_BUDGET is no longer 0, and the test that held both
changes with them. The wire header's new bit moves the option ROM's and the
guest set's records of their sources; their bytes stay.
2026-11-08 21:20:15 -08:00
Anees Iqbal 27b87befa3 🐛 Fail the scripts whose aborts an EXIT trap passed as 0
On macOS's bash, 3.2, a script that stops at an unset variable under set -u
exits 0 where an EXIT trap is set, and $? is 0 inside the trap too, so a check
that aborted read as a pass (measured: the same script exits 1 with no trap).
payload_test.sh showed it; seven more scripts pair set -u with an EXIT trap:
check-boot.sh, check-imports.sh, walk_window_macos.sh, opencore-add-kexts.sh,
ship-commit.sh, msi-boot.sh and msi-image.sh.

Each now keeps an ended flag, set at each deliberate success end, and its trap
does its cleanup as before, then turns an exit 0 short of that end into 1 and
keeps any other status. payload_test.sh takes the same form in place of the
trap its last fix removed, so it cleans its scratch on an abort again.
2026-11-08 21:03:01 -08:00
Anees Iqbal 96b1298853 📦 Build the ROM's record and kext set again with the decode caps
The wire header gained RgfxVideoCaps.decode, so the kext's copy of the device
info and caps is larger, and the option ROM's record names the header. The ROM's
bytes are the same; its record's hash of the header changes. Built on the M3 Max
with make -C firmware prebuilt and make -C guest prebuilt.
2026-11-08 12:51:01 -08:00
Anees Iqbal 331c53b27b 🐎 Map only the file-backed RAM ranges for the GPU
Bump vendor/qemu to the reims-graphics-pci change that gives the library the
map of the RAM ranges with a shared file and leaves out those without one.
On vmapple the main RAM is a shared memfd but the 1 MiB firmware and 64 KiB
config regions are not, so the device copied every IOSurface; now it maps
the main RAM in place and copies only a surface that falls in an unbacked
region, of which there are none, so every surface is used in place. A q35
guest whose RAM is all a shared memfd is unchanged.

Update docs/qemu.md and check-boot.sh to say the device maps the file-backed
ranges and copies a surface outside them, in place of the old all-or-nothing
rule.
2026-11-08 05:02:15 -08:00