Commit Graph
86 Commits
Author SHA1 Message Date
Anees Iqbal d3cd30088b 🔥 Delete the import twins, the files of zeros and their budget
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.
2026-11-14 09:27:31 -08:00
Anees Iqbal 372f39e877 🔥 Delete the client-direction tests of host-made surfaces
tests/client_direction.rs made host-OS IOSurfaces read-only for the GPU
(kIOSurfaceClientDirection) and wrote through them, its blit test faulting a
Mac's GPU on purpose. No production caller has made a host-OS IOSurface since
110b53637: the reims-graphics device's surfaces are the guest's pages, which
the library reaches through buffers, so nothing the guest or the host observes
changes. nextest's override for the fault test goes with it, since a filter
that names a binary the workspace no longer has fails every run, and the
lesson it taught says the test was deleted.
2026-11-14 08:30:30 -08:00
Anees Iqbal cee5813f21 📝 Record that a wrapper must forward a HostVm default [ci skip]
Group dma-bufs were implemented on LinuxVm and FakeVm, and every test passed,
while remap::VulkanVm, the VM the devices are given, answered the trait's
default: a Geekbench walk on the 780M grouped no view. view_mappings had the
same gap. Record the trap, the lint that now keeps it shut and its sign, a
feature's counter at 0 on the hardware it is for.
2026-11-14 08:07:42 -08:00
Anees Iqbal 39783f7d90 📝 Record the guest's stalls beside a terminal's build [ci skip]
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.
2026-11-13 20:42:23 -08:00
Anees Iqbal 99d927a987 📝 Record the desktop over a timed Metal app as a trap [ci skip]
Apple's Modern Rendering sample ran 8% slower on the RTX 3090 in each run
after 843056209, with WindowServer at 6 times the render encoders, and the
commit was blamed. The runs' desktops differed: an active window with a glass
sidebar lay over the sample, which the harness never brings to the front, and
WindowServer drew twice the command buffers at three times the encoders. One
build read 4.74 frames a second with the Finder window over the sample and 5.18
with the sample in front, so the lesson says how to spot the next one.
2026-11-13 12:21:54 -08:00
Anees Iqbal 7fc3deed4e 📝 Record the device's QMP and BQL waits as a lesson [ci skip]
QMP's screendump held every QMP monitor while the display read it waited
for never ended, and the teardown's release under the BQL waited for a
route call that took the BQL. Both are traps of the same kind: a host call
that waits on device work while holding what other parties wait for. The
lesson says how each showed and how to spot the next one.
2026-11-13 12:10:36 -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 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 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 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 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 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 5212c7b692 🐛 Clear the HVF GIC's SPIs when an arm64 guest reboots
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).
2026-11-12 11:47:37 -08:00
Anees Iqbal 6f98f2664a 📝 Record that an address and a length are not memory [ci skip]
The trap behind the pages block join's check: a cache kept by a process's
virtual address joined new memory to a block of old pages, and unit tests never
remapped an address.
2026-11-12 04:21:43 -08:00
Anees Iqbal 2c4edf33da 📝 Record the AIR reader's and the library URL's traps [ci skip]
Two traps the bundle's fixes came from: a reader whose conservative fallback
hid every OpenCL kernel's arguments (only a log line showed it), and Metal
reading a library URL by its path where Foundation's URL loading refuses a URL
of no scheme, which left Espresso with no kernel library.
2026-11-12 03:49:54 -08:00
Anees Iqbal 55b05bc419 📝 Record why a cache in its source's layout hid its shadows [ci skip]
A device cache keeps an IOSurface's guest layout, so a texture over it whose
rows miss the GPU's linear pitch is the runtime's shadow in VRAM, which no
count of the caches' own copies showed. The trap goes in docs/lessons.md
with the XTX walk's numbers before and after the rows were aligned.
2026-11-12 03:39:50 -08:00
Anees Iqbal 53a5dfcf72 📝 Record what macOS finds on NVMe, and the 10-27 cause [ci skip]
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.
2026-11-12 03:22:29 -08:00
Anees Iqbal 6000cf1fcb 📝 Say how the bundle's debug lines are read now [ci skip]
The bundle's os_log lines go to a subsystem of their own since the change
before the sets. conventions.md names it beside the bundle's once-a-kind
logging, with what its NSLog lines keep, and the lesson on the unread
counter says what read it on 26.7.2 and 27.0.1, and that a probe of the
counter reads a resource's answers once its buffer is scheduled.
2026-11-12 02:35:28 -08:00
Anees Iqbal b62270b59e 📝 Record why a hardware test needs the exit gate [ci skip]
The VA-API hardware tests opened their displays on a runtime with no exit
gate, and one aborted at its exit after it passed. Say how to spot the next
test of the hardware that runs beside the driver's exit-time destructors.
2026-11-12 02:27:46 -08:00
Anees Iqbal 7fab68dab2 📝 Say why a timing boot runs on a clone, not an overlay [ci skip]
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.
2026-11-12 01:21:33 -08:00
Anees Iqbal be10b4df83 📝 Say why a lost screen region can be a redraw over bad textures [ci skip]
The arm64 26.6.2 Dock lost a region of icons after an app quit whose edge cut
one icon in two, which read as that region's surfaces failing to upload. It was
WindowServer's damage rectangle redrawn from textures already wrong: every
IOSurface was in place on the M3 host, the bundle counted no upload, and the
loss followed the size the icons were drawn at, not their content. The lesson
says how to tell the two apart before chasing the copy path.
2026-11-11 20:55:00 -08:00
Anees Iqbal dad771fc5f 🐎 Fold a made import's view where its GPU keeps the pages
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.
2026-11-11 20:29:39 -08:00
Anees Iqbal a308583a50 📝 Say how a host build stretches a TCG guest's launch storm [ci skip]
m3-max-17945 ran arm64 macOS 14.6.1 under TCG on the 780M with a cargo
build from scratch beside the whole probe. The probe's call took 121 s
against 53 to 62 s in quiet boots, and it presented half the frames a
second. Its main thread sat runnable after its exec, while the library's
command buffers stayed at 3.4 ms p99, and amdgpu's order-9 allocations
stalled metal2vulkan's threads 8 times for at most 0.06 ms each. The
lesson now says the build stretches the guest's side, not the device's.
2026-11-11 17:17:10 -08:00
Anees Iqbal 9d9c8abaad 📝 Say why a fixed white threshold read a widget defect as gone [ci skip]
A runtime change was judged to fix the 27.0.1 weather widget's white edge
strips on three boots a scorer read as clean. The scorer took pixels with
every channel at 240 or more as the defect, and the widget's strips are
Read against the region's own colours, the three boots were two combs and a
strip, and none of the 33 saved 27.0.1 screens was clean. The lesson says how
to score such a defect and to check a known-bad screen before trusting a clean
result.
2026-11-11 17:09:47 -08:00
Anees Iqbal 3f73b29476 📝 Say which GPU each launch-storm boot ran on [ci skip]
Two of the four jobs the lesson cites ran their device on homelab-um870-1's
RTX 3090, not the 780M, as their exclusive lease listed the 3090 first. The
guest's storm and its spindumps do not depend on the host's GPU; the
library's command buffer times do, so the lesson names the GPU of each.
2026-11-11 17:05:46 -08:00
Anees Iqbal 72163a7d9a 📝 Say why a TCG guest shows a new window late after login [ci skip]
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.
2026-11-11 17:05:46 -08:00
Anees Iqbal 167ba0be50 🐛 Run check-boot's TCG device on the leased GPU, and say host load
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.
2026-11-11 17:05:46 -08:00
Anees Iqbal 38e0a32fa1 📝 Say why a guest's debug counter read as no line [ci skip]
The webgl11 lane's count walks read the guest bundle's resource-wait counter,
an os_log_debug line on OS_LOG_DEFAULT, through the unified log. On macOS
26.7.2 and 12.7.6 the debug stream dropped every line under a walk's load, and
on 26.7.2 the log store kept none: the system mode persists no debug lines, and
a per-process mode was refused. The zero was no reading at all. The entry says
what such a counter needs (a subsystem of its own, or the default level) and
how to spot the next one.
2026-11-11 16:45:15 -08:00
Anees Iqbal 4292628ec8 📝 Say why a resource answer measured at a commit misled [ci skip]
A resource SPI answer the bundle took from an M3 probe right after a commit
was the answer before scheduling; Apple's GL renderer asks after the buffer is
submitted, where the Intel 630 and the M3 wait. The lesson says how the stale
read-back showed and how to spot the next such answer.
2026-11-11 15:20:18 -08:00
Anees Iqbal 07767193ed 📝 Say how an x86-64 guest picks its scale and follows a resize [ci skip]
The design doc said x86-64 macOS picks its default scale by the window's
width alone. That was measured, but it was not the rule. CoreDisplay starts
a built-in display HiDPI by its density, and any display by width where its
EDID is 32 inches or more. The framebuffer now answers to both: its display
is built in, and its EDID is a 1920 x 1080 display's at the screen's
density. The doc says so, with what was measured on 11.7.11 to 26.7.2.

lessons.md gets three traps. The 3800-pixel rule applies to built-in
displays too, which a first reading of the code missed. An EDID that stays
the same across window sizes stops the guest following the window. And a
mode the framebuffer keeps listing for a reader mid-change was restored on
a display resized to another size.
2026-11-11 14:04:05 -08:00
Anees Iqbal b22535736b 🐛 Answer Metal's 16 for both IOSurface alignments again
Since 18b642dab the guest's Metal device answered iosurfaceTextureAlignmentBytes
and iosurfaceReadOnlyTextureAlignmentBytes from the host's runtime, 128 on an
NVIDIA GPU and 256 on RADV, so that CoreAnimation would round its backing
stores' rows to what the host takes in place. CoreAnimation also refuses a
Metal texture of any surface whose rows or planes are not at a multiple of
that answer, and the surfaces other code makes keep their own rows. In macOS
26.7.2 guests on an RTX 3090 and an RTX 2080, WindowServer logged "Failed to
allocate MTLTexture from IOSurface ... Row bytes (5312) not 128 aligned" for
rows of 192 to 14272 bytes, and Safari drew pages blank and WebGL black on
every load (appwalk2 walks m3-max-16925, -17008). On a Radeon 780M, at 256, it
found Safari's 1080p and 2160p video frames without the proper alignment.

What the guest observes: the device answers 16 for both again, as Metal's
devices and the IOGPU base do, whatever the host's GPU answers. On RADV the
backing stores' rows go back to 64-byte multiples, so the runtime shadows
those 18b642dab moved in place (1399 textures over a cold boot and a Safari
scroll of macOS 11.7.11 on a 780M).

test_iosurface_alignments_divide_other_codes_surface_rows holds the answer to
the rows WindowServer refused; the member register lists both as Metal's. The
trap is in docs/lessons.md.
2026-11-11 13:09:30 -08:00
Anees Iqbal 1ee966bce7 🐛 Let go of the platform's GPU devices once nothing holds them
The platform kept every runtime device it adopted to the process's end, with
the caches it made of them and the threads that hold them. On NVIDIA's
proprietary driver an exit with a device live can end with SIGSEGV inside the
driver's exit handler, which tears its SPIR-V compiler down while a worker
thread the driver started from the device's thread still runs in it: on an
RTX 3090 (620.70.06), 6 of 80 exits right after the device's in-place check,
0 of 80 with the device dropped first (measured by metal2vulkan's
maintainers). Vulkan has no call that waits for that worker, so the device
has to go before the exit.

reims_vgpu_vulkan::let_go::let_go_of_devices waits, bounded, until nothing
beyond the platform's own keeps holds an adopted device, then takes them all:
DEVICES, the libraries of its shaders, its no-draw and predication pipelines,
the device the sampler mempool follows, the device format answers come from
(now droppable), and the devices handed the guest's RAM. A device object's
drop stops its awake, work-log and warm-pass threads and joins them before
its runtime device's handle goes, so the runtime's teardown runs on the
let-go's thread. Where a handle outlives the bound, nothing goes and the
answer names the device. A device adopted after it is a new runtime device.

Nothing calls it yet but the tests. The test that faulted,
an_adopted_device_starts_its_in_place_check, now lets go of its device before
it returns, and new tests hold the let-go to a buffer still live and to every
cache, and the awake thread's stop. The trap is in docs/lessons.md.
2026-11-11 10:35:16 -08:00
Anees Iqbal b31748b637 🐛 Unmap memory under a runtime import only once it is freed
The runtime frees a no-copy object's host-pointer import on its own threads,
after the object goes: once the command buffers that used it ran their
completed handlers, or when its residency thread lets an idle one go. Memory
the library does not unmap itself was unmapped as its objects went, while an
import of it could still be live. On a Radeon 780M (RADV, Linux 7.3.3) the
decode test shared_surface_composites unmapped its region, mapped by
Region::new, while a handler thread freed a buffer's import of it: amdgpu's
notifier faulted the kernel (amdgpu_hmm_invalidate_gfx, from the test's
munmap, length 0x8454000, that region's), and the GPU hung until a reboot.

- Tests on a real platform take their region from the platform
  (platform::test_region), whose unmap waits for every import's hold.
- remap::wait_unimported waits, bounded, until no hold or keep lies over a
  range; the tests' own memory (heap pages, their RAM, the cost rig's RAM)
  is freed only after it.
- The runtime's imports of the guest's RAM whole carry a keep of each range
  in their keep-alive (remap::ImportKeep), so that wait sees them.
- learn_view_imports' probe pages go into the probe buffer's keep-alive and
  are unmapped once the runtime freed its import, not as the buffer drops.

The new test on_vulkan_a_test_region_outlives_the_imports_of_its_pages holds
a no-copy buffer over a test region past the region's drop and checks the
page is still mapped, then that the wait ends once the buffer goes; with
Region::new the page was gone at the drop. Nothing the guest or host sees
changes. The trap is in docs/lessons.md.
2026-11-11 10:35:16 -08:00
Anees Iqbal 4107c69205 🆕 Give the OS the display's density from its host screen's scale
What the guest observes changes. Both kexts take DISPLAY_SCALE and state
the display's density as 110 pixels per inch a point of its host screen:
110 at 1x, 220 at 2x, 231 at KDE's 2.1, and 110 before the window first
draws. The x86-64 kext puts it in the EDID's size and each mode's size in
millimetres, the arm64 kext in DisplayAttributes' size and the dot pitch,
which before followed the native width (220 from 2880 pixels, else 110).
The x86-64 kext's modes are valid for HiDPI only on a screen above 1x, at
any size whose pixels halve exactly, where before every mode 2880 pixels
wide or more was.

The arm64 guest's default follows the published size, so it now runs at
1x on a 1x screen and HiDPI on a screen above 1x at every window size
(measured on 14.6.1 and 26.6.2), where before it ran HiDPI from 2880
pixels wide and at 1x below, whatever the screen. The x86-64 macOS 26.7.2
guest decides by width alone: it starts HiDPI from 3840 pixels wide and
at 1x below, whatever the EDID's density (110, 220 and 330 ppi) and the
flag (a mode 3888 pixels wide on a 1x screen started HiDPI), so its
default is as before, and what changes for it is which modes carry the
HiDPI flag. The lesson and design.md record it.
2026-11-11 10:19:26 -08:00
Anees Iqbal fa9c4d300a 📝 Record that 11 to 13 give CLI tools no default device [ci skip]
A probe of Foundation and Metal alone got nil from
MTLCreateSystemDefaultDevice on macOS 11.7.11, 12.7.6 and 13.7.8 guests,
while MTLCopyAllDevices listed our device, and the same binary got the
device once CoreGraphics was loaded. That is the behaviour Apple documents
for command line tools, not a fault of the device, and it cost a round of
diagnosis that looked at the registry first. The lesson says how to tell.
2026-11-11 06:32:24 -08:00
Anees Iqbal 7565966aec 📝 Record NVIDIA's exit crash after a test unloads Vulkan [ci skip] 2026-11-11 05:51:31 -08:00
Anees Iqbal 9e2f9e90fd 🐛 Lower IOSurface's limits to what the device's textures take
IOSurfaceRoot answers INT_MAX for the largest surface's width, height and bytes
per row (IOSurfaceGetPropertyMaximum) until an accelerator lowers them at its
start, as a Mac's GPUs do: 16384 wide and tall on the Intel and AMD Mac, with
131072 bytes a row, and 16384 and 32768 on the M3. The kext lowered none, so
our guests answered INT_MAX. Safari 16.6 under macOS 13 divides the maximum
width by the screen's scale in float to size the tiles of a page that scrolls
only vertically: at 1x that is 2^31, its int overflows, and every such page drew
only its scroll bar, on every host GPU. In a HiDPI mode the same page drew.

The kext now lowers them at its start, from the device info: the width and the
height to the device's max_texture_width_2d and max_texture_height_2d, which
the bundle answers to Metal, and the bytes per row to that width times 16, the
largest pixel a texture over a surface has (RGBA32Float). updateLimits' three
limits are named from a measurement: a probe kext's three distinct values, read
back in a 13.7.8 guest, came out as the bytes per row, the width and the height.
The row alignment the kext asked for before is asked for as it was.

What the guest sees: IOSurfaceGetPropertyMaximum answers the device's width and
height (16384) and 16 times the width a row, where it answered 2147483647.
surface_limits_test holds the limits it takes from the device info.

Checked: make -C guest test, both sets and prebuilt-check on the M3 Max. Cold
boots with this change's library and set, through the desktop, Finder,
Launchpad, Mission Control, Safari and the tall pages: 11.7.11, 12.7.6, 14.8.9
and 15.8.2 on the 780M, 13.7.8 on the 780M and the 3090, 26.7.2 on the 780M,
and arm64 27.0.1 under HVF (check-boot, 15 of 15). Each answered 16384, 16384
and 262144, and 13.7.8 drew the tall pages at 1x.
2026-11-11 05:03:01 -08:00
Anees Iqbal b7e6ab2cc2 🐛 Read the guest's logs where check-boot's checks look for them
Over ssh the guest user's shell is zsh, whose log builtin takes the name and
fails on log show's arguments; with its stderr thrown away, grep -c counted 0,
so amfi-map's AMFI half and ax-matrix passed on every boot without reading a
line. Name /usr/bin/log in those reads. page-count's kext lines are not in
the unified log at all (our IOLog lines reach the kernel's message buffer
alone), so read them with sudo dmesg. Record the trap in docs/lessons.md.
2026-11-11 04:57:55 -08:00
Anees Iqbal 1176c68272 📝 Record a KVM guest's frame rate beside a build on Linux [ci skip]
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.
2026-11-11 04:00:29 -08:00
Anees Iqbal 2c3fbdc7ff 📝 Pin a held GPU: tests run on the library's own pick [ci skip]
A leg that held gem10's RTX 3090 and named no device ran its Vulkan tests on
the Radeon 780M, the library's measured pick kept in the tests' cache, and the
device cache's planes test passed there and failed on every leg that pinned
the 3090. docs/lessons.md now says how a test process picks its GPU, how to
pin the held card, and how to spot a run on another one.
2026-11-11 03:27:14 -08:00
Anees Iqbal 68828b93d6 📝 Record an arm64 guest's frame rate beside a host build [ci skip]
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.
2026-11-11 02:00:30 -08:00
Anees Iqbal 9906e201c7 📝 Record the lock order a frozen 12.7.6 desktop taught [ci skip]
The deadlock bfc3e18f2 fixes had no test and no earlier round that showed
it, and its only sign in a boot was a desktop that stopped with no fatal
line: the lesson says what decides the kext's lock order and how a spindump
shows the next one.
2026-11-09 06:32:20 -08:00
Anees Iqbal 3f683a0986 🐛 Fail set-check on any weak import, which OpenCore cannot bind absent
set-check let a weak import through when OpenCore bound it to 0, but 0 at link
time is not 0 at run time: the kernel rebases the word by the collection's
slide, and the kext read the result as a definition and called it on 11.7.11.
No word tells an absent weak import from a present one under OpenCore, so the
check now fails on any weak import in the set; a name some release lacks is
bound through Graft, which binds it to gOSKextUnresolved. The lessons entry
says so, and that set-check proves a kext links and injects, not that it runs.
2026-11-09 02:01:02 -08:00
Anees Iqbal 292f55782f 📝 Record the brittle release allow-list trap [ci skip]
A version-keyed allow-list for a private kernel-struct offset refuses
releases where the offset is in fact correct; prove the offset in-kernel by
data reads, never by calling through an unproven pointer. And a "pass ended"
flag is not a "pass succeeded" flag.
2026-11-09 01:23:28 -08:00
Anees Iqbal 723a6c72e1 📝 Record the arm64e PAC trap on a looked-up address [ci skip]
A kernel address looked up at runtime and cast to a function-pointer type
panics an arm64e kext at the call site under FEAT_FPAC, because the cast
authenticates a raw value. Sign it for the schema the call site uses.
2026-11-09 00:43:09 -08:00
Anees Iqbal 4377c7ebcb 🐛 Link the arm64e bundle with small objc stubs so its set reproduces
Two builds of one tree gave two arm64e RgfxGate binaries, alternating
(three clean builds on the M3 Max: A, B, A). They differed only in the
Metal bundle's arm64e image inside RgfxGate: its UUID, its signature and
__objc_stubs. ld (ld-27106.1) makes two slots for objc_msgSend in the
authenticated GOT, one for the message-send stubs and one for
objc_msgSend's own call stub, and gives each stub its slot in either order
from one link to the next. The arm64 image, whose GOT is not
authenticated, was the same every time.

The arm64e bundle now links its message-send stubs in their small form,
which branch to objc_msgSend's call stub and take no GOT slot of their
own, so the one slot leaves nothing to order. docs/lessons.md records the
trap.
2026-11-08 23:07:49 -08:00
Anees Iqbal 624ce770ca 🐛 Reach the weak page count only through a pointer in data
OpenCore's linker binds an unresolved weak import to 0, and the kext's
direct call to IOMemoryDescriptor::getPageCounts's three-count form is
relative to the instruction, so it cannot reach 0: on the Boot KCs of
11.7.11, 13.7.8 and 15.8.2 the linker reported "RIP-relative overflow ...
target=0x0" and left ReimsGraphics out of the kernel collection, which
would boot those guests with no display driver (make -C guest set-check
with OpenCore's TestKextInject; 26.7.2's links, the symbol resolved).

The function is now reached only through a volatile function pointer in
data, whose whole address the linker binds, 0 or gOSKextUnresolved where
it is absent, and the code reads that word, never the symbol.

make -C guest set-check now passes a weak import the linker bound to 0,
where the kext was injected, and names it; any other import bound to 0
fails as before. docs/lessons.md records the trap.
2026-11-08 22:59:17 -08:00