120 Commits
Author SHA1 Message Date
Anees Iqbal 391edf9731 📦 Rebuild both sets and the ROM's record for HEVC encode
make -C guest prebuilt and prebuilt-arm64e, and make -C firmware prebuilt,
from the guest sources and the wire header of the commit before (m3-max-77590,
which also ran the guest's tests and both prebuilt-checks): ReimsGraphics
publishes the HEVC encoder only where the host codes a frame in place, and
RgfxGate carries the Metal bundle, which sends a retried HEVC frame in place
of the last. The ROM's bytes are unchanged; its record follows the wire
header, which gained the in-place flags.
2026-11-27 16:26:01 -08:00
Anees Iqbal 132868d988 🆕 Offer VP9 decode to arm64 guests
The hosts' drivers list VP9 decode at profiles 0 and 2, and an arm64 macOS
26 guest has no VP9 decoder of its own: every VP9 session fails -12906
without one from the host. The previous commit gave the host VA-API
and NVDEC decoders; this one offers them to the guest.

What the guest sees: the device's video caps gain a VP9 entry, codec 3
(RGFX_VIDEO_CODEC_VP9), where the host's arm decodes VP9, listing profile 0
into NV12 and profile 2 into P010 as the driver answers them, at the arm's
sizes up to 16384 a side, and level 62 (6.2, as vpcC numbers it). On the
paravirtual route (RGFX_FEATURE_VT_MESSAGES) the host then lists a vp09
decoder, reims-vgpu-video.videodecoder.vp9, with those profiles; once a
process registers VP9 (VTRegisterSupplementalVideoDecoderIfAvailable, as on
a Mac) the guest's VideoToolbox decodes VP9 on the host's hardware. A sample
is a frame or a superframe whole, which the host splits. A stream the host
does not decode (profiles 1 and 3, 12 bits) is refused at its session's
start, as an HEVC format the arm lacks is, and the guest has no VP9 decoder
of its own to fall back on: known-issues.md says so. No encoder of VP9 is
listed.

The guest's pictures of the two libvpx streams equal vpxdec's, frame by
frame, on an RX 7900 XTX, an Iris Xe and an RTX 3090 under macOS 26.6.2 and
on the 3090 under macOS 14.6.1, and VP9 decodes as fast as HEVC on the same
route at 1080p and at 8192x4352 (devices.md, with the guest's CPU emulated).

The wire change is additive. An x86-64 guest's kexts read no caps entry past
HEVC's, and the device takes no session of codec 3. An older host's caps
have no VP9 entry, so a newer guest's VideoToolbox lists no vp09; a newer
host's caps list H.264's and HEVC's entries as before, beside VP9's
(vt_decoders_list_vp9_beside_the_others_where_the_caps_decode_it). The
header's hash moves in the option ROM's and both kext sets' source records;
their bytes are unchanged.
2026-11-27 14:57:30 -08:00
Anees Iqbal 0df657bde1 🆕 Scroll x86-64 guests sideways through their own mouse
An x86-64 guest scrolled only up and down: QEMU's usb-tablet, which took the
host window's scrolling, has no sideways wheel. The x86-64 kext's mouse now has
an AC Pan beside its wheel, which IOHIDEventDriver makes the scroll event's
sideways axis, and once the mouse is up the kext names it to the host with the
new SCROLL_DEVICES command. From then on the window sends its scrolling to the
guest as SCROLL events instead of QEMU's wheel buttons: a wheel's notches as
they are, and a touchpad's distance as one notch per 10 points, the points a
line is on SDL (FINE_PER_NOTCH), the rest carried to the next event and
counted afresh where the scrolling turns back. The kext posts the notches as
the mouse's wheel and pan reports, at most 8 x 127 a SCROLL.

For the guest: its scrolling comes from "Reims vGPU Mouse", sideways included,
with macOS's own wheel acceleration, as the tablet's did. For the host: the
window's wheel and scroll callbacks are not called for scrolling the guest's
devices take. An arm64 guest names no devices, so its scrolling goes to the
vmapple tablet as before; the arm64e kext's binary is unchanged.

The wire also carries a SCROLL's distance in 1/256 points, for a guest that
names a precise scroller (RGFX_SCROLL_DEVICE_PRECISE), which no kext names yet.

Measured in windowed walks with a wheel mouse over the window, on macOS 26.7.2
(potluck job m3-max-76095) and 11.7.11 (m3-max-76100): notches up, down, right
and left reach the guest three for three on their axes, in the tablet's
directions; eight quarter-notch parts make two; a burst of ten at 16 ms ramps
from 1 to 91 points, as the tablet's did; QEMU's tablet takes no wheel button.
2026-11-26 21:50:54 -08:00
vintowareandClaude Opus 5.5 9c91714b60 🆕 Boot arm64 macOS under KVM, and check its boot there
macOS's kernel sets up each GIC redistributor with a pre-indexed store,
`str w9, [x8, #128]!`. Under KVM it traps with no instruction syndrome
(ISV=0) into KVM's in-kernel vGIC, which neither KVM nor QEMU's ISV=0
emulator can complete, so an arm64 guest on an arm64 Linux host panics
early in its boot. firmware/ambrosia/kvm.plist holds an Ambrosia
Kernel > Patch that writes the same values to the same two registers with
plain stores. Its four instructions are once in com.apple.kernel in each
VirtualMac2,1 kernelcache from 13.6 to 27.2.1, so it sets Expect to 1: a
kernel they leave stops at Ambrosia with a named error.

reims-ctl adds the patch to an arm64 VM's bundle where the VM runs on KVM,
after the VM's own patches; HVF and TCG bundles are unchanged.
`make config-bundle KVM=1` adds it to our configuration's bundle, and
check-boot.sh -k boots that bundle under KVM, with HVF's limits and
judgements and TCG's memfd RAM, refusing a bundle without the patch.

Booted on an M1 Pro under Fedora Asahi Remix 45: reims-ctl restored
macOS 27.2.1, its first boot made the Data volume, and after finish-eacs
it reached Setup Assistant and the desktop (docs/qemu.md). check-boot.sh
-k has not run, as its guest probes build on a Mac.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:06:12 -08:00
Anees Iqbal 55e5dbef5b 📝 Say what the wire's queue priority field is
RgfxQueueCreate.priority's doc read "0 normal and higher higher", which runs
against Metal's order: a new queue's GPU priority is 1, and on an Intel 630 a
queue of a lower value runs first (dgpu-oracle.md Q50). It now says what the
field is: the bundle sends 0 for every queue, a guest's setGPUPriority: stays
in the guest, and the host reads none, so no queue the platform makes takes a
priority. Q50's note on the comment says it was changed.

reims_graphics_wire.h is regenerated with it (cargo xtask header). The header
is a source of the option ROM, so the ROM's record is rewritten with
make -C firmware prebuilt. The ROM's bytes are unchanged: its sha256 is
749434f87f562895548f60681cd4cd8bf6cc0d0e967ac2fea297674426709161 before and
after.
2026-11-22 10:08:08 -08:00
Anees Iqbal 4c8033a817 🆕 Let deferred dormant blocks age out again
This reverts cd369b7457, which kept deferred dormant blocks out of the
10 s age rule. That commit followed the reading's fixed rule, whose
item 2 tripped on a let-go's BLOCK_RELEASE answered in 27.451 ms, 10.2 s
after the browser's close.

The planner amended item 2 (02:4x): it trips only on a let-go's own work
on the answer's line, meaning its copies and rt's release and free
calls. The wait for the context's command buffers to end does not
count. The with-walk's trace splits that answer: its ring-0 job took
0.447 ms. The one command buffer it committed holds only event waits,
on values signalled 64 to 70 s before, and a signal. rt stamped that
buffer's GPU start 26.244 ms after its submission, and it ran in 0 ms
on the GPU. No other command buffer ran in the 9.4 s before it, so the
wait was the host GPU's start after an idle stretch, not other work.
The answer came 0.507 ms after the buffer completed.

Over the whole walk, no BLOCK_RELEASE answered in 16.7 ms or more has
own work that long. The jobs took 1.614 ms at most, and the longest
command buffer committed between a job and its answer, from any
context, ran 7.660 ms on the GPU.

Items 1 and 3 held as measured: frames -0.86%, and the Mac's footprint
90 s after the close was 12893 MiB with the deferred part against 15381
MiB without it. So the deferred part stays, with its footprint gain.
The option ROM's record goes back to its build before cd369b7457, and
both guest sets are rebuilt from this tree.
2026-11-22 03:50:35 -08:00
Anees Iqbal 88fa50cd8f 🔥 Keep deferred dormant blocks out of the 10 s age rule
Walks m3-max-66747 (without the age rule) and m3-max-66749 (with it), arm64
macOS 27.0.1 on the M3, headless, read the rule fixed for the deferred part: it
stays only if frames are within 1%, no guest answer of 16.7 ms or more names a
let-go, and the Mac's footprint after the close is not higher than without it.
Frames were 5402 against 5449 (-0.86%), and the footprint 90 s after the close
12893 MiB against 15381. But 10.2 s after the browser closed, the release of a
block let go for its age was answered in 27.451 ms, and the walk's
BLOCK_RELEASE answers of 16.7 ms or more rose from 311 to 445. The trace does
not say whether that block was deferred; the rule removes the deferred part.

So a deferred block goes past its caps and for the other causes alone, as
before the age rule, and the age timer waits for the others alone. A dormant
block not deferred still goes once it has slept 10 s.

What the guest sees: a deferred surface's pages take the GPU's writes at its
next lock, or at its block's let-go past a cap, as before the age rule.

guest/prebuilt and guest/prebuilt-arm64e are rebuilt from these sources, and
firmware/prebuilt/ReimsGraphics.toml records the wire header's new comment.
2026-11-22 03:50:35 -08:00
Anees Iqbal 0a599afb73 📝 Name the kext's dormant deferred cap and age in the comments
The DEFERRED_BUDGET register's comment said the kext lets dormant deferred
blocks go past half the budget. The kext's cap is the smaller of half the
budget and an eighth of the guest's RAM (rgfxSurfaceDormantDeferredCap), and
with this lane every dormant block also goes once it has slept 10 s. The
comment now says both, in wire.rs and in the header cbindgen writes from it.

RgfxBlockTable.hpp listed Shared buffers and heaps among the region's blocks,
which holds only where the device offers no Shared pool; where it offers one
they lie in the pool's blocks, as docs/graphics-kext/design.md, Decided 5,
says. The comment now lists the region's blocks as the design does.

The option ROM compiles the header, so its record takes the header's new
hash; the ROM's bytes are unchanged.
2026-11-22 03:50:35 -08:00
Anees Iqbal 36655c417b 🐛 Name the x86-64 guest's GPU "AMD - " without Intel or NVIDIA
WindowServer died while QuickTime Player played a 4K video full screen: a
user's 780M host, and measured here on a 780M (macOS 26.7.2 and 15.8.2) and on
an Iris Xe (26.7.2), each time on a walk's second clip. Read from their code,
SkyLight's compositor takes a Metal device whose name holds "Intel" for an
Intel GPU, and scales a full-screen video's YUV layer through Intel's video
pixel processor (AppleGVACore). That keeps only plugins of Intel's renderer
IDs, so with ours it has none and asserts. The naming rule gave integrated
hosts "Intel - ", and an Intel host's own name holds "Intel" under any prefix.

What an x86-64 guest sees now, on every host (the owner's rule):
- MTLDevice.name, and the GPU's `model` that System Information shows as its
  Chipset Model, are "AMD - " and the host's name with "Intel" and "NVIDIA"
  taken out, in any case, each with a mark directly after it ("(R)", "(TM)",
  "®", "™") and one space:
  - 780M: "AMD - AMD Radeon 780M Graphics (RADV PHOENIX)" (was "Intel - ...")
  - Iris Xe: "AMD - Iris(R) Xe Graphics (RPL-P)" (was "Intel - Intel(R) ...")
  - UHD 630: "AMD - UHD Graphics 630 (CFL GT2)", on Windows "AMD - UHD
    Graphics 630"
  - Arc A770: "AMD - Arc(tm) A770 Graphics (DG2)"
  - RTX 3090: "AMD - GeForce RTX 3090" (was "AMD - NVIDIA GeForce RTX 3090")
  - 7900 XTX and llvmpipe: unchanged, "AMD - " and the host's name
  The kext's `model` was the host's name whole, and none for no name; it is
  now the same name as Metal's, "AMD - reims-graphics" for no name.
- vendorName is "AMD" on every host (was "NVIDIA" or "Intel(R)" by the host
  name's first word), so the GL renderer takes NVIDIA's settings on every
  host, as on a 5300M, where an Intel host's guest took Intel's
  (design.md, "The renderer's settings").
- SkyLight's NVIDIA name test finds nothing on an NVIDIA host either: it takes
  an AMD GPU's path there (MetalTiledBacking's +0x71 now set).

The device info's `integrated` byte stays on the wire and the host still
writes it; nothing in the guest reads it now, as its docs say. arm64 guests
see what they saw. The ROM's bytes are unchanged: its record changes for the
wire header's comment alone.

Tests: serializer_tests' test_metal_names, test_vendor_names and
test_metal_answers_hold_no_vendor_word; the kext's device_name_test, now built
for the x86-64 kext's rules and, as device_name_arm64_test, the arm64e kext's.
2026-11-21 18:40:44 -08:00
Anees Iqbal bd18665fef 🆕 Name the x86-64 guest's Metal device by the host GPU's type
An x86-64 guest's MTLDevice.name is now the host GPU's name, whole, after a
prefix: "Intel - " where the host's Vulkan driver reports the physical device's
type as INTEGRATED_GPU, and "AMD - " for every other type (discrete, virtual,
CPU, other). An RTX 3090 now reads "AMD - NVIDIA GeForce RTX 3090", a Radeon
780M "Intel - AMD Radeon 780M Graphics (RADV PHOENIX)" and llvmpipe "AMD -
llvmpipe ...". The rule reads the device type alone, with no list of vendors,
drivers or devices. The name keeps its spaces as the driver gives them, and an
empty name reads "AMD - reims-graphics" or "Intel - reims-graphics".

A 3D modelling app chooses its GPU by a vendor word in the device's name
(Intel, AMD, Apple), and on a host GPU of another vendor it listed only the
CPU (walk m3-max-61607).

What stays: arm64 guests' name; the Metal device's vendor and family names, by
which the GL renderer picks its settings; and System Information's Chipset
Model, the kext's IOPCIDevice model, which stays the host's name, whole.

The device info carries the type in its byte at 0x453, reserved and zero
before, now `integrated`: 1 for INTEGRATED_GPU. Its layout and wire version
stay, and a host older than the field writes 0, which reads as not
integrated. The firmware's record and both prebuilt sets follow the header and
the bundle; the option ROM's bytes are unchanged.
2026-11-21 10:07:22 -08:00
Anees Iqbal 7ea4edc2fb 📦 Rebuild the guest's kext sets for the sole holder's memory
ReimsGraphics and RgfxGate in guest/prebuilt and guest/prebuilt-arm64e,
built by make -C guest prebuilt and prebuilt-arm64e from this branch's
sources: the kext's SoleHolderPages feature and the bundle's anonymous
private clause. The option ROM's record takes the wire header's new text;
the ROM's bytes are unchanged.
2026-11-20 14:02:42 -08:00
Anees Iqbal 83c4898877 🆕 Name a sole holder's anonymous memory unchanging
The bundle now names read-only anonymous memory unchanging where its maximum
protection has no write, the kernel answers it SM_PRIVATE at a shadow depth of
0, and mach_vm_page_info's VM_PAGE_INFO_BASIC answers its object's count as 1
at depth 0 with the region's object id (kRgfxAnonymousPrivate). The kext takes
such a block (kRgfxPagesSoleHolder, 1 << 3, where it sets
kRgfxKextFeatureSoleHolderPages, 1 << 20) and marks its SURFACE_PAGES
RGFX_SURFACE_PAGES_UNCHANGING without COPY_ON_WRITE, so the host reads its
pages once, as the view is imported. On P2's guest (macOS 26.7.2, the Windows
mini) the 4K block over such memory was copied whole at each commit that used
it.

A wire holds no reference, so the count leaves out wires for writing taken
while the memory was writable. The kext knows its own: it refuses the block
(kIOReturnNotPermitted) where, once its pages are wired, a writable block of
its own in the table or an in-place surface block covers a page of them, or a
block of writable memory is being made (writableMakes), and the bundle then
asks a read-only block, why RGFX_PAGES_WHY_REFUSED. The check sorts the
block's runs and walks every writable wire's segments under contextLock, once
per such make. What is left is a write another driver started before the app
removed write for good, still landing after the make.

The clause is on for every guest kernel, with no release gate. The facts it
rests on, read in xnu's published source at each tag from macOS 11.0.1 to
26.5, osfmk/vm/ lines:
xnu-               cnt   pid   rid  fake  prot   upl clamp  iopl  walk     id
7195.50.7.100.1  19154 19264 14459 19126  6172  6459 17037  9030 14915   1209
7195.60.75       19074 19184 14406 19046  6156  6459 16984  9030 14862   1209
7195.81.3        19074 19184 14413 19046  6157  6459 16984  9030 14869   1209
7195.101.1       19119 19229 14290 19091  5915  6457 17020  9010 14749   1190
7195.121.3       19158 19268 14329 19130  5916  6457 17059  9010 14788   1190
7195.141.2       19158 19268 14329 19130  5916  6517 17059  9070 14788   1190
8019.41.5        19330 19440 14493 19302  6007  6551 17227  9137 14952   1190
8019.61.5        19330 19440 14493 19302  6007  6551 17227  9137 14952   1190
8019.80.24       19330 19440 14493 19302  6007  6551 17227  9137 14952   1190
8020.101.4       19330 19440 14501 19302  6003  6543 17247  9143 14960   1188
8020.121.3       18885 18995 14245 18857  5918  6541 16960  9131 14704   1168
8020.140.41      18945 19055 14305 18917  5909  6542 17019  9135 14771   1168
8792.41.9        19527 19637 14780 19499  5939  6701 17519  9294 15246   1166
8792.61.2        19538 19648 14791 19510  5939  6753 17530  9346 15257   1167
8792.81.2        19538 19648 14791 19510  5939  6753 17530  9346 15257   1167
8796.101.5       19669 19779 14872 19641  5926  6750 17650  9273 15338   1164
8796.121.2       19669 19779 14872 19641  5926  6750 17650  9273 15338   1164
8796.141.3       19738 19848 14911 19710  5940  6774 17695  9297 15377   1164
10002.1.13       19897 20007 15074 19869  6032  6791 17854  9316 15540   1163
10002.41.9       19910 20020 15087 19882  6032  6771 17867  9296 15553   1165
10002.61.3       19910 20020 15087 19882  6032  6771 17867  9296 15553   1167
10002.81.5       20023 20133 15121 19995  6041  6771 17980  9296 15587   1167
10063.101.15     20254 20364 15180 20226  6098  6774 18210  9299 15646   1355
10063.121.3      20357 20467 15247 20329  6123  6774 18308  9299 15714   1355
10063.141.1      20359 20469 15249 20331  6125  6774 18310  9299 15716   1355
11215.1.10       20139 20249 14984 20111  5692  6843 18096  8188 15442   771i
11215.41.3       20139 20249 14984 20111  5692  6843 18096  8188 15442   771i
11215.61.5       20501 20611 15230 20472  5759  6817 18384  8162 15693   765i
11215.81.4       20507 20617 15236 20478  5765  6817 18390  8162 15699   765i
11417.101.15     20646 20756 15393 20617  5804  6766 18487  8111 15856   765i
11417.121.6      20694 20804 15441 20665  5843  6781 18535  8129 15904   766i
11417.140.69     20703 20813 15449 20674  5841  6777 18546  8124 15913   766i
12377.1.9        20960 21070 15518 20931  5974  6988 18734  8331 16004   776i
12377.41.6       22004 22114 16433 21975  6174  7198 19709  8562 16933   807i
12377.61.12      22037 22147 16463 22008  6204  7203 19742  8567 16963   808i
12377.81.4       22109 22219 16534 22080  6275  7209 19813  8573 17034   808i
12377.101.15     18688 18805 13571 18677  5743  7659 16128  8765 14068   824i
12377.121.6      18686 18803 13569 18675  5722  7659 16126  8765 14066   824i
 cnt   vm_map.c, vm_map_page_range_info_internal: the top object's count,
       less the query's own reference to 12377.81.4, read before it after
 pid   there: the id, VM_KERNEL_ADDRPERM to 10063.101.15, ADDRHASH after
 rid   vm_map.c, vm_map_region_recurse_64: the region's id, VM_OBJECT_ID
 id    vm_object.h (i: vm_object_internal.h): VM_OBJECT_ID, the low 32 bits
       of pid's macro in each tag
 fake  vm_map_page_range_info_internal: a footprint query's count of 1 and
       an id of no object (task_self_region_footprint)
 prot  vm_map.c, vm_map_protect (its preflight from 12377.101.15): no
       protection the maximum lacks
 upl   vm_pageout.c, vm_map_create_upl: no write UPL where the entry's
       protection lacks write; from 12377.1.9 through vme_allows_upl_write,
       whose test is at 6786, 6986, 6991, 6997, 7413 and 7413
 clamp vm_map.c, vm_map_remap_extract: a share's maximum is the source's at
       most, which memory entries take through vm_map_copy_extract
 iopl  vm_pageout.c, vm_object_iopl_request: the UPL keeps the object with
       no reference of its own
 walk  vm_map.c, vm_map_region_walk: the count less one while paging, so
       the share mode alone leaves it in doubt

Later releases are checked by test: guest/bundle/tools/sole_holder_probe.c,
which the lane gate's info phase (item sole-holder) and Ambrosia's
check-boot.sh (check sole-holder) run on each guest they boot, reads the count
as 2 with a memory entry or a second mapping holding the memory and 1 once it
goes, sees a footprint query answered otherwise, the kext's writable wire of
memory whose maximum lacks write refused, a sole holder's block made, and
refused while a writable block of the kext's covers it. A release where it
fails is a red leg. The kext's tests cover the wiring and the runs' sort and
search, and the bundle's a sole holder's block named and refused.
2026-11-20 14:02:42 -08:00
Anees Iqbal e2bad8dd27 📦 Rebuild the kext sets and records for copy-pending memory
make -C firmware prebuilt, make -C guest test, prebuilt and prebuilt-arm64e,
and both prebuilt-checks on the M3 (m3-max-60005) at e3f576069a. RgfxGate's
binary, which carries the Metal bundle, is rebuilt in both sets for the
bundle's copy-pending clause; ReimsGraphics and Graft are the same bytes.
The ROM's bytes are the same (sha256 749434f8...); its record and both
sets' sources.toml name the wire header 4d49a1b9....
2026-11-20 12:31:26 -08:00
Anees Iqbal 5205b9a372 📦 Record the wire header the ROM and kext sets were built from
d9b51ad264 changed only the comments of reims_graphics_wire.h, which the option
ROM's record and both guest kext sets' records hash. make -C firmware prebuilt,
make -C guest prebuilt and make -C guest prebuilt-arm64e on the M3 (potluck job
m3-max-59858) rebuilt them: the ROM and every kext binary came out byte for byte
the same, so only the three records change, each the header's new sha256. Both
prebuilt-checks passed there.
2026-11-20 11:47:58 -08:00
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