Two builds of one tree gave two arm64e RgfxGate binaries, alternating
(three clean builds on the M3 Max: A, B, A). They differed only in the
Metal bundle's arm64e image inside RgfxGate: its UUID, its signature and
__objc_stubs. ld (ld-27106.1) makes two slots for objc_msgSend in the
authenticated GOT, one for the message-send stubs and one for
objc_msgSend's own call stub, and gives each stub its slot in either order
from one link to the next. The arm64 image, whose GOT is not
authenticated, was the same every time.
The arm64e bundle now links its message-send stubs in their small form,
which branch to objc_msgSend's call stub and take no GOT slot of their
own, so the one slot leaves nothing to order. docs/lessons.md records the
trap.
OpenCore's linker binds an unresolved weak import to 0, and the kext's
direct call to IOMemoryDescriptor::getPageCounts's three-count form is
relative to the instruction, so it cannot reach 0: on the Boot KCs of
11.7.11, 13.7.8 and 15.8.2 the linker reported "RIP-relative overflow ...
target=0x0" and left ReimsGraphics out of the kernel collection, which
would boot those guests with no display driver (make -C guest set-check
with OpenCore's TestKextInject; 26.7.2's links, the symbol resolved).
The function is now reached only through a volatile function pointer in
data, whose whole address the linker binds, 0 or gOSKextUnresolved where
it is absent, and the code reads that word, never the symbol.
make -C guest set-check now passes a weak import the linker bound to 0,
where the kext was injected, and names it; any other import bound to 0
fails as before. docs/lessons.md records the trap.
A's fresh test read a surface fresh with its lock seed 0 and none of its
pages resident. A page a writer that takes no lock dirtied (seed 0 still,
as VTDecoderXPCService writes), then compressed or paged out by the guest,
is not resident but holds its bytes: the surface read fresh, its block was
deferred, and the host's cache of zeros took the place of those bytes.
Fresh now means no page has bytes anywhere: the seed 0, under the
read-only lock, and none of the surface's pages resident, compressed or
paged out (rgfxSurfaceHoldsOnlyResident, one verdict the carry calls too,
over rgfxSurfaceLocksPageCounts, which takes no lock). The count of the
compressed and paged-out pages is IOMemoryDescriptor::getPageCounts's
three-count form, referenced weakly: the release kernels of 26.6.1 and
26.7.2 export it in com.apple.kpi.iokit, those of 11.7.10 to 15.8.2 do
not, nor any routine of any KPI set that tells a page compressed or paged
out (each kernel's symbol sets). Where it is unresolved no surface is
counted, so no block is deferred and every block's pages are named at its
ask, as before deferral. Only a buffer the kernel allocated
(IOBufferMemoryDescriptor, anonymous memory) is counted: a descriptor over
a client's own memory may be a file's, whose pages not resident hold the
file's bytes, which no count shows.
What the guest sees: on 26.x kernels, a surface with a compressed or
paged-out page has its pages named at its ask instead of being deferred;
on 11.x to 15.x kernels no block is deferred. The host side is unchanged.
Safari's WebKit tiles, which the GPU alone draws, each wired 7 MiB of an
8 GiB guest at its first use on the Iris and the 780M. About 400 tiles of a
long page took WebContent's footprint past its 2 GB limit, since wired pages
count in their owner's footprint though WebKit marked the tiles volatile,
and the corpse and the memory pressure that followed stalled its frames for
100 to 800 ms (jobs m3-max-10419, m3-max-10438, m3-max-10517).
Where the host offers SURFACE_DEFERRED_ASK the kext takes it beside
SURFACE_CACHE_REFUSED and defers a fresh cacheable surface as on a GPU of
its own memory, its SURFACE_PAGES carrying ASK_CACHE and the surface's
layout. Refused, past the budget, or not fresh, it names the pages asking as
before: answered a cache, it posts them again cached; answered in place, the
device cache's entry the deferral made goes (rgfxSurfaceLocksUngate) and the
block is not cached. A deferred block's pages are wired, named and copied
only at a CPU lock that needs them, as on such a GPU.
These surfaces cannot lie in place on that host whatever their pages, so a
deferral chooses no copy over in place; it only stops eagerly wiring and
zero-filling guest pages the CPU never touches. guest/prebuilt is built
again from these sources.
On a GPU that shares the CPU's memory the host keeps a device cache only of
the surfaces whose pages its textures cannot use in place
(SURFACE_CACHE_REFUSED), and it offered no deferral there. So a fresh surface
that needs one had its pages wired and zero-filled by the kext at its first
texture, and copied into the cache once, though the CPU never touched them.
The host now offers SURFACE_DEFERRED_ASK (FEATURES_LO bit 30) beside it,
with the budget a host of a GPU of its own memory gives (DEFERRED_BUDGET, a
quarter of the device-local heap's budget). A deferral then asks with the
surface's layout (DEFERRED with ASK_CACHE and no runs), and the host defers
the block only where the surface would need a cache whatever its pages
(GpuDevice::fresh_surface_never_in_place). Every other is refused with
nothing made and counted, as is one past the budget, so the kext names its
pages asking, as without the feature: a full budget fails safe to today's
wire and ASK_CACHE path.
This is inside the rule that surfaces are used in place, cost and all, only
because these surfaces genuinely cannot be placed in place: their layout
needs a device cache either way (on the Iris, rows ending inside the GPU's
64-byte lines; on the 780M, runs exceeding one udmabuf). So it does not
choose a copy over in place; it only stops eagerly wiring and zero-filling
guest pages the CPU never touches.
What the guest reads changes on a unified-memory host: FEATURES_LO gains
bit 30 and DEFERRED_BUDGET is no longer 0, and the test that held both
changes with them. The wire header's new bit moves the option ROM's and the
guest set's records of their sources; their bytes stay.
The arm64e set, guest/prebuilt-arm64e, joins guest/prebuilt among the committed
outputs, with what writes it (make -C guest prebuilt-arm64e) and what checks it
(prebuilt-check, which cargo xtask check runs), and the guest/ row of the checks
asks for both sets. design.md records why the arm64e kext has its own Graft
declaration and Info.plist, and the owner's call on the arm64 display: an
IOMobileFramebufferLegacy subclass, since an arm64 WindowServer drives no
IOFramebuffer. qemu.md's arm64 boot check names the set's kexts for Ambrosia's
config bundle and what a pass still needs.
An 8 GiB x86-64 macOS 26.7.2 guest on the Radeon 780M host has no 2 MiB
superpage left a minute after its boot, yet every pages slab still asked the
kernel for one first. Each refusal cost the asking thread the kernel's search
for a contiguous 2 MiB: 140 to 190 ms in cpm_allocate, sampled with spindump,
in the first slabs of every process, which then took plain pages anyway. A
video decoder session's first access unit waited that long (the AVPlayer
probe's start hold there was 283 ms, against 133 to 150 ms on a native Mac),
and so did Safari's GPU process's layer drawing as a page opened.
The kext now keeps one record for all the guest's processes: 'RGFX' selector
12, Superpages, kext feature bit 1 << 8 (RgfxSuperpageRecord.hpp). A superpage
the kernel refuses for want of contiguous RAM closes it, a slab of superpages
given back to the kernel opens it, and while it is closed a pages slab takes
plain pages without asking, as a refused take did. A refused slab of several
superpages, or a refusal past the wire budget, leaves it as it was.
What the guest observes: the same slabs as before, without the search. The
host sees the same pages blocks, a superpage's one run or plain pages' many.
Where the kext lacks the bit, the bundle never calls the selector and asks the
kernel at every take, as before; where the call fails, the take asks too. A
bundle that knows no record leaves a kext's record untouched. The host plays
no part. test_pages_source_superpage_record holds the record's closing, the
takes it spares in another process and its reopening on a superpage slab
given back; user_client_words_test holds the selector, the bit and the
kext's record.
The boot harness's 60/s wheel ran on the clock the refresh grid ticks on, so a
scroll run's clicks kept one offset into the refresh for the whole run. Runs
whose clicks fell at a frame's edge composited at 30 Hz for seconds with every
present on time, and read as a device stall that came and went. A boot that
set the offset (0.3 and 15.2 ms against 9 ms) showed the offset alone decides
it.
The documented VA-API check, `cargo nextest run -p reims-vgpu-video
--run-ignored only -E 'test(/^vaapi::/)'`, failed from a clean checkout:
the target probe's ignored test, in that set, needs RVG_VA_STREAMS, the
streams the conformance scripts write with x264, x265 and ffmpeg.
The probe becomes a tool rather than a test, since the target check's own
tests are the check. The probe prints how many pictures of each way came
out as the driver's own surfaces', and asserts only that it decoded
something; the target check's tests check every byte of their targets'
memory after each picture, and run in the set with no streams. Taking the
streams where the scripts leave them would still fail from a clean
checkout, and running the probe inside the scripts would add its decodes,
about 150 s on a 780M, with no verdict, to every conformance run.
The tool is an ignored test at the crate's root (`probes::`), outside the
`vaapi::` and `nvidia::` sets the hardware hosts' checks run, as the
fuzzers' long runs and reims-vgpu's RVG_VA_STREAMS tests sit outside them.
It is not an example: an example reaches only the public API, and the
probe's import hook (`surface::MAKE_SURFACE`), which has every surface a
decoder's pool makes imported over the probe's memory, exists only in a
test build. Its code and unsafe blocks stay in the `va` module. Without
RVG_VA_STREAMS it still fails, naming it. Nothing it compares changed.
Adds U28 to the video bugs: radeonsi's decodes write an imported surface only
within the bytes its declared planes span from the luma plane's first byte, and
what the targets do about it.
Graft 1.0.0 published ReimsGraphics' personalities after binding it. 1.1.0
keeps them in the kext, each gated by an IOPropertyMatch on the device nub
that Graft sets once it has bound the kext, then re-registers the nub. The
gate is passive, so IOKit constructs none of our classes, whose parent
constructors run through Graft's sites, until those sites are written; an
IOResourceMatch would hold back only start(), and a gate probe deriving
from IOAccelerator panicked on 11.7.11 and boot-looped on 26.7.2 that way.
The passive gate booted clean on both, with its forced refusal holding.
Vendored by Graft's tools/vendor.py from v1.1.0 (1b17bb7c5ec3) with its
record.
A scroll A/B of two metal2vulkan pins on the 780M showed vkQueueSubmit
stalls of 8 ms or more falling from 22 to 1, which read as the new pin's
gain. The same arms in the reverse order gave 20 and 1: the boot that ran
first, right after a build or a perf run on the host, stalled, and the
second did not, whichever pin it ran. The lesson says how to spot it and
how to run an A/B that the order cannot decide.
The cut of the VA arm's H.264 answer to 65,535 macroblocks kept the driver's
largest width and lowered the height. radeonsi answers 4096x4096, which came
out as 4096x4080, but iHD answers 8192x8192 in VAConfigAttribMaxPictureWidth
and Height, which came out as 8192x2032: the guest's video driver would then
refuse 3840x2160 and every H.264 stream taller than 2032 at its create, and
VideoToolbox would decode 4K H.264 in software on Intel hosts.
iHD decodes nothing wider than 4096: its surfaces' bound is 4096x4096, and
ffmpeg's VA-API decode refuses every size from 4112x2160 to 8192x1024 on an
Iris Xe (iHD 26.3.5). So where the driver's largest size holds more than the
bound, the answer is at most 4096 wide and as tall as the bound leaves there:
4096x4080 on both drivers, holding 3840x2160 and 4096x2160. The test now
feeds iHD's answer too, and the sizes users play.
For the guest: on an iHD host H.264's largest size is 4096x4080, where it was
8192x2032 since the bound came in.
A boot of the guest on a Radeon 780M decoded the item's 30 H.264 streams, on
the hardware decoder alone and as a player takes them, beside the MacBook Pro
16 2019's answers: interlaced streams, 4:2:2, 4:4:4, monochrome, lossless and
8192x4320 fail their session's create in the guest as on the Mac's 5300M, and
a 4096x4096 stream now fails it too, at the driver's size check, and decodes
right in software. High 10, FMO, data partitions and SP slices reach the host
only with a picture, and give the 5300M's frames.
T3 says what interlaced streams do now, D25 what is left of it, and devices.md
and design.md where an H.264 decode is checked.
iHD and radeonsi answer 4096x4096 as their largest H.264 decode, yet give
every frame of a 4096x4096 stream back with its luma all zeros, every call
succeeding: ffmpeg's VA-API decode as ours, on an Iris Xe, an RX 7900 XTX
and a Radeon 780M. 4096x4080, 4080x4096 and 15 other sizes decode right.
4096x4096 is the one size within the drivers' bound of 65,536 macroblocks.
So the VA decoder refuses a picture of more than 65,535 macroblocks at its
SPS, and the graphics device answers H.264's largest size under the bound,
4096x4096 as 4096x4080: the guest's video driver then refuses such a stream
at its create, and VideoToolbox decodes it in software, where before every
frame reached the guest black. Recorded as bugs.md U28.
The codec module refused every SPS of profile_idc 88, at the first picture,
which through the graphics device reaches the guest as undecoded frames:
AppleGVA's H.264 decoder hears of no failure. Apple's AVC decoder on an x86-64
Mac decodes such a stream in hardware (measured on a Radeon Pro 5300M's
AppleGVA flow and an Intel UHD 630's, macOS 26.7.1: JM 19's Extended stream of
CAVLC B slices decoded as JM's reconstruction). Its pictures are Main's where
they use none of Extended's own tools, so the SPS is taken, the VA-API arm
asks for VA's Main profile, else High, and data partitioning and SP and SI
slices stay refused at the slices that use them.
For the guest: an Extended stream now decodes on the host where it reached the
client as undecoded frames.
At each Mission Control open WindowServer captures a window list for Dock
into a new IOSurface. It composites the capture with
commitAndWaitUntilSubmitted, and Dock's main thread waits for the capture.
The surface's first use fills its device cache from its pages. The host
held that buffer's CB_SUBMITTED until its scheduling: after the fill's
encode and commit, and after the walk. On the 780M host the guest waited
about 4 ms per open in that call, of Dock's 14 ms wait for the capture
(guest sample of WindowServer and Dock, 3 opens).
What the guest sees now: a buffer that asks for CB_SUBMITTED, waits for no
event and follows no deferred copy of a device cache gets its CB_SUBMITTED
as the host takes it, before the fills its begin makes at once. It used to
get it at its scheduling. It also gets CB_SCHEDULED there, where no buffer
begun before it on its queue owes its own. The ring keeps its order:
CB_SUBMITTED is still the buffer's first record, ahead of CB_SCHEDULED and
CB_COMPLETE, and a queue's CB_SCHEDULED records keep the queue's order. A
fill made at once no longer holds the buffer's queue, so the buffers behind
it are answered at their takes too.
A buffer whose fill must wait for buffers begun before it, or that follows
a copy asked and not yet made, still holds its queue and keeps its records
at its scheduling, as a buffer that waits for an event does: its copy waits
for those buffers, and they may wait for the guest.
Why nothing reorders:
- the buffer's ticket in the commit order is issued before the post, as at
any take;
- a fill made at once waits on the GPU for nothing the guest has yet to
send, since no buffer begun and not finished uses the cache;
- from the answer until the fills are made, the caches hold the buffer's
blocks. Another begin that names one of them waits, so it cannot count a
use that would turn a fill decided at once into a deferred one.
The doorbell still answers no buffer that needs a fill. It cannot know the
fill will be made at once, because another queue's begin before the take
may count a use of the cache.
Tests: a_buffer_behind_a_fill_is_submitted_at_its_scheduling becomes
a_buffer_whose_begin_fills_a_cache_is_submitted_before_the_fill: the
CB_SUBMITTED is posted before the fill's copy and the buffer's commit.
a_buffer_behind_a_deferred_fill_is_submitted_at_its_scheduling keeps the
old order for a deferred fill.
a_begin_waits_while_another_answered_before_its_fills_makes_them covers the
hold on the blocks.
Measured on the 780M host (um790), two boots of each, with guest samples of
WindowServer and Dock over 3 opens. Before is development d2a27d46a.
- WindowServer's capture spent 12 and 7 samples in
commitAndWaitUntilSubmitted before the change, and 0 and 1 after.
- Its handling of the capture took 20 and 11 samples before, 10 and 9
after.
- Dock's wait for the capture was 52 and 23 samples before, 34 and 30
after. It varies with WindowServer's main thread.
- The first Mission Control frame lands no earlier: a median of +122 and
+125 ms after the key before, +129 and +131 ms after. The fill was not on
that frame's path.
- In the boot pair whose guests were in the same state, frames lost per
open were 2.4 before and 2.6 after.
Two traps the macOS 11 WebGL work found: a guest framework that looks for the
GPU by what a Mac's GPU states and gives up without a word, and a system
LLVM whose exported C API differs by release, which the build Mac's tests
never meet.
On macOS 11, Safari's WebGL runs on WebKit's ANGLE over OpenGL, and ANGLE
refused to start on our device ("Unable to query ANGLE's SystemInfo."), so
Safari 14.1.3 made no WebGL context. ANGLE lists the Mac's GPUs by their PCI
devices' class-code, which reads 0x038000 for ours, a display controller of
class "other"; both GPUs of an Intel Mac state 0x030000 (measured, macOS
26.7.1).
The accelerator now sets class-code to 0x030000 on its PCI device's registry
entry when it starts. Configuration space keeps the device's own class, so
the firmware and the PCI family's matching see what they saw. On a macOS
11.7.11 guest, ANGLE then starts, in a plain process, without WindowServer
and inside the web content sandbox, and Safari makes its WebGL context.
AppleGVA's decode flow takes every query of a decode for its completion
and reads no status or error from it (read from its code on macOS
26.7.1); the one failure it reports to VideoToolbox is a failed
schedule. The driver answered a query of a decode the host was still
running as running and never looked at its token again, so a host
failure that came after the query was lost: the guest got the untouched
surface as a decoded frame and no error. Only a failure the host had
already reported at the query failed the session's next schedule, two
pictures late.
Now the schedule of an HEVC picture waits for the host's verdict on it,
out of the lock that orders the sessions' pictures, and fails where the
host failed it. What changes for the guest: an HEVC decode's
ScheduleCommands returns once the host has decoded the picture, and a
picture the host fails gets kVTVideoDecoderMalfunctionErr itself, from
that frame on, instead of two frames later or never. H.264 is unchanged:
AppleGVA's H.264 pipelines keep no decode's result, so its schedule waits
for no verdict (docs/video/bugs.md D25, now H.264's alone).
The tests that held the deferred failure (failsLaterSchedule,
queryReport) change with it, and checkHostVerdict drives the schedule
through a host that fails one picture.
The exit lesson's VA shapes now carry the runs that followed the fix on the
Iris Xe: 60 full-workspace runs under glibc's malloc checks with no failure at
exit, against 2 in 100 before it, and a program of its own whose vaTerminate
after iHD's destructors ends cleanly in 400 runs, so the abort needs live
decode state in the display.
The install and boot checks of the prealloc change through reims-ctl: QEMU's
first vCPU 0.53 s after its start on um870, reims-ctl start returning in 0.8 s
there and in 8.9 s on ms01, both at the desktop with the guest's RAM in 2 MiB
pages; and what a host without the memory now shows.
On a Linux host, reims-ctl's q35 VMs now have QEMU allocate the guest's
memfd RAM whole at start (prealloc=on), with as many threads as the VM has
vCPUs (prealloc-threads).
Without it, the guest's first touch of each page faulted on a vCPU, and
KVM resolved the fault through get_user_pages under the process's mmap
lock. Where the host backs shmem with transparent huge pages (CachyOS's
shmem_enabled=advise, with QEMU's MADV_HUGEPAGE), the fault allocated a
2 MiB page with direct reclaim and compaction. On a fragmented host that
mostly failed and took up to 1.8 s, and any writer queued on the lock held
every other vCPU behind it. On msi-5080 playing Safari's 4K HEVC clips,
two boots without prealloc spent 15 and 22 s with vCPUs blocked on the
lock, and the clips presented 1.1 to 57 frames a second, dropping up to
1,570 frames each. Two boots with prealloc had no vCPU take the lock at
all; the clips presented 50 to 58 frames a second, dropping 0 to 4.
For the host: QEMU takes 5.3 to 6.5 s longer to reach its first vCPU on
that fragmented host (16 GiB, 8 threads), the VM holds all its RAM from
the start (17.1 GiB at the guest's first Safari page, against 10.9 GiB),
and a host without the free memory for a VM's RAM refuses the VM as QEMU
starts instead of overcommitting. For the guest: the same RAM, with no
stalls on first touch.
A process's exit runs its exit handlers and its libraries' destructors on the
exiting thread while the library's other threads go on. A device's display let
go as a test process exited made its last vaTerminate on the device's thread
beside the driver's exit-time destructors: on the Iris Xe (intel-media-driver
26.3.5) test processes aborted after "ok" in iHD's frees, "double free or
corruption (out)" and "free(): invalid pointer", in 2 of 90 runs of the
workspace's tests. A host that quits with a display open meets the same race.
Two holes let the call through. The exit gate's handler was last registered
before vaInitialize loaded the driver, so the driver's destructors ran before
it; and the VA crate's Calls made its at-once calls on the caller's thread
(where its call thread is idle, and in its paths with no thread) without a
step of the gate. The video runtime now registers the gate's handler again
after each vaInitialize (Runtime::arm_exit, the platform runtime's
exit_gate::arm), and every VA call takes a step, so the exit waits out a call
in progress before the driver's destructors run, and parks a thread that
would make the next.
For the host: a process that exits with a VA display open no longer aborts in
the driver; a thread that would call VA once the exit began parks until the
process ends. The C API's release is unchanged.
no_call_runs_beside_a_drivers_exit_time_destructors holds the pattern without
a driver: a child process with a stand-in for the driver's destructors and a
runtime gated as the host's exits while another thread makes Calls' at-once
calls; without the steps the child ends as a call reaches the stand-in after
its destructors ran.
An HEVC picture that the host refuses was sent anyway, and the refusal came
back only at the host. AppleGVA takes such a picture, and the one after it,
for decoded (D25), so VideoToolbox delivered two wrong frames before
-12911. The refused pictures were: one whose coded size was outside the
caps; one whose PPS had a tile column narrower than the host decodes; and one
whose current reference sets held more pictures than the caps'
max_references, as kvz-720p-ref15's tenth picture does.
The driver now checks each picture against its HEVC decode entry and the
entry's decode caps before it sends it (hevcTaken). It reads NumPicTotalCurr
from the first slice segment's header (h265::currentReferences): its own
short-term set or the SPS's, with prediction, and its long-term pictures.
It works out the PPS's narrowest tile column with 6.5.1's layout
(h265::narrowestTileColumn). A picture that fails the check fails its
schedule. VideoToolbox reports kVTVideoDecoderMalfunctionErr for that frame
and every one after it, where it used to deliver two wrong frames. A bound
of 0 refuses nothing, and a header the driver cannot read leaves the verdict
to the host. kvz-720p-ref15 now decodes 9 frames and then fails, as it does
on an M3's VideoToolbox. H.264 gets no such check: AppleGVA's H.264 decoder
delivers a picture whose schedule failed.
The kext set is built again with the bundle.
The host refuses an HEVC picture whose PPS has a tile column under 128 luma
samples (MIN_TILE_COLUMN_WIDTH), and nothing on the wire said so. The guest
could learn it only after it had scheduled the picture, which AppleGVA takes,
with the picture after it, for decoded.
RgfxVideoCaps gains decode (at 0x510), an RgfxVideoDecodeCaps for each entry.
Its min_tile_width is 128 for HEVC decode on both arms, and 0, no bound, for
every other entry. The kext copies the device info and the caps by their
sizes, so the kext set is built again with the header. The option ROM's
record names the header, so the record is written again too.
The HEVC decoder refused a PPS with a tile column under 256 luma samples or a
row under 64, the Main profiles' bounds (A.3.2 to A.3.4), after the guest had
scheduled the picture. kvazaar writes such streams without a warning. The
hardware decodes them: columns of 128 and 192 samples and rows of 16 and 64
matched kvazaar's MD5 SEI and reconstruction on every frame on radeonsi (a
Radeon 780M), on iHD (an Iris Xe), on NVDEC (an RTX 5080 Laptop GPU), and on an
x86-64 Mac's Apple decoders (Intel UHD 630, and AMD's driver on a Radeon Pro
5300M). A column of 64 samples, one CTB of 64, came out wrong on every frame,
with no error, on radeonsi and on the Mac's AMD driver, and right on NVDEC and
the Intel ones.
The decoder now refuses only tile columns under MIN_TILE_COLUMN_WIDTH, 128.
No driver reports the bound, so it is the same on every host. For the guest,
kvz-720p-tiles-narrow (a 192-sample column) and a stream with a row of 16
decode on every frame. A stream with columns of 64 is still refused.
hevc-check.sh decodes kvz-720p-tiles-narrow and kvz-720p-tiles-short, and
expects kvz-720p-tiles-col64 to be refused at its PPS.
The HEVC decode entries said 15 for max_references on both arms: the size of
VA's ReferenceFrames, and the DPB bound on NVDEC. Neither host decodes a
picture with more than 8 pictures in its current reference sets. VA-API's
decoder refuses it (va.h: NumPocTotalCurr "should be equal to or smaller than
8"), and radeonsi decodes one wrongly when it is sent. NVDEC's
CUVIDHEVCPICPARAMS holds 8 a set, so 8 in all is the most with which every
picture decodes there. kvz-720p-ref15 is refused from its tenth picture, with
9 current references.
The guest now reads 8 for max_references in its HEVC decode entry on both
arms. H.264's 16 stays: the hosts take a reference list of 16 frames
(ReferenceFrames[16], NVDEC's dpb[16]), which is the standard's bound.
The framebuffer names its accelerator in IOAccelTypes by the accelerator's
service-plane path, which IOAccelFindAccelerator follows, and with it OpenGL's
list of renderers in a process with no WindowServer connection. The framebuffer
starts first and names it through the PCI device's name; the accelerator then
renames the device GFX0, so the path led nowhere. IOAccelFindAccelerator failed
for our framebuffer (0xe00002bc), and on macOS 11.7.11 such a process was
offered the software renderer alone (measured: CGLQueryRendererInfo after
CGSSetDenyWindowServerConnections).
The accelerator now names itself again whenever it finds the framebuffer, where
the path there is not its own as it stands (RgfxAccelTypes.hpp, with its native
test). On 11.7.11 IOAccelFindAccelerator then answers 0 and that process is
offered the accelerated renderer too. Safari 14.1.3's WebGL on 11.7.11 still
fails to make a context, for a cause not yet found.
OpenCore now injects Graft, ReimsGraphics and RgfxGate from Darwin 20
(macOS 11) instead of Darwin 23 (macOS 14). x86-64 guests on macOS 11, 12
and 13 now get our set, so their display and Metal run on the reims-graphics
device. Before this commit OpenCore left these guests without the set.
These releases' x86-64 matrix rows now pass in full. Graft 1.0.0 binds what
each release's kernel has. The set chooses the completion words each
release's family exports. The HEVC search finds the frame description in
each release's layout. With pin 22, the library compiles 11's Core Image
metallibs.
The bound's comment in guest/tools/prebuilt.py and the design doc now say
macOS 11. The set is regenerated with it: set.toml's MinKernel, and
sources.toml's record of prebuilt.py.
The register's check walked only the public protocols the bundle's classes
adopt, so it could not see the class of member macOS 13's Maps died on: a
member of Metal's SPI counterpart (MTLLibrarySPI for MTLLibrary), which
Metal's own objects adopt and the guest's frameworks send without asking. It
now walks each protocol's SPI counterpart too, and adds the members only
older guest releases' protocols carry, which the Mac it runs on lacks
(tests/protocol_members_releases.txt: macOS 11.7.11, 12.7.6, 13.7.8 and
26.7.2 against 27.0.1).
The register lists every SPI member: the forwarders as implemented, the
constant answers as Metal's with why, and the rest by what the AMD 5300M's
and the Intel 630's objects answer (measured with respondsToSelector:, macOS
26.7.1), counted by class family: pending where both answer (305, to be
answered as Metal's), absent where neither does (54) or they differ (6),
pending where the oracle's macOS lacks the member (14). A new kind, pending,
is checked as absent. The 31 members only older releases carry are absent:
no app pass on those releases showed a framework sending one, and the 4 of
MTLDeviceSPI are answered there by the device's own IOGPU base.
tools/protocol_dump.m dumps a Metal's protocols for the releases list, and
tools/oracle/oracle_spi_members.m asks a Mac's own objects for the verdicts
and what their getters answer. docs/lessons.md says what the trap was.
Each new IOSurface of the guest's video pool cost its device cache a fill
from the guest's pages as the cache was made: 12 to 24 MB copied by runs, 1.06
to 1.70 s each on the 5080 at pin 22 (m3-max-8949). The decode that writes the
surface waited for that fill on the CPU, so a clip's start and each growth of
the pool held the decoder for a second or more, and Safari dropped frames
behind it.
A new cache is now made as zeros on the transfer queue and owes its first
fill from the pages, which the first thing that reads it makes: a named use, a
present, a command buffer of render, compute or blit work in the context that
made the block's first buffer, or a buffer over the block in another context.
A command buffer of decodes alone that writes both planes of a new two-plane
4:2:0 surface whole takes that fill as met: its picture lands over the zeros,
and from then on the cache's downloads, releases and early copies copy those
planes' rows alone, so the pages' other bytes (CoreVideo's header) stay as the
guest's CPU wrote them. A decode that answers no picture (a picture the
stream's random access skips) makes the owed fill before anything reads the
cache.
For the guest, nothing observable changes, except that a decoder's new output
whose picture fails to land, or lands short of its planes, reads zeros where
the picture did not write, where it read the pages' bytes before; no other
memory's bytes reach it. Such a decode's command buffer completes failed, which
leaves what it wrote undefined, and a new surface's pages are zeros unless its
client wrote them under a lock, which moves the count and has the decode's use
fill the cache (docs/graphics-kext/design.md).
The caches' tests now see the first fill at the first use instead of at the
make. New tests: work in the context of a new cache's buffer fills it, and so
does a buffer over it in another context; a decoder's new output takes no fill
and copies out its planes alone, header bytes kept; a failed landing into one
reads zeros and no host bytes; a skipped picture fills its new output.
A macOS 13.7.8 test base booted and answered SSH, but Safari, Preview and
Maps never opened a window, with our kexts and without them. The test
user's home carried the BSD flag restricted, which SIP guards, so the
user's containermanagerd could not make its directories and launchd
restarted it every 10 s. chown and resetUserPermissions cannot clear the
flag under SIP. The note says how to spot it (ls -lOd ~ ~/Library) and how
a copy is repaired with one SIP-off boot, the base's later boots running
with SIP on as before.
On macOS 12, Safari's web content process may call only the external
methods its sandbox lists on an IOAccelerator connection: 0-13, 15-18,
22-24, 28-31, 40, 42, 48, 256-265, 267, 268 and 512 in every Safari from
15.1 to 17.6. Its sandbox refused Features (0x10f) before the kext saw it,
and the bundle went on without the kext's features: it took 64-id chunks
where the kext granted 16, and the host refused the textures past each
chunk's first 16 ids (BadResourceId), so pages drew without their body and
text. Under Safari 15 and 16, SurfaceBlockRelease (0x10a) and
SurfaceRetire (0x10d) were refused too. macOS 11, and 13 and later, list
no numbers.
What the guest sees:
- New selector numbers, selector map 1: Features 3, PagesBlock 4,
TakeAnswers 7, SurfaceBlockRelease 8, SurfaceRetire 9, and a shared
event port's Export 10 and Import 11. 1, 5 and 6 stay reserved, 2 is
given to none, and the rest keep their numbers. No number of map 0
takes a new meaning, so a bundle or kext of map 0 is refused, not
misrouted.
- Features answers a third word, the selector map, and keeps its number
in every map. A bundle that meets another map has no Metal device.
- ResourceIds answers the chunk's size after its first id, and the bundle
takes its chunks at that size.
- Where the bundle's setup left a stubbed device (no features, the device
info unread or of another version, the context or the user client not
opened) or returned silently (the IOGPU base declined), the process has
no Metal device, with a log line that says why. A host's video caps of
another version still leave the device without video codecs, now
logged.
user_client_words_test holds the sandbox's set, checks every selector and
the kext's routing against it, and checks that every IOConnectCall*Method
in the bundle's sources names one of them. design.md's registry gives map
1 and what map 0 was. The kext set is built again.
What changes for the guest: on a host whose GPU shares the CPU's memory
(RGFX_FEATURE_SURFACE_CACHE_REFUSED), with VA-API's hardware video (the
Radeon 780M's radeonsi, the Iris Xe's iHD), the video caps now say
RGFX_VIDEO_CAPS_OUTPUT_CACHED, with no output layouts, as a host of a GPU
of its own memory says them where its video lands pictures in caches. The
guest's video driver then asks its output surfaces cached, with their
layout, as any other surface (RgfxAskUncachedScope no longer covers them),
and the device keeps a cache of those it answers RGFX_STATUS_CACHE: an
output whose textures would not lie in place in its pages, or whose view
has no room for its mappings. A picture lands in such a cache by the
runtime device's copy of the decode surface (or the CPU's, through the
session's staging, where that copy is refused), and a CPU read of a decoded
frame has the cache copied out into its pages first. An output that lies
in place stays in its pages, as before.
For the host: VaapiVideo::lands_in_device_caches is true, and the device
offers cached outputs wherever the kext makes caches (video_caps, out of
GraphicsDevice::with_platform). The caches lay the first plane on 256
bytes of their memory (the commit before), so textures over the decoded
planes lie in them rather than in the runtime's shadows.
Measured on guest boots of macOS 26.7.2, Safari playing 4K60 HEVC clips
(8-bit, then 10-bit; then two and three at once), against development
81f187735 on the same host, vm.max_map_count 1048576, before this change
was rebased onto development's df50639ea (a laid-out cache's bytes between
rows declared unobserved), which the boots did not include:
- Radeon 780M (radeonsi and RADV, Mesa 26.2.6): the runtime's shadow
texels copied in per presented frame fell from 10.2-15.6 M to 0.00-0.03 M.
18 of 85 sessions landed in caches (4K outputs whose planes exceed
udmabuf's 1024 pieces), the rest in place; 148 caches were made aligned.
Presented fps 55.8/55.5 single, 53.9/57.0 two, 52.1/51.9/54.0 three
(development 57.0/57.2, 56.0/57.5, 53.9/53.3/52.6), drops 14/14/6 at
three (13/15/5). Mappings 5.7-6.6 k both.
- Iris Xe (iHD, ANV Mesa 26.2.6), where ANV answers a cache for every
surface: all 85 sessions landed in caches, and the process's mappings
peaked at 13.3 k (311 k on development). Shadow texels 0.07-0.32 M per
frame both. Presented fps 53.3/54.0 single, 54.4/53.6 two,
54.5/55.2/55.0 three (development 57.1/56.6, 55.4/53.9, 54.0/51.8/54.0),
at most 2 drops a clip; a second pair of boots, development's first,
gave 56.5/55.4 single (development 54.1/55.7): the single clips' spread
is the boots', not the change's.
- Both: 0 pictures copied by the CPU, 0 fatal lines. A guest process
reading every decoded frame on the CPU (decode_md5 against ffmpeg's
framemd5) matched on 63 of 75 streams both ways, the same 12 failing on
development, the three 4K streams (in caches) among those matching. The
byte-exact test lands every third of 4951 pictures of the conformance
streams in a cache made as the device makes one, equal to the CPU's copy.
- RTX 5080 Laptop GPU (NVDEC): its caps and caches are as before (no cache
made aligned); the boot's playback swung as development's does there.
What changes for the guest: a block that asks whether it needs a device
cache (RGFX_SURFACE_PAGES_ASK_CACHE) is now answered RGFX_STATUS_CACHE,
with no view made, where the platform has no room for its view's
mappings (HostVm::view_room). The check comes after the cached views no
block holds have gone, where those cover the room. The kext then posts the
block cached, as for a block whose textures would not lie in place. On a
device that copies by runs it takes no view, and pictures land in its
cache through the video host's staging buffer.
Why: Intel's ANV imports a view's pages only mapped from their files, one
mapping per 4 KiB page, and every view's pages are imported. On
homelab-ms01-1 (Iris Xe, an 8 GiB macOS 26.7.2 guest at 3648 x 2038,
Safari playing two 4K HEVC clips at once, then three), the views held
about 66,000 mappings by the desktop and 273,000 to 282,000 with the
clips. With the library's limit set to a stock host's vm.max_map_count of
65,530 (job m3-max-8341, a diagnostic build), the views stayed within the
40,954 short of the headroom. Past that, views went through dma-bufs and
116 buffers of 1.7 GiB over them were copied, at a compare of their bytes
per command buffer. The clips presented 29 to 31 frames a second two at
once, and 7 to 30 three at once, against 52 to 56 at the host's limit.
On its own this reaches only blocks that ask. With the same stand-in limit
(job m3-max-8430), 3 blocks were answered a cache for want of room, and
114 buffers were still copied. The views past the line are the decoder's
4K outputs, which the bundle asks no cache for until the host lands
pictures in caches (RgfxAskUncachedScope). So this commit goes with the
video arm's change that lands VA-API pictures in device caches.
Pin move 23: metal2vulkan development 2e381ae1f0..f84816ddec,
RUNTIME_VERSION 1890 -> 1897, SEMANTICS_VERSION 1992 -> 1993.
What changes for the guest and the host:
- dma-buf imports run with the device's memory lock released, as pointer
imports do, so a 780M import no longer holds the device's other makings
(62-273 ms seen).
- A GPU pool block a queue lets go becomes the device's spare for the next
queue, and a device makes blocks only up to its peak of queues holding one.
- A texture over a copied host buffer lies in place over the copy where its
check passes, not in a shadow (the Iris's refused placements).
- A host RAM gather that would wait for a chunk import goes through the CPU.
- Host RAM copies over a listed RAM take lists of their own pages from an
opt-in source.
- In-place reads of two-plane YCbCr textures (500, 505) take Vulkan's Y'CbCr
model by default, Metal's behind YCbCrInPlacePolicy::Exact. Our device policy
takes Exact on every device, as it takes exact completion and uncompressed
heap textures, so the guest's samples stay Metal's as at pin 22: the default
reads outside the bounds our YCbCr sampling tests hold to Metal's answers.
The conversion's staging, sets and refresh are made at the first conversion.
- New counters: linear runs' checked frames, host RAM copy import waits and
their time, staged copies and chunk import time.
Not in this pin: metal2vulkan 31e642ecc2 (the RTX 5080's first fill staged
through the CPU), a65dec2e53 (the exit hook kept registered during a making)
and 0beaeca5fe (with_vk_queue hands its closure the VkDevice); they come with
pin 24.
On 11, AppleGVA's H.264 decoder keeps a picture of at most 480x320 pixels
off the hardware. A session that requires hardware then fails its create
with -12913. AppleGVA logs why only with its debug preference set, and
VTIsHardwareDecodeSupported still answers yes. 12 and later decode from
64x64. A Mac on 11 behaves the same, so the device answers nothing for it.
A check of 11's hardware H.264 has to decode a larger picture: the 320x240
stream the boots used was refused on 11 for that reason alone. Measured on
the 780M host on 11.7.11 and 12.7.6.
A process exits on one thread, which runs the exit handlers and the loaded
libraries' destructors while every other thread goes on. A thread of the
library's inside a driver then ends the process: on the RTX 5080 test processes
ended with SIGSEGV inside libnvidia-glvkspirv after their tests passed, and the
awake thread's touches segfaulted 79 times in six minutes before it got a gate
of its own. The runtime's guard covers only the runtime's own threads, and the
platform keeps its devices for the process, so dropping them is no way out.
So the awake thread's gate becomes the library's: reims_vgpu_vulkan::exit_gate.
Each job of the library's threads that may call a driver is a step of it:
every reims-vgpu entry (the C API's calls, the device's callbacks, the jobs of
lanes, compile threads and surface workers), each compile (a making), a
window's frame, a video picture landed or frame encoded, and each call of the
video crate's threads, through a new Runtime::exit_step. An exit handler,
registered at each device's adoption, as a compile pool starts, after each
making and at each power of two of a thread's steps, closes the gate and
waits for the steps in progress on other threads, 2 s at most, or 60 s while
a compile is among them, as the runtime's guard waits for its makings. A step
begun after it ran parks its thread for good, except on the exiting thread.
What the host sees: an exit (QEMU's quit, a test process's end) now waits for
the library's GPU work in progress, bounded as above, where it could end the
process with a signal; a library thread or a call of the host's that would
begin work after the exit began parks. docs/api.md says so. Nothing the guest
sees changes. Tests: a child process that exits mid-compile with a second
compile queued (the first ends, the second never runs), the gate's own exit
children, and the awake thread's exit test on the shared gate.
A device cache on a GPU that shares the CPU's memory exists because textures
over the surface's pages cannot lie in place. A 3662x2038 desktop's surface
is one of them: 14648 bytes of texels in rows 14848 apart. metal2vulkan then
made each texture over the cache a shadow, as an image at that pitch holds the
bytes between rows, and Vulkan lets layout moves and a render pass's load and
store write them. On the 780M that cost about 1 G texels/s of copies in a
Finder drag (pad boot m3-max-7495: 169 shadowed textures, drag 36 fps).
A laid-out cache's copies into the pages already take the texels alone
(d48b1fe76), and nothing else reads those bytes, so the cache's buffer now says
so. GpuDevice::new_buffer_of_length_padding_unobserved is a buffer as
newBufferWithLength:options: makes one. The Vulkan platform makes it with
metal2vulkan's BufferDescriptor::with_padding_unobserved, and the default
makes it as any other buffer. SurfaceCaches::new_cache makes a laid-out cache
so. An exportable cache, a deferred one and one with no layout are made as
before: only a GPU of its own memory exports or defers caches, and only a GPU
that shares the CPU's memory lays them out.
What changes for the guest: a texture over such a cache is an image over the
cache's memory, which may change the bytes between rows there. No copy carries
them into the pages, so what the guest's CPU reads of the surface is
unchanged. The host does fewer copies.
Measured on the 780M (cold boots of macOS 26.7.2 on um870 and um790, each
against development without this commit on the same runtime, 0 fatal): 12 or 13
textures a boot lie over laid-out caches of small padded surfaces, where each
was a shadow (unobserved_padding_aliases), all as Safari's, Finder's and
TextEdit's windows open; 5 to 12 fewer shadowed textures, and the shadows'
copies back over the session fall from 23.5-28.8M texels to 12.2-12.8M, as
those textures' writes land in the cache. Copies in and the frame rate (60)
are unchanged. The desktop's surface, 3648 wide since 7638d2ea0, is not
padded and lies in place in every run.
Tests:
- Over a buffer with the declaration, a texture lies over the buffer's memory
(unobserved_padding_aliases +1, no shadow). This holds where the device lays
its linear images' rows at multiples of an alignment past Metal's 16 bytes
(RADV's 256). Over a buffer without the declaration, the texture is a
shadow.
- A laid-out cache's buffer is made by the new call, and one with no layout by
newBufferWithLength:options:.
The answer of a present waited for the window's draw of it, and on an RTX 5080
Laptop GPU every frame of a 30-frames-a-second probe came a refresh late while
its uncapped run did not: the GPU clocks down between frames, and the
composite and the draw each took about ten times their time under load. The
lesson says how to spot the next one: measure at a capped low rate too, and
read the per-present timing lines for the step that grows as the rate falls.
A display pipe transaction completed at the first refresh after the host's
window had finished copying its surface. On an RTX 5080 Laptop GPU at 30
frames a second the copy ended 5.2 ms after the show, which itself came 6.0
ms after the 120 Hz refresh WindowServer composited at, so nearly every
present was answered at the second refresh after its take: present_probe -f
30 saw 2.67 to 2.79 refreshes from commit to presentedTime, one more than on
a 780M host.
The guest now gets each answer at the first refresh after the present is
shown (its writers finished), whether or not the window has drawn it yet, as
a Mac's display completes a flip at the vblank that latches it. A present the
window never draws (a hidden window) is answered at the first refresh too,
not the second.
What an answer frees is the surface of every present before it, never its
own, so the host still holds an answer while a window draw still running may
read the surface of a present before it: each draw now holds the answers of
the presents shown after the latest one when it began, until it finishes. The
window's frames, their pixels and their order are unchanged; only when the
guest hears of them moves. The tests that held the old timing now hold the
new one, and a new one checks that a guest drawing into a surface only once a
later answer freed it never draws into one a window draw reads, with draws
of up to four refreshes.
On VA-API every picture the reims-graphics device decoded was read back and
copied into the guest's output planes by the CPU (B93): CoreVideo lays each
plane 32 bytes into its page, and neither radeonsi's nor iHD's video
processing writes that layout, so the in-place write declined every picture.
Where the in-place write declines, the arm now exports the decode surface as
dma-bufs (vaExportSurfaceHandle, each plane a layer of its own, kept with the
surface's pool), imports each plane once into the runtime device as an image
of its DRM format modifier, and copies it with vkCmdCopyImageToBuffer into the
buffer the output plane lies in, the surface's pages or its device cache, at
the plane's offset and rows: the Vulkan platform's PlaneCopier, one a session
on a runtime queue of its own, which waits for the copy on a fence. The copy
writes the crop the CPU's copy writes and nothing past it, after the decode is
done, and the session signals the decode once the copy is done on the GPU.
Which way each host's pictures take, in order, each where those before it
refuse:
- radeonsi (Radeon 780M, Mesa 26.2.6): the in-place write declines
CoreVideo's planes (it imports planes 256 bytes apart alone); every picture
lands by the GPU's copy: radeonsi exports one object of modifier
0x200000010401b04, and RADV imports each plane.
- iHD (Iris Xe, intel-media-driver 26.3.5): the in-place write declines them
(iHD writes a plane only at its dma-buf's first byte, U26); every picture
lands by the GPU's copy: iHD exports one Y-tiled object (0x100000000000002),
and ANV imports each plane.
- A host whose driver exports a surface other than as a layer a plane, whose
runtime device lists none of the dma-buf image extensions or refuses the
modifier for the plane's format, or whose plane lies in a buffer the GPU's
writes do not reach (pages the runtime copies, a detached buffer): the CPU's
copy, as before. The session logs each reason once at that point, as `a
picture copied by the CPU: <the in-place write's refusal>; and the GPU's
copy: <its refusal>`, or `; and no GPU copy: <why>` where the device made
the session no copier.
The in-place write stays first wherever the import check passes for the
planes' layout.
For the guest nothing changes: the planes hold the same bytes, padding
included, and the decode's event and completion come as before. For the
host, the pictures land by the hardware instead of the CPU, the session's
counts say so, and each session logs its GPU copies and their GPU time at its
end.
Checked on the Radeon 780M and the Iris Xe: the conformance suites
(h264-check.sh 62 and hevc-check.sh 156 checks pass on each), the video
crate's ignored VA tests (15 on each), and a new ignored test,
a_picture_copied_by_the_gpu_is_the_cpus_copy_byte_for_byte, which lands every
picture of the suites' Annex B streams by the GPU's copy and by the CPU's into
the same CoreVideo-like layout at two pitches and compares every byte: 4849
pictures of 79 streams equal on the 780M, 4951 on the Iris (the latter going
on past the leading pictures random access skips). The workspace's Linux
tests pass on the radeonsi host (1862).
In cold boots of a macOS 26.7.2 guest playing 4K 60 fps HEVC in Safari,
against the arm before it on the same GPU: on the 780M no picture was copied
by the CPU (9979 before), 10000 by the GPU at 1.01 ms of GPU time each, and
three clips at once played at 53.2, 53.7 and 52.5 fps with 3, 2 and 0 frames
dropped (50.0, 50.3, 52.0 and 10, 11, 5 before); on the Iris none (9899
before), 10040 at 0.52 ms each, 53.8, 54.2 and 56.4 fps with 4, 3 and 0
dropped (52.3, 51.7, 53.5 and 71, 74, 1 before).
The driver searched AppleGVA's HEVC frame record for its surface's
description from +0x70 to +0xa0, and macOS 11.7.10 and 11.7.11 keep it at
+0x70, the window's first start: an 11 release whose record began one field
lower would have had every HEVC picture refused. Measured since: 4-byte
fields from +0x70 on 11.7.10 and 11.7.11, from +0x78 on 12.7.6 and from
+0x80 on 13.7.8; 8-byte fields from +0x80 on 14.8.9 and from +0x88 on 15.8.2
and 26.7.2. The description moves 8 bytes a release from 11 to 13.
The window now starts at +0x60, two 8-byte steps below 11's start, for the
11 releases before 11.7.10, which no base boots. In the frame words read on
11.7.11, 12.7.6, 13.7.8, 14.8.9, 15.8.2 and 26.7.2 (from +0x60 to +0xdc), no
start and width in the wider window but each release's own reads the
surface's width, height and pixel format, so no measured record becomes
ambiguous. The tests now cover every measured layout and the window's new
ends.
What changes for the guest: an HEVC frame record whose description starts
from +0x60 to +0x6c lands its picture instead of being refused; on every
release measured the surface found is the one it was.
WindowServer's display pipe callback asserts that a transaction's completion
has exactly the word count its IOAccelerator expects, and aborts on any
other. The kext always sent 11, the count from macOS 13 on, so WindowServer
aborted at its first completion on macOS 11 and 12. Booting the kext with
each count measured them: 8 on 11.7.11, 9 on 12.7.6, 11 on 13.7.8 and later.
The count follows what the client and the system show, never the release:
- macOS 11's WindowServer submits 0x108-byte transactions, the 0x118 layout
without its last 16 bytes (zeros on 12 and 26). Selector 8 now takes either
size, reads a short one as 0x118 with zeros past its end, and a client
whose first transaction is 0x108 bytes gets 8 words.
- A client of 0x118-byte transactions gets 11 where IOAcceleratorFamily2
exports IOAccelMemoryMap::getAssignedGPUVirtualAddressLength() const
(13.7.8 to 26.7.2's kernel collections do; 11.7.10 to 12.7.6's do not),
else 9. ReimsGraphics names the family in OSBundleLibraries and its Graft
declaration (anchored by IOAccelMemoryMap, a class every release from 11
to 26 defines there), references the symbol weakly without calling it, and
reads at start whether its binder resolved it (OSKextSymbolIsResolved, or
a null address).
What changes for the guest: on macOS 11 and 12 WindowServer's transactions
complete instead of aborting it; from macOS 13 on the completions are
unchanged.
Graft 1.0.0 is its first release. It reorganizes the repository: the built
kext moves from dist/ to built/, and the header, start glue and build rules
move under sdk/. It also binds an absent weak import to the pointer
gOSKextUnresolved holds, and verifies an imports-only provider through an
anchor class, which kextvers needs for macOS 11 and 12.
Point the guest build, the OpenCore link check, the lane gate and the
design doc at the new paths, and rebuild guest/prebuilt from them.
Bump vendor/qemu to the reims-graphics-pci change that gives the library the
map of the RAM ranges with a shared file and leaves out those without one.
On vmapple the main RAM is a shared memfd but the 1 MiB firmware and 64 KiB
config regions are not, so the device copied every IOSurface; now it maps
the main RAM in place and copies only a surface that falls in an unbacked
region, of which there are none, so every surface is used in place. A q35
guest whose RAM is all a shared memfd is unchanged.
Update docs/qemu.md and check-boot.sh to say the device maps the file-backed
ranges and copies a surface outside them, in place of the old all-or-nothing
rule.
An HEVC decode names its output surface only in AppleGVA's own frame
record, and the driver read the surface's id at the frame's +0x88, where
macOS 26 keeps it. Every release measured describes the surface with the
same fields, its id, a size, its width, its height, a pitch, 8 bytes and its
pixel format, but where they start and how wide each is differ: macOS
26.7.2's are 8 bytes each from +0x88, 14.8.9's 8 bytes each from +0x80 and
13.7.8's 4 bytes each from +0x80. On 13 and 14 every HEVC picture went to
the host with no output and was refused: VideoToolbox answered -12911 for
each, the HEIC desktop picture stayed black on 13, 14's video wallpaper
logged "VideoPlayerLayer failed to create decoded pixel buffer", and our
decode tool decoded no HEVC frame (its H.264 frames, whose output comes on
the command, matched).
The driver now searches for the layout instead of listing the releases':
every start from +0x70 to +0xa0 in steps of 4, with fields of 4 or 8
bytes, where the id names a live surface whose width, height and pixel
format the description itself gives. The first picture of a session whose
frame describes its surface in exactly one layout shows the session's
layout, which the session keeps, so the search runs once a session. A
picture whose frame describes no surface, one in more than one layout, or
none in its session's layout, is refused before it reaches the host,
logging which.
What changes for the guest: on macOS 13 and 14 HEVC decodes, HEIC images
and the desktop picture and video wallpaper among them, land in their
surfaces instead of failing; on 26 the surface is the one it was.
A create that keeps the Mac of the image beside an existing disk would give a
copy of the disk of a VM reims-ctl has that VM's Mac: its serial number, MLB,
UUID and ROM, and its network card's address. The copy can run beside the VM,
and Apple's services know a Mac by those, so two VMs running as one Mac would
be one Mac to them. reims-ctl's network is QEMU's user mode alone, so the two
cards' one address clashes nowhere.
The create now gives such a copy a Mac of its own, as before, and says why;
its macOS opens Setup Assistant once, as on a new Mac. A disk given in place
keeps its Mac: the VM runs that VM's own macOS, and never beside it, since a
start on a disk another VM runs on is refused. A disk from a VM reims-ctl does
not have, whose image is beside it, keeps its Mac as before.
The lesson says what remains: a stop still powers off at its timeout while
Setup Assistant is up, since nothing the host sends without the guest's
password ends it.