Two builds of one tree gave two arm64e RgfxGate binaries, alternating
(three clean builds on the M3 Max: A, B, A). They differed only in the
Metal bundle's arm64e image inside RgfxGate: its UUID, its signature and
__objc_stubs. ld (ld-27106.1) makes two slots for objc_msgSend in the
authenticated GOT, one for the message-send stubs and one for
objc_msgSend's own call stub, and gives each stub its slot in either order
from one link to the next. The arm64 image, whose GOT is not
authenticated, was the same every time.
The arm64e bundle now links its message-send stubs in their small form,
which branch to objc_msgSend's call stub and take no GOT slot of their
own, so the one slot leaves nothing to order. docs/lessons.md records the
trap.
OpenCore's linker binds an unresolved weak import to 0, and the kext's
direct call to IOMemoryDescriptor::getPageCounts's three-count form is
relative to the instruction, so it cannot reach 0: on the Boot KCs of
11.7.11, 13.7.8 and 15.8.2 the linker reported "RIP-relative overflow ...
target=0x0" and left ReimsGraphics out of the kernel collection, which
would boot those guests with no display driver (make -C guest set-check
with OpenCore's TestKextInject; 26.7.2's links, the symbol resolved).
The function is now reached only through a volatile function pointer in
data, whose whole address the linker binds, 0 or gOSKextUnresolved where
it is absent, and the code reads that word, never the symbol.
make -C guest set-check now passes a weak import the linker bound to 0,
where the kext was injected, and names it; any other import bound to 0
fails as before. docs/lessons.md records the trap.
The boot harness's 60/s wheel ran on the clock the refresh grid ticks on, so a
scroll run's clicks kept one offset into the refresh for the whole run. Runs
whose clicks fell at a frame's edge composited at 30 Hz for seconds with every
present on time, and read as a device stall that came and went. A boot that
set the offset (0.3 and 15.2 ms against 9 ms) showed the offset alone decides
it.
A scroll A/B of two metal2vulkan pins on the 780M showed vkQueueSubmit
stalls of 8 ms or more falling from 22 to 1, which read as the new pin's
gain. The same arms in the reverse order gave 20 and 1: the boot that ran
first, right after a build or a perf run on the host, stalled, and the
second did not, whichever pin it ran. The lesson says how to spot it and
how to run an A/B that the order cannot decide.
The cut of the VA arm's H.264 answer to 65,535 macroblocks kept the driver's
largest width and lowered the height. radeonsi answers 4096x4096, which came
out as 4096x4080, but iHD answers 8192x8192 in VAConfigAttribMaxPictureWidth
and Height, which came out as 8192x2032: the guest's video driver would then
refuse 3840x2160 and every H.264 stream taller than 2032 at its create, and
VideoToolbox would decode 4K H.264 in software on Intel hosts.
iHD decodes nothing wider than 4096: its surfaces' bound is 4096x4096, and
ffmpeg's VA-API decode refuses every size from 4112x2160 to 8192x1024 on an
Iris Xe (iHD 26.3.5). So where the driver's largest size holds more than the
bound, the answer is at most 4096 wide and as tall as the bound leaves there:
4096x4080 on both drivers, holding 3840x2160 and 4096x2160. The test now
feeds iHD's answer too, and the sizes users play.
For the guest: on an iHD host H.264's largest size is 4096x4080, where it was
8192x2032 since the bound came in.
Two traps the macOS 11 WebGL work found: a guest framework that looks for the
GPU by what a Mac's GPU states and gives up without a word, and a system
LLVM whose exported C API differs by release, which the build Mac's tests
never meet.
The exit lesson's VA shapes now carry the runs that followed the fix on the
Iris Xe: 60 full-workspace runs under glibc's malloc checks with no failure at
exit, against 2 in 100 before it, and a program of its own whose vaTerminate
after iHD's destructors ends cleanly in 400 runs, so the abort needs live
decode state in the display.
A process's exit runs its exit handlers and its libraries' destructors on the
exiting thread while the library's other threads go on. A device's display let
go as a test process exited made its last vaTerminate on the device's thread
beside the driver's exit-time destructors: on the Iris Xe (intel-media-driver
26.3.5) test processes aborted after "ok" in iHD's frees, "double free or
corruption (out)" and "free(): invalid pointer", in 2 of 90 runs of the
workspace's tests. A host that quits with a display open meets the same race.
Two holes let the call through. The exit gate's handler was last registered
before vaInitialize loaded the driver, so the driver's destructors ran before
it; and the VA crate's Calls made its at-once calls on the caller's thread
(where its call thread is idle, and in its paths with no thread) without a
step of the gate. The video runtime now registers the gate's handler again
after each vaInitialize (Runtime::arm_exit, the platform runtime's
exit_gate::arm), and every VA call takes a step, so the exit waits out a call
in progress before the driver's destructors run, and parks a thread that
would make the next.
For the host: a process that exits with a VA display open no longer aborts in
the driver; a thread that would call VA once the exit began parks until the
process ends. The C API's release is unchanged.
no_call_runs_beside_a_drivers_exit_time_destructors holds the pattern without
a driver: a child process with a stand-in for the driver's destructors and a
runtime gated as the host's exits while another thread makes Calls' at-once
calls; without the steps the child ends as a call reaches the stand-in after
its destructors ran.
The framebuffer names its accelerator in IOAccelTypes by the accelerator's
service-plane path, which IOAccelFindAccelerator follows, and with it OpenGL's
list of renderers in a process with no WindowServer connection. The framebuffer
starts first and names it through the PCI device's name; the accelerator then
renames the device GFX0, so the path led nowhere. IOAccelFindAccelerator failed
for our framebuffer (0xe00002bc), and on macOS 11.7.11 such a process was
offered the software renderer alone (measured: CGLQueryRendererInfo after
CGSSetDenyWindowServerConnections).
The accelerator now names itself again whenever it finds the framebuffer, where
the path there is not its own as it stands (RgfxAccelTypes.hpp, with its native
test). On 11.7.11 IOAccelFindAccelerator then answers 0 and that process is
offered the accelerated renderer too. Safari 14.1.3's WebGL on 11.7.11 still
fails to make a context, for a cause not yet found.
The register's check walked only the public protocols the bundle's classes
adopt, so it could not see the class of member macOS 13's Maps died on: a
member of Metal's SPI counterpart (MTLLibrarySPI for MTLLibrary), which
Metal's own objects adopt and the guest's frameworks send without asking. It
now walks each protocol's SPI counterpart too, and adds the members only
older guest releases' protocols carry, which the Mac it runs on lacks
(tests/protocol_members_releases.txt: macOS 11.7.11, 12.7.6, 13.7.8 and
26.7.2 against 27.0.1).
The register lists every SPI member: the forwarders as implemented, the
constant answers as Metal's with why, and the rest by what the AMD 5300M's
and the Intel 630's objects answer (measured with respondsToSelector:, macOS
26.7.1), counted by class family: pending where both answer (305, to be
answered as Metal's), absent where neither does (54) or they differ (6),
pending where the oracle's macOS lacks the member (14). A new kind, pending,
is checked as absent. The 31 members only older releases carry are absent:
no app pass on those releases showed a framework sending one, and the 4 of
MTLDeviceSPI are answered there by the device's own IOGPU base.
tools/protocol_dump.m dumps a Metal's protocols for the releases list, and
tools/oracle/oracle_spi_members.m asks a Mac's own objects for the verdicts
and what their getters answer. docs/lessons.md says what the trap was.
A process exits on one thread, which runs the exit handlers and the loaded
libraries' destructors while every other thread goes on. A thread of the
library's inside a driver then ends the process: on the RTX 5080 test processes
ended with SIGSEGV inside libnvidia-glvkspirv after their tests passed, and the
awake thread's touches segfaulted 79 times in six minutes before it got a gate
of its own. The runtime's guard covers only the runtime's own threads, and the
platform keeps its devices for the process, so dropping them is no way out.
So the awake thread's gate becomes the library's: reims_vgpu_vulkan::exit_gate.
Each job of the library's threads that may call a driver is a step of it:
every reims-vgpu entry (the C API's calls, the device's callbacks, the jobs of
lanes, compile threads and surface workers), each compile (a making), a
window's frame, a video picture landed or frame encoded, and each call of the
video crate's threads, through a new Runtime::exit_step. An exit handler,
registered at each device's adoption, as a compile pool starts, after each
making and at each power of two of a thread's steps, closes the gate and
waits for the steps in progress on other threads, 2 s at most, or 60 s while
a compile is among them, as the runtime's guard waits for its makings. A step
begun after it ran parks its thread for good, except on the exiting thread.
What the host sees: an exit (QEMU's quit, a test process's end) now waits for
the library's GPU work in progress, bounded as above, where it could end the
process with a signal; a library thread or a call of the host's that would
begin work after the exit began parks. docs/api.md says so. Nothing the guest
sees changes. Tests: a child process that exits mid-compile with a second
compile queued (the first ends, the second never runs), the gate's own exit
children, and the awake thread's exit test on the shared gate.
The answer of a present waited for the window's draw of it, and on an RTX 5080
Laptop GPU every frame of a 30-frames-a-second probe came a refresh late while
its uncapped run did not: the GPU clocks down between frames, and the
composite and the draw each took about ten times their time under load. The
lesson says how to spot the next one: measure at a capped low rate too, and
read the per-present timing lines for the step that grows as the rate falls.
A create that keeps the Mac of the image beside an existing disk would give a
copy of the disk of a VM reims-ctl has that VM's Mac: its serial number, MLB,
UUID and ROM, and its network card's address. The copy can run beside the VM,
and Apple's services know a Mac by those, so two VMs running as one Mac would
be one Mac to them. reims-ctl's network is QEMU's user mode alone, so the two
cards' one address clashes nowhere.
The create now gives such a copy a Mac of its own, as before, and says why;
its macOS opens Setup Assistant once, as on a new Mac. A disk given in place
keeps its Mac: the VM runs that VM's own macOS, and never beside it, since a
start on a disk another VM runs on is refused. A disk from a VM reims-ctl does
not have, whose image is beside it, keeps its Mac as before.
The lesson says what remains: a stop still powers off at its timeout while
Setup Assistant is up, since nothing the host sends without the guest's
password ends it.
A create given an existing disk of macOS and no OpenCore image made the VM an
image presenting a Mac of its own: a new serial number, MLB and UUID. The
disk's macOS then opened Setup Assistant at its first boot. While that is up,
macOS ignores Control-Option-Command-Power and the power button, so every
reims-ctl stop waited out its whole timeout and powered the VM off, which
risks the guest's disk.
A disk taken from another VM's directory sits beside the image it booted from,
as reims-ctl and reims-util leave them (opencore.qcow2, or opencore.img). The
create now reads the Mac that image presents and makes the VM's new image
present it too, with OVMF beside it. The VM's network card gets that Mac's ROM
unless a MAC is given, as a made image's ROM is its card's address. macOS then
sees no new Mac, opens no Setup Assistant and shuts down when asked. Where no
image sits beside the disk, the create makes a new Mac as before and says what
that does.
Measured with a macOS 26.7.2 disk on a Radeon 780M host. The create without
this change gave the VM UUID 95D24845, against the disk's own D507F3EA.
Setup Assistant (-MiniBuddyYes) was up, MiniBuddyLaunch was 1 for any host
and for the new host, and reims-ctl stop --timeout 180 powered the VM off at
181 s. With this change the VM presented D507F3EA and the disk's MAC, no Setup
Assistant came up, and the stop shut the guest down in 9 s. The disk's ByHost
preferences for D507F3EA hold MiniBuddyLaunch 0, and a new UUID has no ByHost
file, so loginwindow took the any-host 1 (docs/lessons.md).
The lesson read as if the harness's sudo wait had been this same trap. The
original harness's wait was real and measured; only a copy of it ran
timeout(1) in the guest, and its failures were waived as that known fault.
A boot harness bounded kmutil in the guest with timeout(1), which macOS lacks,
so every release's kext check failed as a timeout and was waived as a harness
fault for a day of boots. Record how it looks and how to bound a guest-side
command instead.
A git hook and `git rebase -x` export GIT_DIR and its kin to what they run,
and `git -C` does not override them. reims-ctl's update and installer tests,
run under `git rebase -x` in a linked worktree, made their throwaway
repositories in the enclosing one: its shared config became core.bare=true
with the tests' identity, which stopped the main checkout and gave another
worktree's commit the tests' author. reims-ctl update itself ran git and
install-ctl.sh the same way. Each git and script reims-ctl runs on a checkout,
its tests' included, now drops those variables. docs/lessons.md says how to
check commits without it.
Without an -install_name the linker names the cdylib by its output path, an
absolute path in the target directory, and a host linked to it records that
path and loads it whatever its own rpaths. kache restores a cached link with
the bytes first linked, so the C harness of a new worktree linked to a dylib
naming the worktree it was first linked in, and c_harness_passes failed on a
Mac once that worktree was removed.
A build script now gives the cdylib the install name
@rpath/libreims_vgpu_c.dylib on macOS, which the harness, linked with an rpath
to the library's directory, finds wherever the build ran. the_dylib_is_found_by_rpath
holds the install name and the harness's link. cargo xtask dist still renames
the dylib it installs to @rpath/libreims_vgpu.dylib, and QEMU links the archive.
The guest bundle must import none of open(2)'s family: every Metal process
loads it, sandboxed ones included, where a file write outside the process's
own paths is refused and logged (guest/bundle/tests/bundle_files_check.sh).
@available lowers to __isPlatformVersionAtLeast, which links compiler-rt's
os_version_check fallback that reads SystemVersion.plist through fopen, so a
guard written with @available fails that check. The trap, and the presence
check that replaces @available, go in lessons.md next to the LTO one on the
same symbol.
macOS 12's Metal keys every limit of a device on its feature profile and has
none for the M3 Max's 10, which the device answered on every guest: it left
the limits 0 and ended WindowServer at device creation, so 12.x guests never
reached a desktop (launchd gave up after 14 runs).
The device now answers the host's profile only where the guest's Metal knows
it, told by what that Metal has: the MTLArchitecture class, which macOS 13
and later have (13.7.8, 14.8.9 and 26.7.2 boot with 10). Elsewhere (macOS 11
and 12) it answers 10001, as 12's drivers for the 5300M and the UHD 630 do.
26 keeps 10 rather than the x86 Macs' 10002: under 10002 its WindowServer
still asks for a mipmapped tiled texture over a buffer, which the device
refuses (dgpu-oracle.md, Q11, rechecked).
What changes for the guest: featureProfile on macOS 11 and 12 is 10001; on
13 to 26 it is unchanged.
The crate rename's lane found that guest/prebuilt rebuilt from unchanged sources
differs from the committed set unless the build runs with LC_ALL=C (the bundle
links src/*.mm in shell sort order) and SOURCE_DATE_EPOCH at the committed
kexts' date (Lilu's plugin_start writes the build date). lessons.md now says how
to show a change leaves the kexts byte-identical.
The crate that holds the reims-graphics device's wire and transport now
carries the library's prefix, as reims-vgpu-video does: its directory is
crates/reims-vgpu-graphics, its package reims-vgpu-graphics, and its Rust
path and log target reims_vgpu_graphics. The guest's, the option ROM's and
Ambrosia's Makefiles include the wire header from the new directory, and the
prebuilt records name it there.
Nothing changes for the guest or the host. The device keeps its name
(reims-graphics, QEMU's reims-graphics-pci, PCI 1234:5247), and the wire
header keeps its file name and RGFX_ symbols. The C API header is unchanged,
and the prebuilt kexts and option ROM are byte-identical; only the records'
paths and source hashes move. A log filter names the crate's lines by its
new target (REIMS_VGPU_LOG=info,reims_vgpu_graphics=trace), a diagnostic.
The Metal platform is gone (the commit before): AGENTS.md, README.md and the
docs now say the library carries out the guest's calls on the Vulkan
platform, on Linux and on a Mac over MoltenVK for development and tests;
that the display's shaders live in the Vulkan crate; that `cargo xtask
dist` writes target/dist-vulkan on every OS; and that the tests of the
Vulkan platform compare with Metal's recorded answers. architecture.md's
section 4.6 describes the answer layer and the macOS message layer in
place of the metal crate's. conventions.md keeps "core changes as little as
the Vulkan and Linux work allows" without its reason, the Metal product.
testing.md was the behaviour-lock suite's specification and the paravirt
guest ABI; it now says how the code is tested and keeps the Tags convention.
development.md's layout, tests and commands, conventions.md's examples and
the lessons and accuracy-ledger entries that cited the paravirt device, its
FIFOs or QEMU sections that are gone now describe the code there is.
metal_fills_a_colour_it_packs_none_in_with_its_stacks_bytes failed on
development and on a3c88d75b alike: its first format read the selector's
address and a heap address where the earlier fill's bytes, 7 9 3 1, were
expected. A probe of four pairs in one process (m3-max-6495) read those
addresses in the first pair alone; the other three read the earlier fill's
bytes, and a pair that set the stack read its byte even first. Under nextest
each test is a process of its own, so the first format always met what the
process's first send left. Our code is not in that path: both fills go by
objc_msgSend itself, and the control failed the same way.
The test now sends one pair first and compares from the second, with its
expectations as they were: the earlier fill's bytes, and after a stack set to
one byte, that byte. That is what a guest's long-lived process sees, and what
the Vulkan platform's colour fill writes
(leftover_colours_fill_an_earlier_colours_bytes_as_metals). The lesson on
bytes Metal never wrote now says so.
The wire header is an input of the committed option ROM, and a change to it
alone passes the library's checks. 286e89cbd's change landed and left
development red, in reims-ctl's cargo test and in prebuilt-check only. The
entry says how to spot the next one: a diff that touches a file the ROM's
record names rebuilds the ROM in the same branch.
Reverts 0825b1ea2, restoring 0afc30f37, e8d04b187 and ea13ccbca. A write-combined
mapping of the region does take: the region's descriptor is physically
contiguous, and xnu's fault path maps such an object's pages in its own cache
mode (vm_fault's pmap_map_block_addr, read from the public xnu source), which
the earlier reading missed. The page-table probe that seemed to agree saw only
the processes on the CPUs at its instant, not the bench.
Measured on the Radeon 780M host, draws.10k's encode: 9.2-9.5 ms at the base,
7.7 ms with the slabs in the process's own pages alone (936e3968d's set), and
1.05-1.3 ms with the spans write-combined as well (0afc30f37's and ea13ccbca's
sets). The kext's comment and the design doc say why, and docs/lessons.md the
probe's trap.
For the guest, as 0afc30f37: a queue's submission ring starts 3840 bytes into
its block, the kext's Alloc takes a third input and its feature word holds
1 << 7.
Two of gpu::fill's Metal tests failed on the M3 Max (macOS 27.0.1): for a
colour in a format Metal packs no colour in, Metal wrote 80 ef 0b 82 02 00 00
00 42 a2 3d fe 01 00 00 00 where the tests expected the bytes of the colour
fill before it.
Metal packs no colour there. It fills the 16 bytes of the calling thread's
stack where its packing writes a colour. Sent right after another colour
fill, with no call between them, it writes that fill's texel. Sent right
after a call that set the stack below to one byte, it writes that byte.
Both were measured from a plain Objective-C process and from the test
binary. The tests sent through the Metal platform, and in a dev build
objc2 checks the method before each send. That check left the encoder's
class and the selector there as pointers: the bytes above are those two
addresses (measured). So the tests were reading our own build's stack. It
held the earlier fill's texel when the tests were recorded.
The tests now send Metal's two fills by objc_msgSend itself.
metal_fills_a_colour_it_packs_none_in_with_its_stacks_bytes (renamed) pins
both measured answers for every format in LEFTOVER_FORMATS and
UNPACKED_FORMATS. leftover_colours_fill_an_earlier_colours_bytes_as_metals
compares ours, after the earlier fill in the same encoder or in an earlier
one, with Metal's fill sent right after another. Across an encoder's end,
Metal's stack holds other bytes, and the runtime holds the command buffer's
last packed texel: one answer of that envelope. The AMD 5300M and the
Intel 630 (macOS 26.7.1) raise NSInvalidArgumentException at every colour
fill, so they give no other answer to match.
Nothing the guest or the host sees changes. The module's docs and
docs/lessons.md say what was measured.
reims-graphics' device tests were leaky in car 12's and car 13's checks,
and they spawn no process. A probe of tests that only read their own
descriptors and sleep shows why: std on macOS sets close-on-exec on a
child's pipes after making them, so a test nextest starts in that window
holds the output pipe of the test started beside it, and that test is
leaky when the other outlives it. No change to the tests can prevent it.
kache served dist's SDL from a run with none of its flags, as SDL's build
script declares none of them, and a release test link after a dist lost
std's __isPlatformVersionAtLeast to LTO; each says how to spot the next.
metal_drops_small_blits_into_the_texture faults the GPU on purpose, and
a_reservation_of_2_31_minus_1_is_metals holds 16 GiB of its memory for about
a second. On a Mac every process shares the GPU, so each run failed the
in-flight work of every other process, the desktop's included: a stress loop
of the first restarted the GPU under the owner's WindowServer on the M3 Max.
Both are #[ignore]d now, run only for a change to what they test (nextest
--run-ignored only), and nextest.toml still runs them first and alone then.
AGENTS.md and docs/lessons.md say so.
The guest lane's HEVC check took ffmpeg's software decode for the truth, and
a difference on 16x16-CTB streams with SAO and deblocking on was first taken
for a bug of NVIDIA's decoder. x265's reconstruction, NVIDIA's decode,
VideoToolbox's on an M3 Max and the guest's all agree; ffmpeg 9.0.2's
software decode is the one that differs.
The writer's model of AppleGVA's short-term sets put the delta lists where
the flags are, and tests built from the same model passed while the guest
refused the stream that used them; a dump compared field by field with the
stream found the layout.
Tests that pass alone failed under the check's load:
- client_direction's GPU-faulting test failed 9 to 14 others of each
check on the M3 Max; it runs first and alone;
- the Vulkan crate's paging and unmap tests held work in flight with busy
kernels sized for the M3 Max, too short on an RTX 5080 Laptop GPU; each
holds as long as it means, through gpu::spin;
- Metal's compute answers are made in a child the test restarts when the
compiler service crashes;
- a released ICB's ID may come back once the handlers ran, timed by the
crate's clock.
docs say what a busy kernel holds and what it cannot, and tie a compiler
crash's client to its binary.
Source: 3ff3ef405 f278b85aa 88b524c90 92ffe0067 38bd30f60 084cad5ae c442c1d44
294a44dcf
Each worktree's check compiled everything again with full debuginfo and
incremental caches no rebuild used. The dev profile keeps line tables for
the workspace and none for its dependencies, the check builds without
incremental caches, and builds go through kache where it is installed, so
a worktree's first build reuses what another tree built, build scripts
included. Tests read the tree's paths at run time, so a build is the same
in every tree.
scripts/new-worktree.sh makes a worktree from clones of the main checkout's
suite files, and AGENTS.md says a profiling run removes its traces.
Source: 53a4a8edd b568f382e 0c7a0eabc 72c24f74b 10051ba78 8f415697a 73d557f71
bde4220b6 46c7c6b23
A Linux surface's buffers at an offset, or over memory read-only for the
GPU, lay over a second view of the allocation, with a writable twin per
buffer. They now lie over the surface's own view of the pages. The
over_pages registry, which checked every command's uses against textures
that core's flow never places, goes with its searches.
- Placements in Metal's space find the lowest gap by a treap search, not a
walk (33 us a placement at 20k held runs before).
- The search for unmap holds is bounded by the longest live hold.
- A one-range surface's hold starts at the range's first byte, and a
released hold's unmaps are ordered with the VM's fixed overwrites.
- A command buffer's submissions live in its own place, a detached object's
release is stored before its lower count, and a close no longer lets go
of a command buffer that is committing.
Tests count a surface's dma-buf import and say per import path what a remap
under a buffer does on RADV.
Source: 9c12c6687 5995c12f7 586dd3df7 4c87c0bf8 9a7423f9e 06ad006cd 4ad9f7d0c
c592b5830 65c0d62c5 60e369ddf 0eb75522d 8bd0dbac8 f5331d86c 5cdb739ca
8fe111c39 22400b296
This repository now holds libreims_vgpu, a Rust library that is the host
side of the paravirtualized GPU macOS guests drive, in place of Apple's
ParavirtualizedGraphics.framework: the library and its C API
(reims_vgpu.h), the PCI device's option ROM, QEMU's apple-gfx on that API
(vendor/qemu), the behaviour-lock suite that drives the C API as QEMU
does, and reims-ctl, the VM manager users run. README.md says what it is
and how it is laid out, and AGENTS.md how to change it.
Every file of the earlier tree is replaced. vendor/qemu moves to the
steelbrain/reims-vgpu branch of the same public repository.