Commit Graph
714 Commits
Author SHA1 Message Date
Anees Iqbal c178927136 🐎 Check argument overlaps without following the entry's body
Batch 41's overlap check (1fc43b257) runs at every newFunction with constant
values whose arguments may overlap. It ran rgfxAirSpecialise, which runs the
module's initialisers and then follows the entry point's body twice, with the
values and blind. The check reads only the initialisers' globals: each
argument's predicate, index and count. The body passes were 99.5% of its cost.
For VideoToolbox's VTMTSComputeFunction, which its pixel transfers make for
every tile of a HEIC decode, a specialisation took 35.6 ms against 0.19 ms for
the initialisers alone (measured on the M3 Max, macOS 27). The guests' heic
step slowed from 6-7 ms a tile to 52-104 ms on every GPU.

rgfxAirConstantGlobals runs the initialisers alone, through the same
Specialiser and the same reading of its memory that rgfxAirSpecialise uses for
its globals. RgfxOverlappingArgumentError takes its globals from it. The
answers are unchanged, and test_overlapping_arguments_refused_as_metal still
compares each against Metal's. A new shell test counts the bodies followed over
sixteen makes each of a function that is made and one that is refused, with the
same values: none.
2026-11-13 11:19:22 -08:00
Anees Iqbal f40f2d9e92 📝 Say design.md's device is the one lane, for both guest arches [ci skip]
The Goal still called the device "a second lane beside the Apple paravirt
lane", and Decided 1 kept arm64 guests on that lane. The paravirt lane was
deleted on 2026-11-07, and since 2026-11-08 arm64 guests from macOS 14 take
the device's arm64e set on Ambrosia (Decided 13). The Goal now describes
the device as it is; Decided 1 stays as the record it is, with a dated line
saying what superseded it.
2026-11-13 11:10:26 -08:00
Anees Iqbal 1c88f72c8e 📝 Drop design.md's comparison with the apple-gfx lane [ci skip]
The surface-pages passage said the host maps a surface's guest pages "as the
apple-gfx lane maps guest memory". That lane is gone, so the comparison names
nothing a reader can look up; the map QEMU gives is the whole statement.
2026-11-13 11:10:26 -08:00
Anees Iqbal 4fea044105 🔥 Delete run_vmapple.sh and the tour that drove it
run_vmapple.sh booted a Virtualization.framework guest on vmapple with
apple-gfx and AVPBooter, all three gone: make qemu builds no aarch64 QEMU,
apple-gfx left the library and QEMU, and AVPBooter no longer boots on
vmapple's layout. vm_drive.py ran its tours through it, and vm_ocr.swift
served vm_drive.py alone. The window's walk, their last user, boots on
Ambrosia since ea18b7f17; arm64 guests boot as docs/qemu.md, "arm64
guests", says.
2026-11-13 11:10:25 -08:00
Anees Iqbal 80a97ebef9 🐛 Sync a surface copy again once a CPU write lock is let go
A copy of an IOSurface synced at a commit while another process's CPU held
the surface locked for writing copied the pages half written, and kept them:
IOSurface moves the surface's seed at a read-write lock, not at its unlock,
so the seed the copy recorded was already the one the finished write leaves,
and nothing synced the copy again until the next lock.

IOSurface keeps a second seed, the unlock seed, which unlockSurface moves at
each read-write unlock (and a GPU write moves with the lock seed), so the two
differ while a CPU holds the surface locked for writing; IOSurface itself
reads them so, and the Mac's GPU families (IOAcceleratorFamily2, IOGPUFamily)
import its getter. The device cache's op 3 is no unlock: IOSurface calls it
inside the lock, after op 2, and calls nothing at the unlock (read from
IOSurface's code in macOS 26.7.1's KDK).

The kext answers a surface's two seeds (SurfaceSeeds, selector 13, kext
feature 1 << 10, set only where IOSurface exports getUnlockSeed, which the
kext references weakly). A copy synced while the two differ records the
unlock seed in its header with a mark, and each commit that uses it asks
the kext again until the unlock seed moves, then syncs once more. A copy
synced with no write lock held asks nothing, so a commit costs what it did.
A named GPU write records its seed and clears the mark, as its seed already
stood over a CPU's write held meanwhile. The surface copies report counts
the uploads made mid-write and the asks.
2026-11-13 11:10:25 -08:00
Anees Iqbal a8a54ad6fc 🐎 Keep heap colour textures compressed where Metal does
exact_policy forced HeapCompressionPolicy::Uncompressed on every device. On the
Iris Xe (ANV, the one driver whose compressed images may keep their texels
apart from their bytes) that gave a guest's Private heap render targets an
uncompressed image and cost them the driver's fast clear: a guest's clear of a
2048x2048 RGBA8Unorm render target in a Private heap took 146.9 us of GPU time
against 28.6 us now (25.8 to 28.7 us for one in memory of its own), and a copy
of it 294.1 us against 148.2. The platform now takes the runtime's default,
Compressed. REIMS_VGPU_EXACT=all still takes the uncompressed form
(exact_answers()); no other name does.

What the guest sees change, on the Iris Xe alone:
- heapTextureSizeAndAlignWithDescriptor: answers the compressed image for a
  colour texture Metal keeps losslessly compressed (allowGPUOptimizedContents,
  no ShaderWrite, PixelFormatView or ShaderAtomic usage, 16 texels or more a
  side) whose image is 64 KiB or more: its alignment moves from 0x1000 to
  0x10000, its size kept (0x1020000 bytes for that 2048x2048 render target).
  A smaller one keeps the uncompressed image a 4 KiB alignment holds, and its
  answer (0x4080 at 0x1000 for a 64x64 BGRA8Unorm texture). The x86 Macs
  answer 4096 (UHD 630) to 65536 (Radeon Pro 5300M).
- Such a texture in a Private heap is the driver's compressed image, so a
  write through a buffer or texture over its bytes may leave its texels as they
  were. Metal's compressed texture shows no such write as written either: an
  M3 Max reads opaque magenta in drawn content a buffer fill over its bytes
  covered. Heaps over the guest's pages (Shared heaps, the bundle's slabs) take
  an image over the pages under either form.

heap-texture-compressed moves from DIES to the relayed precision kinds, with
that M3 measurement as its reason: Metal's own answer there is not one value,
so a strict run no longer dies where the Iris keeps Metal's compression.
Other drivers keep the optimal image they took before under either policy.

Cold boots of macOS 26.7.2 and 14.8.9 on the Iris (desktop, Finder, Launchpad,
Mission Control, Safari, Maps) logged no fatal line, and their apps made no
such texture: only the guest microbench that measured the clears did.
2026-11-13 10:36:40 -08:00
Anees Iqbal 95843e7838 ✅ Prove a route waiting for the host's lock holds up nothing
QEMU applies a doorbell route under the BQL before route_doorbell returns,
so a ring-0 thread may wait for the BQL inside the device. That is safe
only if the device calls the route functions holding no lock of its own,
and no device function a host calls under the BQL waits for a thread
inside one. The device module's doc now names each call site and what it
holds: a QUEUE_CREATE, OBJECT_DESTROY or CONTEXT_CLOSE on the context's
lane (a ring-0 thread or the control thread) after the queues' table and
the ended rings are let go, and a reset on the resetting thread after it
let go of ring 0, the display, the completion ring, the table and the
ended rings. QEMU's registers are lockless, and its reset holds the BQL,
which its route function sees. What a host calls under its lock waits at
most for the control thread's display message, a ring's take or post, or
the table; the last device's release waits for the threads at most 5 s.

the_host_s_lock_held_around_its_calls_while_a_route_waits_for_it_holds_up_nothing
gives the test host a stand-in BQL its route functions take: while a
create's route waits for it, the thread holding it reads and writes the
registers, rings ring 0's and the queue's doorbells and resets the device,
and a watchdog ends the process if any call never returns. The route the
create took goes once the lock is let go. The C API and api.md name the
control thread among route_doorbell's threads, and design.md says which
hosts offer DOORBELL_ASKS.
2026-11-13 09:50:12 -08:00
Anees Iqbal 28250f0bed 🐎 Route plain queue doorbells to KVM where the guest asks apart
Every command queue doorbell write exited to QEMU and ran the library on
the guest's vCPU, though only a buffer that asks for its CB_SUBMITTED can
be answered there; the rest need only the queue's thread woken. Measured
on the Radeon 780M host, a doorbell QEMU takes as an ioeventfd costs the
guest 8.9 us and one run through the library 13.4 us, of a 17.1 us
commit.

The device offers DOORBELL_ASKS (feature bit 43, FEATURES_HI bit 11): a
guest that takes it writes an asking buffer's doorbell with the ring's
id and RGFX_DOORBELL_ASKS (bit 0), and every other doorbell with the id
alone. The device then answers at the doorbell only an asking write, and
gives each queue an eventfd its thread sleeps on, which it hands the host
with the ring's id (route_doorbell, a new C API callback at the end of
RvgGraphicsCallbacks, its second version). QEMU adds it as an ioeventfd
matching the id exactly, so KVM wakes the queue's thread in the kernel and
the vCPU goes back to the guest with no exit; the asking write matches no
route and reaches the library as before. A guest without the bit sees
nothing new: every doorbell is answered as before, and no queue is
routed.

The device routes at most 128 queues (KVM holds 1000 devices on its MMIO
bus, and QEMU ends the VM where KVM refuses one); a queue past them, or
one the host refuses, keeps its doorbell on the write, logged once per
kind and counted. A route goes as its queue ends, before the destroy,
close or reset is answered, and QEMU drops it under the BQL before the
callback returns, so a queue made again over the same ring gets every
write. The thread drains the eventfd and walks its ring on each wake, so
coalesced writes take every buffer in ring order.

QEMU's side is vendor/qemu d81bcaac. The guest's side, the ROM's record
and both guest sets follow.
2026-11-13 09:50:12 -08:00
Anees Iqbal 8430562098 🐎 Hold textures, views and Managed creates with the destroys
A texture's create (TEXTURE_CREATE), a view's (TEXTURE_VIEW), a Managed
texture's and buffer's (MANAGED_TEXTURE_CREATE, MANAGED_BUFFER_CREATE) and a
Managed buffer's modified range (BUFFER_DID_MODIFY_RANGE) are messages no one
waits for, each its own Submit call: on the RX 7900 XTX host 8 to 13 us each,
812 of them and 8.8 ms a Vision process. SubmitBatch now takes them too, each
of its one size, checked as Submit checks it, a create for a context closed
since its check destroyed behind it (rgfxSubmitBatchSize). None names a block,
which spans_test keeps. The bundle holds them with the destroys and the
heap-placed buffers (RgfxSerializer::postUnwaited), in their order, posted
before anything else the process posts or asks of the kext and before any
command buffer it commits. A texture over an IOSurface still goes at once, as
a present of the surface waits for it, and so do the creates that name a block.

This changes what the guest sees under transport exhaustion only (the control
ring full for 5 s, or the device stopped), as 628b03fb3 did for heap-placed
buffers: such an object made then is answered as made, held, where its refused
post answered nil. Its refusal reaches the app where Metal's caller sees a
lost GPU's: the next post retries what is held and is refused in that same
call where the held are refused again; a create that needs the held gone to
make room is refused at once; and a commit that finds anything but destroys
held fails its command buffer, unposted, with MTLCommandBufferErrorInternal.
postHeldCreates already answered so for every held type; serializer_tests'
test_held_creates checks each kind on its own, and protocol_tests'
test_commit_behind_an_untaken_buffer_fails a texture through a commit. A
create the host refuses was answered by no one before, and is not now.
2026-11-13 09:01:40 -08:00
Anees Iqbal 170976bcae 🆕 Measure where Metal refuses arguments at one location
oracle_overlap makes functions whose arguments of one argument table take
overlapping locations under function constants, by every way of making a
specialised function, and prints each answer and error. The AMD 5300M and the
Intel 630 on macOS 26.7.1 and the M3 Max on macOS 27.0.1 answer the same: Metal
refuses such values where it makes the function, with one line per argument
that overlaps an earlier present one. The guest's bundle accepted them, so the
host refused the pipeline later instead. Q33 records the answers. [ci skip]
2026-11-13 08:43:21 -08:00
Anees Iqbal f1ffa96c22 📝 Record the rebase that reset a file and dropped a landed change [ci skip]
The ring 0 trace commit landed records.rs as it stood before the warm pass's
bound, so the bound and its tests went together and every check passed; only
an Iris Xe walk showed the warm pass never ending again. The lesson says how a
merge spots the next one: a changed file whose new blob equals an older one.
2026-11-13 08:22:37 -08:00
Anees Iqbal 55137c25f4 📝 Say why macOS 11's coreaudiod dies on a sound device of both streams [ci skip]
appwalk8's 11.7.11 walk lost coreaudiod in AppleVirtIOSound's ring code,
which read as a new fault in our virtio-snd. 11.7.11's plug-in frees an
input stream's ring under its four posted receive buffers, which the device
completes at RELEASE, so on one device of both streams any sound can kill
the daemon, on QEMU from before our capture changes too. reims-ctl's two
devices start no input stream for a sound. docs/qemu.md gives the boots and
the code read, and lessons.md the trap: a failure only the harness's device
config reaches is the harness's.
2026-11-13 07:43:32 -08:00
Anees Iqbal fc80b3d67d 📝 Give make qemu's ninja build its measured times [ci skip]
The Makefile's comment said a clean build through QEMU's Makefile took about
7 minutes. Measured on um870 (16 threads): 310 s at QEMU's -j1 against 59 s
at ninja's default, the same 1951 steps and the same binary. docs/qemu.md
keeps the measurement; the comment cites it.
2026-11-13 04:02:54 -08:00
Anees Iqbal 082fa9edd7 🐎 Build make qemu's QEMU with ninja at its own parallelism
make qemu built qemu-system-x86_64 through QEMU's Makefile, which hands
ninja -j1 where make was given no -j: a clean build ran one compile at a
time, about 7 minutes on ms01 and um790 (warmbound). The qemu target now runs
ninja itself, which builds at its own default parallelism, or at a caller's
-jN, and has meson regenerate build.ninja where a meson file changed, as
install-ctl.sh's build already relies on.

QEMU's Makefile also ran configure again where vendor/qemu's configure, its
meson options script, its Python dependencies or its VERSION were newer than
config-host.mak: the target's own check of when to configure now takes that
case too, so a submodule move configures as before. The binary built is the
same target's.
2026-11-13 04:02:54 -08:00
Anees Iqbal b0b7cd4834 🐎 Look for a lifecycle answer before sleeping for it
The device answers most lifecycle messages the kext waits for within tens of
microseconds of the post (a heap texture's size, a library's lookup, a
surface's pages: 60 to 110 us on the RTX 3090 host), and the answer then waited
for the interrupt, the work loop's wake and the waiter's, about 25 us more
(measured in a Vision request). postLifecycle now looks for its answer for at
most 150 us before it sleeps (RgfxAnswerLook.hpp): where the control
completion ring holds a record the work loop has not taken, it takes the ring
in the work loop's gate, as the work loop does, and else pauses the CPU. It
never waits for the gate (an IOCommandGate's attemptAction): the event hooks its
holder runs take the release table's lock and the pipe clients', which a
waiter's caller may hold, and only the sleep's deadline bounds that wait, as
before. The rest of the work loop's service follows at the interrupt the record
raised. Only a thread whose call waits for an answer looks, and only that long.
No answer or order changes. Tested by answer_look_test.


Measured, Vision cold request, RTX 3090 host (rts4, the branch without this
commit, against the branch with it; host load 3.0 and 5.4), first process /
second: a heap texture's size and alignment, 60 calls, 36.3/36.6 -> 26.2/25.3
us a call (its answer's leg after the post 12.7 -> 2.4 us); a library lookup
78.8/87.0 -> 52.0/53.1 us; a surface block's ask (its SURFACE_PAGES), 123
asks, 232/215 -> 173/178 us, 32.0/27.5 -> 25.3/24.1 ms. A pipeline create
whose compile outlasts the look is answered as before.
2026-11-13 04:02:31 -08:00
Anees Iqbal 628b03fb37 🐎 Hold heap-placed buffers with the destroys around them
A heap's buffer at an offset (BUFFER_AT_OFFSET, each small buffer of a slab) is
a create no one waits for, and cost its own kext call: 3079 a Vision process,
12 to 15 us each, 40 to 48 ms a process on the RTX 3090 host, between the
destroys, which broke each held run of destroys into one call of about 11.
SubmitBatch now takes BUFFER_AT_OFFSET too, of its one size, checked as Submit
checks it, and a buffer made for a context that closed since its check is
destroyed behind it, as Submit does (RgfxSubmitGate's rgfxSubmitBatchSize;
spans_test checks no message the batch takes names a block). The bundle holds
each buffer with the destroys, in their order, and a command buffer's commit
posts what is held before the buffer goes on its ring, as the host reads a
command buffer after the control ring's messages posted before it.

This changes what the guest sees under transport exhaustion only (the control
ring full for 5 s, or the device stopped):
- before, the buffer's create was refused there and the buffer was nil; now
  it is answered as made, held, as Metal makes objects on a GPU that is gone;
- before, a command buffer committed on a stopped device was never answered,
  and the run hung at its wait; now a commit that finds a buffer still held
  fails the command buffer, unposted, with MTLCommandBufferErrorInternal
  ("Discarded (victim of GPU error/recovery)"), the host's own recovery error,
  as the buffer may name it;
- the next post retries what is held and is refused where it is refused
  again, and a buffer that needs the held gone to make room is refused at
  once, holding nothing more.
Tested by serializer_tests' test_held_buffers and protocol_tests'
test_commit_behind_an_untaken_buffer_fails.


Measured, Vision cold request, RTX 3090 host (rts2, the destroys held,
against rts4, this commit and the next two; load 3.4 and 3.0): destroys and
heap-placed buffers together 62.0 -> 17.6 ms in the first process (3079
buffers and 294 destroy calls become 688 SubmitBatch calls), 51.6 -> 16.1 ms
in the second.
2026-11-13 04:02:30 -08:00
Anees Iqbal 7e8ea3c46f 🐎 Post a process's destroys in one kext call
Each destroy cost the guest a trip into the kext, and a post that found the
host's control thread asleep a doorbell's exit too: 14 us a destroy in a Vision
request on the RTX 3090 host, 3415 destroys and 68 to 70 ms a process, in runs
an app lets go back to back. The kext now carries SubmitBatch (selector 5,
feature bit 1 << 1): the bundle holds each destroy (RgfxRingWriter::postLater)
and posts what it holds in one call of at most 4096 bytes, before anything
else the process posts or asks of the kext (every IOConnectCall goes through
rgfxKextConn, which posts the held first), once the held fill a call, or 1 ms
after the first held. The kext checks each as Submit checks one, all before it
posts any, puts the runs on the ring under one hold of its lock with one
doorbell at most, and ends a queue's as Submit does. A texture over an
IOSurface goes at once: a present of the surface waits for its destroy.

What an object lay over goes back as its destroy is held, as it went back once
the destroy was posted: whatever takes it again is posted after the destroy,
so the host drops the object first, and every answer the guest reads (a heap's
usedSize, a new object's GPU address and resource id) is the one it read
before (shell_tests' test_held_destroys_change_nothing_seen). Where the kext
stops taking them (control ring full 5 s, or the device stopped), the rest stay
held; the next post retries them under its own bound and is refused only where
they are refused again. The one difference, under that exhaustion only: what
the held destroys lay over has gone back, so a heap's usedSize read during a 5 s
stall of ring 0 reads lower than before (design.md, "Destroys go together").

Measured, Vision cold request, RTX 3090 host (rts1 against rts2, load 3.6 and
3.4): destroys 69.6 -> 18.6 ms in the first process, 67.7 -> 14.7 ms in the
second; all kext calls 216 -> 162 and 188 -> 135 ms.
2026-11-13 04:02:30 -08:00
Anees Iqbal f7b7f1ca5c 🐎 Ask the runtime where textures lie before a surface's import
Two asks are answered before any view of a surface's pages is made: whether a
block asking for a device cache needs one before its view (CACHE with no view),
and whether a fresh block is deferred. Both read the runtime's in-place check
report as text, and recomputed how the runtime lays texels on the device's lines
and which check form a texel width takes. They saw the check's verdicts alone,
not the device's policy, a shader's writes of a width the check stores none of,
texels past the pages, rows that share bytes, or what the device's format and
limit queries refuse.

metal2vulkan 3bca3ce246 answers there:
Device::host_pages_texture_placement(backing, descriptor, plane, start,
length), the buffer's answer wherever the steps before an import or an image
decide it, made with no buffer, import or image. Both paths now ask it of each
plane, width and usage as the answer over a buffer does, through one
composition (pages_over), for each import a view may take: by pointer and as
dma-bufs where the device imports pointers, as dma-bufs alone on RADV. They
answer a cache only where every such import's answer is a shadow a cache holds
in place. In place, pending, or a refusal of every ask (HostPagesBacking,
BufferLength) leaves the pages to the view's buffer, which takes the cache at
the making's refusal as before: an in-place answer may still be a pitch, place
or dma-buf refusal that only the image or the import decides.

The view is told it starts at 0, which lies in the device's lines as any page's
first byte does where they divide a page; elsewhere the pages are left to the
import, as before. The fresh path takes the block's length for the buffer the
answer stands for. The report parser and its tests are gone; the one-dma-buf
checks of a plane's pages stay, as the runtime cannot see our source's limits.

What the guest sees changes only in speed: a block the after-import ask would
answer CACHE is answered so before a view is made for it, or deferred, and no
GPU result or device answer changes.
2026-11-13 02:25:24 -08:00
Anees Iqbal bca8c6e7f0 🐛 Give each VM's recording a sound device of its own
A recording made while an output played got nothing. On reims-ctl's one
virtio sound device of an output and an input stream, the guest starts the
input with each output and soon stops posting receive buffers, so a
recording that joins a playing output gets none, and QEMU has nowhere to put
the host's input. AppleVirtIOSound's HAL plug-in makes one Core Audio device
of each virtio-snd device and starts all of its streams together, posting
an input's receive buffers only at its start and as each completes while
its ring has room (read from its code). On a device started for an output,
nothing reads that ring.

reims-ctl now gives every VM a playback-only device at 0x7 (streams=1) and a
capture-only one at 0x8 (streams=1,input-streams=1, vendor/qemu 1422502b),
beside the HDA controller as before.

What the guest sees: two "Apple Virtual Sound Device"s, the default output
and the default input, where one device was both. Measured on a macOS
26.7.2 guest on homelab-um790's Radeon 780M, one cold boot each way (job
m3-max-24761, docs/qemu.md "x86-64 macOS guests: audio"). With the two
devices, a 10 s recording 20 s into a 50 s play got 117 receive buffers and
the host source's live audio in each second. On the one device the same
recording got no buffer, 2 s of older samples and 8 s of zeros. An output
alone no longer starts the input, and the host's source stays suspended
through it. A QEMU built before 1422502b refuses input-streams, so this
reims-ctl needs the QEMU its installer builds (install-ctl.sh without
--skip-qemu, whose warning names a changed QEMU).
2026-11-13 02:07:25 -08:00
Anees Iqbal aabd8a97a2 📝 Rewrite the comments that named apple-gfx's objects [ci skip]
Comments named apple-gfx's core objects, gone with it: the detach heap and
buffer's temporaries, the PGResource kinds core passed as resources, and a
lesson's detach buffers and the testing.md tables and suite cases it cited.
They say now what an aliasable range serves (the gathered alias of a
surface's pages, and the tests' stand-in for guest memory), what a
ResourceRef holds (the three kinds the decoder resolves a guest's object ID
to), what the remap module's reports and holds cover without the
temporaries, and the lesson's rule with the boot that showed it.
2026-11-13 02:07:25 -08:00
Anees Iqbal 39dd1213ca 🔥 Delete heaps over address ranges, which nothing reaches
The wire, the C API and the guest's bundle never ask for a heap or buffer
over address ranges. The decoder passes no ranges to new_heap or new_buffer:
it makes device-placed heaps (HEAP_CREATE) and heaps over the guest's memory
in place (HEAP_OVER_HOST_MEMORY, HEAP_OVER_PAGES, through
new_heap_over_host_memory). The C API makes no Metal object, and the bundle
refuses a buffer descriptor that names address ranges. tests/address_ranges.rs
was their only caller.

Deleted with them: Platform's AddressRangeArray, HeapDesc's address_ranges
(HeapDesc is no longer generic), the testkit's model of ranges, Backing's
record of the guest's pages under a heap (made_over, in_pages, meets_pages,
over_guest_pages) with Kept::Copied's pages, the write tracking through a
heap's pages that read it, and the inexact-heap-layout relay of a multisample
texture Metal keeps losslessly compressed, which only such heaps reached.
gather_or_nil stays: buffers over a surface still gather its pages.

The tests that made heaps over address ranges to stand in for the guest's
pages make them over host memory now, as the decoder does
(resource::tests::heap_over and heap_at): the heap-texture, placement and
heap-layout tests, and the write test, whose heap buffer and texture now lie
in no memory a surface's write check looks for, as a heap over host memory's
did before. The test of a heap over less than its granule and the multisample
death test went with the path they tested.

What the guest and host see: nothing; no call reached what is deleted. A heap
over host memory still relays a multisample lossless texture as its notice
alone, as before, and does not die of it in strict mode (ledger).
2026-11-13 02:07:25 -08:00
Anees Iqbal f09f58266e ⬆️ Build on metal2vulkan 3bca3ce246's runtime
Pin 66 moves metal2vulkan from be1e8bb311 (RUNTIME_VERSION 2195,
SEMANTICS_VERSION 2077, ARTIFACT_FORMAT_VERSION 515) to 3bca3ce246 (2208,
SEMANTICS_VERSION 2081, ARTIFACT_FORMAT_VERSION 515). It carries:
- half values held at 16 bits, half division and sqrt at 16 bits, and
  multisample ShaderWrite images listing their views (2196, SEMANTICS 2078
  and 2080);
- matmul2d of 8-bit floats into float (2197, SEMANTICS 2079);
- a completed command buffer's last host-import frees handed to the free
  thread, so NVIDIA's frees no longer hold submits (2198);
- runtime images whose parts no copy writes, a new buffer's zeros and the
  runtime's attachment images where DontCare stays DONT_CARE starting at
  zero in one fill (2199-2201);
- a Managed buffer's modified range copied in by the GPU as the submission
  runs, with no CPU copy at the commit (2202): on the RTX 3090 Geekbench's
  compute geomean goes from 2.11x native to 1.34x;
- a surface depth or stencil texture's usage shadow copying its plane's own
  aspect, and an X32_Stencil8 view's shadow no longer copying depth bytes
  into the stencil (2203);
- the draw merge passes holding their counts in u32 words, which ends the
  RTX 3090's Xid 109 hang in Apple's Modern Rendering sample (2204);
- a large kernel's whole grids run on its partial-threadgroups variant,
  one pipeline per threadgroup size (2205, SEMANTICS 2081);
- a device recovery carrying indirect command buffers, visible function
  tables and argument encoders, and freeing the lost device's live
  buffers once it comes to rest (2206);
- a merged execution with no whole chunk drawing an empty first draw
  (2207);
- a texture's placement over host pages answered before their import, with
  no image made (2208, Device::host_pages_texture_placement).

The runtime's DevicePolicy gains managed_copy_in, whose exact form,
ManagedCopyInPolicy::AtCommit, copies the range on the CPU at the commit
as the Radeon Pro 5300M keeps it. REIMS_VGPU_EXACT names it like every
other exact form, and docs/accuracy-ledger.md gains its row; without the
name, `all` would set a field no name sets and the exact names' test
fails. No degradation kind or runtime gap changes. ArgumentEncoder::device()
now returns the device by value, which nothing here calls; WorkCounts gains
fields, Problem gains HostPagesBacking, and CompiledFunction two accessors,
which nothing here matches on or calls yet.

What the guest sees changes: a CPU write to a Managed buffer's range after
its command buffer's commit may now be read by it, as on the UHD 630;
Apple's Modern Rendering sample no longer hangs the RTX 3090 (it draws, at
about 200-290 ms of GPU a frame, metal2vulkan's next fixes); a recovery
keeps indirect command buffers, function tables and argument encoders; a
surface depth texture's shadow holds the right aspect. The device's answers
do not change.

Cargo.lock keeps its lines.
2026-11-13 00:47:27 -08:00
Anees Iqbal a579ecf831 📝 Say a walk shares the host's CPUs with other jobs [ci skip]
An after-walk on the 780M lost frames through six steps while another
lane's full build ran on the host, and a walk alone matched the before-walk.
Record the trap and how to spot it; correct the ask count in the lesson
before it (2125 of 2126 asks were answered in place).
2026-11-13 00:03:57 -08:00
Anees Iqbal 81ec160d7f 📝 Say a check's verdict answers less than the making refuses [ci skip]
The cache ask answered from the runtime's in-place check alone, so the
making's own refusals (pitch, place, reach) left 428 surface textures as
shadows on a Radeon 780M walk. Record the trap and how to spot the next one.
2026-11-13 00:03:57 -08:00
Anees Iqbal c7acae16a7 🐎 Ask the runtime where a surface's textures lie for its cache
A block that asks whether its IOSurface needs a device cache was answered
from the runtime's in-place report, parsed as text: the check's verdicts
alone. What only the texture's making decides never reached the answer: rows
at a pitch no linear image of the GPU's takes, a place or import no image
takes, texels past the pages. Such surfaces stayed over their pages, and each
of their textures was the runtime's shadow, copied in at every command
buffer's first use and merged back after its writes.

A probe walk on the 780M (um870, macOS 26.7.2, m3-max-24453) logged 428
surface textures refused for pitch, over 110 blocks answered in place: RADV
lays a linear image's rows at multiples of 256 bytes, CoreAnimation's are
multiples of 64 (3904, 3552, 640) and CoreVideo's 1920 and 1984. A device
cache, laid out at the GPU's pitch, holds them in place.

The answer over the view is now the runtime's own placement for each plane
(Buffer::texture_placement_with_iosurface_plane, the making's decision):
a texture over the plane that only reads, and one that takes every access.
The layout gives no texel width, so each plane is asked as each of Metal's
widths its rows' texels divide into. It takes a cache where no width lies in
place, none is pending, and some width's texture is a shadow a cache holds
in place. A texture the device makes no image in place of over any memory
(its format and usage, more levels than one) leaves the surface over its
pages. The two paths that answer before any import keep the report's
verdicts until the runtime answers there too.

What the guest sees changes only in speed: more surfaces take the device
caches they already took where the verdicts refused.
2026-11-13 00:03:56 -08:00
Anees Iqbal 9237884cf5 📝 Record that QEMU captures only while the guest posts buffers [ci skip]
What boots m3-max-24488 and m3-max-24579 measured on um790 with vendor/qemu
9a03bc4c: the input voice runs about 1.07 s per output and the host's source
stays suspended while the output plays on; a recording alone runs the capture
from START to STOP with no backlog; a recording started during an output gets
no buffers posted by the guest, as before; and how a boot answers the guest's
microphone prompt.
2026-11-12 23:46:16 -08:00
Anees Iqbal ff837ae87d 🔥 Delete the detach and replace machinery no call reaches
Since apple-gfx's detach and replace went on 11-07, nothing the guest or the
host reaches calls a buffer's or heap's detach_backing or replace_backing, or
the runtime's rebind_bytes_no_copy behind them: the device's wire has no op for
them, reims-vgpu's decoder never calls them, the C API has no entry for them,
and the guest bundle's RgfxHeap raises an unrecognized selector at
detachBacking and replaceBackingWithRanges:readOnly:, as Metal's base heap
does. Only tests called them.

Deleted with them: the trait methods and the testkit's, the backing's detached
state, its registry of detached objects, held deallocators and kept contents,
the per-command-buffer parts and the submission check every commit set for
them, and EncodedUseRebound's death, which no rebind can reach now (the
runtime's kind stays placed, and a failure of that kind would die unanswered).
tests/detach_backing.rs goes; its heap-over-address-ranges cases, with Metal's
recorded heap answers, move to tests/address_ranges.rs. reach.metal's comment
named the deleted file, so its metallib is compiled again (the bytes this
Xcode writes; the record changes for reach alone).

What the guest and the host see: nothing changes. The device still answers
supportsResourceDetachBacking as before: that answer is the guest's, and
changes only with boots.
2026-11-12 23:10:01 -08:00
Anees Iqbal a9581c934e 📝 Record when a guest takes none of its PipeWire input [ci skip]
Measured on um790 (m3-max-24213, m3-max-24300): the 26.7.2 guest starts its
virtio-sound input stream with every output stream and posts receive buffers
only for its first 0.73 s, so a play longer than about 25 s fills QEMU's
PipeWire capture ring on a host with a default source. What QEMU 8abc8492
says then, once and as a count, and what it said before, a line per cycle.
2026-11-12 21:53:15 -08:00
Anees Iqbal 7b92865a0b 📝 Say why a pages join may trust a VM object id [ci skip]
The join of a no-copy buffer to a live pages block compares the memory's
VM object id, which the kernel may hand to a new object once the old one is
freed. The join is sound because the kext's wiring of a live block keeps the
object, and a test fake that holds nothing lets the id come back: both remap
tests failed now and then on the M3 Max on 2026-11-12 until their fakes held
the memory (149fc57c8, 927e954de).
2026-11-12 21:46:32 -08:00
Anees Iqbal 645477e64e 📝 Record the unshare posted behind a later share [ci skip]
The kext posted a let-go's BLOCK_UNSHARE after its lock, and a later share or a
share of the span given out again went ahead of it on the device. The lesson
names how the next such pair shows.
2026-11-12 21:25:55 -08:00
Anees Iqbal 34efdc631a 🐎 Ring a walking queue's doorbell only for a buffer that asks
While a queue's service thread walked a buffer on its own thread, it marked
the ring as it marks it before it sleeps, so the guest rang the queue's
doorbell for every buffer it published meanwhile: a VM exit that answered
nothing for a buffer that does not ask for its CB_SUBMITTED, in two of three
commits of a back-to-back run on a 26.7.2 guest (11.9 µs a doorbell on a
780M host). The thread now marks the ring walking (consumer_idle 2,
RGFX_CONSUMER_WALKING), for which the bundle rings only for a command buffer
whose last op is its ask, which the doorbell's write may answer; the thread
takes the rest after the walk, as before. A bundle that rings only for 1
rings for none during a walk, and its asking buffer is answered at that take.

What the guest sees: consumer_idle reads 2 during a walk, where it read 1.

Measured with commit_split, before and after in one job each, cold boots of
26.7.2 on um870 (m3-max-23492, m3-max-23493):
- RTX 3090: a back-to-back commit 15.8 -> 2.2 µs (median), doorbells 0.57 ->
  0.30 a commit, 22.5 -> 20.2 µs a buffer over 100,000 buffers; a commit's
  CPU time in encode_probe's cb.commit 19.6-21.2 -> 15.3-15.7 µs.
- Radeon 780M: 44.5-46.5 -> 44.7-45.3 µs a buffer, bound by the host's
  submits; doorbells 0.66 -> 0.54 a commit, the rest of them posts that wait
  for room; cb.commit's CPU time 19.6-20.2 -> 18.4-18.9 µs.
An idle queue's single commit rings as before (16.4-17.4 µs on both).
2026-11-12 19:06:13 -08:00
Anees Iqbal a4b6ade41b ⬆️ Build on metal2vulkan 63232a93ee's runtime
Pin 62 moves metal2vulkan from 0c0cdf0b12 (RUNTIME_VERSION 2165,
SEMANTICS_VERSION 2064, ARTIFACT_FORMAT_VERSION 509) to 63232a93ee (2176,
SEMANTICS_VERSION 2072, ARTIFACT_FORMAT_VERSION 512), the golden tables
and the authored compile census re-blessed. It carries:
- a device recovery carrying the textures of new_texture (made new, their
  contents lost; those over carried buffers keep their bytes), binary
  archives and dynamic libraries, compute, tile, render and mesh pipeline
  states (made again from what their creations compiled; a bind of one
  whose making failed is refused, RemadeAfterRecoveryFailed), sampler
  states, Private buffers in exportable memory (over their own memory,
  not zeroed), and no-copy heaps with the buffers and textures placed in
  them (2166-2170, 2173, 2174, 2176);
- every batch the lost generation still holds failed as GpuRecoveryVictim
  in commit order, and a queue's new place running its handlers only after
  the old place's, so no command buffer committed around a recovery waits
  for good (2172);
- a Managed buffer's didModifyRange bytes reaching only the command buffer
  that committed them and later ones, on a device whose memory is not the
  host's (2171);
- a rate-mapped pass recorded at the host step drawing each command that
  is safe to fan out once, with a copy per region it touches, where it drew
  it once per region (SEMANTICS 2072, RUNTIME 2175; REIMS_VGPU_EXACT's new
  name rate_map_regions keeps every draw region by region, and the
  accuracy ledger has its row);
- a 16-byte vector access placed at its address unless its offset is
  proven a multiple of 16, as Metal places it: a float4 read through a
  float pointer only 4-byte aligned read k floats low (Geekbench 7 Metal's
  workload 302 softmax rows) (SEMANTICS 2069), and the reach of a pointer
  through a base not yet reached kept unknown (SEMANTICS 2070), which
  6164d3a66a's tree took as reached and so refused 124 MPS NDArray kernels
  of an Iris Xe's pipeline records that 0c0cdf0b12 made;
- flat simdgroups, the rate map's fan-out variant, generic pointers and
  matmul2d's macOS 27 runs (SEMANTICS 2065-2068, 2071).

The runtime's objects answer their device as an owned handle of the
generation serving them, not a borrow: six call sites here take a
reference to it, and two fence devices drop a clone that is now one.
No degradation kind changes. RuntimeGap gains RemadeAfterRecoveryFailed,
which a bind answers as it answers MadeBeforeRecovery.

What the guest sees changes: after a device recovery, pipeline and
sampler states, exportable Private buffers and no-copy heaps made before
it serve again, and command buffers committed around it complete; Managed
buffers' modified bytes on a dGPU reach only their own and later command
buffers; rate-mapped passes take far less GPU time; and kernels reading
16-byte vectors at addresses not 16-aligned read what Metal reads. The
device's answers do not change.

Cargo.lock keeps its lines.
2026-11-12 18:55:13 -08:00
Anees Iqbal 831ce5ef41 ⬆️ Build on metal2vulkan 0c0cdf0b12's runtime
Pin 61 moves metal2vulkan from 1125fb62d2 (RUNTIME_VERSION 2149,
SEMANTICS_VERSION 2062, ARTIFACT_FORMAT_VERSION 508) to 0c0cdf0b12 (2165,
SEMANTICS_VERSION 2064, ARTIFACT_FORMAT_VERSION 509). It carries:
- the chunk gate on RADV and ANV: copies by runs no longer meet the
  runtime's Invariant over chunks an object's own import holds; on the Iris
  such copies are staged on the CPU (2157, 2158);
- address pools made before a recovery taking new buffers after it (2159),
  and an object's device() its generation again, so destroying objects of a
  lost generation through it no longer crashes (2164);
- a process limit on the SPIR-V words of large pipeline makings (2160);
- draws, dispatches and ICB replays whose pipeline is still being made held
  until it is, never dropped (2161, 2162);
- a rate-mapped pass's work submitted in pieces of bounded size, big draws
  cut into index ranges, so no submission nears amdgpu's 2 s job timeout or
  NVIDIA's context-switch timeout (2163);
- IOSurface plane textures taking their buffer's padding_unobserved, so the
  Iris's tile textures lie in place (2165);
- the resident-set search emitted as a loop alone (SEMANTICS 2064), and the
  host-import gauges split into releasable and held-for-good.

Here: the two dropped-while-making degradation kinds leave the answer
layer's list and docs, the accuracy ledger's row says the command buffers
wait, the GPU-times doc names a rate-mapped pass's pieces, the recovered
sink's test runs again, and the generation test holds the device handle it
took before the recovery, since fences are now carried across it.

What the guest sees changes: no draw or dispatch is dropped for a slow
compile (its command buffer completes later), rate-mapped frames no longer
hang the 780M's ring or an NVIDIA GPU, and small buffers made after a
recovery are made. The device's answers do not change.

Cargo.lock keeps its lines.
2026-11-12 17:15:32 -08:00
Anees Iqbal 641be0cec1 🐛 Answer a waiting screendump as QEMU's quit closes the console
With 8de552e91's bounded wait for a display read, QEMU's quit after an
RTX 2080's Xid 109 went past the device's teardown and then hung in
monitor_cleanup (fix-2080, m3-max-23203): a QMP screendump waited for the
update the stuck read was for, closing the console woke it not, and the
quit waits for the QMP dispatcher the screendump holds.

vendor/qemu e829b256 marks the console's update done before closing it, so
a waiting screendump is answered with the console's last frame. What the
host sees: such a screendump now returns at the quit, where it never did,
and the quit goes on; a quit with no screendump waiting is as before.
2026-11-12 16:38:38 -08:00
Anees Iqbal 73b79f7e61 🐛 Quit a VM whose display read waits for a GPU that stopped answering
QEMU's quit hung for good after NVIDIA's Xid 109 (a context switch timeout)
in Apple's Modern Rendering sample, on an RTX 2080 and an RTX 3090: a
screendump's read of the display waited for its draw on the GPU, which never
finished, and the teardown at the quit waited for the read under the BQL
(thread_pool_free), so QMP's and HMP's quit both needed SIGKILL.

vendor/qemu 32a9f9a9 waits for the read at most 5 s, the bound the
library's release of its last device waits for its own threads, and past it
keeps the device to the exit, as a VM whose shutdown pauses it does. What the
host sees: such a quit now ends; a quit with no read under way, or one that
ends in time, is as before. docs/qemu.md says what was measured, including
that a pending screendump holds every QMP monitor while HMP, the vCPUs and the
guest go on, and docs/api.md the quit that keeps its device.
2026-11-12 16:38:38 -08:00
Anees Iqbal 61076b4fd0 🐛 Reserve the guest's texture ids as the device is made
On Linux, a GPU whose imports of views need their pages mapped from their
files (the Iris Xe on ANV, NVIDIA) runs the fold probe as its device is
adopted, wherever its driver's fold verdict is not kept yet: a user's first
boot, and the first boot after each GPU driver or kernel update, as the
verdict's key holds both. The probe makes a command queue on the device
before the graphics device reserves the guest's texture ids, and Metal, as
the runtime imitates it, then keeps the texture pool's first range beside
the reservation and hands those ids out twice: the host's drawables and
cursor took ids 1 to 16 of the guest's first chunk (a cold boot on the
Iris logged "a texture of the host's took resource id 1, one of the
guest's").

The graphics device now tells the platform the guest's ids before it asks
for its device (ApiPlatform::present_guest_texture_ids), and the Vulkan
platform reserves them as a new device's first call in adopt, before the
library's probes and checks; the graphics device's own reservation of
exactly those ids is answered at once. A device adopted before the
declaration reserves nothing there, and the graphics device reserves as
before. The new test makes a queue between the device's making and the
graphics device and finds no plain texture inside the guest's ids.
2026-11-12 16:17:20 -08:00
Anees Iqbal ecf693f1bf 🐎 Build a large command buffer's message off its block
A message too large for half its queue's ring was built in a block of the
queue's pool once it outgrew the ring, and grew from block to block. The
block is write-combined where the kext maps it so, and on an AMD host, which
applies the guest's memory type, a write-combined store still pending
stalls the encoding thread's next locked instruction until it drains. Every
retain and release on that thread, the app's and ours, paid it: on a
26.7.2 guest of a Ryzen host (RTX 3090), encode_probe's
setRenderPipelineState took 108 ns a call in a 10000-call buffer against
21.6 ns in a 400-call one, which stays on the builder's heap, and a
setVertexBuffer between a CFRetain and a CFRelease 103 ns against 17.1 ns.
Growing from block to block also read the old block back, uncached.

The message is now built in the builder's own buffer whatever its size,
which grows to the queue's guess as it outgrows the ring, and the commit
copies it once, whole, into a block from the block's start. The host reads
the same COMMAND_BUFFER bytes; only where the message lies in its block
changes. The tests that held the old placement change with it.
2026-11-12 16:14:00 -08:00
Anees Iqbal f6ef7d8c8d 🐛 Make the host's kept GPU objects again after a device recovery
When the Vulkan platform's runtime recovers a lost VkDevice, it refuses
the textures, pipelines and pooled buffers made before the recovery on
the new device (MadeBeforeRecovery), and a Private buffer reads zero. The
display's draws kept their converter, colour functions and pipelines,
colour buffers and table, and ramps from their first make. After a
recovery every draw of the window was refused, and the window kept its
last frame. The 780M's rate-map hang showed this (perf-scout's 22883 and
22936). The host's read-back texture and the Vulkan platform's no-draw
and predication-step pipelines were kept the same way.

The platform now counts the recoveries the runtime announces
(GpuDevice::recoveries, from the DeviceRecovered notice). Each of those
keepers notes the count it made its objects at, and once the count
changes it lets go of them and makes them again: the sink at the first
draw after the recovery, the read-back texture, the no-draw pipeline and
the step pipeline at their next use.

The sink's recovery test, on_vulkan_a_recovered_device_draws_through_
the_colour_as_before, is ignored on the pinned runtime. That runtime
refuses a new buffer in an address pool reserved before the recovery,
and the draws' small buffers lie in such pools. On metal2vulkan
8bead88369, which places them, the test passes on an Iris Xe
(m3-max-23047, 23050). The pin that carries that commit runs it again.
2026-11-12 15:48:38 -08:00
Anees Iqbal d0486975af 🐎 Keep ICB slot tables in the process's own pages
The bundle wrote a CPU-encoded indirect command buffer's slot table into a
block of the region (BAR 2), which the guest's kernel maps uncached on an AMD
host, so each setter's store and mask OR crossed the bus. icb_probe, in a
guest on development's set, took 2.9-3.8 us a render command, 2.7-2.8 us a
compute command and 2.25 ms to reset 16384 commands on the um790's 780M, and
3.1-3.2 us, 3.0 us and 2.25-2.26 ms on its RTX 2080, where a native 5300M
takes 83-99 ns, 108-135 ns and 66-68 us.

A host that maps the guest's pages in place now offers
RGFX_FEATURE_ICB_SLOTS_IN_PAGES (bit 42). There the bundle takes each slot
table from a chunked pages block of the process's, cached memory the kext
zeroes, and flushes its runs with ICB_SLOTS_IN_PAGES (0x23a), whose runs name
the block, its size and the table's offset in its pages. The host finds the
pages as it finds a pages buffer's (in the sender's own blocks, then in the
block's view) and takes the slots as it takes the region's: it swaps each
written slot's mask words for 0 and copies the rest. The block goes back after
the buffer's destroy. Where the kext gives no chunked pages, the table lies in
the region as before. What the guest sees of an ICB (its results, resource IDs
and refusals) does not change.

With the tables in the process's pages, the same boots take 111-118 ns a
render command, 120-159 ns a compute command and 17-18 us a reset on the 780M,
and 107-122 ns, 105-123 ns and 16-19 us on the 2080. The records path, which
this does not touch, stays at 1.3-1.4 us a command.

The IOSurface copies stay in the region: their block is shared between
processes, so the process's own pages do not apply, and their measured cost is
the copy (1.1-1.3 ms for 4 MiB against 0.6 ms in place on the 780M), not the
region's writes.
2026-11-12 15:33:37 -08:00
Anees Iqbal 7918cbcb94 📝 Record the traced USB audio pair: the restart and the lock [ci skip]
A second boot of each QEMU with every guest event traced (m3-max-22668)
shows the first stream's IsoTooOld restart before the passthrough changes
too, so it is not theirs; and the main loop still stalled for the length
of the output interface's alt-0 call while it took the input stream's
transfers from the same device, which waits for the call. The worker frees
the main loop only where no other endpoint of the device completes during
the call.
2026-11-12 14:35:55 -08:00
Anees Iqbal b592e96aa0 📝 Record what our two-copy guests answer to the capture probe [ci skip]
Q2 recorded which CPU bytes the 5300M's and the 630's GPU copies take of a
Managed buffer written again after its didModifyRange:. The same probe in
an x86-64 macOS 26.7.2 guest gives the 5300M's answers on the RX 7900 XTX
at metal2vulkan 38ab829481 (m3-max-22650), and on the RX 550 at 86d01646ae
(m3-max-22791) for the four steps the RX 550 ran: its fourth step's 2 s
spin ended in the driver's soft recovery, and the fifth step's command
buffer was discarded as its victim.
2026-11-12 14:35:55 -08:00
Anees Iqbal 349d509475 📝 Record when an x86 Mac takes a Managed buffer's CPU bytes [ci skip]
Q2 said a didModifyRange: before the commit reaches a command buffer encoded
before it; it did not say which CPU bytes the GPU's copy takes. oracle_storage
capture (m3-max-22553 on the Radeon Pro 5300M, 22554 on the UHD 630) writes
the buffer again after its didModifyRange:, before the commit or 30 ms after
it while the command buffer's first kernel holds the GPU. The 5300M's kernel
reads the bytes of the commit, whether the command buffer was encoded before
the second write or after it; the 630, one copy, reads the latest.
2026-11-12 13:43:49 -08:00
Anees Iqbal cd74acc238 📝 Record what macOS's USB audio does to qemu-xhci [ci skip]
The patch table lists the three QEMU changes for passthrough USB: usb-host's
SET_INTERFACE off the main loop, Set Latency Tolerance Value on PCI Express
and interrupt moderation. The passthrough section now records one boot of
each QEMU (m3-max-22555 on the Ryzen 7 7840HS host, macOS 26.7.2) with a
USB audio device: the calls' times and QMP's longest round trip before and
after, the BELTs macOS sends as a stream starts and stops and the TRB Error
it logged for each before, the IMODI values it programs, and the stream
restart the after boot's guest made once, whose cause one boot of each does
not settle.
2026-11-12 13:43:35 -08:00
Anees Iqbal f95b7ee14f 🆕 Answer equal pipeline creates of any process from the kext
A process's first create of a pipeline another process already made waited
about 0.28 ms for the device's answer (26.7.2 guest, RTX 3090: MPS kernels in
Vision's second process), of which the host's compile from its caches is 0.1
to 0.2 ms; a real Mac answers it in 0.05 ms. The known creates only spared a
process its own repeats.

The device now offers PIPELINE_KEYS (feature bit 41). A render or compute
create may ask for its pipeline key (RGFX_*_PIPELINE_ANSWER_KEY), and where
the device made the pipeline and holds every library it names under a content
key it checked, its reflection carries the key after it
(RGFX_PIPELINE_REFLECT_KEYED): the SHA-256 of the create with its seqno,
object id and library ids zeroed, and its libraries' content keys. The kext
keeps the answers it waited for that carry a key, 2,048 at most (256 sets of
8, the oldest in a full set replaced), and Submit's shared flag posts a create
by its key without waiting where an answer of that key is kept and a deferred
slot is free.

What the guest observes: a create whose equal create any process made before
is posted without waiting, its reflection the kept one at once and its own
gpuResourceID at the first read, as a process's own repeat was; a refusal at
the create only where no process's equal create was accepted, the residual
reason the known creates already have (design.md, "Known pipeline creates").
The kext's feature word gains SharedPipelines (1 << 9) and the device's
feature word PIPELINE_KEYS; the tests that held the feature words change with
them.
2026-11-12 13:28:15 -08:00
Anees Iqbal d96a612b55 🐛 Check compute pipelines' threadgroup fields as Metal does
The bundle kept requiredThreadsPerThreadgroup guest-side and sent the host
none of it, so a compute pipeline whose required size is past its kernel's
[[max_total_threads_per_threadgroup(n)]] was made, where Metal's compile
refuses it. maxTotalThreadsPerThreadgroup against the kernel's attribute and
the device's limit went unchecked guest-side too, and macOS 27's
forwardProgressUsage and contentionRelief were taken whatever their value.

oracle_threads measured each case on the AMD 5300M, the Intel 630 and the
M3 Max (m3-max-22216, 22217, 22214; dgpu-oracle.md Q32). The AIR reader now
reads a kernel's attribute (air.max_work_group_size), and the bundle checks
the fields before it posts the create, in the x86 guest the AMD GPU's way
and in the arm64 guest the M3's, as its validation and compiler do.

What the guest observes: a required size with an axis of 0, past the
device's limit or past the descriptor's maximum ends the process at Metal's
failed assertion; a required size past the kernel's attribute, a descriptor
maximum other than the kernel's or past the device's limit, and a forward
progress usage or contention relief Metal does not name are refused with
the device's error, and nothing is posted; a pipeline of a required size
answers its threads as maxTotalThreadsPerThreadgroup; and forwardProgressUsage
Automatic answers Weak. The tests that held the old answers change with it.
2026-11-12 12:45:37 -08:00
Anees Iqbal 7ff8cfb02e 🐛 Reflect post-tessellation vertex functions' control points
A post-tessellation vertex function's control point input
(air.patch_control_point_input) takes two nodes the AIR reader did not
follow, its control point function's and its attributes', so the reader
gave up on the whole entry point and its pipelines got no reflection: a
creator asked for reflection answered nil where Metal answers one.

The reader now follows them, keeping each attribute of the control point,
and reads the entry's patch type (air.patch). The reflection answers what
the AMD 5300M, the Intel 630 and the M3 Max agree on, measured with
pipeline_reflection_check's patch cases (m3-max-22312, 22313, 22314): the
control points and the patch's attributes are no bindings, the vertex
descriptor's buffers are unused though the function reads them,
position_in_patch and patch_id are built-ins 14 and 13, and the dump stride
adds the patch's position, 12 bytes for a triangle and 8 for a quad, taken
or not. Two new probe functions (a triangle patch that takes no position,
and a quad that takes one it never reads) pin the last rule.

What the guest observes: those pipelines' reflection, where it got nil.
2026-11-12 12:45:37 -08:00
Anees Iqbal 7d153fc6f2 🆕 Write a picture into its dma-buf cache by the driver's VPP
Where the host's video decodes into device caches, a picture the driver's
check refused to decode into its cache (its codec and format), or whose planes
do not lie as a target's must, landed by the runtime device's GPU copy, which
imports the decode surface as images by their DRM format modifiers, and else
by the CPU through the session's staging. On an RX 550 both apply to HEVC Main
10: its radeonsi fails the check's second step for P010 (the first wrong byte,
0x40, is the low byte of the check's 0x5a5a scribble as a 10-bit sample, read
from the reference's overwritten target), and its RADV lists no
VK_EXT_image_drm_format_modifier, so every 10-bit picture was read back and
copied by the CPU. A 26.7.2 guest's walk there (m3-max-21989) played a
2160p30 HEVC Main 10 clip at 22.2 fps with 109 frames dropped.

The cache's memory is a dma-buf the arm already exports for its decodes
(CacheTargets). The arm's first landing, the driver's video processing into a
linear VA surface over a dma-buf of the planes' pages (Frame::write_to_guest),
now also takes such a cache: CacheBytes hands the cache's memory as the
device memory of the write, each range at its own byte of the one dma-buf, and
the write is acquired as a decode into the cache is
(Buffer::external_write_done). Its import goes as the cache does, by the
cache's identity. Where the driver's import check refuses the format or the
planes' alignment, the picture lands as before.

What the guest sees: the same pictures in its outputs, landed in the cache by
the driver's GPU work rather than by the CPU. The session counts such pictures
"in a device cache, by the hardware".

Tests: the ignored hardware test
a_picture_written_into_a_dma_buf_cache_by_video_processing_is_the_cpus_copy,
on a VA-API host with the conformance suite's streams.
2026-11-12 11:53:16 -08:00
Anees Iqbal 2208a41716 🐛 Wait for a video op's cache and GPU copy as long as they take
A video op faulted its command buffer where its surface's device cache was not
filled, or its last picture not copied into its pages, within 2 s; and a VA-API
picture failed where the runtime device's GPU copy of it took over 2 s. The
fault was seen once, behind a 2 s GPU stall on a loaded host. A Mac's video work
waits for the GPU's earlier work on its surface however long it takes.

The op now waits until the fill and the copy are done. Each ends as the
platform sees its command buffer complete, which it does on every path, failed
where the device was lost; a reset of the device ends the wait, as it ends every
wait of the decoder's, so none holds a reset up. A wait past 2 s is named in the
log. The device caches' waits take what ends them in place of a timeout, and a
deferred fill's make is waited for in the same slices, so a reset ends that wait
too where it waited without end before. The plane copier waits on its fence with
the maximum timeout, which Vulkan returns from in finite time once the device is
lost.

For the guest: a decode or encode whose output's or source's device cache is
slow to fill, or slow to be copied out, no longer faults its command buffer
after 2 s, and a VA-API picture whose GPU copy is slow no longer fails its
decode; both wait, and only a reset of the device or a lost device fails them.
2026-11-12 11:53:03 -08:00
Anees Iqbal 584c90974f 🐛 Lower vmapple's serial and GPIO interrupts on a guest reboot
vendor/qemu 8b804b45: the PL011's and the PL061's resets cleared what
raises their interrupts and left the lines at their last level. HVF's
in-kernel GIC keeps a level line's input across its own reset, so an
interrupt the last boot raised on macOS's serial port or the power
button's GPIO was pending again in the next boot, with nothing in the
device behind it.

For the guest: after a reboot neither device's interrupt is pending
until the device raises it.

Read from code: no loop counted these interrupts. The previous commits'
loop (m3-max-22144) ran with this one, 390 boots with no AES error and
no AppleVirtIO data abort.
2026-11-12 11:47:37 -08:00
Anees Iqbal d5260cc47f 🐛 Reset vmapple's AES engine fully when an arm64 guest reboots
vendor/qemu f9e5348a: the engine's reset cleared its status, interrupt
and watermark registers and kept its FIFO, keys, IVs, mode and the
level of its interrupt line. A macOS guest that panicked mid-command
left words of that command in the FIFO; they led the next boot's first
command, which the engine failed as invalid, and macOS panicked on the
error ("AppleS8000AESAccelerator::AES Error: IntStatus 0x4").

For the guest: a reboot now finds the engine as a cold start does, with
an empty FIFO, no keys or IVs, ECB, and its interrupt low.

Measured with the previous commit's loop (m3-max-22144): the unfixed
QEMU met the AES error in 234 of 391 boots, the first at boot 31; this
commit with its neighbours, in none of 390.
2026-11-12 11:47:37 -08:00