Commit Graph
871 Commits
Author SHA1 Message Date
Anees Iqbal 5a6aaeda7b 📝 Say what the oldest x86-64 release's kc-check stands for [ci skip]
The kc-check runs against x86-64 11.7.11 for both 11 and 12. That holds for
IOHIDDevice: 12.7.6's defines every name 11.7.11's does and lacks the same ones
(measured on the guests' collections, 2026-11-16). It does not hold for every
class: 12.7.6's collection drops some names 11.7.11 defines. None of them is
one the sets import today, but a set that starts importing from another class
needs a run on 12.7.6 as well.
2026-11-16 02:44:27 -08:00
Anees Iqbal dc64dac461 📝 Record that the newest SDK imports what old releases lack [ci skip]
The trap behind the IOHIDDevice imports: a class inheriting a method imports
it by name, the SDK's headers are the newest release's, and boots of only the
newest releases miss it. kc-check against each set's oldest release is how to
spot the next one.
2026-11-16 02:44:27 -08:00
Anees Iqbal 91211ecb57 ✅ Check the guest's kext sets against a release's KC
Neither make -C guest test nor prebuilt-check links a kext against a kernel,
and set-check needs OpenCore's TestKextInject and covers only the x86-64 set.
So the guest's mouse (21632b275) shipped imports that x86-64 11 and 12 and
arm64 14 and 15 lack, and the merge boots, x86-64 26.7.2 and arm64 26 only,
did not see it.

guest/tools/kc-imports.py takes a guest's kernel collection and a set. It
reads the KC raw, or as an arm64 guest's IMG4, whose LZFSE payload it decodes
with compression_tool. It then fails on each name a kext imports that neither
the collection nor an earlier kext of the set defines, which is the rule
Ambrosia's linker refuses by. An x86-64 kext imports its undefined external
symbols; an arm64e kext imports the names its chained fixups bind, so an
import that Graft binds at run time is not counted. make -C guest kc-check
KC=... KC64=... runs it on guest/prebuilt and guest/prebuilt-arm64e.

It runs on a Mac after a set rebuild, against the oldest release of each set
(x86-64 11.7.11's Boot KC, arm64 14.6.1's kernelcache) and the newest. The
collections are copied out of the guests and kept local: nothing taken from
them is committed. docs/development.md, Testing, says where each one lives.

Against development's sets it named the six IOHIDDevice methods on x86-64
11.7.11 and 12.7.6, and didTerminate alone on x86-64 13.7.8 to 15.8.2 and
arm64 14.6.1 and 15.6.1. Against the fixed sets every import resolves on
x86-64 11.7.11 to 26.7.2 and arm64 14.6.1 to 27.0.1 (m3-max-35732).
2026-11-16 02:44:27 -08:00
Anees Iqbal 7590a54120 ✅ Check that every path the tree tracks checks out on Windows
aux.rs (ad3b37b8e) kept every Windows checkout of development out from
25ff40427 on, through every check, as none checks the tree out on Windows.
`cargo xtask paths`, now the first step of `cargo xtask check`, reads every
path `git ls-files` lists, reims-ctl's and reims-restore's workspaces among
them, and fails on what git for Windows refuses or Windows' file systems
merge: a device name Windows keeps (CON, PRN, AUX, NUL, COM1 to COM9, LPT1
to LPT9, CONIN$, CONOUT$) with or without an extension, a character Windows
refuses (<>:"|?*, a backslash, a control character), a name ending in a dot
or a space, and two paths or directories that differ only by case. Its tests
hold bad names of each kind, aux.rs among them, and names that only start
like a device's.

docs/lessons.md records the trap, and the one beside it: reims-ctl's new
dependency, built for Windows only on Windows.
2026-11-16 02:38:30 -08:00
Anees Iqbal f016133f9e 📝 Record the arm64 boots at two displays and one [ci skip]
The boots that checked the arm64 displays go in docs/qemu.md, as the QEMU and
VM measurements do: on Ambrosia 0.1.3 with our bundle, arm64 14.6.1, 15.6.1
and 26.6.2 under TCG and 27.0.1 under HVF each reached the desktop on both
heads at two displays, display 0 the main one, and booted as before at one;
and what 15.6.1 showed before the release registered the displays in turn.
2026-11-16 02:15:58 -08:00
Anees Iqbal 7b5bae0bcc 🐛 Register the arm64 displays in turn, so display 0 is the main one
A process's notification hands it the services waiting for it last first
(read from macOS 27.0.1's kernel), and the first service WindowServer takes
is its main display. With the window alone, both services could wait at once:
an arm64 15.6.1 guest under TCG made display 1 the main display, at the left,
in one of two boots (m3-max-34945), where x86-64 guests and the earlier arm64
boots make it display 0.

The release now registers one display at a time: the next display's service
only once a process has read dfr, AppleTV or external of the one before, or
the window's deadline has passed; and a process's read of those keys of a
display waits only until the next display's service has matched, not for the
whole window. A process waiting for the services then finds them one at a
time, in display order, and takes display 0's first. The native test runs a
process that takes services last-added-first and checks it takes every
display's, by display, for two to four displays, whether it waits from before
the release or comes during it, and that a process that never reads lets
every display register by the deadline. One display opens no window, as
before.
2026-11-16 02:15:58 -08:00
Anees Iqbal 2d84349f73 📝 Name Ambrosia 0.1.3 and what the window rests on [ci skip]
Ambrosia 0.1.3 is released (tag v0.1.3, 1b924d9), so the docs name it as the
minimum for the list form our configuration now gives, and say that an older
Ambrosia refuses the list. The design says plainly that the registration
window rests on WindowServer reading dfr, AppleTV and external of each service
before it asks for the next, which was read on 27.0.1's framework alone, and
what a release that reads otherwise sees: fewer displays driven, never a hang.
2026-11-16 02:15:57 -08:00
Anees Iqbal ce0d6bf5d3 🆕 Name a display node for each display in our arm64 configuration
Ambrosia 0.1.3 adds a /arm-io node for each display a revision 2 module
reports, from a list of names in Graphics > DisplayNode. Our configuration
now gives that list, reims-display0 to reims-display3, so one bundle serves a
device of any count, and an arm64 guest drives each display. Ambrosia 0.1.1
and 0.1.2 refuse a list, so the bundle needs Ambrosia 0.1.3 or later; this
lands once 0.1.3 is released.
2026-11-16 02:15:57 -08:00
Anees Iqbal a4cad1e0d8 📝 Record the arm64 displays' boots, the window and the pointer [ci skip]
The design's multiple-displays section now says what the arm64e kext takes
and when Ambrosia 0.1.3 lets it, why back-to-back registration needs the
window the release opens (found on arm64 15.6.1), what 14.6.1's kernel and
WindowServer showed against the reading of 27.0.1's framework, and A3: on
arm64 14.6.1 the tablet's absolute position maps onto the display the cursor
is on, as X1 found on x86-64, so the arm64 pointer needs the same crossing.
2026-11-16 02:15:57 -08:00
Anees Iqbal 7db049d0da 📝 Say how arm64 guests drive several displays [ci skip]
design.md's Multiple displays section now answers A1 (Ambrosia's revision 2,
Ambrosia 0.1.3, adds a node per display from a DisplayNode list) and A2 as
read from macOS 27.0.1 (the framework pairs services with display nodes by
count alone and takes one batch of notifications, so every display's service
registers together), and describes the arm64e heads and the registration
hold. docs/qemu.md says that several displays on arm64 need Ambrosia 0.1.3,
and that our configuration names display 0's node alone until it is released.
2026-11-16 02:15:57 -08:00
Anees Iqbal f75c2aca51 🆕 Report the device's displays to Ambrosia's revision 2
Ambrosia's graphics driver interface gains revision 2, in which the
framebuffer's reserved word becomes Displays: how many displays the device
drives, so Ambrosia can add a display-subsystem node under /arm-io for each
one its configuration names. IOMobileFramebuffer.framework counts those nodes
to know how many framebuffer services to wait for, so an arm64 guest can drive
a display past the first only once each has a node before the kernel starts.

The module now takes MULTI_DISPLAY where Ambrosia gives revision 2 and the
device offers the feature, so DISPLAYS lists every display, returns their
count, and fits its mode to display 0's scanout room as the host splits the
span. Under revision 1, or on a device of one display, it takes no feature and
leaves the word zero, as before, so every Ambrosia from 0.1.1 on still boots
it. The configuration's DisplayNode stays the one string: Ambrosia releases
before revision 2 refuse a list.
2026-11-16 02:15:57 -08:00
Anees Iqbal 00d86638f7 📝 Say the guest reads a split buffer's span, not its end [ci skip]
A buffer committed in parts sends a CB_COMPLETE whose gpu_end_ns is its first
part's start plus its parts' GPU time summed, which falls before its last
part's own end by the GPU's waits between parts (2.3-2.6 ms at the median in
steady Launchpad on a Radeon 780M). That read as an early GPUEndTime, but no
guest code reads the record's times as times: rgfxNoteGPUTimes answers
GPUEndTime with the guest's clock as it takes the record and GPUStartTime with
the record's span before that, so the guest sees the summed GPU time as the
run, ending after the last part's end by the delivery, as a Mac's buffer spans
its encoders' GPU time. split.rs's "Its GPU times" and design.md's "A command
buffer in parts" and "Completion" now say so, with lane splitend's measure
(sb-base1, m3-max-35830) and which macOS 27 frameworks read the times (none
paces frames from them). No behaviour changes.
2026-11-16 02:13:34 -08:00
Anees Iqbal 49c0417199 📝 Record the padded ticket name that kept 1 in 16 VMs from booting
A name the guest builds from a number takes the guest's width: the restore
padded the ECID in the personalized tickets' names, and VMs whose ECID began
with a zero digit finished EACS, then never booted. Three releases had passed
on ECIDs that happened to have 16 digits. [ci skip]
2026-11-16 02:03:40 -08:00
Anees Iqbal e515a0df83 🐛 Make every release's Data volume by EACS, for its keystore's D-key
WIP: measured facts for 15 and later's EACS boots still to come.
2026-11-16 02:03:39 -08:00
Anees Iqbal b5ad91b938 🆕 Make arm64 VMs from an IPSW with reims-ctl, downloading the latest
On an arm64 Mac or arm64 Linux, `reims-ctl create NAME --ipsw latest|PATH`, or
the interface's form, restores macOS from an IPSW onto a new VM's disk with
reims-restore's pipeline, offline: no VM runs and none of Apple's code. The
create saves the VM in the layout Ambrosia's boot reads (disk.img, aux.img,
machine-identifier.bin, and vm.toml with the profile vmapple-arm64 and its aux
and ECID; the ECID as text, since one can pass TOML's integers). A macOS 14 VM
is named with its one step left: a boot that makes its Data volume, then
`reims-restore finish-eacs DIR`.

`latest` is the current macOS in Apple's IPSW catalog, which lists only the
current release, so another is given by its IPSW's path, as the owner chose. The
IPSW downloads into the installers directory and continues after a stop;
`reims-ctl downloads` lists and deletes what is kept, never one a VM uses or one
being downloaded. The space check covers the download and the restore together.
A failed or stopped restore leaves nothing, and its log moves to the cache,
where the error names it.

reims-ctl doesn't start arm64 VMs yet: start, describe, doctor and the USB and
GPU views say so. Windows and Linux x86-64 keep their profile; host.rs adds
vmapple-arm64 for arm64 Macs (HVF) and arm64 Linux (KVM).

On those hosts scripts/install-ctl.sh installs reims-ctl alone: the restore runs
no QEMU and reims-ctl starts no arm64 VM. A Mac needs Xcode's command line
tools; arm64 Linux a C toolchain, git and curl (apt, pacman or dnf).
docs/qemu.md says so.
2026-11-16 02:03:39 -08:00
Anees Iqbal ad3b37b8e8 🆕 Restore macOS from an IPSW onto an arm64 VM's disk, offline
reims-restore installs macOS 14 to 27 from a UniversalMac IPSW onto an arm64
VM's disk the way a Virtualization.framework restore does, but writes the disk
itself. It reads the IPSW where it is, asks Apple's TSS for the VM's tickets,
and lays out the GPT, the three APFS containers, NVRAM and the auxiliary
storage as a fresh VZ restore leaves them. No VM runs and no Apple code runs:
no AVPBooter, iBoot, restore OS or ASR. That is the owner's rule for the
install (11-11), and it is what lets the same restore run on arm64 Linux and
on a Mac. A guest boots the result under QEMU's vmapple on Ambrosia.

It is its own Cargo workspace (like reims-ctl), with reims-apfs, its APFS
reader and writer, as a member:
- the IPSW's members, BuildManifest identities, UDIF, AEA (with Apple's key
  service) and the deflated images 14's IPSWs keep (ipsw, manifest, udif,
  aea, image);
- TSS requests and their checked answers, and Image4's DER (tss, img4);
- the install plan, which equals VZ's disks record for record (plan,
  xml_plist, mtree), and the three containers it writes, with the system
  volume sealed by our own seal and root hash (containers, reims-apfs);
- NVRAM, both banks, and the ean storage with the SFR manifest (aux);
- the LocalPolicies, signed by the project's chain, with the guest's trust
  anchors swapped for that chain by Ambrosia Kernel>Patch entries found in
  the IPSW's own kernel collection (policy, anchors, kernelcache);
- macOS 14's Data volume, which its first boot makes by EACS, and
  finish-eacs after it (pipeline);
- the current IPSW from Apple's catalog, downloaded and continued in place,
  never truncating a file (catalog, download, http).
docs/design.md says what each step writes and how each fact was found
(VZ's guests, the IPSWs, or measured). Nothing from an IPSW or a guest is
committed; the tests use inputs written from scratch.

docs/lessons.md records why a live download check must never hard-link the
owner's files: an earlier downloader truncated a hard-linked IPSW in place.

This is the lane's WIP history squashed. Its restore-OS route (route (a),
closed by Apple's per-VM activation attestation) is left out.
2026-11-16 02:03:39 -08:00
Anees Iqbal 0717a8730f 📝 Record how i915 resets QEMU's context on Gen12 [ci skip]
GitHub #142 reported VMs dying on a Raptor Lake UHD 770 after i915 reset
QEMU's context. At master on ms01's Raptor Lake-P Iris Xe nothing was
reset: the longest guest command buffer took 128 ms, and B26's two
media-analysis buffers about 100 ms. A full GT reset provoked through
debugfs while QuickTime played logged the same kernel line as the report,
and the runtime made its VkDevice again in 209 ms. The guest ran on, but
the desktop picture stayed flat green.

docs/qemu.md now says when i915 resets a context on Gen12, read from i915
and ANV: with GuC the 7.5 s preempt timeout applies to one draw or one
thread group, not to a whole command buffer. It also gives these runs.

The accuracy ledger's recovery row said nothing makes the guest's objects
again. The runtime now carries most of them: a texture or Private buffer
it remakes reads as new, and it leaves a few buffers and caller-image
textures refused.
2026-11-16 01:35:37 -08:00
Anees Iqbal 4be785aeda 📝 Describe the pointer for games [ci skip]
The design gains feature bit 51 (POINTER_MOTION), the event 0x105, and a
section on the guest's mouse: why the tablet cannot give a game motion past
the image's edge, the kext's HID mouse, the device's per-display hidden
cursor and owed motion, the window's 50 ms settle and its switch in and out,
and what a guest without the bit sees.
2026-11-15 23:02:22 -08:00
Anees Iqbal b6536bbe10 📝 Say Grouped held a few batches in steady Launchpad, not none [ci skip]
Two of ten steady Launchpad windows (one per GPU) held 30 batches in 9
groups, and the first opening saved 0.15-1 submissions a present across all
five Grouped walks, not 0.8-1. Docs only.
2026-11-15 22:59:49 -08:00
Anees Iqbal 1498b14175 📝 Record Metal's completion envelope where Exact is chosen [ci skip]
The doc above exact_policy and the accuracy ledger said only that grouped
completion bought no frame rate on the Iris Xe. They now say what Metal
does, measured on two Macs: each command buffer is seen complete at its
own end, 17-41 us later at the median on a Radeon Pro 5300M and a UHD
Graphics 630, 86-106 us on an M3 Max, never once the next one has ended.
Grouped completion sees a member late by the GPU time of the members after
it, up to the runtime's 16 ms bound. They also say what Grouped did on
RADV, the 780M and the RX 7900 XTX: no grouping in steady Launchpad, and
7-9% fewer kernel submissions in Geekbench's Metal pass for no shorter
run, with completions up to 60 ms late. No code changes.
2026-11-15 22:59:49 -08:00
Anees Iqbal ba4be7000a 📝 Record KWin's confinement and the popups over the walks [ci skip]
Two traps from the drag walks. KWin keeps a confined pointer where it was
when a move would leave the region, so a crossing that waited for the pointer
to come within a point of the edge happened in one direction only. And
plasmashell's notification popups, stacked above the walk's keep-above
windows, took the pointer where they lay and made crossings land short.
2026-11-15 22:04:45 -08:00
Anees Iqbal e024c5039a 📝 Describe a captured drag across displays [ci skip]
design.md gains DISPLAY_BOUNDS (bit 50, command 9) and the crossing's hold,
and "A drag stays on its display" becomes "A drag across displays": how the
guest's arrangement reaches the host, when a captured pointer leaves its
window and why within 32 points of the edge, where it lands, how it comes
back, what stays as it was, and the walks on 26.7.2, 15.8.2, 11.7.11 and
26.6.1 that carried a Finder window across both arrangements.
2026-11-15 22:04:44 -08:00
Anees Iqbal f5b6cd95a5 🐎 Give the kext's chunks at multiples of 64 KiB of guest RAM
The bundle's slabs of the kext's chunks (PagesChunked) reach the host as runs
of 64 KiB, but each chunk lay at any multiple of 4 KiB: the physical mask
0x0000FFFFFFFFF000 asks IOBufferMemoryDescriptor for page alignment alone
(xnu's initWithPhysicalMask takes the alignment from the mask's clear low bits,
read from its source). On RADV the host binds a buffer over several pieces of
its import of guest RAM only where every piece lies at a multiple of the
sparse buffer's alignment, 64 KiB on Mesa 26.2, so a buffer over a slab of
several chunks took an import of its own, which every submission lists. On a
780M walk (macOS 26.7.2, Launchpad), 15 of 92 such buffers had their first
chunk at a multiple of 64 KiB, and about 24 of them were live at once.

The chunks now come with the mask 0x0000FFFFFFFF0000 (kRgfxPagesChunkMask),
each at a multiple of its own 64 KiB, so a slab's runs start and end on the
host's granule. A slab the kernel gives no such chunks for takes plain pages,
as before (test_pages_slab_source_chunks). Nothing the guest sees changes: the
chunks are zero-filled and mapped as before, and the host picks the same GPU
addresses and ids. On ANV, which binds no dma-buf buffer in several pieces,
nothing changes.
2026-11-15 21:33:55 -08:00
Anees Iqbal 85953c70fd 📝 Record how a stalling trace made the gaps it timed [ci skip]
A boot on um870 with REIMS_VGPU_TRACE on a disk whose writes stalled showed
present-answer gaps that were the trace's own: its writer flushed under the
lock every traced thread takes. The same loop with the trace on tmpfs had none.
The lesson also covers log lines stamped on arrival, which reach the file in
bursts, and says to time answers by their refresh numbers.
2026-11-15 20:47:53 -08:00
Anees Iqbal 77237b7d83 📝 Say um870's KWin composites on its RTX 3090 now [ci skip]
The route-1 measurements of 11-13 and 11-14 ran with um870's compositor on
its Radeon 780M. On 11-15 the window's dmabuf feedback named DRM 226:129 as
KWin's main device in boots on both GPUs, and the node's sysfs map puts
renderD129 at 0000:67:00.0, the RTX 3090: so a window there now takes the
compositor's route when the runtime's GPU is the 780M, and the runtime's own
when it is the 3090. The dated measurements stay as they were.
2026-11-15 20:47:45 -08:00
Anees Iqbal 96b9c633b2 📝 Say the mirror's sync, not its draw, holds its answers [ci skip]
The device's design said the host holds a present's answer while a window
draw may still read the surfaces it frees. Since the mirror route answers its
presents at the sync that copies the surface, the design now names that read
for windows drawn on the compositor's GPU, with the traced boot's numbers, and
the sink's module doc is wrapped again where that change left a short line.
2026-11-15 20:47:45 -08:00
Anees Iqbal cfd0ffd7c9 📝 Record the locked session that hid the walks' pointer [ci skip]
Two windowed walks of the pointer across displays on um790 saw no input from
either window while KWin's cursor moved over both: the node's session had
locked itself while idle, and the lock screen took every pointer event. The
lesson says how a walk gets past it and how to spot the next one.
2026-11-15 20:18:21 -08:00
Anees Iqbal 2374a7345f 📝 Specify POINTER_OVER and what moves the guest's cursor [ci skip]
design.md's "Multiple displays" now specifies the pointer crossing as built:
feature bit 49 and event 0x104, what the host sends and when, the x86-64
kext's move through IOHIDSystem's own post, why the event has a bit of its
own (drivers that take MULTI_DISPLAY without the event are never sent it,
and each would drop it anyway), and that a drag stays in the window it
began in. X1 gains lane ptrcross's measurement of which kernel move
WindowServer follows on 11.7.11, 15.8.2 and 26.7.2.
2026-11-15 20:15:05 -08:00
Anees Iqbal 61084eab14 🆕 Tell the host which bytes of a new Managed buffer read zero
On a GPU without unified memory the runtime makes a Managed buffer's GPU copy
by copying all of its CPU copy over the link as the buffer is made. Most of
those bytes are zeros the guest never wrote: on the RX 7900 XTX, Geekbench 7.1
Metal's making copies carried ~4.5 GB beyond what the guest marked written, up
to ~0.94 s of GPU time (one 131 ms job copied six new buffers' 631 MB, 12 MB
of it written). The guest knows which bytes read zero; the host cannot.

What changes for the guest and the host:
- MANAGED_BUFFER_CREATE takes a tail, RgfxManagedBufferZero at byte 56
  (RGFX_MANAGED_BUFFER_ZERO_OFFSET): its CPU copy reads zero from zero_from to
  the length as the create is posted. The bundle sends it with every create:
  0 for a buffer made with no bytes, whose slab range take() zeroed; the
  length, which says nothing, for one made with bytes or over the app's own
  memory. The kext's SubmitBatch takes the create at its new size, 64 bytes.
- The host passes a zero_from below the length to the platform
  (BufferDesc::zero_from), and the Vulkan platform to the runtime
  (HostMemory::with_zero_from): the GPU copy starts with zeros the GPU writes
  there, rather than with those bytes copied in. A guest write there reaches
  the GPU copy by a didModifyRange:, as on a Mac's discrete GPU, whose GPU
  copy is made at the buffer's making; before, a write made before the host
  took the create reached it too. A GPU that shares the CPU's memory keeps one
  copy, unchanged, and a create without the tail (an older guest's) is copied
  in whole, as before. An older host reads the create and ignores the tail.

Tests: the decoder passes the tail's offset and none without it or at the
length; the platform's zero bytes are the device's on a GPU of its own memory;
the serialiser, the slabs and the device buffers send each make path's value.
Both guest sets and the ROM's record are rebuilt in the next commit.
2026-11-15 18:44:04 -08:00
Anees Iqbal 79e338aa1f 📝 Record X1 to X5 and the x86-64 kext's displays in the design [ci skip]
The x86-64 kext's framebuffers per display are built: the design says how the
heads attach, what the device control lists, and the readings of X1 to X5
with the potluck jobs that measured them. The pointer crossing becomes a lane
of its own, after mmx86, and the section's status says what is built.
2026-11-15 17:48:44 -08:00
Anees Iqbal 5affa58b2c 📝 Say why Recovery and the installer composite in software [ci skip]
RgfxGate skips its install where /System/Installation exists, and that skip
looked like a gap left open. Measured on x86-64 macOS 15.4 and 26.6.2, it is
not: Recovery's base system ships no IOGPU.framework, which our Metal device
subclasses. A probe that installed the bundle in 26.6.2's Recovery, and in
the base system the installer's second stage roots from, got it registered
and mapped, then WindowServer aborted at every launch. 15.4's Recovery also
keeps /Library/GPUBundles on its read-only root, with no kernel mount KPI to
put a writable volume there. design.md now says so under "Registration
waits for the bundle".

The same probe found that RgfxGate's VNOP_* writers pass the VFS's read-only
check on HFS, which lessons.md records for any path that lifts the skip.
2026-11-15 17:47:02 -08:00
Anees Iqbal c9bf10c181 🆕 Give QEMU's reims-graphics-pci a displays property
vendor/qemu moves to 010bf827, one commit on top of a86885f8. It adds the
displays property, 1 to 4 and 1 by default; realize refuses any other
value. Display i is head i of QEMU's UI, with its own console, window and
cursor. Console i is filled from rvg_graphics_device_read_display_at, so
QMP's screendump of head i saves display i. Each window's input reaches the
guest through its own display's console. With displays=1, QEMU makes the
same console, window, reads and callbacks as before. docs/qemu.md describes
the property.
2026-11-15 15:16:04 -08:00
Anees Iqbal 64183b449e 🆕 Add several displays to the C API
RvgGraphicsDeviceConfig's fourth version adds display_count and
display_windows (the window configs of displays 1 and up, given exactly
where display 0 has a window). RvgGraphicsCallbacks' fourth version adds
cursor_glyph_at, cursor_show_at and cursor_move_at for displays 1 and up.
rvg_graphics_device_read_display_at and
rvg_graphics_device_cursor_position_at read any display, and
RVG_GRAPHICS_DISPLAYS_MAX names the limit. These are additions only: a host
built against the older structs, or one that gives a display_count of 0 or
1, gets one display and the same results and callbacks as before. The C
harness checks a device of two displays, and docs/api.md describes the
additions. QEMU's side follows in the next commit.
2026-11-15 15:16:04 -08:00
Anees Iqbal 5f750c17e7 📝 Record the cursor guard that a test sink kept green [ci skip]
features.md's Cursor entry kept passing its window-crate guards while no
display fed the window the guest's cursor moves. One of those guards handed the
window the position through a test FrameSink, whose method only the deleted
apple-gfx display answered. The lesson says how to spot such a guard, and that
the end-to-end test from the device is what catches it.
2026-11-15 15:15:42 -08:00
Anees Iqbal 0a2b3827b4 🐎 Map a view one dma-buf holds through it, kept for imports
On a device that needs imported pages mapped from their files and takes the
pages one dma-buf holds in the pointer's place (ANV and NVIDIA's driver), a
view of scattered guest pages was mapped a run at a time, one mmap a run,
however small it was, and only went through a dma-buf past the views'
budget. An x86-64 macOS guest's walk on an Iris Xe made 2,082 views of 2 to
1,024 runs within 64 MiB, 140,322 runs; the host held 36,897 mappings at the
desktop, and each such view's make and teardown paid a syscall a run.

Where textures over such pages also lie in place, such a view (more than one
run of one protection within udmabuf's limits) is now mapped through one
udmabuf of its pages from the first, one mapping, and the udmabuf is kept
with the view's runs (files::Kept). A no-copy buffer's import leaves the
view so, and the runtime's import of the whole view is handed a duplicate of
the kept descriptor, so no udmabuf is made again. Two imports still need the
pages mapped from their files and get them so: a heap's (import_heap_view),
and CUDA's registration of a video surface for NVDEC, which pins a
pointer's pages and cannot pin a dma-buf's mapping
(device_lend::map_for_pointer). A view of more runs than one udmabuf takes
keeps today's route, and so does the fold probe's view (vm::from_files).

The device's probe learns whether textures lie in place
(ONE_DMA_BUF_VIEWS): it makes two linear BGRA8 textures over its one-dma-buf
buffer, rows that fill a page and rows a texel short, sampled, written and
rendered, and takes the route only where neither is a shadow; where the
runtime's check has not answered yet it stays off for the process. NVIDIA's
driver fails it: on an RTX 3090 such a texture is a shadow (the runtime's
check makes no image over pages imported as dma-bufs, job m3-max-31400), and
the import through the dma-buf of 1,024 pages took 10.3-12.8 ms against
2.4-2.6 ms by pointer (job m3-max-31405), so NVIDIA keeps today's route.
The probe's textures are heard by no one, so the runtime now announces each
shadowed texture, as it does copied host pages, keeping the device's notice.

With metal2vulkan fb33065288 (RUNTIME 2381) ANV passes it, so the Iris Xe
takes the route: on homelab-ms01-1's Iris Xe (Linux 7.3.1, Mesa 26.2.6) both
textures lie in place (job m3-max-33714). At 9ce951f521 the texture whose
rows are a texel short of a page was a shadow there (job m3-max-33240), the
runtime's check having found a render pass's load and store over pages
imported as dma-bufs changing bytes the CPU wrote beside texels in the line
of memory they share; 2381 takes such a texture in place where its buffer
holds its last row to the pitch. The RTX 3090 stays a shadow (job
m3-max-33224). The probe answers once, as the device is made: in a host's
first process after a driver update or a change of the runtime's in-place
check, before the runtime keeps the check's verdicts, the probe finds the
check pending and that whole process keeps today's route; the next takes it.
The first guest boot on the Iris after the pin move ran so (job
m3-max-33721), and the next process recalled the kept verdicts as its
device was made (job m3-max-33777). The measurements below were taken
before the probe had its textures. A heap's import on Windows is a no-copy
buffer's, as on macOS.

The fold tests now take views of more runs than one udmabuf, 1,025 pages,
and their GPU fill of half the buffer ended mid-page: it now fills whole
pages.

Measured, release build, a view of 1,024 pages backwards, three rounds, on
homelab-ms01-1's Iris Xe (job m3-max-31409): make 1,086-1,121 us ->
551-574 us, import 46-52 -> 116-120 us, unmap 696-705 -> 118-200 us, 1,024
mappings -> 1. The walk on the same host (jobs m3-max-31194, 31453, the
same guest set): mappings held at the desktop 36,897 -> 33,509, its steps,
Geekbench 7.1 and clbw within their spread, no fatal line. GPU results,
guest-visible values and refusals are unchanged.
2026-11-15 15:06:13 -08:00
Anees Iqbal 67272f78a8 📝 Design the device's multiple displays
The owner decided multi-monitor support on the reims-graphics device, full
scope: several displays, each with its own scanout, modes, VBLANKs and cursor
in a window of its own, on x86-64 macOS 11 to 26 and arm64 from 14. This is
the design the four implementation lanes build, and the wire's definitions it
names, which nothing uses yet.

design.md's new section "Multiple displays" decides the parts: the count is
fixed when the device is made (1 to 4, 1 by default), the guest learns it by a
new feature bit, MULTI_DISPLAY (bit 48), which a host offers only with two
displays or more, the messages name their display as they already do, and each
display's scanout lies in an even share of today's scanout room, so a device
of one display is what it was, bit for bit, and no region offset moves. It
gives the C API's additions, QEMU's displays property, the windows, both
kexts, the option ROM (display 0 alone, unchanged), reims-ctl's setting, the
unknowns each lane measures first (the pointer across displays above all) and
the lanes' split, order and checks.

wire.rs adds RGFX_FEATURE_MULTI_DISPLAY, RGFX_DISPLAYS_MAX, and the rooms'
RGFX_SCANOUT_ROOM_ALIGN and RGFX_SCANOUT_STRIDE_ALIGN; the header carries them
as #defines, which change no built binary, and its test checks their values.
2026-11-15 13:47:31 -08:00
Anees Iqbal 90be359c9b 🐛 Answer GPU times from the GPU's own timestamps off MoltenVK
This changes what the guest observes, on every device but MoltenVK:
- A command buffer's GPUStartTime and GPUEndTime become when its GPU ran it,
  as Metal's are. The device posts them in its completion record, and the
  bundle answers them to the guest, whose compositor reads them. They come
  from two GPU timestamps each command buffer writes, placed on the host's
  clock by the runtime's calibration. Until now device_options asked every
  device for GPU times from the host: the run the guest saw went from its
  submission to the runtime seeing it complete, detection latency included.
  Over the same ~35k command buffers of a Launchpad walk, the GPU time the
  guest received summed 48 s against 62 s on a Radeon 780M, 10 s against
  17 s on an RX 7900 XTX, 31 s against 39 s on an Iris Xe, and 25 s against
  30 s on an RTX 3090.
- VkQueue sharing comes on where the runtime's own check finds the GPU idle
  at queue switches (NVIDIA's; RADV's single graphics queue has nothing to
  share). Host times had kept every device Unchecked (below).
MoltenVK keeps host times: the runtime takes them there whatever the option
says (TimestampsWaitForEveryQueue), as it does on a queue family with no
timestamps.

Cost: +2.5 to +7 us per command buffer at the median across six GPUs,
frames unchanged.

The cost, which the option was set for, was measured only on MoltenVK.
Off it, gpu_times_from_host_latency (release, 1000 one-fill command buffers
each way per run, interleaved) puts commit to completion 2 to 7 us later at
the median: XTX +4 us (13 runs), 780M +4 us (13), RX 550 +2.5 us (10), Iris
Xe +4.5 us (10), RTX 3090 +5 us (10), RTX 2080 +7 us (10), within runs whose
medians spanned 44 to 292 us. Walks of a 26.7.2 guest's desktop and
Launchpad on the XTX, the 780M, the Iris Xe and the 3090 drew the same
presents at the same take-to-show times either way, fatal 0.

Host times also kept the runtime from sharing VkQueues between command
queues (queue_share.rs: a device without timestamps the host reads is
Unchecked), so the accuracy ledger's queue-sharing row never applied to our
builds. It does now on NVIDIA: the 3090 walks moved 9 to 13 queues, take-to-
show 8.08/8.09 ms against 8.15/8.05 with sharing held off and 8.00 from the
host. The row now says which devices it reaches.

A test holds the new answer: the runtime announces GpuTimesFromHost exactly
where the device's driver has TimestampsWaitForEveryQueue, and the times lie
in the command buffer's life. The timing module's debug legs are renamed for
what they measure now ("on the GPU", "GPU end to the handler"), as are the
surface-cache cost bench's.
2026-11-15 13:35:22 -08:00
Anees Iqbal de8b8e8d1e 📝 Record the transport that was the clocks drifting [ci skip]
The XTX scout row sized a queue-thread wake of 128 us p50 from the guest_times
transport; it was the device clock drifting from the guest clock at the
host NTP correction between offset readings. The entry says how the probe
told the two apart and how to spot the next span mapped across two clocks.
2026-11-15 13:25:08 -08:00
Anees Iqbal d092341f9c 🐛 Run the device's clock at the guest clock's rate on Linux, macOS
The device's clock (now_ns: what HOST_TIME reads, what VBLANKs and the
guest's command buffer takes are stamped on) was CLOCK_MONOTONIC, which NTP
disciplines: measured 2026-11-15 against CLOCK_MONOTONIC_RAW it runs +45.1
ppm on homelab-um790-xtx-1, -30.1 ppm on homelab-gem10-1 and +5.7 ppm on
homelab-um870-1 (systemd-timesyncd), and +3.9 ppm on the M3 Max. A guest's
clock counts its TSC (x86-64) or the host's counter (arm64 under HVF), at the
raw rate. The kext maps the device's times by a HOST_TIME reading taken only
at a VBLANK and widens a held reading's bound by 50 ppm of its age, so um790
already ran at 0.9x of that allowance, and a slew correcting a large offset
passes it.

What changes for the guest: HOST_TIME and the VBLANK stamps now run at the
counter's rate (CLOCK_MONOTONIC_RAW) on Linux and macOS, so the kext's offset
holds between readings and the refreshes' and presents' times it maps stay
inside its bound whatever the host's NTP does. Windows keeps the performance
counter, whose frequency is fixed at boot and which nothing disciplines.

What changes for the host: the guest_times diagnostic's transport. On um790
it read p50 128 us in Geekbench 7.1's compute, a sawtooth climbing 45 us a
second to 230 us between readings 5 s apart (VBLANKs off), while a host trace
of the same run (m3-max-33208) put the doorbell's write -> take at 12.6 us
p50; on gem10 it read 0.

Tested by the_clock_is_the_raw_monotonic_one (a read lies between two reads
of CLOCK_MONOTONIC_RAW).
2026-11-15 13:25:08 -08:00
Anees Iqbal 5cdc9a8410 📝 Record that a batch window is waited out by what follows it [ci skip]
A desktop walk's groups of pages blocks' views held one view each while a
Geekbench walk grouped most of its views: a window over requests with no
answer is waited out by the messages behind them, and a batch judged on one
workload says nothing of another's. The lesson says how the window was
first misread, why it stays, and how to spot the next such window.
2026-11-15 13:14:26 -08:00
Anees Iqbal 85656c4d46 🐎 Close a group of views once a ring-0 message waits for it
A pages block's view joins its context's group dma-buf, which stays open
1 ms from its first member. BUFFER_OVER_PAGES and HEAP_OVER_PAGES have no
answer, so the window delays only the context's messages that wait for the
view. On a macOS 26.7.2 desktop walk on the Radeon 780M (Finder, then
Launchpad three times), 559 and 550 groups formed in two walks, all of one
view but one of two, and a view took 1.23 to 1.25 ms at the median from its
begin to its make, nearly all of it the window. A Geekbench 7.1 Metal walk on
the same GPU put 3,665 of its 4,686 views in 930 groups, so the window stays.

A ring-0 message that waits for the context's no-copy buffers holds the
context's lane, and the lane hands no later message over until the views are
made. Once the views the lane handed over before it have joined, nothing more
can join the group. The group now closes then, not at its window's end:
- start_over_pages counts each view handed to the surface worker until its
  job has joined a group or gone on alone (HandedOver);
- handle_stage3's wait counts a ring-0 waiter while it waits (WaitsForViews);
- group_closed seals a group whose context has a waiter and no view still
  to join.

A group keeps every member it took before. A message of a queue's ring still
leaves the group its window, as a later view may still come on ring 0.

Measured on the same walk, two walks each way (gem10, 780M, exclusive): 537 of
553 and 551 of 572 groups closed as a ring-0 message waited, 2 us at the
median after their first member; the rest closed at the window's end with
nothing waiting. A view took 0.20 to 0.22 ms at the median (p90 0.69 to 0.76,
from 1.48 to 1.50). Launchpad's presents a second and its take to show are as
before within the walks' spread; fatal lines 0.

The guest sees the same objects, addresses, answers and order; only how soon
the context's waiting messages are carried out changes. The seal's debug
line says why a group closed and how long it was open, and a debug line gives
each wait for the no-copy buffers.

Tests: the burst test now has its context's next message close the group
with the clock unmoved; a lone view's context is answered with no window
waited for; and a waiting message closes the group only once a view handed
over before it, its job held, has joined.
2026-11-15 13:14:26 -08:00
Anees Iqbal bc2164ea8f 🐛 Wait 450 s for an arm64 guest's SSH login under TCG
check-boot.sh gave a TCG boot 300 s to log in, but macOS 26's login on
homelab-um870-1's 780M comes at one of two times, about 125 s or about
305 s: logins at 131.8 s (m3-max-32336), 122.2 s (32792), 314.9 s (32613)
and 301.6 s (33045). The two slow ones passed only because the last connect
attempt began before the limit, and m3-max-33301 failed on it with its
desktop presenting and no fatal line. The limit is now 450 s, past the slow
time; HVF keeps 90 s, and docs/qemu.md records the two login times.
2026-11-15 13:10:35 -08:00
Anees Iqbal d9779584a5 🐎 Fault a wire's pages from the top down on x86-64
An x86-64 macOS kernel refills each CPU's free-page list last in, first
out, so a range faulted from its first page up gets each 16 KiB clump's
pages backwards: one page a run of guest RAM, which the host maps a run at
a time. Mission Control's capture surface came to 7,261 runs, ~12-20 ms of
mmap an open on Iris, and the views held 36,897 mappings at the desktop.

The kext now faults a range in from its last page down before it wires it,
at the three wires that hand pages to the host (a plane's, a surface's and
a pages block's), so each clump's pages land ascending, four pages a run:
a task's range by a one-byte copyin a page, a surface's memory through a
read-only mapping of it in the kernel's map, made and released there, so no
process's map shows it, and skipped where all its pages are resident. Only
pages the wire faults anyway are faulted; the two rare cases that do more
(a copy-on-write range's page in no object yet, and the pages above one a
wire refuses) are noted at faultTopDown.

Measured on homelab-ms01-1's Iris Xe with an x86-64 macOS 26.7.2 guest
(walks m3-max-31194 and 31227): the boot's view 1.000 runs a page to
0.251, Mission Control's surface 7,261 runs to 1,832 and 2,268, mappings
held at the desktop 36,897 to 12,441; the walk's steps and Geekbench 7.1
within their spread. Again on de23c2d37 (walks m3-max-33250 and 33251):
mappings held at the desktop 25,401 to 10,796 and at the walk's end 41,646
to 24,224, the boot's view 16,201 runs to 4,070, Mission Control's surface
4,244 runs to 2,412 and 2,352, Geekbench's largest view 136,612 runs to
91,301 of its 140,070 pages; steps 572 and 570 s, Geekbench 7.1 286.5 and
282.5 s, clbw within its spread, no fatal line. arm64 builds are unchanged
(x86-64 only).
2026-11-15 12:20:54 -08:00
Anees Iqbal 4b3a5cfeda 🐛 Keep every QEMU's pipeline answer records in the file runs read
The QEMUs of one build on a host share one kept pipeline answers file, and
each held it open from its start. When one wrote the file again (at its
open past half the capacity, or at the capacity), the rename put a new file
in its place while the others kept appending to the replaced one, which no
run reads: their later records were lost, a drop among them, so the next
run could seed the kext with an answer the device had dropped. And a
rewrite at the capacity took the writing QEMU's memory, so it could bring
back an answer another QEMU had dropped, and counted only its own records.

A store now takes the file's lock (File:🔒 flock on Linux and macOS,
LockFileEx on Windows) for each record, rewrite and removal, and with it
the file the path names now: the one it holds where that is still it
(device and inode on Unix, volume and file ID on Windows), else the one
another store put there. A rewrite reads every store's records from the
file under that lock, and the capacity is the file's length. On Windows the
rename replaces a file other stores hold open through std's POSIX rename
semantics, from Windows 10 1607; a full file that cannot be written again
is removed. For the guest: no QEMU's drop is lost to another's rewrite, so
no dropped answer reaches a later run's PIPELINE_ANSWERS.

The capacity test now counts the drop's key among the file's newest, and
the lost-drop test puts an unwritable file in place (Unix); two tests hold
two stores of one identity: one's drop after the other's rewrite at open,
and a rewrite at the capacity that keeps another store's drop.
2026-11-15 10:28:35 -08:00
Anees Iqbal 4c08be7f18 🐛 Write a full pipeline answers file again before its next record
The device's kept pipeline answers appended no record once the file held
its 8,192, a drop's included: the next run then read the dropped answer and
seeded the kext with it, so one create took a stale reflection. Since a run
records each kept key it uses, not only new keys, the cap comes sooner.

A file at its capacity is now written again before the run's next record,
with its newest 2,048 answers, in memory as in the file, as at an open past
half the capacity; and a drop that cannot be written (the file not opened,
a failed write or rewrite) removes the file, so the next run starts from
none. For the guest: no answer the device dropped reaches a later run's
PIPELINE_ANSWERS. The test of the capped file now holds the rewrite at the
next open alone, and two tests hold the drop at the capacity and the drop
that cannot be written.
2026-11-15 10:28:35 -08:00
Anees Iqbal 635f43912e 🐛 Renew a kept pipeline answer's age at its first use in a run
The device's kept pipeline answers appended a record only when an answer
was learnt or dropped, so an answer's age was when it was first kept: the
rewrite past half the file's capacity kept the 2,048 first kept since, not
the last used, and a pipeline a guest makes on every boot dropped out once
2,048 newer keys had arrived; the kext's seed took the answers in the same
order.

A run's first create of a key an earlier run kept now makes its answer the
newest, in memory and in the file, by appending its kept record again: the
reader already takes a key's last record as its newest, so the layout and
ANSWERS_FORMAT stay. For the guest, PIPELINE_ANSWERS now hands the kept
answers newest by the last run that used each, and a rewrite keeps those.
A run appends one record a key it uses, so a host whose runs each use all
2,048 kept answers writes its file again at every second open.
2026-11-15 09:47:37 -08:00
Anees Iqbal aa98cd1977 ✅ Clippy-check the video crate's tests for Windows too
cargo xtask check's Windows clippy left the video crate's own tests and
examples out, since its fuzzers' CPU-time clock was clock_gettime's alone. They
build for Windows now, so the exclusion goes, and the check type-checks every
workspace target for x86_64-pc-windows-gnullvm.
2026-11-15 09:47:37 -08:00
Anees Iqbal 70578a33ff 🐛 Make textures past a buffer's length to the runtime's new bound
metal2vulkan d0ef5e0145 bounds a texture over a buffer of 16 KiB or more
as the M3 Max does: a 2D texture and a texture buffer at their last texel,
whatever the bytes per row past it, and a heap's buffer at its heap's size
from the buffer's start, where it counted bytesPerRow * height against the
length rounded up to 16 KiB. The bundle answered nil wherever the old bound
refused, on both guests, so it held back textures the host now makes.

rgfxTexelsPastAllocation now counts that end against rgfxHostAllocation:
the heap's size for a heap's buffer, the length rounded up to 16 KiB for any
other. The runtime counts a buffer over pages (a no-copy buffer, or one over
the device's region) from the host pointer's offset in its 16 KiB page,
which the guest does not know and which only adds to the bound, so the
bundle keeps the length rounded up for those and posts nothing the host
refuses. 2D arrays keep their slices' end, and a texture whose texels end
inside the length stays made.

For the guest: on either guest, a texture buffer or 2D texture over a
buffer of 16 KiB or more whose last texel ends inside the allocation is now
made where its rows' padding runs past it, and a heap's buffer of 16 KiB or
more takes textures to its heap's size, both answered nil before.
2026-11-15 09:43:56 -08:00
Anees Iqbal d5dbecbdac 📝 Say how Windows-only code is checked [ci skip]
The library builds and tests on Windows now, so AGENTS.md says Windows is
being brought up on homelab-mac-mini-2018, with nothing shipped for it yet.
Checking a change gets a row for Windows-only code: the check's Windows
clippy, then the crate's tests on the mini through
scripts/internal/windows-tests.sh. The note on what the check covers off the
host's own target now names the Windows clippy. conventions.md's list of
per-OS files gains the Vulkan crate's os/windows.rs and the graphics crate's
unix/windows splits.
2026-11-15 09:07:15 -08:00
Anees Iqbal 3a6a25885c ✅ Clippy-check the Windows target in cargo xtask check
Every library crate builds for x86_64-pc-windows-gnullvm since 11-15, but
nothing in the check saw Windows, so the next Unix-only call in shared code
would break the Windows build unnoticed. The check now runs clippy for that
target on the Mac and on Linux, as the Mac already does for Linux: SDL left
unbuilt, nothing linked. The video crate's own tests and examples stay out,
since their CPU-time clock (codec/fuzz_support.rs) is clock_gettime's; its
library is still checked as reims-vgpu's dependency.

rust-toolchain.toml lists the target, so rustup installs it on every host,
and a test keeps the check's cross targets in that list.
2026-11-15 09:07:15 -08:00