Commit Graph
5297 Commits
Author SHA1 Message Date
Anees Iqbal 6af1d77fbc 📦 Rebuild both kext sets with each swap a refresh on
The arm64e ReimsGraphics now gives each swap's presentation a refresh after the
last one's, kept in the absolute clock across a sleep. RgfxGate, Graft and
every x86 binary, plist and set.toml are byte-identical: their records change
only by the sources' hashes. Built on the M3 Max, job m3-max-12544, with the
guest's native tests passing.
2026-11-09 16:13:42 -08:00
Anees Iqbal 4db9b48d3d 🐛 Keep an arm64 swap's refresh a period on across a sleep
The frame clock kept the time it gave last in mach_continuous_time's clock,
lead included, and compared the next swap's time with it there. A sleep
between two swaps grows the lead by the time slept, so the second swap's time
passed the first one's by that much whatever its refresh, and QuartzCore,
which takes each time back into mach_absolute_time's by the lead it reads,
could trace the second up to two periods before the first, where the first
had been given a refresh ahead of its own. The native test's long run, with a
second asleep, failed so ("a traced time never goes back").

The clock now keeps the refreshes it gives in the absolute clock, the one
QuartzCore traces in, and adds the lead last: two swaps stay a period apart
there across a sleep. The long run checks the spacing by the lead the clock
read, and QuartzCore's traced times where that lead is exact, and the
frame-info checks add a sleep between two swaps.
2026-11-09 15:58:48 -08:00
Anees Iqbal 87fdec2c48 🐛 Give each arm64 swap's presentation a refresh after the last one
In Ambrosia's g147 and g148 readbacks, 6 to 18 of each 180 swaps carried the
same presentation time as the swap before, though the two were one frame apart
in wall time. A swap's time is the refresh its present's answer maps to, the
last VBLANK's taken (RgfxVblankClock::shownAt). An answer taken before its own
refresh's VBLANK maps to the refresh before, which the swap before may already
have been given, and the frame clock then gave it that time again, as it kept
times from going back. QuartzCore's trace showed those pairs 3 ticks apart at
most, as it takes each time back by a lead it reads itself.

A display shows one frame a refresh. The frame clock now gives a swap whose
refresh is not after the last one given the refresh after that one, a period
on, where that lies at most two periods past its own; past that, where swaps
come faster than the refreshes, the last time, so the times do not run ahead.
The period is the display's at the answer, read where the VBLANKs set it. The
x86-64 display pipe's times are unchanged.

legacy_swap_info_test drives a swap a refresh with answers at, just before and
just after their VBLANK's receipt: each time is a period after the last and on
its own refresh, and the rule before gives two swaps a refresh apart one time.
The long run of one to three swaps a refresh keeps its checks of the lead, now
with the times a period apart but where they would run ahead.
2026-11-09 15:58:48 -08:00
Anees Iqbal 9e7d8a8fa3 📦 Rebuild both kext sets and the ROM record with whole 16 KiB pages
The arm64e set now carries development's colour matrix and frame times with
the kext naming whole 16 KiB pages of guest RAM (PAGES_16K), so a Mac host
lays an arm64 guest's surfaces in place. The x86 binaries, plists and
set.toml are byte-identical (the x86 kext never takes PAGES_16K), and so is
the option ROM: their records change only by the sources' hashes. Built on
the M3 Max, job m3-max-12485, with the guest's native tests passing.
2026-11-09 15:18:35 -08:00
Anees Iqbal 7d308e4f3e 📝 Note how far a Mac's views are from a map entry limit [ci skip]
An arm64 guest's surfaces now lie in place on a Mac, each view taking a
kernel map entry a 16 KiB run, and vmmap's region count of QEMU (4,500 to
15,000 on the arm64 boots of job m3-max-12451) hides the entries a view's
region holds. One process on the M3 Max made 1,500,000 one-page views, each
its own entry, with none refused: no limit within reach.
2026-11-09 15:18:29 -08:00
Anees Iqbal b31b3b821c ✅ Check another context composites a surface as drawn
On arm64 guests the menu bar shows black and a dialog's text magenta, both
drawn by one process into an IOSurface that WindowServer composites. Nothing
checked that path end to end: one context's texture over the surface's bytes
rendered on its queue, then a second context's own buffer and texture over
the same bytes sampled on its queue.

The decoder's tests now do that on the Vulkan platform, for the bundle's
copy of a surface (each context's BUFFER_OVER_HOST_MEMORY over the shared
block) and for the surface in place (each context's BUFFER_OVER_SURFACE_PAGES
over the block naming its guest pages), of BGRA8 and RGBA16Float. At each
step the surface takes new contents, written by the guest's CPU or drawn in
the first context, and the second composites it with a minified linear read
whose edge rows and columns clamp into the corners. Each composite must equal
the same composite of a texture over a block the CPU wrote fresh, bit for
bit, and so must the texels read and sampled. In place, the bytes past the
surface's own in its last page must stay as they were.

The guest RAM helpers of surface_pages' cost tests are shared with these.
2026-11-09 15:13:18 -08:00
Anees Iqbal c871c1bfae ✅ Check the host keeps out of a page's tail and shares pages
With PAGES_16K an arm64 guest's kext names a surface's pages to the end of the
last one, past the surface's own bytes. Two tests hold what the host does with
such blocks: a cache laid out by its surface's planes, as every device cache on
a Mac is, reads the whole block at its fill but copies no byte past the last
row's texels into the pages at a download after a GPU write or at the block's
release after another; and two live blocks whose runs share a page each get a
view and a buffer, the page one memory under both, as two surfaces' blocks
would if their allocations ever met in one page. No behaviour changes.
2026-11-09 15:13:18 -08:00
Anees Iqbal 89671fe95b 🐛 Name whole 16 KiB pages of guest RAM where the kext took PAGES_16K
PAGES_16K says every run of guest RAM the guest names, and a SURFACE_PAGES'
length, is whole 16 KiB pages. The arm64e kext named a surface's pages as the
bundle asks for them, its IOSurface's alloc size rounded to 4 KiB, and an arm64
guest's IOSurfaces are not 16 KiB multiples: a 1920 x 1080 surface of 8 bytes
a texel is 0xfd2000 bytes, 1013 runs whose last is 8 KiB. On the M3 host the
library refused 212 of 368 blocks in place on 26.6.2 as Unaligned (Ambrosia's
pages16k after-arm), and their surfaces were copied.

Where it took PAGES_16K, the kext now tells the device of every run of guest
RAM in whole 16 KiB pages: the runs it writes for a surface in place or a
deferred block's attach end at their last page's end, the SURFACE_PAGES length
with them (writeRuns, postPages), and a pages block's range is rounded out to
16 KiB pages, where the bundle places a no-copy buffer at the pointer's offset
in such a page (RgfxRegion::pagesPage). The bytes past a surface's own in its
last page are the same allocation's, which the kernel gives and wires in
whole pages; the kext's own copy of the runs, which a later ask compares with
its memory's segments, stays as the segments are.

For the guest: on a Mac host, surfaces whose length is no 16 KiB multiple lie
in place instead of being copied. The x86-64 kext never takes PAGES_16K, and
both changes compile only into the arm64e kext and the bundle's arm64 slices:
the x86-64 set keeps its bytes. pages_block_test checks the rounding.
2026-11-09 15:13:17 -08:00
Anees Iqbal 5b38484167 🆕 Give the library a Mac's guest RAM through QEMU, with no file
QEMU's reims-graphics-pci passed the library no RAM map on macOS, where
HVF's guest RAM has no file behind it, so a Mac host copied every surface
and no-copy buffer of an arm64 guest. The device (QEMU ff604cc8) now gives
every RAM range in pages of the host's size there, with an fd of -1; the
library views it by mach_vm_remap, which shares the pages HVF maps into the
guest. A Mac host offers the guest RAM features only to a guest that takes
PAGES_16K, so an x86-64 guest on a Mac reads what it read before, the new
bit aside, and its surfaces are copied as before. Linux is unchanged.
2026-11-09 15:13:17 -08:00
Anees Iqbal 6fd281ef60 🎨 Format the 16 KiB pages' host changes
rustfmt's layout of the two commits before, and one comment rewrapped to the
line width.
2026-11-09 15:13:17 -08:00
Anees Iqbal 998e28a6fa 🆕 Offer 16 KiB guests their pages in place on 16 KiB hosts
A Mac's library never laid a surface's pages in place: its views needed the
host's page to be the guest's 4 KiB, and a Mac's is 16 KiB, so every surface
of an arm64 guest went through a copy in the region.

The views now take a host page that core's mappings take and that a guest's
runs can be whole pages of: 4 KiB, or 16 KiB. On a host of 16 KiB pages the
device offers RGFX_FEATURE_PAGES_16K, and only a guest that takes it reads
the guest RAM's features (SURFACE_PAGES, PAGES_BUFFERS, HEAP_OVER_PAGES,
SURFACE_CACHE_REFUSED, SURFACE_DEFERRED_ASK and _CARRY) and the deferred
budget. Every other guest reads the features it read before.

What changes for the guest: on a Mac, FEATURES_HI also reads bit 34. The x86
kext does not take it and reads the same features and device info as before.
The device info stays as from a host without the in-place features: it is
written before any guest takes the bit. A 4 KiB host is unchanged.
2026-11-09 15:13:17 -08:00
Anees Iqbal 934c7b03f8 🆕 Offer guest RAM features to 16 KiB-page guests on 16 KiB hosts
A host whose page is 16 KiB, a Mac, can map guest RAM for its GPU only in
whole pages of its own, and an x86-64 guest's runs are 4 KiB pages, so a
Mac host offered no feature over guest RAM to any guest: every arm64
guest's surfaces and no-copy buffers were copied, and WindowServer spent
most of its updates merging no-copy buffers' shadows.

The wire gets feature bit 34, PAGES_16K: the guest's runs of guest RAM are
whole 16 KiB pages. A host whose page is 16 KiB offers it where it maps
the guest's RAM, and offers its features over guest RAM only to a guest
that took it: FEATURES_LO and _HI, and DEFERRED_BUDGET, read them from the
DRIVER_FEATURES_HI write that takes PAGES_16K, a write may take them from
then on, letting PAGES_16K go lets them go, and a reset hides them. Until
then every register reads as from a host that maps no guest RAM, with
PAGES_16K offered beside.

The arm64e kext writes DRIVER_FEATURES_HI with PAGES_16K first, reads the
offer again, and takes from that. The x86-64 kext never takes it and reads
the offer once, so an x86-64 guest on a Mac reads what it read before, the
new bit aside. No host offers PAGES_16K yet.
2026-11-09 15:13:17 -08:00
Anees Iqbal 84351df405 📦 Rebuild both kext sets with the colour matrix and frame times
The arm64e ReimsGraphics now answers WindowServer's colour matrix and shows it
(482ca612f), and keeps the frame info's presentation times from stepping back
(f041f0075). Every other arm64e binary and plist is byte-identical. The x86-64
set's binaries and plists are byte-identical too: the kext's changes are in its
arm64e part alone. Both sets' sources.toml records the changed kext sources.

Built by `make -C guest prebuilt` and `make -C guest prebuilt-arm64e` on the M3
Max (Xcode 27.2), with `make -C guest test`, `prebuilt-check` and the option
ROM's check passing there.
2026-11-09 14:15:12 -08:00
Anees Iqbal ab4f8161c8 📝 Describe the colour matrix by what the display does with it
The comments of the arm64 colour matrix told what Apple's paravirtual display
does with the call, as the reason for ours. They now say what the guest sends,
what WindowServer does with the answer, and what our display answers and shows;
the floating-point reference in mobile_color_test is named for the conversion it
does (floatBits) rather than for the paravirtual display.

The reason stays as the colour matrix's 🐛 commit (482ca612f) gave it: on
27.0.1, AppleParavirtDisplay answers the call 0 for any function and field,
takes the identity for NULL, and gives its host the nine words converted to a
double, times 2^-32, to a float, which is what ours does. No behaviour changes.
2026-11-09 14:10:45 -08:00
Anees Iqbal cd923a1108 ✅ Check that the frame time run reproduces the old back-steps
The long run's last check asked for a swap whose lead the frame clock had not
yet read exactly, which the largest-lower-bound reading rarely leaves: the
first try of a swap's reading that sees no tick after its continuous read
gives the lead exactly. The check now asks what the run is for: that the
times each swap's own last try gives, as the display gave them before, go
back somewhere in the run, while the clock's never do.
2026-11-09 14:10:33 -08:00
Anees Iqbal f041f00755 🐛 Keep arm64 frame info times from stepping back a tick
QuartzCore takes each swap's Presentation_time back into mach_absolute_time's
clock by the continuous clock's lead, which it reads with mach_get_times, and
traces it (kdebug 0x31ca002c). On Ambrosia's g147 boots of 14.6.1, 15.6.1 and
26.6.2, 2 to 5 of about 180 traced times in 3 s came 1 or 2 ticks before the
one before, each a swap shown in the same refresh as the one before it. The
display's refresh times never go back (2135d1600); the lead did. Each swap
took it from its own reading of the clocks, the continuous one between two
absolute reads, and where none of a swap's eight tries agreed it took the
last try's, short by the ticks between the reads.

The display now keeps a frame info clock (RgfxFrameInfoClock): the lead is the
largest lower bound any reading has given (continuous less the later absolute
read), exact from the first reading that agrees and never past the lead,
which only grows as the system sleeps; and a time before the one given before
is given as that one. For WindowServer: a swap's presentation time is its
refresh plus the exact lead, and never before the last one.

legacy_swap_info_test checks the readings' bounds, a sleep growing the lead,
the clamp, and a run of 100000 refreshes at 60 Hz with late VBLANKs, one to
three swaps a refresh answered at once, and 0 to 2 ticks passing at each clock
read: what QuartzCore would trace never goes back, is at most 2 ticks before
the shown refresh, and is the refresh exactly once the lead was read exactly.
2026-11-09 14:10:33 -08:00
Anees Iqbal 482ca612f4 🐛 Answer WindowServer's colour matrix on arm64 and show it
An arm64 WindowServer sets its accessibility matrix with
IOMobileFramebufferSwapSetColorMatrix (function 2) at each swap until the call
succeeds. IOMobileFramebufferLegacy's own swap_set_color_matrix answers
kIOReturnUnsupported on 14.6.1, 15.6.1, 26.6.2 and 27.0.1, so WindowServer
retried every frame and logged "IOMFB was not able to set accessibility
matrix." about 60 times a second on all four (Ambrosia's g147v readbacks:
240-314 lines a boot).

ReimsGraphics now overrides it as Apple's paravirtual display does: any
function and field are answered 0, NULL sets the identity, and the matrix's
nine s32.32 words become the device's DISPLAY_COLOR matrix stage, three rows
of four floats with a fourth 0, converted as the paravirtual display converts
them (to a double, times 2^-32, to a float), in integer arithmetic. The host
stages it for the next present and turns an identity off, as it does for the
x86-64 display pipe's matrix. For the guest: the call succeeds, WindowServer
sets its matrix once, and a colour filter's matrix shows on the display.

The layout, the class's answer and the paravirtual display's are read from
each release's IOMobileGraphicsFamily, IOMobileFramebuffer.framework and
27.0.1's AppleParavirtGPU (RgfxMobileColor.hpp). graft-arm64e.json requires
the override; legacy_overrides_test records its slot on each release (331,
334, 335, 343); mobile_color_test checks the conversion against the
paravirtual display's floating-point one over edges, rounding ties and two
million words, and the rows' order.
2026-11-09 14:10:33 -08:00
Anees Iqbal 8ab096ca74 📦 Rebuild both kext sets with the display's answer times in order
Both ReimsGraphics binaries change: the display pipe's answer times stay on
the VBLANKs' grid and never go back (RgfxVblankClock::shownAt), and the
arm64e kext reads the two clocks together for frame info. Built on the M3
Max from 238c3f3da: guest tests, prebuilt-check and the firmware's
prebuilt-check pass, and the manifest is as before (17 Legacy imports, 24
synthesized overrides, the enqueue from library 1). RgfxGate and Graft are
byte-identical in both sets; the x86 ReimsGraphics' symbols are unchanged.
2026-11-09 14:07:57 -08:00
Anees Iqbal 75ca37569a 🐛 Keep the display's answer times on its refreshes and in order
A frame info presentation time went back 6.3 ms on a macOS 14.6.1 arm64
guest, and another one tick: QuartzCore now paces by these times. A pipe's
answer taken a period or more after the last VBLANK's receipt took its own
receipt time, after the next refresh's, and the next answer, mapped to that
refresh, went back. Such an answer now takes the refresh of the last
VBLANK's grid a whole number of periods on, up to four (past that the
VBLANKs are off, and it keeps its own time), and no answer's time goes
before the last one's. The tick: the frame info read the absolute and the
continuous clock once each, so a tick between the reads moved a swap's time
off the one shown before it in the same refresh; the continuous clock is
now read between two absolute reads that agree.

For the guest: the times the display pipe completes its transactions with
(x86-64 and arm64) and the arm64 frame info's presentation times are on the
VBLANKs' grid and never go back. The x86-64 kext's binary changes.
2026-11-09 14:07:57 -08:00
Anees Iqbal 47f010c149 🐛 Fail metal-app as unread while Setup Assistant covers the session
27.0.1's guest runs Setup Assistant after its login, and its full-screen
window covers present_probe's: the probe's frames are never shown, so it
reports presented=0 with every frame dropped, which read as our device
failing to present. check-boot now reads, just before the probe, whether a
Setup Assistant process runs; a probe that then falls short fails as unread,
naming the process and its pids, with the probe's line kept beside it. A
probe that passes still passes. A covered fixture no longer looks like a
device failure.
2026-11-09 13:42:07 -08:00
Anees Iqbal f0ac11ef2f 🐛 Fail check-boot's checks on unread guest readings, slower on TCG
A TCG boot on a Linux member passed windowserver-metal with "WindowServer
none, Dock none, Finder none": every desktop poll ran out of time and
printed nothing, and the check took the empty reading for a desktop with
no "none" in it. A reading of two pids and a trailing "none" passed too.
The desktop is now up only once all three read as pids, and no poll that
answered is "unread". The same empty-reading pass hid in amfi-map (a log
query that timed out counted as no denial) and page-count (panic reports
and the kext's count lines unread read as none, and kern.boottime unread
at the login passed): each now fails as unread.

Under TCG `kmutil showloaded` was cut off at 120 s and every desktop poll
at 20 s, so each command in the guest, and the probes' own alarms and
copies, now gets 5 times its HVF limit there.
2026-11-09 13:07:58 -08:00
Anees Iqbal bf82eae464 📦 Rebuild both kext sets with the shared-queue frame info
The arm64e ReimsGraphics now enqueues each swap's frame info in the
requesting client's IOSharedDataQueue, where IOMobileFramebuffer's user
library reads it. Built on the M3 Max from be0fa471a: guest tests,
prebuilt-check and the firmware's prebuilt-check pass, the manifest
imports the enqueue from library 1, and every x86 binary and Info.plist
is byte-identical to the last set; only the x86 record of sources moves.
2026-11-09 13:00:16 -08:00
Anees Iqbal d4bfd26d07 🐛 Give check-boot's network device no option ROM
An uninstalled QEMU build has no efi-virtio.rom, and virtio-net-pci refuses to
realize without the option ROM it names by default, so check-boot.sh could not
boot a guest on such a build (Ambrosia's TCG pre-check on a Linux host). The
arm64 guest's firmware runs no option ROM, so the device names none, as
Ambrosia's own run-guest.sh does.
2026-11-09 12:56:15 -08:00
Anees Iqbal be0fa471a1 🐛 Enqueue arm64 frame info in the client's shared data queue
No frame info reached WindowServer: CA's frame_info_callback never ran
(no 0x31ca002c in a guest's ktrace on 15.6.1, 26.6.2 or 27.0.1), so every
drawable still read as dropped.

On every release from 14 to 27.0.1, IOMobileFramebufferLegacy's
finfo_support_io_shared_queue answers true, and add_notification_gated adds a
frame info request with no async reference. The async result we sent had no
reply port, and IOUserClient answers such a send with success and sends
nothing. The user client takes supported_frame_info's data-queue answer as
the flag that makes its shared data queue, and we answered 0, so no queue
existed either.

The display now takes the class's own path, as an Apple display does:
supported_frame_info answers that the records come in a data queue, which the
user client makes at the frame info port and IOMobileFramebuffer.framework
maps and reads (FrameInfoNotifyFuncIOShq). do_swap_info_notify_gated enqueues
the same record (mask, swap ID, then the values in the tags' order) through
the request's user client (request+0x10), with
IOMobileFramebufferUserClient::enqueueInIOSharedDataQueue, which every
release exports and Graft binds from IOMobileGraphicsFamily. The async send is
gone.
2026-11-09 12:55:53 -08:00
Anees Iqbal afe6d606a0 📦 Rebuild both kext sets with frame info and XR10 textures
The arm64e set carries the arm64 clock conversion, the frame info's two
tags, the swap-info notifications, the two-plane XR10 textures under an
Apple GPU's rules and the device's nil log. The x86 set's RgfxGate carries
the bundle's nil log and the creators' new argument; its ReimsGraphics and
Graft are byte-identical (job m3-max-12260: prebuilt-check, the guest's
tests and the firmware's prebuilt-check pass).
2026-11-09 12:23:11 -08:00
Anees Iqbal 341ea4269f ✨ Log each nil the device's creators answer, at the info level
A process that ends at a nil the device gave it, as 14.6.1's WindowServer
did at a texture's, left nothing in the log of what the device was asked
or why it answered nil. Each of the device's creators of buffers, textures,
tiled textures, heaps, indirect command buffers and states now logs a nil
it answers once at the info level: the creator, the cause where the device
knows it, and what was asked (a texture's descriptor in full, its
protection options among it). A creator asked the same every frame logs
once. Nothing else changes for the guest.
2026-11-09 12:23:11 -08:00
Anees Iqbal 46b930fbfe 🐛 Make arm64 guests' textures of the two-plane XR10 formats
14.6.1's WindowServer ended in SkyLight's MetalBacking::AbortWithTextureInfo:
on a display that answers extended range it flattens a window's layers into
a Private texture of RGB10A8_2P_XR10 (550), usage ShaderRead and
RenderTarget, and the device's creators answered nil for every two-plane
format under an Apple GPU's rules. The M3 Max was measured to answer nil
for a two-plane Y'CbCr format (500); Metal there makes a texture of either
XR10 format (550, 551) of its own memory, as the Vulkan platform's tests
that compare theirs with Metal's make them, and the runtime makes them, in
heaps too.

The device's and a heap's creators now make them on an arm64 guest's
device; a buffer's creator still answers nil, as the runtime makes no
texture of one over a buffer. An x86-64 build is unchanged: its rules end
the process at both formats in the validation.
2026-11-09 12:23:11 -08:00
Anees Iqbal 61f4c79b42 🐛 Give arm64 WindowServer its swaps' presentation times
An arm64 app's drawables never got a presentedTime: QuartzCore registers
for IOMobileFramebuffer's frame info only where SupportedFrameInfo answers a
list of tags, and its frame info callback is a composited frame's only
source of a presentation time. The display answered unsupported, as the
paravirtual display does, so every drawable read as dropped.

The display now answers two tags it fills from the device,
Presentation_time and Presentation_delta, as async results: a swap's
presentation time is the refresh the host showed its layer-0 surface in,
in the guest's clock, sent in mach_continuous_time's, which the library
turns into mach_absolute_time's. A swap that showed nothing sends 0. The
swap-info record's field_08 is that time, where it was the class's last
vblank time. The mask's bit 31 now splits a value in two arguments, as the
paravirtual display and the library do; it read the other way before.
2026-11-09 12:23:11 -08:00
Anees Iqbal bf8af71073 🐛 Take an arm64 guest's clock in nanoseconds for its refreshes
RgfxVblankClock maps the host's refresh stamps, in nanoseconds, into the
guest's clock, and takes the guest's mach_absolute_time as nanoseconds too,
as an x86-64 guest counts them. An arm64 guest counts its timebase's ticks
(24 MHz), so the times its VBLANK and present answers carried mixed the two
units. The kext now converts an arm64 guest's ticks to nanoseconds for the
clock and its answers back to ticks; an x86-64 build is the same code.
2026-11-09 12:23:11 -08:00
Anees Iqbal 183810e97a 🐛 Send the swap-info result through an IOUserClient subclass
IOUserClient::sendAsyncResult64WithOptions is protected, so fc05cc2a0 didn't
build for arm64e (potluck job m3-max-12174). The paravirtual display sends
its swap-info result through its user client class's
sendAsyncResult64WithOptions. RgfxAsyncResult does the same through a
subclass that is never instantiated.
2026-11-09 12:23:11 -08:00
Anees Iqbal b2e8c3560a 🐛 Send arm64 WindowServer its swaps' swap-info notifications
On arm64, every present_probe drawable came back with presentedTime 0, while
WindowServer's own swaps were shown (Ambrosia m3-max-12164: presented=0,
dropped=1185 on 27.0.1; the same on 26.6.2 and 15.6.1). Our
set_notify_tag_mask_gated, do_swap_info_notify_gated and
notify_swap_done_gated did nothing, so WindowServer was never told when a
swap was displayed.

This follows what Apple's paravirtual display does on 14.6.1, 15.6.1, 26.6.2
and 27.0.1 (read from AppleParavirtGPU and IOMobileGraphicsFamily):
- IOMobileFramebufferLegacy's swap_complete_gated calls
  notify_swap_done_gated with the completed swap's ID. The display builds a
  0x30-byte record: the swap's ID, the class's last vblank time (written by
  note_vbl_ISR), the swap's copy of its IOMFBSwapRec's field_00, and the
  swap's flags word. It hands the record to the class's
  swap_info_notify_dispatch_gated, which calls do_swap_info_notify_gated
  for each notify request the class holds.
- While a halfword in the class is not 0, the display keeps the records in
  six slots and dispatches them before the next record.
- do_swap_info_notify_gated sends the request's client an async result,
  which the client may drop, through
  IOUserClient::sendAsyncResult64WithOptions. The result carries the tag
  mask, the swap's ID, and the record values the mask selects. The second
  value is the vblank time minus the one sent last.
- set_notify_tag_mask_gated stores the mask for the swap-info notification
  only (type 3) and answers kIOReturnBadArgument for any other type. Before
  this change it answered success for every type and stored nothing.

RgfxLegacySwapLayout gains the per-release offsets.
RgfxLegacySwapInfo.hpp holds the record, the result's values and the kept
records. legacy_swap_info_test checks them against the offsets read from
each release. This is arm64e code only.
2026-11-09 12:23:11 -08:00
Anees Iqbal 9e3d5ad251 📦 Rebuild both kext sets with the copy blocks' counts
ef4fa18da's diagnostic, in both sets: the bundle counts each copy's block,
shared or its own, and the kext logs its first refusal of a shared copy block
for each reason. Built by potluck job m3-max-12223 (prebuilt-check, the
firmware's prebuilt-check, the guest tests and the arm64e manifest checks
green); Graft is unchanged in both sets.
2026-11-09 12:23:11 -08:00
Anees Iqbal 69717f399a ✨ Count copies' own blocks and log why the kext refuses one
A surface copied rather than used in place lives in one region block that
every process holding it shares, so one process's GPU writes reach another's
GPU with no copy. Where the kext refuses that block, the bundle silently
copies the surface in a block of its own, which sees other processes' GPU
writes only through the surface's pages, uploaded when its seed moves, and so
can keep a stale copy of a surface another process draws once. Nothing said
when that happened.

The bundle's "surface copies" line now counts each copy's block, shared or
its own, and the kext logs the first refusal of a shared copy block for each
reason (shape, pages, a block of another size or mode, holders, table,
region room, window map, share post) with the process. Refusals of blocks in
place are already counted by the bundle. Neither changes what the guest or
the host observes.
2026-11-09 12:23:11 -08:00
Anees Iqbal 2f500bbecf 📦 Rebuild both kext sets with the per-second swap line
The arm64e set's ReimsGraphics logs each second of its display's swaps
(891861c1e). The x86 set's binaries are byte-identical; its record of
sources changes. Built by potluck job m3-max-12206.
2026-11-09 12:23:11 -08:00
Anees Iqbal a4e8668369 ✨ Log each second of an arm64 display's swaps
present_probe's drawables all come back with presentedTime 0, and the swap
lines the kext logs (its first 16 and every 1024th) cannot say what
WindowServer swaps while the probe runs. Once a second while swaps happen,
and never while the display is idle, the kext now logs the second's swaps:
begun, completed, dropped, begun with nothing shown, with a layer-1
surface, and each distinct layer-0 surface with its count. Whether the
probe's own surface reaches a swap, and at what rate, is then in the
kernel log.
2026-11-09 12:23:11 -08:00
Anees Iqbal d7a74c95f0 ⬆️ Build on metal2vulkan 6efa9fe7b9's runtime
Pin move 30: metal2vulkan 47e072ccd3..6efa9fe7b9 (its steelbrain/pin30),
RUNTIME_VERSION 1977 -> 1980, SEMANTICS_VERSION 2005 -> 2006,
ARTIFACT_FORMAT_VERSION 497 unchanged, so cached translations are made again
once. What changes for the guest and the host:
- A pool of exportable buffers (Exports, DmaBufs) that grew gets its next
  block made ahead on the ready thread, so a creation call on our
  SURFACE_PAGES worker takes it instead of making 64 MiB while the guest
  waits (780M, fragmented: slowest creation 12-15 ms -> 0.3 ms at most).
- Where every import-tax try splits under load and the last falls short of
  its bound by its margin, the device answers Fails for its life instead of
  Unchecked.
- Host-visible Shared and Managed buffers lie in blocks of the runtime's own
  pages where the device's checks allow, and a device recovery carries those
  blocks, so such buffers are no longer refused as MadeBeforeRecovery; one
  more pooled block at rest. WorkCounts gains page_buffer_blocks_made and
  page_buffer_blocks_plain, which the work log reports as it reports every
  field.
- The translator proves sample cells apart in a row; no kernel's outcome
  changed.

Nothing here needed adapting: no degradation kind was added, and no enum we
match on changed.
2026-11-09 11:39:27 -08:00
Anees Iqbal d8e7735ac2 📦 Rebuild both kext sets with the Apple rules and 16 KiB spans
The arm64e set's RgfxGate carries the bundle that takes an Apple GPU's
texture rules on an arm64 guest's device (2a7078b2b), and both sets'
ReimsGraphics maps whole window pages (560e96b2c). The x86 set's RgfxGate,
which carries the x86-64 bundle, is byte-identical; its ReimsGraphics
differs in code, mapping the same spans. Built by potluck job m3-max-12192.
2026-11-09 11:13:59 -08:00
Anees Iqbal 560e96b2cc 🐛 Map whole 16 KiB pages of an arm64 process's surface blocks
On arm64 a window maps whole 16 KiB pages, and refused every span of a
surface's block or the scanout that was whole 4 KiB guest pages alone: a
27.0.1 WindowServer's 1920x1080 RGBA16Float plane (0xfd3000 bytes) and others
were "not mapped in: 0xe00002c2", so it never reached their blocks. Every
caller of mapSpan and unmapSpan now passes the span of whole window pages
(rgfxWindowSpanLength): a surface block's runs start past that span
(rgfxSurfaceRunsFrom), the scanout's grant is rounded to it, and a block's
write-combined split in the block's rounding leaves the block write-back
(rgfxWindowWriteBackPart). Every block is whole window pages, so the pages a
span adds are its block's own.

On x86-64 a window page is 4 KiB and every length was a 4 KiB multiple, so
each span is as before; the kext's code differs, not what it maps. The arm64
region test checks the layouts on 16 KiB pages, with the refused sizes, and
that every mapSpan and unmapSpan call passes a span.
2026-11-09 11:09:07 -08:00
Anees Iqbal 2a7078b2bd 🐛 Take an Apple GPU's texture rules on an arm64 guest's device
14.6.1's WindowServer ended at the bundle's descriptor validation: it makes a
texture of a two-plane format (550), which the x86 Macs' rules call lacking,
and the bundle chose those rules because the device answers no Apple family,
as the host lets it answer none. An arm64 Mac's GPU is always Apple's, so in
an arm64 guest the device now takes an Apple GPU's rules (the M3 Max's),
whose creators answer nil for a two-plane format. The choice is the device's
own (RgfxAppleRulesDevice), built for arm64 alone; an x86-64 build is the
same code as before. rgfxAppleGPU is the bundle's one place that chooses a
behaviour by Apple-family answers; RgfxCaps's Mac2 asks are feature answers.
2026-11-09 11:02:31 -08:00
Anees Iqbal b3dedd3c90 📦 Rebuild both kext sets with the arm64 display's start mode
Rebuilt from 7a97cd15d by potluck job m3-max-12163. Only the arm64e
ReimsGraphics binary changes (sha256 f2bd7bc93f7a...). Graft-arm64e and
RgfxGate are byte-identical, and so is every x86-64 binary. The records
change with them: both sets' sources.toml, and the arm64e set.toml's
ReimsGraphics hash. The manifest still has 24 synthesized overrides, 16
direct Legacy imports and 3 IOAVFamily imports from library 2.
prebuilt-check (both sets, with the own-symbol check), firmware
prebuilt-check and make -C guest test pass.
2026-11-09 10:35:03 -08:00
Anees Iqbal 7a97cd15d5 🐛 Start the arm64 display in its preferred mode
WindowServer never called set_digital_out_mode on any of the four releases
(Ambrosia m3-max-12149: no "N timing modes" line, current mode 16383 x 16383,
every SkyLight size 0 x 0, IOSurface creation failing with e00002c2).
QuartzCore's IOMFBDisplay::update_framebuffer_locked reads an internal
display's TimingElements and ColorElements only when there are more than one
colour mode or at least two timings (read from 14.6.1's and 27.0.1's
QuartzCore). The paravirtual display publishes three colour modes. Ours
publishes one 8-bit colour mode, which is the only format the device scans
out, and the device lists one mode. With one of each, WindowServer adds its
placeholder mode, sets no mode, and takes the display's size from
get_display_size and get_display_area. Both answer from the class's display
size fields, which held 0 x 0 until a mode was set.

So start_hardware now sets the preferred timing, the first one
publishMobileModes lists, the same way set_digital_out_mode does: SET_SCANOUT
first, then the class's size fields in its gate, then DisplayWidth,
DisplayHeight and DPTimingModeId. The class's start calls start_hardware
last, so the size is there before WindowServer opens the framebuffer. When
WindowServer does pick a mode, set_digital_out_mode still sets it.
rgfxMobileStartTimingId picks the timing, and mobile_modes_test covers it.

This is arm64e code only, so the x86-64 kexts are unchanged.
2026-11-09 10:30:40 -08:00
Anees Iqbal 5a699bbc90 📦 Rebuild both kext sets with timingFor in the arm64e kext
The arm64e ReimsGraphics, built from d4c52b77d, defines timingFor itself and
leaves none of our own symbols undefined; staging and prebuilt-check now check
that (b4715e940). Graft, RgfxGate and every binary of the x86-64 set are
byte-identical: the x86-64 build compiles the same text, and its sources.toml
records the changed sources alone. Built by potluck job m3-max-12139, which
also ran the x86 set's set-check on four Boot KCs, both prebuilt-checks, the
option ROM's and make -C guest test.
2026-11-09 10:07:41 -08:00
Anees Iqbal 021d71856e 🐛 Build timingFor for the arm64e front end too
publishMobileModes (92f36d24d) gives each timing element the reduced blanking
timingFor computes, but timingFor sat in ReimsGraphics.cpp's x86-64 block, so
the arm64e ReimsGraphics left it undefined and no arm64 guest booted
(Ambrosia 12132: "boot failed: NoSymbol(__ZN13ReimsGraphics9timingFor...)" on
14.6.1, 15.6.1, 26.6.2 and 27.0.1).

The x86-64 block now ends before timingFor and starts again after it, each
directive on a line that was blank, so every line keeps its number and the
x86-64 build compiles the same text. Of the arm64e kext's undefined symbols,
timingFor was the only one of ours; prebuilt.py's check (b4715e940) fails
any set that leaves one.
2026-11-09 10:07:41 -08:00
Anees Iqbal f122d7a14b ✅ Fail a kext set that leaves one of our own symbols undefined
24b9b4ca2's arm64e ReimsGraphics called ReimsGraphics::timingFor, which is
compiled for x86-64 alone. A kext links with its undefined symbols left to the
boot linker, so the set built, staged and passed prebuilt-check, and Ambrosia
then stopped every arm64 guest before the kernel: "boot failed:
NoSymbol(__ZN13ReimsGraphics9timingForERK8RgfxModePNS_6TimingE)".

Staging a set and prebuilt-check now read each kext's symbol table and fail
where a kext leaves a symbol of ours undefined (a name with ReimsGraphics,
Rgfx, rgfx, RGFX, Graft or graft in it) that no kext before it in the set
defines: RgfxGate's imports of Graft's client API stay allowed, since Graft
comes first. The reader is Python alone, so prebuilt-check still runs on any
host. On 24b9b4ca2's sets it names that one symbol, in the arm64e
ReimsGraphics; ae4f88215's sets have none.

prebuilt.py is one of the sets' recorded sources, so both sets are stale
until the next commit's fix rebuilds them.
2026-11-09 10:07:41 -08:00
Anees Iqbal 5c7b508fb5 📦 Rebuild both kext sets with the arm64 display's modes
The arm64e ReimsGraphics, built from 92f36d24d and 922abb96c, publishes the
display's TimingElements and ColorElements through IOAVFamily, sets the mode
WindowServer picks, and gives the class the mode's size. Graft and RgfxGate
are byte-identical, and so is every binary of the x86-64 set: its
sources.toml records the changed sources alone. Built by potluck job
m3-max-12121, which also ran prebuilt-check, the option ROM's prebuilt-check,
the x86 set's set-check on four Boot KCs and make -C guest test.
2026-11-09 10:07:41 -08:00
Anees Iqbal a0a39407e1 🐛 Give the arm64 class its display's size when a mode is set
IOMobileFramebufferLegacy keeps the display's width and height in two words
of its own (0x16b0 on 14.6.1, 0x17c8 on 15.6.1, 0x1900 on 26.6.2, 0x1bf0 on
27.0.1). Its get_display_size, display_width and display_height answer them,
and its swap_submit and default framebuffer surface read them, but the class
never writes them: Apple's paravirtual display writes both in its
set_digital_out_mode, in its gate. ReimsGraphics left them 0, so
GetDisplaySize answered a 0 x 0 display to every process.

set_digital_out_mode now writes the mode's size there, in the class's work
loop's gate, once the device shows the mode. The offsets join each release's
row in RgfxLegacySwapLayout.hpp, and legacy_swap_queue_test checks them
against the releases' get_display_size and that the write touches its two
words alone.
2026-11-09 10:07:41 -08:00
Anees Iqbal 83ac9340dd 🐛 Publish the arm64 display's modes and set the one picked
An arm64 WindowServer found the display but no mode: "current mode (16383 x
16383)", preferred 0 x 0, a mode list of one 0 x 0 scaler mode, and every
swap without a surface (Ambrosia 12100, 14.6.1 to 27.0.1). It reads a
display's modes from the framebuffer's TimingElements and ColorElements,
which Apple's paravirtual display publishes and ReimsGraphics did not, and
sets one with SetDigitalOutMode, which the class answers kIOReturnUnsupported.

The display now publishes them as the paravirtual display does, as
IOAVFamily's own elements (withData and withCapabilities, IDs and Scores at
the elements' offsets, a timing's colour modes by setColorElements): a timing
for each mode the device lists, with the x86 framebuffer's reduced blanking at
the device's rate, the preferred one first and scored highest, and one 8-bit
colour mode, ID 100. IOAVFamily joins graft-arm64e.json as a third library,
anchored on IOAVVideoTimingElement; IOMobileGraphicsFamily depends on it on
every release, so it is loaded at the bind. set_digital_out_mode takes the
colour ID, then the timing ID, as WindowServer passes them and the
paravirtual display reads them; it shows the mode by SET_SCANOUT, as x86's
setDisplayMode does, and publishes DisplayWidth, DisplayHeight and
DPTimingModeId. Any other pair keeps the class's kIOReturnUnsupported.

The framebuffer also publishes IOMFBScalingLimits, at 1 each way rather than
the paravirtual display's 4: the device shows layer 0's whole surface and
scales no layer by its rectangles. CursorPlane stays unpublished while no
swap's cursor layer is shown. GetBlock 0x40 stays the class's: no paravirtual
release overrides get_block, and WindowServer then sets a published mode.

mobile_modes_test checks the element layouts against each release's
IOAVFamily (14.6.1, 15.6.1, 26.6.2, 27.0.1), the timings' values, order and
scores, and the IDs set_digital_out_mode takes; legacy_overrides_test adds
set_digital_out_mode's slot on each release. x86-64 code is unchanged: all
of it is under __arm64e__ or in the arm64e declaration.
2026-11-09 10:07:41 -08:00
Anees Iqbal 6e74c2c75b 📝 Say which Ambrosia our arm64 bundle needs for its display node [ci skip]
Our Config.cpio now names Graphics > DisplayNode, which Ambrosia 8f2655b and
later turn into /arm-io/reims-display0 before the kernel starts. An older
Ambrosia ignores the key, as it ignores every key it does not know, and the
guest boots as before: ReimsGraphics attaches its node too late for
WindowServer's count, so WindowServer stays headless.
2026-11-09 10:07:41 -08:00
Anees Iqbal e5e4f877b0 ⬆️ Build on metal2vulkan 47e072ccd3's runtime
Pin move 29: metal2vulkan 97fd8d0fe8..47e072ccd3 (its steelbrain/pin29),
RUNTIME_VERSION 1973 -> 1977, SEMANTICS_VERSION 2003 -> 2005,
ARTIFACT_FORMAT_VERSION 497 unchanged, so cached translations are made again
once. What changes for the guest and the host:
- A device recovery carries no-copy buffers, made again over the same pages,
  and the uses of guest RAM to the new VkDevice, and a second recovery
  carries them on. The import gate, the guest-RAM resolver and the dma-buf
  source are asked again on the recovering thread before the new device
  serves. Pooled Shared/Managed buffers, caller VkBuffers and exported
  memory are still refused after a recovery (MadeBeforeRecovery).
- Metal 4.1 block reads of textures read their texels, as the M3 measures
  them, where they were refused; a cube's clamp-to-edge read is refused.
- An explicit imageblock cell holds the widest access through its pointer,
  so a half2 store into a half member runs where it was refused.
- On the RX 550, a depth at custom sample positions is cleared ahead of its
  pass, since RADV there clears at the standard positions.
- On MoltenVK, a draw that samples a colour its pass clears, after a barrier
  at the pass's start, reads a copy cleared before the pass.
- Texture makings read the kept pools in place and a tiled heap texture's
  copy units without collecting them, which ends pin 28's two allocation
  regressions.

Nothing here needed adapting: no degradation kind was added, and no enum we
match on changed.
2026-11-09 09:57:09 -08:00
Anees Iqbal ae4f882154 📦 Rebuild both kext sets with get_dot_pitch and Graft 1.3.3
Rebuilds guest/prebuilt and guest/prebuilt-arm64e from this branch's sources
(potluck job m3-max-12094 on d6f0a6f0a): Graft 1.3.3, the arm64e
ReimsGraphics' get_dot_pitch override and display node reuse, and the swap
dequeue, on development 46cb7f4da.

The x86-64 ReimsGraphics differs from development's by two runs of three
instructions in another order and the display name's symbol
(kRgfxDisplayName, from the shared display identity); RgfxGate by the Metal
bundle it carries; Graft is 1.3.3's, which differs from 1.3.2's only in its
version and LC_UUID. The four Boot KCs' set-check, prebuilt-check, the
firmware's prebuilt-check and the guest tests pass.
2026-11-09 09:41:26 -08:00