A cold guest thread wake on um870 waits 48 to 52 us on the host, most of it
the CPU leaving C3, so per-VM halt polling (KVM_CAP_HALT_POLL) looked like a
lever for our QEMU. Measured at 200 us, 1 ms and 4 ms on um870's 780M and
ms01's Iris: 4 ms takes the cold wake away but costs 16 to 18 W while Safari
plays a video and half a CPU over a Geekbench pass, for 2% on um870 and
nothing on ms01; 1 ms is inside the noise. So QEMU keeps the host's
kvm.halt_poll_ns, and reims-ctl gives no cpu-pm, which holds a host CPU per
idle vCPU.
The doc said halt polling is a module parameter QEMU cannot set; a VM can
set its own, and the new section says why ours does not.
A writable twin of read-only pages was made only for a surface's read-only
alias, and a file of zeros only for an alias's block past its ranges: both
went with the host-OS surfaces, which no production path has made since
110b53637. So import_view loses its twin argument, and with it the twins'
map (shown_at), their mappings in the views' budget, the notwin refusal and
its trace record. Read-only pages are given to the runtime as they are, and
the views' gate refuses them, so the runtime copies them, as before.
The dma-buf sources lose their files of zeros (Zeros), which only those
blocks' pages took, and the budget's claims their reach, as only a twin
reached into the headroom. An import's pages are made once, so its record
says whether that import is still being made rather than how many are. The
remap, budget, vm, files and host_ram docs, qemu.md, lessons.md,
architecture.md and conventions.md no longer describe the twins, the
stand-in or the IOSurface memory the library held; the measured facts about
what a remap under an import reads stay in remap.rs. ResourceAddressRange,
which only the surface aliases gathered, goes.
Nothing the guest or host observes changes, as no production path has made
an OS surface since 110b53637.
Since 110b53637 nothing in production makes a host-OS surface: the
reims-graphics device's surfaces reach the Vulkan platform as buffers, and a
texture over a surface's plane is made with new_texture_over_surface_plane.
Only tests made IOSurfaces, and the previous commit moved those onto that
creator.
So the platform's surfaces go: the Surfaces trait and Platform::surfaces,
GpuDevice::new_buffer_on_surface and new_texture_on_surface, the resources'
iosurface getters, the OS modules (os/surface.rs, os/linux/surface.rs,
os/macos/iosurface.rs) and the testkit's counted surfaces. With them goes
what only an object over an OS surface reached:
- metal_space's surface ranges and Over::Surface/Over::Plane;
- backing.rs's surface aliases (Alias, gather_or_nil, its zeros);
- writes.rs's bound-memory and slot-writes queries, and encode_render's
Reach and binds, which decided the refused writes of 523 and 527 into a
texture over a surface, with the compute pipelines' kept descriptors that
only those queries read (a render pipeline keeps its guest descriptor,
which its encoders read);
- predication's dropped texel writes, and the message layer's fatal_send;
- allocate_zeros, TWINS_READ_ONLY and an import's second making on Linux.
The measured facts the live path relies on stay, in the live modules' docs:
metal_space's (the surfaces' address ranges Metal gives), ycbcr.rs's
("Writes": which YCbCr writes Metal stores, drops, or changes by a rule the
runtime does not hold) and resource.rs's (the plane Metal asserts or answers
nil at). out_of_host_memory is Linux's alone now, as only Linux's views and
imports run out of memory short of Metal. docs/architecture.md,
development.md and qemu.md no longer describe the OS surfaces.
Nothing the guest or host observes changes, as no production path has made
an OS surface since 110b53637.
A cold `cargo xtask dist` typed into a bash terminal on CachyOS runs its
compilers at nice -4 (ananicy-cpp's rule for bash) against QEMU's nice 9, and
stopped the guest's Safari pages for up to 2.6 s with 8 vCPUs. In the stalls
the vCPUs waited on run queues while the device's threads were idle, and the
gaps were 2.4 to 28 times what the lost share accounts for.
Record the measurement in docs/qemu.md, with why nothing of ours moves it and
why reims-ctl's vCPU default stays: 4 vCPUs cut the worst scroll gap 3 times
but took 1.81 times as long for a CPU-bound guest on an idle host. Record the
nice -4 trap in docs/lessons.md, since a load started at nice 0 measures less
than a user's build.
docs/qemu.md's table of the branch's QEMU changes gains 3d04e62f and
926fc8dc (each command's own Command Completion Event) and 78b3270c (no
usbfs call on a device while it sets an alternate setting), and the USB
passthrough section the before and after boot of 78b3270c (m3-max-26476):
the output interface's alt-0 calls no longer stall QMP.
vendor/qemu moves to baa655fe. reims-graphics-pci's teardown deleted the BH
that the window's input and the cursor's callbacks schedule, right after
the library's release, and set it to NULL. A window callback already
running on the window's thread as the release closes the window, or a
cursor callback of a device thread the release's 5 s bound left running,
then scheduled NULL and ended QEMU with SIGSEGV at its quit. The BH now
stays to the exit and drops the events it finds once the console is
closed. Read from the code; no run reached the crash.
vendor/qemu moves to 104d7b18. route_doorbell, which the library calls on
its ring-0 and control threads as a command queue is made or ends, takes
the BQL, and the teardown at QEMU's quit held the BQL across the library's
release of its last device, which waits up to 5 s for those threads: a
route call waiting for the BQL at that moment held the quit for 5 s and
left the GPU device to the exit (commitpath2's teardown race). The release,
and nothing else of the teardown, now runs with the BQL let go: the route
call takes it, finds the routes the teardown closed, and returns. Routes
still change only under the BQL, before the queue's create or destroy is
answered. QEMU's commit lists each callback that can run in that window
and what it finds. No C API change: the library already allowed either.
vendor/qemu moves to 17098f76. A screendump waits for the console's read
of the display, which waits for its draw on the GPU, and QMP runs one
command at a time on every monitor: a GPU that never answered the read
(NVIDIA's Xid 109 on the RTX 2080 and RTX 3090, 11-12) left every QMP
monitor without an answer to the quit, so reims-ctl and the harnesses,
which drive VMs through QMP, lost the VM. A read still under way 3 s after
its start is now late: the screendump waiting for it, and every update
until the read ends, is answered with what the console shows, the frame of
the last read that ended or QEMU's placeholder where none has. A read that
ends within 3 s is waited for as before, so a screendump on a GPU that
answers still shows the frame the display shows. 3 s leave reims-ctl's
viewer, which waits 5 s for a QMP answer, 2 s of margin.
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.
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.
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.
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.
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).
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).
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.
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.
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.
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.
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.
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.
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.
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.
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.
vendor/qemu 47098463: HVF's in-kernel GIC wrote each SPI's distributor
bits to the register 32 IRQs below its own and wrote the clear half of
each set/clear pair as 0, so its reset, which runs on every guest reboot,
left the last boot's SPI enables, pendings and actives in place. A
macOS guest that panics leaves MSIs pending; the next boot took them
before AppleVirtIO had set up its queues and died reading a null used
ring (far 0x2, AppleVirtIOQueue::handleEvent+0x18).
For the guest: a reboot now starts with every SPI disabled, idle and
level-triggered, as a cold start does.
Measured on the M3 Max under HVF, a macOS 27.2.1 restore OS on Ambrosia
fbe305f7 that panics at boot and reboots in one QEMU, 240 s a build
(m3-max-22144): the unfixed QEMU (bbe10728) took 8 AppleVirtIO data
aborts in 391 boots, the first at boot 111, and 234 AES errors from
boot 31; with this commit and the next two (8b804b45), 0 of either in
390 boots. The paused realize of vmapple with reims-graphics-pci passes
(22144), and qemu-system-x86_64 builds none of the devices these
commits touch (its x86_64-softmmu device list, 22130).
A new VM's disk was to move to NVMe if NVMe's disk waits on um790 stayed
within AHCI's spread. They did not: in six cold boots of macOS 26.7.2 from
reflink clones, two of the three on NVMe waited 7.76 and 13.67 s in their
first 150 s and no AHCI boot waited, though NVMe reached the desktop about
3.5 s sooner. New VMs keep SATA. docs/qemu.md records the numbers, where the
waits came from, and what is still unknown.
docs/qemu.md gains "x86-64 macOS guests: the disk on NVMe": the command line,
what Recovery 11.6 to 26.6.2 and installed 11.7.11 to 26.7.2 found on it
(measured 2026-11-12), and why the 10-27 report's Recovery found no disk: that
day's video kexts blocked Recovery's start on either controller. lessons.md
records the trap of blaming the controller a hang showed on.
A page-load stall in an x86-64 macOS guest on um790 was traced to the host's
SSD. To find out whether any disk option reims-ctl could pass would avoid
it, cold boots of one macOS 26.7.2 disk compared QEMU's defaults with
aio=io_uring, a nodatacow image, cache=none and NVMe on two btrfs hosts.
On um790's DRAM-less Lexar, which now and then takes up to 2 s over a
single read, none of the options did better than the defaults, and three of
them did worse. On um870's 970 EVO Plus the defaults showed no stall.
NVMe reached the guest's SSH about 8 s sooner in three boots of four.
reims-ctl's disk arguments stay as they are; the numbers go in qemu.md so
the A/B is not run again.
The 847 ms rAF gap at Safari's page load (run 12101) was measured on a
qcow2 overlay over the shared VM's disk. Traced with QEMU's AHCI commands
and the host's block layer on homelab-um790-xtx-1, the overlay's guest
writes waited up to 1.96 s behind its first-write reads of the cold,
compressed base on btrfs and the SSD's occasional 2 s reads, where a
reflink clone of the same disk, as reims-ctl copies one, kept every write
under 28 ms. Guest flushes, the suspect, took at most 843 ms.
metal2vulkan gives a few answers the way the class of Mac a device
presents gives them (DeviceOptions::mac_class): what a new Private texture
reads before anything writes it, the encoding a GPU blit through a
texture Metal compresses writes, a half NaN clear's sign, and how far a
Clear load reaches past the render area in a pass of one layer without a
draw call. The library declared no class, so every device presented its
host GPU's: an arm64 guest on a Linux host got an Intel or AMD Mac's
answers, and an x86-64 guest on a Mac host Apple silicon's, the M3's
magenta fresh pattern among them, where the Intel UHD 630 and the AMD
Radeon Pro 5300M read zero.
A graphics device now tells its platform the guest's architecture before
it opens its GPU device (ApiPlatform::present_guest), and the Vulkan
platform declares the guest's class for every device of the process
(GuestArch::mac_class, present_mac_class): Apple silicon for an arm64
guest, an Intel or AMD Mac for an x86-64 guest. The runtime fixes a
device's class as it makes it and keeps one device per physical device
and options, so the class is the process's, fixed by its first
declaration, or left to each GPU where the options were read first; the
platform warns where it is not the guest's. QEMU makes every
reims-graphics-pci of a process for its target's architecture
(target_aarch64() in reims-graphics-pci.c), and rvg_graphics_device_create
is its first call into the library, so its guests get their own class.
What the guest sees change:
- An x86-64 guest on a Mac host (MoltenVK; development and tests only): a
new Private texture reads zero where it read Metal's fixed pattern (the
runtime fills it with zeros, WorkCounts::private_textures_zero_filled);
blits through a texture Metal compresses keep their bytes, but where
MoltenVK's own copies still rewrite RG11B10Float and RGB9E5Float; a half
NaN clear goes through half; a Clear load in a pass of one layer without
a draw call clears the whole level.
- An arm64 guest on a Linux host (TCG today, KVM on arm64 hosts later):
the reverse. A new Private texture Metal keeps compressed reads Metal's
fixed pattern (opaque magenta in RGBA8Unorm) and any other zero, where
it held what its memory held; the runtime writes the pattern as the
texture's first move, and announces fresh-pattern-zeroed where the
device cannot write it exactly. Blits through such a texture write the
canonical BGRA10_XR, RG11B10Float NaN and RGB9E5Float encodings, a half
NaN clear keeps its sign in a pass without a draw call, and that pass's
Clear load clears an uncompressed texture over the render area's 32x32
tiles.
- x86-64 guests on Linux and arm64 guests on a Mac: nothing; the host
GPU's class was the guest's already.
The device info is unchanged: Metal has no property for the class, and
both guests keep the host GPU's name and no Apple family, the lane's own
limit.
No test held the host GPU's class through a graphics device: every
reims-vgpu and reims-vgpu-c test passes unchanged on the M3 Max, where
the x86-64 guests' devices now present an Intel or AMD Mac. The Vulkan
crate's tests make their devices with no graphics device, so they keep
the host GPU's class, the M3's Metal their reference; ff4185d73, which
declared an Intel or AMD Mac for every device, broke three of them. New
tests: the guest's class decides the answers whatever the host GPU (each
architecture in a child process: a new Private RGBA8Unorm render target
reads the pattern for arm64, and zero or no fill for x86-64), and the
process's class is fixed by its first declaration.
Past the headroom of the views' budget, a buffer or heap over guest memory
whose view lies in dma-bufs was copied rather than imported, as a driver that
imports by pointer needs the pages mapped from their files, a mapping a run.
NVIDIA's driver refuses the pointer of a view through dma-bufs, but takes the
pages one udmabuf holds through that dma-buf, as an allocation dedicated to the
buffer, which takes no mapping. So where a probe at the device's making finds
the device takes such a dma-buf, the gate lets pages one dma-buf holds through
(at udmabuf's defaults 1,024 runs and 64 MiB), and only an object of more runs
is copied there.
Measured on the RTX 2080 at the stock 65530, before made imports' views were
folded: once 24 scattered 16 MiB buffers had filled the budget, 160 scattered
2 MiB buffers were all imported (m3-max-17739). With the fold, the budget
rarely fills on NVIDIA in a desktop walk, so this is for heavier loads.
The probe's import is the process's first Shared dma-buf import. Before
metal2vulkan's RUNTIME_VERSION 2080 the runtime tried NVIDIA's host-mapped
system type first, which the driver refused, and every exportable device-local
allocation after that refusal lay in system memory: with the probe, boots on
the RTX 2080 and RTX 3090 logged the fallback and NVIDIA's mapping faults, and
three of four hung the GPU. At this runtime (bf442ceb9e), boots of the same
tree at 65530 logged neither the fallback nor a driver fault (RTX 2080
m3-max-19103 and 19104, RTX 3090 m3-max-19116).
Tests: past the headroom, a view of one dma-buf's pages passes the gate
uncounted and maps nothing, and one of more runs than one dma-buf takes is
refused and counted.
A no-copy buffer's or heap's view of scattered guest pages kept a mapping per
run of pages for as long as its import lived, as a driver that imports by
pointer needs the pages mapped from their files to pin them. On NVIDIA at the
stock vm.max_map_count the live imports' views filled the budget, and every
import after that was a copy: 11 of 24 scattered 16 MiB buffers on the RTX 2080.
NVIDIA's driver pins the pages as it imports them and keeps those pages. Once
the runtime's call that imports them returns, the view may be folded into a
dma-buf of the same pages like an idle view, and its mappings go back to the
budget. Each import site tells its record so, but only on a GPU that passed a
probe and on a device that does not release idle pointer imports. A second
import of an alias's view maps it from its files again until it is made too.
The probe runs where views are mapped from their files (NVIDIA, ANV on i915),
once for each GPU, driver version and kernel release: its verdict on the
GPU's own behaviour is kept in the library's cache, as the device checks
are. It first maps other pages over an import's view, which a GPU that kept
its pages must not read; only then does it fold the view, write the bytes
through the pages' own mapping, which the GPU must read, and run a GPU fill
both mappings must show. A first version folded before asking and lost the
device on the Iris Xe at every device's making (docs/lessons.md); the Iris
now refuses at the remap, with no lost device.
What the probe costs the device's making, over 5 makes each at metal2vulkan
842fd73b71: 26.7 to 33.0 ms on the RTX 3090 and 5.2 to 13.1 ms on the RTX 2080,
which pass it, and 16.5 to 17.5 ms on the Iris Xe, which refuses it; a kept
verdict answers in 0.05 to 0.09 ms. The Radeon 780M and RX 7900 XTX map views
through dma-bufs and run no probe, nor does a Mac. No run on those five GPUs
logged a lost device, a recovery or a GPU fault.
At the stock 65530 on the RTX 2080 (NVIDIA 620.70.06), a 26.7.2 guest's walk,
boots alternated with development's at metal2vulkan d0f800ddd0 (m3-max-18444 and
18503 against 18502 and 18504), copied 17 buffers and heaps over guest memory
where development copied 186 and 197: 16 of the 17 are cl_bw's 256 MiB buffers,
each more runs than the whole budget. The runtime's copied-host-pages count fell
from 370 and 392 to 34, and mb_probe's command buffer over its 192 buffers took
12 ms where it took 230 ms. Neither side logged a kernel fault of the driver's
or a fatal line.
Tests: a fold of a made import and an alias's second import; on a GPU that
folds, 100 rounds of make, fold, GPU check and release that end with the
file's pages unpinned (F_SEAL_WRITE) and the mappings back, and a folded
import that keeps its pages through a remap; elsewhere both say so and check
the fold stays off. The probe answers alike ten times, and a kept verdict
answers under its key alone.
An --exclusive potluck job holds every GPU of its node, and its lease lists
them all, homelab-um870-1's RTX 3090 first. Taking the lease's first GPU put
three exclusive TCG runs on the 3090 in place of the 780M they were meant for
(m3-max-17679, 17862, 17863). The script now keeps a MESA_VK_DEVICE_SELECT
the run gives, names the GPU of a lease that holds one, and stops on a lease
of several, so an exclusive run must name its card.
Ten arm64 macOS 14.6.1 boots under TCG on homelab-um870-1 put the metal-app
probe in the guest's post-login launch storm, over 200 runnable processes
on 4 vCPUs. Its window was shown 2.1 to 8.1 s after it was ordered front,
or not within the probe's run. Spindumps over the probe's first 15 s found
WindowServer mostly idle and never waiting in our kext, and the probe's
launch waiting on system daemons that barely ran. docs/lessons.md records
that, the windowed probe's second boot, and docs/qemu.md now says what
m3-max-17111's probe showed: no frame, which was all it measured.
Under TCG on a quiet homelab-um870-1, arm64 macOS 14.6.1's full-screen
probe window was first shown 2.1, 4.4 and 8.1 s after it was ordered front
in three boots, and not within the probe's 11 s in a fourth, which dropped
all 245 frames and failed metal-app (m3-max-17482). The probe ran 3 to 4
minutes after QEMU started, while the guest's post-login launches kept over
200 processes runnable on its 4 vCPUs. Counting frames over a fixed time
from the window's start read that delay as a device that shows nothing.
present_probe -v SECONDS now renders while it waits up to SECONDS for its
window to be shown (its occlusion state turning visible, or a frame's
nonzero presentedTime), then warms up a second and measures. Its line gives
the wait as visible_s, or none. check-boot runs it with -v 60, and fails a
window not shown in that time as such. Without -v the probe measures as
before, so the lane gate's runs are unchanged but for the new key.
A TCG run left the device to the library's own pick of the host's GPUs, so
on homelab-um870-1 one ran on the RTX 3090 the job did not hold (m3-max-17037).
The script now names the lease's first GPU in MESA_VK_DEVICE_SELECT and
stops where neither a lease nor a selection is given.
metal-app under TCG passes only on frames shown within the probe's 10 s, so
CPU taken by other work on the host can fail it, as a build did for 14.6.1 in
m3-max-17111. Its line now gives the host's pressure over the probe (PSI for
CPU, memory and IO, direct compactions and reclaims), and docs/qemu.md says a
gating TCG run takes the whole machine (--exclusive --hold-line).
docs/lessons.md records why the probe stays full-screen at the status level:
a titled probe window started over SSH was never shown, and every frame
dropped, while WindowServer denied the probe the right to be in front.
The C API's release of the process's last graphics device now lets go of
the platform's GPU devices before the process exits, and QEMU releases its
device as it quits. The architecture's C API section names the let-go beside
the other release rules, and docs/qemu.md says when QEMU's device goes at
its quit, with the boot that measured it on an RTX 3090: a clean exit after
the guest's shutdown, the let-go logged, no core.
docs/qemu.md's "Beside a build" gets its Linux counterpart, measured on
homelab-um870-1 (m3-max-14318, 14617, 14702): with QEMU in the cgroup that
started it, at ananicy-cpp's nice 9, 16 nice-0 spinners there kept an x86-64
macOS guest from finishing a 10 s probe in 2 minutes; in reims-ctl's own
scope it ran at 39.7 frames a second beside the same 16, and at 32.2 beside
64. docs/lessons.md says how to spot a VM sharing its caller's cgroup.
check-boot passed a boot whose screen was black: under KVM the runtime
refused FramebufferFetch and HostMemory, so CoreAnimation's composites
came out empty, while metal-app, which measures presentation and not
pixels, still counted 59.9 fps and every other check passed.
The new check, screen, reads the screendump check-boot already takes
(screen.png, else screen.ppm) with the standard library alone, and fails
when its commonest colour covers more than 90% of it or it has fewer than
1024 distinct colours. The bounds sit well clear of the screendumps of the
69 passing boots under HVF of 2026-11-11 (14.6.1 to 27.2.1, clean and
white-widget desktops among them): the commonest colour on 3.7% to 21.0%
of the screen and 240,414 to 404,446 colours. Of the 71 boots with a
screendump it fails one, a 27.2 control whose windowserver-metal and
metal-app failed too (15 colours, 95.0%). An all-black frame, and a black
one with a menu bar (97.8%), fail; a missing or unreadable screendump
fails as such. The header's check list and docs/qemu.md describe it.
A boot's check reads the codes of its degradations from its logged
degradation counts (AGENTS.md), which nothing wrote: the counts of the
relayed, native and inexact kinds and of the calls answered as when memory
runs out were read only by tests. HeapTwoPlaneTexture, one of the kinds a
creator hears, was relayed at every heap texture it was announced for, and
a driver's error message at every occurrence.
Every heard kind is now relayed the first time alone and counted, the
other kinds the runtime announces are counted, and a driver's or a layer's
error message is relayed once per id name and class of its text, then
counted. At each reset of the device and at the process's exit (the exit
gate's hook, after its wait), the library writes, where they changed,
"reims-vgpu: degradation counts: <code> <n>, ..." on stderr, sorted by
code, and the logger's count of the lines it wrote at debug.
The Asahi experiment booted macOS 27.2.1 under KVM with 84f164fff's
Ambrosia module and arm64e kexts to all 14 of check-boot's checks, and
again on a QEMU built without the ISV=0 emulator commits, with no data
abort. Our module's ECAM read was the emulator's first case only before
8e7e0aa71. Replace the earlier 12-of-14 note.
The arm64 boot check now covers 27.2.1 beside 14.6.1 to 27.0.1. 27.2.1 boots
only on Ambrosia's development (0e6489b on), not on 0.1.1, and the docs say so,
with the pass on the M3 Max under HVF and its control on the set without
27.2.1's swap layout.
vendor/qemu's bd5ac1ce to 3892a92f, the Asahi Linux experiment's next four
patches for vmapple under KVM on an arm64 Linux host. KVM refused macOS's
pointer authentication calls with x1 to x3 zeroed, where HVF and TCG write x0
alone, and XNU keeps x3 of GET_DEFAULT_KEYS, so launchd died of a pointer
authentication failure; QEMU now answers them as HVF does. KVM's data aborts
with no instruction syndrome, such as the option ROM's ECAM read, got an
external abort; they now go through the ISV=0 emulator HVF used, moved to
target/arm/isv0-mmio.c, in a strict mode that leaves the abort where QEMU has
no device. HVF's calls to the moved emulator are unchanged.
docs/qemu.md's "Beside a build" gives the M3 Max's numbers: metal-app at
60 beside 16 spinning processes, 22.5 to 24.4 beside 64 and 13.4 beside 128
with the vCPUs at the default QoS, the guest's own sleeps up to 1.9 s late
while a host thread on a 60 Hz grid kept every tick, and 59.9 beside 64 with
5658f96c's user-initiated vCPUs, a frame later than on an idle host.
docs/lessons.md says how a gate's slow metal-app beside a build reads, and
how to tell the guest's CPU from the device's refresh.
vendor/qemu's 5658f96c starts each HVF vCPU thread at the user-initiated
QoS. At the default QoS, a build's, a vCPU running the guest's work is one
CPU-bound thread among the build's and gets a share like each of them: on
the M3 Max beside 64 spinning processes, an arm64 macOS 27.0.1 guest's own
timers fired up to 1.9 s late and a full-screen Metal app in it presented 22
frames a second, against 60 alone. A host thread sleeping on a 60 Hz grid,
as the device's refresh thread does, kept every tick under the same load.
The arm64 gates on the M3 run beside potluck's builds, and one boot's probe
ran at 39 frames a second beside a full-core cargo build for that reason.
HVF is built on macOS alone, so Linux's QEMU is unchanged.
Under KVM on an arm64 Linux host the kernel serves PSCI, so a secondary CPU
macOS powers on starts from KVM's reset state: arm_set_cpu_on() never runs,
cpu-on-copies-pauth-keys never copies the boot CPU's pointer authentication
keys, and every secondary hangs on a PAC-corrupted return (seen by the Asahi
Linux experiment, M2 Pro, macOS 27 at -smp 4).
vendor/qemu (steelbrain/reims-vgpu) gains three commits, from that
experiment's patches:
- 570daa78 target/arm/kvm: kvm_arm_forward_psci_cpu_on() has KVM pass PSCI
CPU_ON (SMC32 and SMC64) to QEMU through KVM_ARM_VM_SMCCC_FILTER (Linux 6.4),
whose KVM_EXIT_HYPERCALL starts the target through arm_set_cpu_on() and then
hands KVM its reset state and power state;
- da466bd8 hw/vmapple: calls it under KVM when -smp is above 1, fatal where
the kernel has no filter;
- 5093524e hw/vmapple: under KVM its CPUs get pmu=off and PSCI 1.1, which
macOS's ApplePSCI takes (it refuses 1.3), so the command line needs neither.
All of it is behind kvm_enabled(): under HVF and TCG nothing changes. docs/
qemu.md's branch table has the row.
Every build, test, boot and copy on the shared machines has run as a
potluck job since 11-05, and the job's lease is the lock: --gpu holds a
GPU, --exclusive gives a timing run the whole machine. gpu-locks.sh and
metal2vulkan's maclock took lock files potluck never sees, so a run under
them could still share a GPU with a potluck job.
AGENTS.md, the boot section of docs/qemu.md, the video checks, the cost
benches' docs and the oracle README now name potluck's lease. The
conformance scripts take no lock of their own, and lane-gate runs its
tests under its job's lease. A build holds no GPU: it builds in a job
without --gpu, and the tests run in the same workspace holding one.
The owner keeps the pin 36 scroll result as a to-do in the orchestrator's
notes, not in docs/qemu.md: it records an open fix, not a fact of how QEMU
or the VMs run.
Pin 36 landed on the owner's word with one 12.7.6 scroll block measured
and the second, with 26.7.2's, stopped, to be fixed forward. Its block
showed 3 rAF gaps of 100 ms or more against pin 30's 2, 30 of 50 ms or
more against 17, and 28.7 presents a second against 29.6, each gap on block
makings' direct compactions on the runtime's block-making thread, mostly of
68 MiB image-pool blocks. docs/qemu.md records the measurement, what pin 35's
exportable fill did before it, and that the rest is metal2vulkan's to fix.
Graft 0.1.0 (commit bb884fe, release zip sha256 2bea380e) is Graft's first
public release: bundle id ai.aneesiqbal.graft, serving only
ai.aneesiqbal.ReimsGraphics and ai.aneesiqbal.RgfxGate, with a C++17 SDK tool,
graft-kext, that consumer.mk builds from source with Xcode's clang++ in place
of the Python SDK. Its zip, copied by its own tools/vendor.py with the record
of all 156 files, puts Graft's source tree, the two kexts and the SDK in
guest/graft; the kexts sit at guest/graft/Graft.kext and Graft-arm64e.kext,
with no built/ any more, so the set's staging, its Graft check and the lane
gate read them there. The only binaries are the two kexts. AGENTS.md now says
guest/graft is Graft's release as vendor.py copies it.
RgfxGate depends on ai.aneesiqbal.graft 0.1.0, Graft's compatible version.
Graft hands an arm64e route's original back as a void * holds a function
pointer, discriminator 0, so RgfxGate keeps each AMFI original in a void * and
converts it to its mpo type at the call, which re-signs it; a typed variable
written through a void ** would authenticate with the type's discriminator and
fault. The static_asserts on the wrappers' discriminators stay. Graft's kernel
side refuses by name where it could have panicked, among them an arm64e AMFI
slot not signed with its operation's discriminator and a donor table that
differs from the live vtable.
set-check checks the prelinked collection with graft-kext check-prelinked,
which takes prelink.py's arguments and exit codes. Graft reports a bound
consumer as "bound: imports and vtables committed;" and either waiting for the
device or "activation gate open on the device nub"; the lane gate's graft-bind
passes only on the open gate, since only then does IOKit start ReimsGraphics.
Graft's own id moves in stage-config.py and docs/qemu.md, check-boot marks a
panic report naming ai.aneesiqbal as ours, and msi-appload posts its
measurement notification under the new prefix.
The prebuilt sets are rebuilt from these sources in their own commit.
The owner moves our reverse-DNS names from com.steelbrain to ai.aneesiqbal,
keeping each name's last part: ReimsGraphics, RgfxGate and the Metal bundle
(reims-graphics) take the new prefix. Graft 0.1.0 pins these new consumer ids
and refuses the old ones, so this lands with its adoption. What the guest sees
changes with it: the kexts' bundle ids, the Graft gate property
(ai.aneesiqbal.ReimsGraphics.graft-bound) and the registry root's
GraftClient.ai.aneesiqbal.* keys. The boot checks match the new names.
The prebuilt sets are rebuilt in the adoption batch, on Graft 0.1.0.