Commit Graph
106 Commits
Author SHA1 Message Date
Anees Iqbal 3323ff3b75 📦 Rebuild both guest sets and the ROM record for unchanging pages
make -C guest prebuilt and prebuilt-arm64e on the M3 (m3-max-59429), at
3010578b8d, for this branch's guest changes: the kexts' UNCHANGING_PAGES (kext
feature 1 << 19) and the pages block's flags with their why; the bundle's
classification of read-only memory at a no-copy buffer's make and its counts;
its read-only shadows copied whole at each sync, and their counts; and the
wire header's prose. prebuilt-check passes on both sets.

make -C firmware prebuilt (m3-max-59461) rewrote the ROM's record for the new
wire header; the ROM's bytes are unchanged (sha256 749434f87f56...), and
prebuilt-check passes.
2026-11-20 10:45:23 -08:00
Anees Iqbal 44a89a0114 📦 Record the option ROM's build from the new wire header
The ROM is built from reims_graphics_wire.h, which the IMPORT_ADDRESSES_LATER
bit, the PAGES_BUFFER_ADDRESS query and the SURFACE_CACHE docs changed.
make -C firmware prebuilt rebuilt it on the M3 (job m3-max-58120): its bytes
are unchanged, and its record now names the header's new hash, so
prebuilt-check passes. The guest's firmware sees nothing new.
2026-11-20 07:15:39 -08:00
Anees Iqbal d9cc457b5a 🐛 Drop the GPU's writes to read-only pages on rt, as Metal does
A buffer or heap over pages their process maps read-only (option bit 24, a
read-only pages block) lay in place on metal2vulkan-rt's device, so the GPU's
writes reached the pages, where Metal drops kernel and blit writes to them and
the M3 Max faults a render pass's store. Read-only pages are now imported as a
copy whose GPU writes are put back from its base at each completion, so the
pages keep their process's bytes:
- a read-only pages block's view is imported as such a copy, and the decoder
  caches those views apart from writable ones;
- a no-copy buffer or heap of bit 24 with no pin lies over a copy of its own;
  one pinned in a known block whose writes reach the pages stays in place,
  counted rt-no-copy-read-only as before;
- a render pass that stores into a texture over such a copy completes with the
  store dropped, as the 5300M and the UHD 630 answer, counted
  rt-copied-store-outs.

What the guest sees: once a command buffer completes, its GPU writes to
read-only memory are gone from the pages, as on a Mac; within a command buffer,
and between ones in flight at once, a read after the write still sees it.
Tests: the count test, the decoder's view-import test (read-only asked, cached
apart), the drop merge's unit test, and a GPU test of a read-only buffer's
dropped fill, copy and render pass store. The wire header's IMPORT_ADDRESSES
sentence now says what rt gives a read-only block. The kext sets' and the ROM's
records take the header's new hash; no binary changes.
2026-11-19 17:00:15 -08:00
Anees Iqbal cdc383f3be 🆕 Rebuild the kext sets and the ROM record for MANAGED_AT_COPY
The guest's kexts and Metal bundle now carry RGFX_FEATURE_MANAGED_AT_COPY
(feature bit 63), and the wire header they and the option ROM compile
changed with it. This commit holds what `make -C guest prebuilt`,
`make -C guest prebuilt-arm64e` and `make -C firmware prebuilt` wrote
from this tree on the M3 (potluck job m3-max-54315, where
`make -C guest test`, `make -C guest prebuilt-check` and
`make -C firmware prebuilt-check` passed too).

guest/prebuilt and guest/prebuilt-arm64e: ReimsGraphics and RgfxGate
rebuilt, with set.toml and sources.toml. Graft is unchanged.

The option ROM's bytes are unchanged: the ROM compiles no part of the
header that changed. Only its record changes, for the header's new hash.
2026-11-19 15:43:47 -08:00
Anees Iqbal 73de5043a3 📦 Rebuild both guest sets for every surface cached, on b264
The branch's kext and bundle changes (SURFACE_CACHE_EVERY, the copy views
counted by why, the grown table's signed index, 16-byte planes in place) now
sit on b264, which rebuilt both sets for the Private take's answer and the
read-only decode planes. So ReimsGraphics and RgfxGate change in both sets.

Rebuilt on the M3 (m3-max-52307): make -C guest test, prebuilt,
prebuilt-arm64e and prebuilt-check, all with no warnings; then make -C
firmware prebuilt and its check. The option ROM's bytes are unchanged. Its
record moves with the wire header, which gained the bit.
2026-11-19 07:47:41 -08:00
Anees Iqbal 1d770049bf 📦 Rebuild both guest sets and the ROM record for the arm64 pool
The arm64e kext now takes the Shared pool, so its binary and both sets'
source records move, and wire.h's POOL docs move the ROM record's hash
(m3-max-51421: guest tests, both sets, prebuilt-check; the ROM's bytes are
unchanged, 749434f87f562895).
2026-11-19 03:46:35 -08:00
Anees Iqbal aff93c6c16 🐛 Look for panic reports of this run only
The Metal probe's timing set t0 to bash's SECONDS, which overwrote QEMU's start
time. The panic report search then asked find for reports from the last
29918092 minutes (m3-max-51279), which took every report on the disk. A
report copied in with the guest's image would have failed page-count though
this run made none. The probe's timing now has its own variable, so the search
covers the time since QEMU started.
2026-11-19 03:12:13 -08:00
Anees Iqbal 9816903af6 🐛 Read the session uuid at an arm64 login again until it answers
At an arm64 26 login under TCG (m3-max-51279), sw_vers and sysctl answered
nothing, and the guest's later commands answered. check-boot read
kern.bootsessionuuid once there, so page-count and amfi-refuse failed with
"unread at the login" though the guest never booted again: its later reads
matched. The first read now retries every 5 s, for 30 s at most, until it
reads as a uuid, and anything else counts as unread, as before.
2026-11-19 03:10:14 -08:00
Anees Iqbal c3d67c4730 📦 Rebuild both guest sets and the ROM record for import addresses
Both kexts now take IMPORT_ADDRESSES and the bundle places no-copy buffers at
the address the host gives their block, so both prebuilt sets are rebuilt from
guest/ at aa4796f05 (make -C guest prebuilt and prebuilt-arm64e, job
m3-max-51192, prebuilt-check passing). The wire header gains RgfxPagesAnswer
and the feature bit, so the ROM record takes its new hash; the ROM's bytes
are unchanged.
2026-11-19 02:54:55 -08:00
Anees Iqbal e7bf73d021 📦 Rebuild both guest sets and the ROM's record for Private blocks
Both kexts now take PRIVATE_BLOCKS, and the Metal bundle inside RgfxGate
places Private objects in the blocks the host gives. Both prebuilt sets
were rebuilt from bf7ce7ac6 on the M3 with Xcode 27.2, with 0 warnings,
and make -C guest prebuilt-check passed.

The wire header changed, so the ROM's record now holds the header's new
hash. The ROM's own bytes did not change (749434f87f562895).
2026-11-19 02:30:57 -08:00
Anees Iqbal d77c9db73c 📦 Rebuild both guest sets and the ROM's record for pool addresses
The kext now answers PoolTake's GPU address and the bundle places a pool heap
at it, so both prebuilt sets are rebuilt from those sources. The option ROM's
bytes are unchanged; its record names the wire header that gained the
POOL_ADDRESSES feature and the block's gpu_address.
2026-11-19 01:38:52 -08:00
Anees Iqbal ed23349ba8 📦 Rebuild both guest sets and the ROM's record for surface refills
Both kexts now take the SURFACE_REFILL feature (bit 58), and the bundle
names a cached IOSurface for a refill after the CPU's unlock and, on the
arm64 device, names the IOSurfaces a residency set holds at a buffer's
commit. Both sets are rebuilt from this tree's sources on the M3 with Xcode
alone (make -C guest prebuilt and prebuilt-arm64e, job m3-max-50539, which
also ran make -C guest test and prebuilt-check). The same job ran make -C
firmware prebuilt and prebuilt-check: the ROM's bytes are unchanged
(749434f87f56), and its record changes only by the wire header's hash.
2026-11-19 01:11:57 -08:00
Anees Iqbal d735b28d67 🔥 Drop ICB_SLOTS_IN_POOL: the bundle's ICB slots stay in the region
Only buffers' slabs and dedicated buffers move to the Shared pool. The bundle
takes an indirect command buffer's slot tables from region or page blocks of
their own, not from a buffer slab, so no slot run would ever lie in a pool
block and the command would have no sender. 0x23d is free again.

The header loses the command's define and its notes; the option ROM's record
takes its new hash, and the ROM's bytes do not change.
2026-11-19 00:00:11 -08:00
Anees Iqbal 9c5d81def0 🆕 Add the Shared pool's wire: its range, takes, gives and heaps
The guest's buffers are to live in the device's Shared pool, host memory the
host maps past the guest's RAM, rather than in the region. This is the wire
for it, with nothing yet carrying it out:

- RGFX_FEATURE_POOL (feature bit 57), offered where the host reserved a pool
  but on Windows, which the x86-64 kext takes;
- POOL_BASE_LO/HI and POOL_LENGTH_LO/HI (0x044 to 0x050), the pool's range,
  0 where the guest did not take the feature;
- POOL_TAKE (0x2fb) and POOL_GIVE (0x2fc) on ring 0 from the kext: a
  context's ask for a zeroed block of the pool, answered POOL_BLOCK (0x410)
  with the block's offset and length, each context's takes in its own order;
  and its giving one back, refused while an object of the host's lies in it
  and answered once the context's committed command buffers have finished;
- HEAP_OVER_POOL (0x23c), a Shared heap over a block the sender holds, and
  ICB_SLOTS_IN_POOL (0x23d), slots read in place in one.

The header is cbindgen's, with the three records exported. The option ROM
compiles the header, so its record's hash of it changes; the ROM's bytes do
not, as it uses none of the new names.
2026-11-19 00:00:11 -08:00
Anees Iqbal 8447199fee 🆕 Note a no-copy buffer's identity the first time it escapes
The host reads a no-copy buffer's bytes in place. The guest's Metal can hand
that buffer's identity to the app, or write it where the GPU reads, with no
message naming the buffer, and from then on the GPU may reach the buffer
through memory alone. The host had no way to know which buffers that happened
to. This commit adds a note for it, so the host can tell them apart.

The note is RGFX_CMD_BUFFER_ESCAPED (0x23b), RgfxBufferEscaped of 32 bytes:
the buffer's object id and the act, one of GPU_ADDRESS, ARGUMENT_ENCODER,
RESOURCE_ID and RESIDENCY_SET. The device offers it as
RGFX_FEATURE_BUFFER_ESCAPED (bit 56), and both kexts carry it. The submit gate
takes it in a batch, like a Managed range's write: unwaited, a fixed size,
naming no block and making no object.

The bundle marks each covered buffer as it is made (_rgfxEscape, set by
rgfxOwesEscapeNote) where the host took the feature. The first of these acts
in the buffer's life posts the note, before the act returns:
- a read of the buffer's gpuAddress;
- an argument encoder's setBuffer(s) of it, or setTexture(s) of a texture or
  view over it;
- a read of such a texture's or view's gpuResourceID;
- the buffer, or such a texture, joining a residency set.
Every later act is one relaxed load.

Wire order holds the note ahead of any command buffer that could use the
identity. The note goes on ring 0, posted or held in the serialiser to go
before the next commit's messages, and the device carries out a command buffer
only after every ring-0 message its process posted before it. Across threads,
the act's slow path posts the note under the buffer's lock and then clears the
mark with a release store. Every commit takes an acquire fence before it posts,
so a commit after an act that found the mark clear posts after the note.

The covered buffers are the app's no-copy buffers over its own pages
(BUFFER_OVER_PAGES, writable or read-only, bit 24) and over bytes already in
a block of the process (BUFFER_OVER_HOST_MEMORY). Managed buffers, heaps over
pages, IOSurface shadows and buffers placed in a slab's heap
(BUFFER_AT_OFFSET) are not covered.

A slab buffer made with an address of its own is covered too: a Shared buffer
past 2 MiB over a slab of the process's own pages, a device buffer, or a
no-copy buffer's shadow (RgfxSlabSource::Made's ownsAddress). It reaches the
host as the same BUFFER_OVER_PAGES or BUFFER_OVER_HOST_MEMORY message as an
app's no-copy buffer, and the host takes every such message alike. Leaving
slab buffers out would leave the host unable to read the mark as "this
buffer's identity never left".

The host marks the buffer's entry escaped, once for its life, and a later
note changes nothing. A note for an object that is not such a buffer is a bad
reference. A note for an object whose create the host refused is dropped, as
any naming of one is. Escapes are counted in the degradation counts line and
in the recorder's stats (`counted <code> <n>` lines), with no new stream
records:
- buffer-escaped-gpu-address, -argument-encoder, -resource-id and
  -residency-set, by the act that noted the escape;
- buffer-escaped-read-only-pages, the escaped buffers over a copy of their
  pages;
- no-copy-buffers, every no-copy buffer made, of which the escapes are a
  share.
Each act's first escape is also logged at info.

This changes nothing the guest observes. No one waits for the note, it has no
reply, and the mark changes no answer, object, address or command. Both
prebuilt sets and the option ROM's record are rebuilt from these sources. The
ROM's bytes do not change: its record changes only by the wire header's hash.
2026-11-18 19:52:34 -08:00
Anees Iqbal 191daab32a 🐛 Send a render pipeline's tessellation state and call stack depths
A guest's render pipeline drew its patches with Metal's default tessellation
state, whatever its descriptor set: power-of-two partitions, a maximum factor
of 16, no factor scale, constant factors per patch and clockwise output. The
bundle never sent the seven tessellation fields, so the device never saw them.
For the same reason the device never saw maxVertexCallStackDepth or
maxFragmentCallStackDepth, and created every pipeline with a depth of 1.

The bundle now reads each of these properties and sends it. Each tessellation
field travels as Metal's raw value, and tessellationFactorScaleEnabled as a new
flag, RGFX_RENDER_PIPELINE_TESSELLATION_FACTOR_SCALE (bit 8). The depths are
read only where the descriptor answers their selectors (macOS 12 and later);
older guests send 1.

The decoder passes every value through FullRenderPipelineDesc to the runtime's
RenderPipelineDescriptor. A state equal to Metal's defaults becomes the
runtime's `None`, so a pipeline that sets nothing is created exactly as
before. A raw value the runtime has no enumerator for dies at the send, as
every other enumerated field does. The recorder's tag-13 map carries the
values as three keys after privateState: `tessellation`,
`maxVertexCallStackDepth` and `maxFragmentCallStackDepth`.

Guests now see patches tessellated with the partition mode, maximum factor,
factor scale, step function, winding and control point index type that their
pipeline sets. They also see pipelines created with the call stack depths
they asked for.

The tessellation fields and the call stack depths share this commit because
they share one wire record. RgfxRenderPipelineCreate grows from 464 to 496
bytes, with eight u32s appended at offset 464, and both prebuilt sets and the
option ROM's record are rebuilt from these sources. The ROM's bytes do not
change.
2026-11-18 18:12:19 -08:00
Anees Iqbal 428996c490 📦 Rebuild the guest's kext sets and the ROM's record for run tables
The arm64e ReimsGraphics lends a surface whose runs overflow its VT_MESSAGE
through a run table. The x86-64 set's binaries and the option ROM's bytes
are unchanged; their records follow the sources and the wire header. Built
on the M3 by potluck job m3-max-39410.
2026-11-16 23:06:56 -08:00
Anees Iqbal 47f256720d 📦 Rebuild the guest's kext sets for the cursor's colour chain
The arm64e set's ReimsGraphics now takes CURSOR_COLOR and sends the
cursor's chain; the x86-64 set's binaries are unchanged, only its record of
the sources (the wire header and the kext's sources) moves. The option
ROM's bytes are unchanged, and its record names the new wire header.
Built on the M3 by make -C guest prebuilt and prebuilt-arm64e, and
make -C firmware prebuilt; prebuilt-check passed (job m3-max-39374).
2026-11-16 23:01:59 -08:00
Anees Iqbal 57ef9a3cb6 🆕 Send an arm64 guest's cursor chain to the host
The arm64e kext refused layer 1's XYZ2Blend, the cursor's chain from XYZ to
the display's profile, because the display applies no chain and that one is
not the identity: WindowServer logged "Failed to set ICC matrix" at each
login and more at each switch of the profile, and the cursor showed sRGB's
colours as they are.

Where the host offers CURSOR_COLOR, the kext takes it on arm64 and takes
each block of layer 1's chain it reads (Src2XYZ's curve and matrix,
XYZ2Blend's matrix and curve) without judging it, and posts the chain at
the first swap after it changed, before that swap's cursor, as a display
engine latches a layer's colour with the flip. It posts the chain off until
it is whole and where it is the identity within 2^-14. The x86-64 kext
does not take the feature, and against a host without it layer 1 is judged
as before.

check-boot's icc check keeps its limit of one matrix line, which now stands
for layer 0's XYZ2Blend that can come a swap before its Src2XYZ.
2026-11-16 23:01:59 -08:00
Anees Iqbal 9f5795c044 📦 Rebuild the guest's kext sets and the ROM's record for VT_RING
The arm64e ReimsGraphics takes VT_RING with VT_MESSAGES and takes the
host's messages from the VideoToolbox ring. The x86-64 set's binaries and
the option ROM's bytes are unchanged; their records follow the sources and
the wire header.
2026-11-16 18:48:19 -08:00
Anees Iqbal 4b44845763 📦 Rebuild both guest sets and the ROM's record for UPLOADS_WRITTEN
ReimsGraphics and RgfxGate of both sets, built from 3c60f57f7 on
development: both kexts take UPLOADS_WRITTEN, and the bundle names its
Managed set*Bytes chunks' extents in each command buffer's stream where it
does (make -C guest prebuilt and prebuilt-arm64e, make -C firmware prebuilt,
on the M3, job m3-max-38479, which also ran make -C guest test and both
prebuilt-checks). Graft and the option ROM's bytes are unchanged; the ROM's
record names the new wire header.
2026-11-16 17:50:07 -08:00
Anees Iqbal 8a8711206e 📦 Rebuild the guest sets and ROM record for the VideoToolbox service
The arm64e ReimsGraphics, built from 81d19961b: it publishes the VideoToolbox
service, carries its messages as VT_MESSAGEs and lends VideoToolbox's
IOSurfaces to the host until its rels (make -C guest prebuilt and
prebuilt-arm64e, make -C firmware prebuilt, on the M3, job m3-max-37648, which also
ran make -C guest test and both prebuilt-checks). The x86-64 set's binaries,
RgfxGate, Graft and the option ROM's bytes are unchanged; their records name
the new wire header.
2026-11-16 12:53:15 -08:00
Anees Iqbal fb4480077d 📦 Rebuild both guest sets for the arm64 crossings
Both ReimsGraphics binaries change: the arm64e one for the kext's moves of
the cursor across displays, the report of their places, the rules that
learn no place from a landing past the host's hold, and the wait for a
landing past the image over an edge; the x86-64 one for the code the two
kexts share. Graft and RgfxGate are unchanged byte for byte in both sets.
The option ROM's bytes are unchanged; its record names the wire header's
new hash, whose comments changed. make -C guest test, prebuilt-check, the
firmware's prebuilt-check and kc-check against the ten collections (x86-64
11.7.11 to 26.7.2, arm64 14.6.1 to 27.0.1) pass (m3-max-37258).
2026-11-16 11:25:19 -08:00
Anees Iqbal a29b9cb650 ✅ Check that the arm64 display takes WindowServer's ICC chain
check-boot gains icc: the boot's log has no "Failed to set ICC curve" line and
at most one "Failed to set ICC matrix", the cursor's layer 1, whose
standard-sRGB source the display's blend space does not invert. Before the
display took the ICC blocks, a login logged 20 to 32 such lines. The read
counts only where log show printed its header, so a read that fails is not a
pass (docs/lessons.md).
2026-11-16 09:18:38 -08:00
Anees Iqbal ce0d6bf5d3 🆕 Name a display node for each display in our arm64 configuration
Ambrosia 0.1.3 adds a /arm-io node for each display a revision 2 module
reports, from a list of names in Graphics > DisplayNode. Our configuration
now gives that list, reims-display0 to reims-display3, so one bundle serves a
device of any count, and an arm64 guest drives each display. Ambrosia 0.1.1
and 0.1.2 refuse a list, so the bundle needs Ambrosia 0.1.3 or later; this
lands once 0.1.3 is released.
2026-11-16 02:15:57 -08:00
Anees Iqbal f75c2aca51 🆕 Report the device's displays to Ambrosia's revision 2
Ambrosia's graphics driver interface gains revision 2, in which the
framebuffer's reserved word becomes Displays: how many displays the device
drives, so Ambrosia can add a display-subsystem node under /arm-io for each
one its configuration names. IOMobileFramebuffer.framework counts those nodes
to know how many framebuffer services to wait for, so an arm64 guest can drive
a display past the first only once each has a node before the kernel starts.

The module now takes MULTI_DISPLAY where Ambrosia gives revision 2 and the
device offers the feature, so DISPLAYS lists every display, returns their
count, and fits its mode to display 0's scanout room as the host splits the
span. Under revision 1, or on a device of one display, it takes no feature and
leaves the word zero, as before, so every Ambrosia from 0.1.1 on still boots
it. The configuration's DisplayNode stays the one string: Ambrosia releases
before revision 2 refuse a list.
2026-11-16 02:15:57 -08:00
Anees Iqbal f8d10e128f 📦 Rebuild both guest sets and the ROM's record for the mouse
Both kext sets now carry the guest's mouse for games, RgfxPointerDevice,
which the kext publishes when it takes RGFX_FEATURE_POINTER_MOTION, and the
arm64e kext links IOHIDFamily for it. The wire header gained the bit and the
event, so the ROM's record names its new hash; the ROM's bytes are unchanged.
Built on a Mac by make -C guest prebuilt, prebuilt-arm64e and make -C
firmware prebuilt; prebuilt-check passes.
2026-11-15 23:02:22 -08:00
Anees Iqbal 8e94777147 📦 Rebuild both guest sets and the ROM's record for the bounds
Rebuilt on the M3 (m3-max-35201) over the tree with both the 64 KiB chunk
mask and the display bounds (bit 50, command 9): make -C guest test,
prebuilt, prebuilt-arm64e and prebuilt-check, and make -C firmware
prebuilt with the option ROM's bytes unchanged (749434f8).
2026-11-15 22:10:45 -08:00
Anees Iqbal 625ffc05ac 🆕 Move the guest's cursor onto the display the host's pointer is over
macOS scales the VM's one USB tablet over the display its cursor is on, so
with several displays a window's pointer never carried the cursor past
display 0: pointing in display 1's window moved the cursor over display 0.

The device now offers POINTER_OVER, feature bit 49, beside MULTI_DISPLAY on
a device of two displays or more. To a guest that took both, it sends the
event POINTER_OVER (0x104: display, x, y in the display's pixels, and the
buttons held) when a window's pointer comes over a display the guest's
cursor does not show on, once per crossing, before the tablet gets the
position. The x86-64 kext takes the bit and, on the event, posts
IOHIDSystem's own mouse-moved (or the held button's drag) at that pixel's
point of WindowServer's global space, from its framebuffer's bounding rect;
it now links IOHIDFamily, where IOHIDSystem lives.

Measured on x86-64 macOS 11.7.11, 15.8.2 and 26.7.2 with a scratch kext:
IOHIDSystem::extPostEvent with kIOHIDSetCursorPosition puts the cursor on
display 1 and the tablet's next position lands there, while
extSetMouseLocation answers success and moves nothing WindowServer shows.

The event has a bit of its own rather than riding on MULTI_DISPLAY, so a
driver that takes MULTI_DISPLAY without knowing the event (the kext before
this change, the arm64e kext, the firmware drivers) is never sent it. For
the guest: a device of two displays or more offers one more feature bit,
the x86-64 kext takes it, and its cursor follows the host's pointer between
displays. A device of one display offers what it did. Both guest sets and
the ROM's record are rebuilt for the header; the ROM's bytes are unchanged.
2026-11-15 19:41:57 -08:00
Anees Iqbal dc094d42d7 📦 Rebuild both guest sets and the ROM's record for the zero bytes
The previous commit changed the bundle (MANAGED_BUFFER_CREATE's zero tail),
the kext (SubmitBatch takes the create at its new size) and the wire header.
make -C guest prebuilt and prebuilt-arm64e on the M3 (m3-max-34522) rebuilt
ReimsGraphics and RgfxGate in both sets from this tree, with the displays'
kext changes and the allocation count's bundle changes before it; Graft is
unchanged. make -C firmware prebuilt rewrote the ROM's record for the
header, the ROM's bytes unchanged. prebuilt-check, the firmware's
prebuilt-check and make -C guest test pass.
2026-11-15 18:44:04 -08:00
Anees Iqbal 1b9582129b 📦 Rebuild both guest sets with framebuffers per display
The x86-64 set takes the kext's framebuffers per display, its device control's
display list and MULTI_DISPLAY. The arm64e set takes the code both kexts share
(the display table and the cursor slot's lock), and still drives display 0
alone. wire.rs's docs of MULTI_DISPLAY and DISPLAY_COUNT said no host offers
the bit and that a device has display 0 alone, both stale since a host gives a
device up to four displays; the header follows them, and the option ROM's
record follows the header's hash, its bytes unchanged (749434f8).
2026-11-15 17:48:44 -08:00
Anees Iqbal d64d31f0a5 📦 Record the wire header both guest sets and the ROM build from
The wire header gained the multiple displays' definitions, which no guest code
uses, so each prebuilt record names its new hash and nothing else changes.
Rebuilt on the M3 (make -C guest prebuilt and prebuilt-arm64e, job
m3-max-33552; make -C firmware prebuilt, job m3-max-33551): the seven files of
each guest set and the option ROM came out byte for byte as committed (the
ROM's sha256 749434f8 before and after), and prebuilt-check passes on both.
2026-11-15 13:47:31 -08:00
Anees Iqbal bc2164ea8f 🐛 Wait 450 s for an arm64 guest's SSH login under TCG
check-boot.sh gave a TCG boot 300 s to log in, but macOS 26's login on
homelab-um870-1's 780M comes at one of two times, about 125 s or about
305 s: logins at 131.8 s (m3-max-32336), 122.2 s (32792), 314.9 s (32613)
and 301.6 s (33045). The two slow ones passed only because the last connect
attempt began before the limit, and m3-max-33301 failed on it with its
desktop presenting and no fatal line. The limit is now 450 s, past the slow
time; HVF keeps 90 s, and docs/qemu.md records the two login times.
2026-11-15 13:10:35 -08:00
Anees Iqbal 032e8c937c 🆕 Name the wire's PIPELINE_ANSWERS feature and query
A pipeline create that waits for its answer costs a round trip to the host,
and the kext forgets every answer at each start, so each boot's first creates
of the same pipelines wait again. Feature bit 47 (FEATURES_HI bit 15),
PIPELINE_ANSWERS, says the device keeps its keyed answers from one run to the
next, and the kext's ring-0 PIPELINE_ANSWERS (0x2f9,
RgfxPipelineAnswersQuery) asks for them, newest first: each comes as a keyed
PIPELINE_REFLECTION of the query's seqno, its per-create fields 0, then a
COMPLETE whose status is how many went. It makes nothing, so no command
buffer waits for it (backlog's NoOne), and the control thread carries it out.

The host knows the bit from here (KNOWN_FEATURES); the peer test's unknown
bit moves to 48. The wire header is cbindgen 0.29.4's output, and the option
ROM's record takes its new hash: make -C firmware prebuilt on the Mac wrote
the same ROM bytes and record (m3-max-30999).
2026-11-14 20:26:38 -08:00
Anees Iqbal 1c8ae23515 🆕 Ring a context's queues at its doorbell page
Where the host offers DOORBELL_PAGES the framebuffer takes it, and the
accelerator maps BAR 4 into the kernel at its contexts' start. A context
opened for a bundle that asks for OpenContext's seventh output (kext
feature 1 << 12, DoorbellPage) gets a free page, taken round-robin: the
kext binds it to the context with DOORBELL_PAGE_BIND before the process
learns of it, and maps it into the process uncached, its address the
seventh output. The bundle then rings a queue with one 32-bit store of the
ring's id at the page (a DMB OSHST first on arm64, and one STR of a W
register, the form a hypervisor decodes from its abort's syndrome), where
it called the kext before. The kext's own publish of a queue's ring rings
at the page too, where the host routes the queue's doorbell now. At the
context's close the page is unmapped from the process with its window,
then unbound, then given back.

A context with no page (a host without the pages, every page held, a
context numbered 2^24 or more, or a mapping that failed) answers 0 and its
process rings through the Doorbell call as before.

Ambrosia's driver module places BAR 4 between BAR 0 and BAR 2, so an arm64
guest's kernel finds it assigned; BAR 2 keeps its address.
2026-11-14 18:01:06 -08:00
Anees Iqbal 18a87b6026 🆕 Give the device doorbell pages in BAR 4
A guest's single commit costs 5.4 us against 2.9-3.1 on a native Mac, and
about 1.5 us of it is the bundle's call into the kext to write DOORBELL.
The device now has a BAR 4 of 256 doorbell pages of 16 KiB, which a guest
binds to its contexts through DOORBELL_PAGE_BIND (0x040, `page | context <<
8`) where it took DOORBELL_PAGES (feature bit 46). A page is its context's
own DOORBELL: a write of a ring's id at its first byte wakes that ring
where it is one of the context's queues', and is answered at the doorbell
as there when it asks. Every other write is dropped and counted, logged
once per kind: at an unbound page or another offset (`unbound`), or of
ring 0 or another context's ring (`foreign`). Reads answer 0. A reset
unbinds every page.

A queue of a context with a page is routed on the page's doorbell
(`route_doorbell_page`), and on DOORBELL otherwise. A page bound to another
context drops the routes on it of its old context's queues, so the host
wakes no ring at a page but its context's.

What the host and guest see:
- the C API: `rvg_graphics_device_doorbell_write`, the config's
  `doorbell_pages` (third version) and the callbacks' `route_doorbell_page`
  (third version), whose thread docs/api.md section 5 names;
- FEATURES_HI bit 14 is offered only where the host sets `doorbell_pages`;
- QEMU's reims-graphics-pci (b4771167) maps BAR 4 and offers the pages;
- a guest that does not take the bit, or a host that does not offer it,
  has every doorbell on DOORBELL as before: the bind is ignored and every
  BAR 4 write dropped (`without_doorbell_pages_the_doorbells_are_the_register_s`).

The wire header's change rewrites the option ROM's record; its bytes are
the same.
2026-11-14 18:01:06 -08:00
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