Commit Graph
53 Commits
Author SHA1 Message Date
Anees Iqbal b0f350dfbf 🆕 Open reims-vgpu's window at the VM's resolution
reims-vgpu's display follows its window, which always opened at 1920x1080,
and reims-ctl refused any other resolution for a VM on it. A person who wanted
a larger or smaller desktop resized the window at every start.

QEMU's reims-graphics-pci now takes a resolution property, WIDTHxHEIGHT, the
window's first size (the library's window config mode_width and mode_height).
reims-ctl passes the VM's resolution there where it is not 1920x1080, which
leaves a QEMU built before the property working at the default, and its TUI
shows the field for reims-vgpu. host stays refused there: it names no size.

Measured on a KDE Wayland desktop of 3840x2160 at 2.1x, 1829x1029 points, with
a macOS 26.7.2 guest: 1280x720 opened the window at 1280x720 points and the
guest ran 2688x1512; 2560x1440 and the default opened it shrunk to fit, at
1744x981 points, the guest at 3662x2039.

vendor/qemu moves to the commit that adds the property.
2026-11-07 10:23:33 -08:00
Anees Iqbal fe127c1117 📝 Say the graphics region is a memfd of the library's on Linux
The region's memory changed with the previous commit: the design's Decided 5,
docs/qemu.md and the C API's doc of rvg_graphics_device_region (and so the
header) said it was private anonymous memory on every host.
2026-11-07 08:27:28 -08:00
Anees Iqbal 331ce78b88 📝 Record that x86-64 macOS drives the virtio sound device [ci skip]
Whether x86-64 macOS has a driver for reims-ctl's virtio-sound-pci had never
been checked by a boot. A macOS 26.7.2 guest booted on reims-ctl's q35
command answers it. AppleVirtIOSound binds the device, and Core Audio makes
it the default output and input. Played sound reaches QEMU, and with the
pipewire backend it reaches the host's default sink. Safari's Media Source
player plays to the end with audio. With audio off, every Media Source
stream that has an audio track fails with MEDIA_ERR_DECODE, and a video-only
stream still plays. The ICH9 HDA controller has no guest driver and plays
OpenCore's boot chime alone.

The command already gives x86-64 VMs working audio, so nothing in it
changes. The module doc and docs/qemu.md now give these results in place of
the "unchecked" note.
2026-11-07 07:58:08 -08:00
Anees Iqbal caf1db7b9c 🐛 Name Metal's error mode for apple-gfx VMs alone
reims-ctl told every x86-64 VM to set METAL_ERROR_MODE once macOS is installed:
in its install steps, after create, after an eject and in the TUI's create
message. That was measured on apple-gfx, whose guests' icon service ends as it
starts without it. On reims-vgpu's own device, the x86-64 default, a macOS
26.7.2 guest without the key comes up with its Dock and icon services running
and no crash report (a Radeon 780M host, 11-07), so users of the default were
sent through Recovery for nothing. runtime::needs_error_mode now gates every
one of those messages on apple-gfx, and README step 3 and docs/qemu.md say
which device needs it.
2026-11-07 05:57:55 -08:00
Anees Iqbal e75c72b731 🐛 Write QMP's PPM screendumps without row padding
A screendump of a display whose width is not a multiple of 4, such as
reims-graphics-pci's window of 3662 x 2039 pixels on a host scaled by 2.1,
read back sheared by 2/3 of a pixel a row, with a dark diagonal seam and
its colours rotating from row to row (grey once scaled down). The display,
its window, VNC and SPICE were right, and so was a PNG screendump: QEMU's
ppm_save wrote each row with its pixman line buffer's stride, which is
rounded up to 4 bytes, where a PPM's rows are width * 3 bytes.

vendor/qemu moves to 23198e4b79, which writes width * 3 bytes a row, with
a qtest that dumps bochs-display at widths of 64, 66 and 67.
2026-11-07 05:19:23 -08:00
Anees Iqbal 70b64690bf 📝 Record a macOS guest's view of a passed-through USB stick [ci skip]
The boot that checked USB passthrough end to end: a macOS 26.7.2 guest
given a USB stick the host's kernel makes lists it, mounts it, writes to
it, and loses and regains it as reims-ctl takes it back and gives it again
while the VM runs. docs/qemu.md now says what was measured, and that macOS
26 lists USB devices under SPUSBHostDataType, not SPUSBDataType.
2026-11-07 04:59:54 -08:00
Anees Iqbal bbd9aaf510 📝 Say how USB passthrough uses QEMU's xHCI ports [ci skip]
What reims-ctl's command line relies on, read from QEMU's code: the
controller's ports and their speeds, the full-speed hub QEMU chains on the
last free one, how usb-host matches a device and waits for one not plugged
in, and why a macOS host has no passthrough.
2026-11-07 04:59:54 -08:00
Anees Iqbal 61d08db578 📝 Say reims-ctl's x86-64 VMs have the graphics device [ci skip]
docs/qemu.md still said reims-ctl's VMs do not have reims-graphics-pci, which
stopped being true when x86-64 VMs moved onto it by default: reims-ctl now
adds the device and the max-ram-below-4g=1G option the device's BAR needs.
2026-11-07 04:21:01 -08:00
Anees Iqbal e5fb681450 🐛 Draw the guest's cursor in QEMU's displays on reims-graphics
vendor/qemu moves to c119b802, where reims-graphics-pci gives QEMU's
console the guest's cursor from the graphics device's new cursor
callbacks: its image and hot spot, its place and whether it shows. A VM on
the reims-vgpu graphics option now shows its cursor through a SPICE, VNC,
GTK or D-Bus display added to its QEMU command, as one on apple-gfx does;
before, the pointer moved the guest's cursor and nothing drew it. Under
-display none nothing changes: the console has no display, and the window
shows the cursor as the host's pointer.
2026-11-07 04:20:17 -08:00
Anees Iqbal 18872e171b 📝 Trace QEMU system-wide, never with per-task perf events [ci skip]
Car 13's WindowServer frames run (c13t-wsframes, RTX 5080 host) traced QEMU
with `perf record -p` and 47 tracepoint-class events, which every new thread
inherited. The host's lane threads come and go in bursts, and each exit then
freed its events in perf_event_exit_task: 0.12 to 12 s an exit, 22 to 23 of
24 CPUs at once, the vCPUs starved and the guest frozen for 1.3 to 10 s, read
in the guest as frames of up to 9.5 s. Every frame over 200 ms in that run
came from the recorder. Say so where the docs say how WindowServer is
measured, with what a host trace does instead.
2026-11-05 21:59:36 -08:00
Anees Iqbal 202e0a6560 🆕 Build the kext for a trace image with OSBundleForceDTraceInit
dtrace lists no fbt probe in our kext. For a Boot-collection kext, as
OpenCore injects it, the kernel makes the probes at its load only where its
Info.plist sets OSBundleForceDTraceInit and the guest boots with keepsyms=1,
on an image whose csr-active-config allows dtrace. make DTRACE=1 now writes
the key into the built Info.plist; a plain make leaves it out, so the kext
guests get is unchanged. docs/qemu.md says how to build it and how to check
the probes on a trace image.
2026-11-05 21:59:36 -08:00
Anees Iqbal 8e4c8bc455 🐛 Fault the exec at a function whose IR sits over a page-table hole
A function whose IR the task could not copy was handed to Metal as nil, so a
pipeline naming it ended the host's process inside Metal ("Metal aborts at a
render descriptor with no vertex function"), isolated tasks included. On an
x86-64 macOS 26 guest, Safari's WebGPU renderBundles sample ended QEMU this
way, right after an info indirect (69). The guest commits a buffer's pages
to the task's page table as it prepares a command buffer that lists the
buffer, and every stream that names a pipeline lists its functions' IR
buffers (read from the guest's Metal driver), so IR over a hole is IR the
guest has not mapped yet.

What changes for the guest and the host: IR over a hole in the task's page
table now raises the function lookup's failure ("function lookup failed"),
as an empty entry's lookup already does, so the exec or info faults and the
guest restarts the channel, where the host's process used to end. Nothing
is cached, so a lookup after the guest maps the IR makes the function. IR
the task cannot otherwise copy (past the task's end, or ending at it) is
still nil to Metal, as Apple's framework answers it. Whether the boot's
failed copy was a hole is for the next boot's log to say: the previous
commit makes it name the reason.

The suite's mutgap_svc_function_over_hole locks it; its records follow.
2026-11-05 21:59:34 -08:00
Anees Iqbal d8aa8f1b5d 📝 Say why fbt lists no probes in our kext, and what tracing needs [ci skip]
dtrace -l -P fbt -m com.steelbrain.ReimsGraphics lists nothing, and the
kext's build is not why: as built it keeps all 398 __text symbols, 324 of them
global, has its LC_UUID, and 384 of its 392 functions start with the push
%rbp; mov %rsp,%rbp prologue fbt patches. The guest's kernel decides it (read
from xnu's source): with SIP restricting dtrace no module gets fbt probes, and
a Boot-collection kext, where OpenCore injects ours, gets them only from
symbols the dtrace command finds for its UUID, unless OSBundleForceDTraceInit
asks for them at load, which the kernel honours there only under keepsyms=1.
The note says what a tracing image sets; a boot measures whether it works.
2026-11-05 21:59:34 -08:00
Anees Iqbal f15b1b3b6d 🔊 Warn at realize where BAR 2 gets no address in macOS
reims-graphics-pci's BAR 2 (1 GiB) needs -machine max-ram-below-4g=1G on a
PC machine: macOS lays 64-bit BARs out below 4 GiB, and with q35's default
2 GiB of RAM there the BAR gets no address and the kext finds no region,
with nothing said on the host. The docs left the option to whoever adds the
device; reims-ctl's VMs still have no reims-graphics-pci, so nothing there
needs it yet.

For the host: QEMU (vendor/qemu 22ae1fd1) now warns at the device's realize,
naming the option, where a PC machine has RAM at 1 GiB, so a host that adds
the device without the option is told. The guest sees nothing new: the
device is realized as before.
2026-11-05 21:59:34 -08:00
Anees Iqbal a562b48c14 🆕 Read the graphics display back, and show it in QEMU's console
reims-graphics-pci's QEMU console carried input only, so QMP's screendump
was always an empty 640x480 image: the login-clock, desktop and lane-gate
checks had no way to see the guest's frame once WindowServer presents
IOSurfaces, which live in the host's device caches, not in the scanout.

For the host: rvg_graphics_device_read_display, the C API's 57th function
(additive), reads what the display shows now into the host's buffer: the
scanout or the presented IOSurface, through the display's colour, drawn as
the window draws it into a texture of the display's mode, BGRA8 rows of
width * 4 bytes, black where the guest shows nothing. It gives the mode's
size whatever it answers, so a NULL buffer asks it, and waits only for its
own draw on the GPU, on a queue of its own. QEMU (vendor/qemu 70a9a466)
calls it from the console's gfx_update on a thread of its pool, so the
console, QEMU's displays and screendump show the guest's frame.

For the guest: nothing. The read answers no present (the window's draw does,
through ScanoutDraw::encode, now over encode_shown), tells the guest no
mode, and holds a presented surface's block only while its draw reads it,
as the window's draw does. A device with no window keeps the guest's
scanout in a screen of its own for the reads, offering the same 1920 x 1080
at 60 Hz as before.
2026-11-05 21:59:34 -08:00
Anees Iqbal c9b243ff80 📝 Say what reims-graphics-pci calls and what its BAR 2 needs [ci skip]
QEMU's reims-graphics-pci writes every register through
rvg_graphics_device_mmio_write_taking, so a queue's doorbell may answer its
next command buffer on the vCPU; docs/api.md said it called everything but
that function. Its BAR 2 is the library's 1 GiB region, with the guest's
allocations from 0x400000, where the docs still said 256 MiB and 0x20000,
and a 1 GiB BAR needs the machine's max-ram-below-4g=1G, which docs/qemu.md
never named: reims-ctl does not add the device, so whoever adds it needs the
option too.
2026-11-05 21:59:32 -08:00
Anees Iqbal 0600467702 ⬆️ Ring a queue's doorbell with the plain write in QEMU
QEMU 67cc08ad takes reims-graphics-pci's command queue doorbells through
rvg_graphics_device_mmio_write again, so the queue's thread takes its
command buffers and the vCPU only wakes it. The library keeps
_mmio_write_taking, additive and now unused by QEMU.

The take on the vCPU did not pay on msi's x86-64 guest. 86% of the
compositor queue's doorbells found ring 0 behind and fell back to the
queue's thread, so the frame's command buffer was rarely taken inline.
WindowServer's composite (CLTD, its CompositeLayersToDestination call's
wall time) was a wash at the tip, mean 555 us with the take against 621
without and p50 442 against 435, and the take cost the vCPU about 15 us a
doorbell at the p50. Its tail was jemalloc's decay purge, madvise calls of
up to 340 us run on the vCPU inside the take's allocations.

A cold boot of the x86-64 guest on msi with this QEMU reached the desktop
and dragged a window with no fatal or ERROR line; CLTD measured mean 407 us,
p50 396, p99 613.

docs/qemu.md and docs/api.md say what QEMU calls again.
2026-11-05 21:59:21 -08:00
Anees Iqbal 0ee908e0a8 ⬆️ Point vendor/qemu at reims-graphics-pci's taking doorbell
QEMU f2c7e2a5 sends the vCPU's BAR 0 writes of reims-graphics-pci to
rvg_graphics_device_mmio_write_taking. A DOORBELL write of a command queue's
ring can then take the queue's next command buffer on the vCPU, post its
CB_SUBMITTED and raise the interrupt there, through the irqfd under KVM or
the BH elsewhere. The control ring's doorbell still goes to the ioeventfd,
and reads are unchanged.

Measured on msi under KVM in one boot, the same guest under window-drag
load, with the take switched on and off every 20 s (the first 5 s of each
window left out; 60 s on, 51 s off):
- WindowServer's commit to its wake in commitAndWaitUntilSubmitted fell to
  173 us on average, from 218 (p50 168, from 185; p99 440, against 402);
- its CA::Layer::commit_transaction-to-display (CLTD) fell to 384 us on
  average, from 434 (p50 376, from 400; p99 667, against 654). Every 20 s
  window with the take on beat both windows next to it;
- the vCPU took 32% of all doorbell writes, and 62% of the buffers that ask
  for their CB_SUBMITTED. The rest went to the queue's thread: 2731 because
  a ring-0 message published before them was not carried out yet, 23
  because a lock was held. The 6608 buffers that ask for no CB_SUBMITTED
  were left too;
- a take cost the vCPU 14 us at the p50 and 31 us at the p99, 274 us at
  most, and a plain doorbell write 2 us. A vCPU-posted CB_SUBMITTED reached
  the ring 10.7 us after the doorbell, against 199 us for one the queue's
  thread posted;
- the control thread waited for the decoder at 20.6% of its locks, from
  15.3%, for 38.2 ms a second in all, from 36.8. 2204 of those waits were
  behind a take's carried lock. The queue's thread never waited for it.
A boot of the plain build (no measurement) reached the desktop and dragged
at 59.6 composites a second, with CLTD averaging 369 us and no fatal,
ERROR or WARN line in the host log.

docs/qemu.md and docs/api.md now say which BAR 0 call QEMU makes, and how
the interrupt is sent since 36deb281.
2026-11-05 21:59:21 -08:00
Anees Iqbal 45ca49738f 📝 Say how to time the guest's composites without dtrace's cost [ci skip]
Each pid or objc probe that fires in an x86-64 guest costs it about 10 us,
so a script probing what CompositeLayersToDestination calls adds 0.4 to
0.5 ms to the very time it reports, on Apple's driver as on ours, and on-CPU
sampling of the vCPUs adds about 30% of a host core to QEMU. Measured on the
RTX 5080 Laptop host with a macOS 26.6.1 guest; the doc says to time CLTD
with its own probes only and QEMU's CPU with no dtrace in the guest.
2026-11-05 21:59:20 -08:00
Anees Iqbal 0b798d10f7 🐎 Take no dirty source on the graphics device
This reverts 71d7ba107 (Give the graphics device the host's dirty source),
8f1b8b02e (Resolve an import's pages once per range for the dirty log) and
67edfb6ee (its test's fix), and points vendor/qemu at 926401c49, which
reverts reims-graphics-pci's dirty source on its branch.

With the source, the runtime asked the guest pages behind each IOSurface's
import at each command buffer's reports and watches, and the graphics
device's thread resolved them through the backing table and the registry,
under locks the runtime's queue threads also took. On the msi's RTX 5080,
the same guest under window-drag load, the host with the source against the
host without it, back to back:

- the decode and commit of a command buffer took 5.2-7.3 ms, against
  0.33-0.51 ms;
- WindowServer composited 27-30 times a second, against 40-45, and its
  CompositeLayersToDestination averaged 9.65 ms, against 3.24 ms;
- QEMU used 122% of a core, against 89%.

The copies the source saved, an IOSurface's shadow copied in whole at each
use on a discrete GPU, are what the device cache of IOSurfaces replaces.
RvgGraphicsDeviceConfig is at its second version again; the third was never
in development.
2026-11-05 21:59:20 -08:00
Anees Iqbal 2705249327 🐎 Give the graphics device the host's dirty source
WindowServer composites into an IOSurface the GPU now draws in place over
its guest pages. On the Vulkan platform the runtime keeps a render target
over host pages as a shadow, copied in before each use: with no dirty
source each copy in was the whole surface, 37 MB at 3840x2400, every
composite. RvgGraphicsDeviceConfig's third version takes the host's dirty
source, as RvgDeviceConfig does, and the device keeps the same harvest and
log over the guest's RAM, so the runtime copies again only the pages the
guest wrote. The log is closed while the host's reset runs, as a device's
is under its host's lock.
2026-11-05 21:59:19 -08:00
Anees Iqbal 824e9cee23 🆕 Add reims-graphics-pci to QEMU
QEMU gets the reims-graphics device's transport, reims-graphics-pci
(1234:5247), on the C API's graphics device, so a VM can be given the new
lane's GPU: BAR 0 the registers with MSI-X, the doorbell an ioeventfd the
library polls, BAR 2 the library's region as RAM with only the guest's
allocations dirty-logged, and the library's window under -display none, as
apple-gfx has.

The device is built for every target where the library is found, so an
x86-64 guest under TCG on a Mac has it too. docs/qemu.md says what the
device is and what its paused realize measured.
2026-11-05 21:58:28 -08:00
Anees Iqbal bd8f89bccc 🆕 Hand NVIDIA's device the guest's RAM whole
On a device that needs imported pages mapped from their files, the guest's
RAM is now handed to the device whole. NVIDIA's 615 driver refuses foreign
dma-bufs, so there a view of scattered guest pages takes one kernel mapping
per run. Each lease of the guest's memory makes the runtime's HostRam of its
ranges, with the dirty log's answers where the device has one, and every
such device uses it while the lease lives. Each no-copy object's memory
carries a resolver of the RAM's runs its pages are. An object over one run
inside one 64 MiB chunk is bound in the device's import of that chunk: no
import of its own, no kernel mapping, no gate. Other objects keep the views.
A device without VK_EXT_external_memory_host keeps the views, said once.
Only writable pages of the RAM resolve: read-only pages, files of zeros,
twins and the library's own memory answer none.

Every import the library makes now asks the views' gate, rebinds included.
A rebind's import of a view's pages used to have no other way than kernel
mappings: no gate was asked, its pages were mapped from their files into the
views' headroom, and past the whole budget it was handed over as mapped,
which NVIDIA's driver refuses (in strict mode a death). The runtime now
makes a rebind over a copy where the gate refuses or the import fails,
including a heap's, an image's in place and moved bytes'. So a rebind stops
short of the headroom like a no-copy buffer. Gone with it: ImportSite::gated,
the ungated import's way into the headroom (Reach::Whole for unfolds), and
the hand-over past the budget with its death and its `noroom` count.

A device lend (the video device's decoder writing a frame into the guest's
buffer through CUDA) also stops short of the headroom. It used to map its
pages from their files as far as the whole budget, as a rebind did. A lend
has another way: where the device does not register the pages, the decoder
declines the frame and the session copies it into the guest's buffer on the
CPU, the same bytes. Past the headroom its pages stay in their views through
dma-bufs, the device refuses them, and the CPU copies the frame. It no
longer counts as an import handed over, and no longer ends the process in
strict mode.

The headroom now holds only what has no other way: views through dma-bufs,
ranges, stand-ins, and twins where no device needs imported pages mapped
from their files. What the guest sees changes only where a run died: a
guest whose objects met the views' limit used to end the process there,
and now runs, a copy holding the same bytes where no mapping was left.

docs/qemu.md says:
- how NVIDIA's device takes the guest's RAM whole;
- that the copy reads the pages with the CPU, and that rebinds and lends are
  gated;
- how the RTX 5080 Laptop host booted at the kernel's default
  vm.max_map_count (65,530), where objects go past the gate to copies.
  Before the route, a 4K x86-64 guest died about 17 s in, at a 63.3 MiB
  surface whose copy could not read its pages. With the route at
  daf1bf625f, it reached its desktop and ran the workload with no fatal
  line, at a Finder drag of 5 fps. At f4f88dad89, whose copies compare only
  the pages the dirty log reports written, the desktop came by 30 s and the
  drag ran at 29 fps.

Checked with the previous commit at f4f88dad89: the checks it lists, the
route's test on the 5080 among them, and that boot, with no wrong frame in
29 screenshots.

Squashes fc5ab85ef, b5bdc1a8f, 7fee65ff4, 7d9f0df6f, f30bb371c and
ef416d02d.
2026-10-29 15:50:30 +02:00
Anees Iqbal 3e27fc9688 🐎 Copy a buffer or heap past the headroom rather than import it
On a device that pins a pointer's pages (NVIDIA's), every imported page must
be mapped from its file, a kernel mapping a 4 KiB page of an x86-64 guest. So
far an import took those mappings as far as the whole budget of
vm.max_map_count, the headroom kept for what has no other way included, and
past it was handed over as mapped, which the driver refuses.

metal2vulkan's runtime now asks a gate before it imports a no-copy buffer's
or heap's pages, or a buffer's new pages, by their pointer
(HostMemory::with_import_gate), and makes the buffer or heap over a copy of
the pages in the device's own memory where the gate refuses. Every import the
platform hands the runtime carries the views' gate:

- A buffer's or heap's import maps its pages from their files only short of
  the headroom, as views do. Past it, the pages stay in views through
  dma-bufs, and the gate refuses them, so the buffer or heap is copied, which
  takes no mapping. The writable twin a buffer's read-only pages need also
  stops short of the headroom; without one, the gate refuses the read-only
  pages and the runtime copies them where they were refused before.
- A rebind's or a device lend's import has no other way: a heap's rebind is
  never asked, and a buffer's rebind the gate refuses is refused itself where
  a texture's image lies in place over the buffer, which dies. So those still
  take the whole budget, and are handed over as mapped past it.
- Before a buffer or heap is copied, the views no import holds are folded back
  into dma-bufs, as the whole budget's claims do, where the views grew or an
  import was freed since the last such fold: a fold reads every run of the
  backing table, and a copy costs each command buffer a compare of its bytes.
- Each copy is counted with its bytes, traced (nrcopy for pages left in
  dma-bufs, notwin for read-only pages with no twin) and logged at powers of
  two. The runtime announces each (copied-host-pages, a kind of DIES), so
  strict mode ends the process there.
- The startup line for a guest whose RAM would not fit the budget is
  information now, not a warning: past the line buffers are copied, slower
  but working, and the sysctl it names is a speed-up.

What the guest sees changes only past the headroom on such a device, where a
buffer or heap is copied rather than refused.

Checked on this tree with the pin before it, whose only difference from the
tree tested is a doc comment:
- on the M3 Max (macOS 27.0.1): the three clippy passes cargo xtask check makes
  (the Mac's, its tested features', and x86_64-unknown-linux-gnu's), rustfmt,
  and the 905 tests of reims-vgpu-vulkan and reims-vgpu on MoltenVK: 104 fail,
  the same 104 development fails (development's own run of the pin's failures:
  104 failed and one passed, no_copy_buffers_over_pages_without_access_are_
  nil_as_metals, which passes here now);
- on msi's RTX 5080 Laptop GPU (NVIDIA 615.71.09): the Vulkan crate's tests
  and reims-vgpu's and the C API's video and scaler tests, 503: the three
  encode_render colour failures development has, and three aborts under the
  run's load (an_execution_of_states_of_its_own_writes_no_bound_texture,
  a_surface_texture_keeps_its_range_until_its_command_buffer_completed,
  every_texture_takes_a_descriptor_while_it_lives), each passing alone.
The AMD and Intel Linux hosts were offline, so RADV's and ANV's imports were
not run. Only the Vulkan crate links the runtime, so the rest of cargo xtask
check and the suite, which drives the Metal platform, do not reach the change
and were not run. Neither commit changes what the Vulkan platform ends the
process on by default or what device info and feature queries answer, so no
cold boot is owed.
2026-10-29 00:48:51 +02:00
Anees Iqbal 3bad8fe3a0 🐛 Answer as memory runs out where the host refuses a map
On Linux the library's views of guest memory hold kernel mappings within a
budget short of vm.max_map_count, and where the host refused a map, a file or
memory that Metal's own call does not need, the process ended. A 4K Safari run
on an RTX 5080 Laptop host died so at the views' budget. Each such refusal now
answers with the refusal the same call gives on the Metal platform when memory
runs out, counted and logged at the first and at each power of two
(crate::answer::out_of_host_memory), and ends the process at the same call
under REIMS_VGPU_STRICT=1, so the tests that ran strict keep their deaths:

- a remap of guest pages, or a range a view can be made of, past the views'
  budget, or refused again at the kernel's limit after the idle views were
  folded back, answers KERN_NO_SPACE with nothing mapped, which core's
  map.rs takes as it takes Mach's;
- an IOSurface stand-in's memory is none, as IOSurface answers nil;
- a file the kernel gives none of (memfd_create, its size or its seals) is
  refused alike, and a dma-buf source that needs one for zeros refuses the
  request (NoFile);
- an import's writable twin past the budget is none: its read-only pages go
  to the runtime as they are, which refuses them as it refuses any such import;
- a buffer over a surface, or a heap over address ranges, whose alias the host
  refused is nil, nothing left mapped; the block of zeros an alias maps is
  asked for again after a refusal instead of being refused for good.

What still ends the process: a replace (replaceBackingWithRanges) whose alias
the host refused, and a call whose runtime refusal of read-only pages its own
policy answers with a death. Answering those as Metal would (YES with the
object left detached, its command buffers failing with code 8 until a retry
takes) needs the gap fallbacks the Vulkan platform does not have yet.
2026-10-28 23:31:37 +02:00
Anees Iqbal 617269da31 🐛 Keep guest-memory views within vm.max_map_count on Linux
An x86-64 macOS guest hands out its pages in 16 KiB clumps laid backwards, so
a view of them mapped from the guest's memfd takes a kernel mapping per 4 KiB
page. At 3840x2160 HiDPI on the RTX 5080 Laptop host, Safari's scroll held
about 4 GiB of surfaces at once, a million mappings, and the process died at
the views' budget, even at a vm.max_map_count of 1,048,576; at the kernel's
default of 65,530 far less ends it.

- Core's two mapping loops gather a mapping's pieces and hand them to
  HostVm::remap_runs_shared_overwrite in one call. Its default remaps a piece
  at a time, in order, so the Mac's Mach calls are unchanged.
- On Linux that call, the surface stand-in and the platform's aliases make a
  view of scattered pages as dma-bufs of them (udmabuf's UDMABUF_CREATE_LIST),
  one mapping per 1,024 pages at udmabuf's stock list_limit, where the host
  has /dev/udmabuf. A dma-buf of a read-only file is refused, and the view is
  mapped from its files.
- A device that pins a pointer import's pages (NVIDIA's 615) refuses both such
  a pointer and the dma-buf. Each device is probed as it is made; where one
  refuses, views are mapped from their files while they fit 8,192 mappings
  short of the budget, and through dma-bufs past that. An import of their
  pages, which has no other way, maps them from their files into the
  headroom too; only past the whole budget is it handed over as mapped, which
  the driver refuses, counted and logged (trace record noroom), and strict
  mode dies there.
- Before a view or an import would die or be refused at the budget, the views'
  pages mapped from their files that no live pinning import holds are folded
  back into dma-bufs, and the budget is weighed again. A map the kernel itself
  refuses at vm.max_map_count folds the same way and is tried once more.
- A device that needs pages mapped from their files warns when imports of all
  of the guest's RAM would pass the budget, with the sysctl value that covers
  them.

metal2vulkan's import gate, with which the runtime copies a buffer whose
import would pass the headroom instead of refusing it, is not in the runtime
at this pin; the imports past the whole budget move onto it at the next one.
qemu.md, "Linux hosts: vm.max_map_count", says what each host gets.
2026-10-28 23:31:37 +02:00
Anees Iqbal 3b085bf926 🐎 Back memfd guest RAM with huge pages where the host allows
QEMU mapped file-backed guest RAM, the memfd that reims-ctl's VMs run on, at
the base page's alignment, and the kernel puts a transparent huge page in a
shmem mapping only where the mapping's address keeps the file's offset in
one. So every reims-ctl VM ran on 4 KiB pages, whatever the host allowed.
QEMU 1b41f5f5 maps such RAM 2 MiB-aligned on Linux, as it maps anonymous RAM.

Nothing is forced: the host's shmem_enabled decides. At advise (CachyOS ships
it) QEMU's MADV_HUGEPAGE takes huge pages, at always or within_size the kernel
does, and at never or deny, upstream's default, nothing changes. KVM maps a
slot under the dirty log 4 KiB at a time, so where the dirty source runs the
guest keeps its huge pages only until the first harvest.

Measured on msi-5080 with no dirty source (macos-26, 16 GiB): KVM maps about
10 GiB of the guest at 2 MiB, none before, and the vCPUs' time a frame falls
6-7% in a drag and a UFO test at the same frame rate. qemu.md says so.
2026-10-28 22:55:25 +02:00
Anees Iqbal 12765ee8ae 🐎 Copy again only the guest pages written since the last copy
Where the Vulkan runtime keeps copies of guest memory in GPU memory (a
discrete GPU's, and an iGPU's whose driver cannot use the guest's pages in
place), it copied each one whole at each use, as nothing told it which pages
the guest wrote. Under KVM the host now gives the device a dirty source, and
the runtime copies only the row bands of the pages written since its copy.

- Core keeps the dirty log: a stamp per watched 4 KiB guest page (8 bytes),
  read without a lock, fed by the harvests and by the library's own writes
  into guest RAM (every GuestPtr write, the IOSurface byte copies, the video
  decoders' lends), each stamped after its bytes land, so a copy racing a
  write takes the page again. With no log a write costs one relaxed load.
  Waits are bounded (about 4 ms) and refuse at once while the device resets,
  pauses, stops or suspends; an answer the log cannot give is a whole copy,
  never a missed write.
- The C API, additively: RvgDeviceConfig's fourth version (72 bytes) carries
  an RvgDirtySource: the KVM VM's fd and four callbacks (start, flush_vcpus,
  for_each_slot, take_host_writes), and rvg_dirty_slot, which for_each_slot
  calls for each logged slot. The device's thread reims-vgpu.dirty
  runs each harvest: the vCPUs' page-modification logs flushed where PML is
  on, one KVM_GET_DIRTY_LOG and one KVM_CLEAR_DIRTY_LOG of exactly the
  watched pages written per slot, then QEMU's own DMA. QEMU's side is 154
  lines (vendor/qemu 01650c7f08).
- The Vulkan platform answers the runtime's DirtyPages per import, in the
  import's offsets, and leaves a shadow's own copy back out of its next copy
  in (REIMS_VGPU_DIRTY_WRITERS=0 counts it). The EFI framebuffer is never
  logged, so the firmware's presents never start the KVM log.
- REIMS_VGPU_DIRTY_PAGE_TRACKING=0 turns the source off.
- The runtime moves from metal2vulkan 0db5825a60 to eeb7934025, its release
  with the dirty-band copies, the discrete GPU's device copies of sampled
  textures and one wait per log per submission. It also fixes the MoltenVK
  failure the owner hit on the M3 Max with a macOS 26 guest ("Vulkan failure
  -3 (the pipeline of draw 0 of the command buffer's render encoder 0)" after
  a 4K HEVC decode): Core Animation's fragment that samples the in-place
  Y'CbCr texture in a loop had its push field's uvec4[2] materialized with an
  OpCopyObject, whose SPIRV-Cross copy Metal's compiler refused; 751c861c15
  copies it element by element. And it takes the device's native forms: its
  own depth bias on every depth format, its store of an extended-range,
  padded 10-bit or bfloat attachment's untouched texels, a half colour output
  declared 16-bit where the device enables storageInputOutput16, and its own
  Y'CbCr conversion for 4:2:2 twins and planes read in place. Its semantics go
  from 1907 to 1911, so every cached shader compiles again on the first boot.
- With the runtime's unused-bits load pass and its capture replay gone, a
  pass that loads and stores such an attachment keeps the bytes its draws do
  not write, and each draw announces extended-range-bits-kept; the
  unreached-tiles-rewritten kind is gone. The Vulkan platform's answer table,
  its tests of the extended-range formats and its docs follow, and the test of
  the captured reach goes with the machinery.

Measured on an RTX 5080 Laptop GPU with an x86-64 macOS 26 guest
(docs/qemu.md, "Linux hosts: the dirty source"): a window drag at 3840x2160
went from 18.0 to 26.1 fps with 439 MB a frame host to GPU, from 938; at
1680x1050 the drag stays at about 56 fps with 98 MB a frame, from 182, and
SM use 46%, from 65%. Pixels are unchanged. Nothing changes on macOS, nor
where the runtime uses the guest's pages in place.
2026-10-28 21:55:55 +02:00
Anees Iqbal f6b7e92720 🆕 Let a VM's settings turn video acceleration off
A user asked to be able to turn off the VideoToolbox and M2 scaler devices
that 054ac2080 gave every VM on reims-vgpu, the host's hardware video decode,
encode and scaling for the guest.

A VM's settings gain video_acceleration, on unless they say off, so every
existing vm.toml loads and saves as before. Off, the VM has neither device,
on x86-64 and arm64 alike, and the guest decodes, encodes and scales video in
software; the command line is then the one every VM ran before 054ac2080. On,
it is unchanged. The edit form has a Video acceleration toggle, hidden on
VMware SVGA, which has neither device either way; `set` takes
--video-acceleration[=false], and `show` gives its state. The OpenCore image
is unchanged: with the devices off, its video kexts match nothing.
2026-10-28 16:46:17 +02:00
Anees Iqbal 7198fe60c9 📝 Cut docs/testing.md and docs/qemu.md to what holds now [ci skip]
Both docs had picked up history, and docs/qemu.md had grown into a journal:
dated measurement blocks, the commits and builds each figure was taken at,
and the story of how each hang or death was hunted. A reader needs what
holds now.

docs/testing.md:
- Cut: which macOS builds the suite's host ran and when its files were
  dropped, a dated suite run, the run tallies behind the determinism and
  exclusive-scenario rules, a probe's raw values, and an Apple blob's size.
  Each now states its conclusion once, with its tag and the host that makes
  it checkable.
- Corrected to match QEMU: apple-gfx-iosurface-pci also drives the IOSurface
  host device and passes 8-byte accesses whole, and apple-gfx-pci isolates a
  task when its guest's mapper has a descriptor table, so it does not always
  run tasks in-process. The runner's MMIO row no longer explains itself by
  what QEMU did before, the environment list names REIMS_VGPU_TRACE, and a
  pytest wrapper that does not exist is gone.
- Facts said twice now live in one place, with a pointer from the other: a
  fresh device's registers (4.2), the EFI frame as a view (6.22), the debug
  layer's assert (6.21), the heap reply's descriptor bit (6.10), the W3
  recovery (6.7), and the runner's 32-bit IOSurface access (3.1).
- interplay_fifo_timeout_report_mismatch_dies no longer quotes 7.4 as "read,
  not yet locked": the row has been measured by that very scenario. A
  docstring is not hashed into the expected files.

docs/qemu.md:
- Cut: the measurement dates and the reims-vgpu, metal2vulkan and QEMU
  builds behind them; table rows and notes naming QEMU commits that the
  squashes and reverts left out of vendor/qemu's history (the table now
  names only commits in it, with one note for the replaced and reverted
  ones); the qtest and paused-realize logs, kept as the facts they showed;
  the lists of what was tried and was not the cause; and repeated facts,
  among them the density list policy.rs holds and the shadow-copy
  explanation video/bugs.md holds. Evidence lists fold into their
  conclusions, each marked measured with its host and guest.
- Corrected: the build's configure line gains --enable-gnutls, as the
  Makefile has it, and apple-gfx calls 21 of the header's 47 functions, not
  35.
- reims-ctl's command-line notes no longer cite docs/qemu.md for how long a
  core dump with guest RAM takes; that doc has never covered core dumps.

No rule, contract statement, ABI fact, kept behaviour, device contract,
procedure, host requirement or run instruction changed. Every section number
and title other files cite is kept and still says what they cite it for; the
4K-on-780M section keeps the tables and method that video/bugs.md's B73
points to.

Source: 501010f72 2d5eb81dd d261c89d4 2d25dc1e8
2026-10-28 01:19:16 +02:00
Anees Iqbal f424dadad9 🐛 Build QEMU with gnutls, and refuse vmapple without AES
vmapple's AES engine runs the guest's commands on QEMU's ciphers, and QEMU
gets those from a crypto library: gnutls, nettle or libgcrypt. Neither
install-ctl.sh nor `make qemu` asked for one, so whether QEMU had AES depended
on what else the host's Homebrew held. Built without one, QEMU falls back to a
stub that refuses every cipher. A macOS guest then hangs for good as it mounts
its root volume: its first AES DATA command fails and stays at the head of the
engine's FIFO, with every command after it. Serial output ends at "End of
iBootStage2", and the display never gets a mode. That was the hang on the
Scaleway M2 Pro Macs on macOS 27.2, whose Homebrew had none of the three; the
M3 Max's QEMU links gnutls.

- vendor/qemu moves to c7a4f070 on steelbrain/reims-vgpu. The AES engine
  checks at realize that AES-128, -192 and -256 work in ECB and CBC mode. A
  QEMU without them exits at start, saying what the build lacks, instead of
  hanging the guest.
- install-ctl.sh installs Homebrew's gnutls with the other formulas on macOS.
  Both it and `make qemu` configure QEMU with --enable-gnutls, so configure
  stops where gnutls is missing. An install's next update reconfigures QEMU,
  since its configure options changed.
- docs/qemu.md says how the hang was found and told apart from macOS 27.2,
  and README.md lists gnutls among QEMU's dependencies.

This is development-performance's 9d4f0a635, f8ef804f4 and 79225f10f
squashed. The QEMU change is its f1c10385 alone, picked onto development's
QEMU, without the dirty-source commits under it there.
2026-10-27 13:42:42 +02:00
Anees Iqbal 054ac2080e 🆕 Give reims-ctl's VMs the VideoToolbox and M2 scaler devices
QEMU has had apple-videotoolbox-pci and apple-m2scaler-pci since the video
devices landed, but reims-ctl never put them on a VM's command line, so no VM
it starts had them, and the drivers reims-util 381f913 puts in x86-64 images
had nothing to drive.

Every VM on reims-vgpu now gets both. An x86-64 VM has them at slots 8 and 9,
after the IOSurface mapper their ported drivers link; one on vmware-svga, which
has no mapper, gets neither. A vmapple VM gets them too: arm64 macOS ships the
drivers, which link the mapper vmapple builds in. A guest without the drivers
leaves the devices without one. docs/video/bugs.md's D6, the images without
the kexts, goes.

Both devices realize on the installed QEMU (paused, on an arm64 machine's
PCIe bus). No guest has booted with them from reims-ctl's command yet, and no
arm64 guest has run against them at all (bugs.md T9).
2026-10-26 14:18:08 +02:00
Anees Iqbal 28aecd0f04 🎨 Move the development scripts to scripts/internal
scripts/ mixed the one script a person installing reims-ctl runs,
install-ctl.sh, with eight that only developing the project runs: the worktree
and build environment, the GPU locks, the VM boot and tour drivers, the window
walk and the IOSurface qtest. Those move to scripts/internal, so scripts/ holds
what users run. run_vmapple.sh, walk_window_macos.sh and vm_drive.py find the
repository from their own path, one level deeper now; every reference in the
docs, the Makefile, the video crates' tools and the code's comments follows.
2026-10-26 14:08:39 +02:00
Anees Iqbal 95644d758d 🆕 Add the VideoToolbox and M2 scaler devices to the library and QEMU
A macOS guest hands its VideoToolbox sessions, and its
IOSurfaceAccelerator's scaling and conversion, to the host through two
virtio-PCI devices, 106b:1a03 and 106b:1a0b, as Virtualization.framework
gives them. The library gains their host side, VideoDevice and
ScalerDevice over core's host session and scaler, and QEMU their
transports, apple-videotoolbox-pci and apple-m2scaler-pci, with no
properties of their own.

The library picks each device's backend itself and logs why, on the GPU
apple-gfx-pci's device runs on, taken from the runtime's identity of it:
NVDEC and NVENC on an NVIDIA GPU, else VA-API on its render node, and
VideoToolbox on macOS. The scaler device exists on every host and refuses
its features where it cannot transform; a guest message over 16 MiB is
answered -12904 unread.

For the host: the C API gains rvg_video_device_* and rvg_scaler_device_*,
additively. For the guest: a VM given the devices has the host's video
decode, encode and scaling.

Source: c5b409362 375acb462 8be7593eb fbbeebfb2 e3d5616a4 60d08c4f4 c4c476643
        fe105edcb 36a6a82c6 ee2b1ca71 d7d5cfede b15f40717 a07ffd70b bfe6b8338
        7433026a9 0030b24a7 64497f931 76acbacc7 3bf366e81 6d3b97a59 fa5b4aafc
        401e0b727 1af53ce1a 0fa52d070 ce6eab571 33b40ae4a 82beaf64a ef26f02e1
        08bb763c4 5ff2dd73f 62e19c8ef ce406ddb2 fd92f66c4 52fba93c9 e179dc0bd
        b5f40ad74 d01bbdc9e 950a7e024 601c23067 9857b1fc8 b427bebfb 55a1d96e7
        a0243edfc ef54c395f c23c83073 bc6fcdaa7 1b783baca
2026-10-26 12:24:31 +02:00
Anees Iqbal d221a2b4e5 ✨ Give arm64 and x86-64 VMs a virtio sound device
QEMU's usb-audio has one output stream and no input, so a guest had no
microphone. reims-ctl gives every VM virtio-sound-pci in its place, with one
output and one input stream: arm64 macOS's AppleVirtIOSound matches it, the
driver Virtualization.framework's guests use. An x86-64 VM keeps its ICH9
HDA controller for OpenCore's boot chime; whether x86-64 macOS 26 drives
the virtio device has not been booted yet.

For the guest: a virtio sound device with a microphone, where it had a USB
audio device.

Source: 557ebcc85 e704daf94
2026-10-26 12:24:31 +02:00
Anees Iqbal c60e16cb18 🐛 Fix the window's capture, input and sizes, and offer the set rate
- A captured window drops its resize edges until capture ends, so a click
  where the image meets the window's edge reaches the guest.
- No window input reaches the host once the display's release has
  returned, and the display's end lets go of the keyboard grab, mouse rect
  and size hold the capture set.
- A sixth mouse button or later captures nothing, as the guest's tablet
  has no such button.
- A smooth scroll gesture whose end went unseen no longer decides where
  the next one goes.
- A mode or cursor the guest sets while the window's opening is posted is
  delivered.
- An X11 window is sized in pixels at the desktop's content scale, and a
  Linux screen's rate comes from modes of its own size.

For the guest: its display modes run at the host screen's current rate,
the one the person set, where they ran at the highest its size offers.
For the host: HostScreen's max_refresh_hz is refresh_hz in the Rust API
(the header changes in a comment only), and features.md registers that a
captured window cannot be resized.

Source: 5806f9c1c bc50f04b4 b12cb3ab0 76b7ae409 f6c3b116b 5811164a5 2ad407c98
        42c178305 6415d881f 1c0563f85 78426429a e61a8dc56
2026-10-26 12:24:31 +02:00
Anees Iqbal afdb76f844 🆕 Give every x86-64 VM the IOSurface device over PCI
An x86-64 macOS guest running Apple's arm64 GPU driver, ported, needs the
IOSurface host device vmapple has as apple-gfx-mmio's second region: the
driver's start waits for its mapper's service, and every texture over an
IOSurface is a mapper texture. reims-ctl now gives every x86-64 VM on
reims-vgpu that device, with no opt-in, and Apple's own x86-64 driver keeps
running as before.

For the guest:
- apple-gfx-iosurface-pci (106b:eeef, ours) sits at 00:06.0 next to the GPU
  at 00:04.0: its registers in BAR 0 at 0x1000, 8-byte accesses passed
  whole, one MSI vector per completed command. A reset returns its
  registers to 0, ring size aside.
- 0x1028 offers the second, 0x400-byte descriptor form only where its table
  holds all 8192 mapping ids (16 KiB pages); on x86-64's 4 KiB pages it
  reads 0, and the guest's mapper takes the first form, which fills them.
- On apple-gfx-pci, a task other than task 0 runs isolated only if the
  IOSurface device has a descriptor table when the guest defines it, and
  device info offers argument buffers (key 33 bit 0x20, key 42) only while
  it has one. Apple's x86-64 driver, stock (binary version 6) or patched by
  reims-util (245), never programs the IOSurface device and makes ref
  textures whose backing is in task 0, which an isolated task does not
  serve (testing.md 6.20); its tasks stay in process and its device info
  is as without isolation. The ported driver's mapper programs the device
  before its GPU driver starts, and its tasks run isolated, which its info
  replies need. apple-gfx-mmio still isolates every task.

For the host:
- apple-gfx-pci has no option for this: adding apple-gfx-iosurface-pci is
  the only switch, and a VM without it runs as before. Its gpu link is
  optional, the machine's only apple-gfx-pci when unset. vendor/qemu moves
  to bd95509a.
- RvgDeviceConfig gains process_isolation_follows_guest at its end (64
  bytes; a host that passes 56 reads it false), and the Rust API's
  DeviceConfig the same field; apple-gfx-pci always sets it with
  use_iosurface_mapper and process_isolation. Each task made under it logs
  whether it runs isolated or in process, and device info logs each change
  of its argument-buffer answer.
- reims-ctl's q35-x86_64 profile adds
  apple-gfx-iosurface-pci,id=iosfc,gpu=gfx,addr=0x6; vmware-svga and
  vmapple VMs are unchanged. reims-ctl and QEMU from this commit go
  together, as its installer installs them.
- On Linux, the detach heap's temporary and a writable alias with zeros
  past its pages come from a range of a file of the library's own, so the
  Vulkan platform can alias and import them; QEMU no longer ends at an
  x86-64 guest's first such heap. macOS is unchanged.
- The first command given to a task whose service has died writes one
  warning naming the task.
- scripts/qtest_iosurface_pci.py checks the device under qtest (27 checks).

Checked: cargo xtask check and the suite on the M3 Max; reims-ctl's install
and a cold boot on um780; stock, reims-util and ported-driver guests booted
on gem10 and ms01 with the isolation rule, Apple's driver's tasks in
process at about 62 fps, the port's isolated.
2026-10-17 06:43:31 +03:00
Anees Iqbal c03936edfc 🐛 Boot arm64 macOS 27 guests: virtio capabilities in address order
A macOS 27.0.1 (26A434) guest showed a black screen on vmapple: each of its
virtio devices read the PCI_CFG capability at 0x84, then the notify
capability at 0x70, then started over, about 100 000 config reads a second.
QEMU links the capabilities from high offsets to low, and macOS 27's virtio
transport never starts a device whose list runs that way. No device's status
left 0, the root disk saw no I/O, and the kernel never reached its GPU
driver. macOS 26 walks the same list once and goes on.

vendor/qemu's d235e51310, Jesus Martínez's change, relinks the capabilities
in address order on vmapple-virtio-blk-pci, and on virtio-net-pci under
x-ascending-capabilities, and gives the disks Apple's vendor capability;
fbda9c8b28 turns x-ascending-capabilities on in vmapple's defaults.

What the guest sees: the same capabilities at the same offsets, linked in
ascending order, and on its disks one more, Apple's. A macOS 27.0.1 guest
reaches Setup Assistant and its login window on the library's Metal
platform, and a macOS 26 guest still reaches its desktop, each booted with
reims-ctl's command unchanged. reims-ctl's QEMU takes this at its next
update; no VM's settings change.

docs/qemu.md lists the commits and records the measurements.
2026-10-14 23:51:03 +03:00
Anees Iqbal 7685e5027a 🆕 Let x86-64 VMs run on VMware SVGA in QEMU's own window
An x86-64 VM's edit form (e) and reims-ctl set --graphics now choose between
reims-vgpu and QEMU's VMware SVGA II, for when a guest should come up without
the library: the firmware's framebuffer, one display, no GPU acceleration.

With VMware SVGA the library takes no part: vmware-svga takes apple-gfx's slot
and its id, gfx, which the terminal viewer's screendumps and input name, the
library's window and GPU variables and warnings are left out, and QEMU's own
GTK window shows the display. install-ctl.sh builds Linux QEMU with GTK for
it; on a QEMU without it, start refuses and names reims-ctl update. With no
Wayland compositor or X server in QEMU's environment (reims-ctl's, under the
VM's extra environment), GTK would end QEMU at its start, so the VM runs
headless under -display none there, as the library's window does. The edit
form hides the display and GPU fields on VMware SVGA and keeps their values
for a switch back; a test pins that a field following one the form lacks (an
arm64 VM's, with no graphics choice) still shows.

Booted on msi-laptop (docs/qemu.md): macOS 26.6.1 reaches its desktop at
1280x720 in QEMU's window, the viewer's screendump and input work, and stop
shuts it down.
2026-10-14 00:33:10 +03:00
Anees Iqbal 9ec90bb632 🐛 Give x86-64 VMs no ACPI S3, so a sleeping guest's display wakes
An x86-64 macOS guest that system-sleeps never gets its display back. Idle
sleep or Apple menu > Sleep puts it in S3, and in QEMU only PS/2 input
requests a wakeup: the USB keyboard and tablet on qemu-xhci leave it
suspended behind a black window. A wake that does come (an RTC alarm,
QMP system_wakeup) resets every device, and the guest's GPU driver
restores none of the device's state, so WindowServer waits on the GPU
for good and the guest hangs.

q35 VMs now run with ICH9-LPC.disable_s3=1. The guest's sleep then stops
at a dark wake: the display turns off and input through the window turns
it on again, in all 8 rounds measured on um780 (docs/qemu.md, "x86-64
macOS guests: sleep").
2026-10-13 23:27:37 +03:00
Anees Iqbal a5777987ef 🔥 Drop the 2048-pixel warning for x86-64 VMs
An x86-64 VM's details warned that a display wider than 2048 pixels, or
resolution = "host", crashes its WindowServer. With ReimsVgpu.kext in its
OpenCore image and the host's real-extent check, macOS 26 runs such a display,
so the warning would steer people off a resolution that works; an image
without the kext now gets its own line (opencore.rs), which says how to
replace it.

docs/qemu.md's section says what fixes it and what was measured with the kext,
and the README no longer says there is no kext.
2026-10-13 19:34:48 +03:00
Anees Iqbal b859025495 🐛 Stop PerfPowerServices spinning on x86-64 guests' SMC
macOS 15.4 and later walk the SMC's keys at boot, asking isa-applesmc for
key after key by index until it answers that the index is out of range.
QEMU's device took reads alone and answered every other command "bad
command", so the walk never ended: on an x86-64 macOS 26.6.1 guest behind
reims-util's OpenCore, PerfPowerServices ran a vCPU at 100% from boot on,
and QEMU used more than a host core with the desktop idle, as a user
reported.

vendor/qemu's 8d795445f2 answers GET_KEY_BY_INDEX, listing four keys in
the order of their names and answering 0xb8 past the last. The walk now
ends: PerfPowerServices used under 1 s of CPU in its first 3 minutes, and
QEMU 15% to 25% of a core once the guest settled, from 119%.

What the guest sees: GET_KEY_BY_INDEX answered where it was refused.
Every other command, every key and every value are as before. reims-ctl's
QEMU takes this at its next update; no VM's settings change.

docs/qemu.md describes what the device answers and what the boots measured.
2026-10-13 15:47:45 +03:00
Anees Iqbal 0d44fea30a 🐛 Keep QEMU alive when a guest process dies with work queued
A guest empties a task's object list when the process that owns it ends,
without waiting for the execs that process queued. On an x86-64 macOS 26
guest the icon services abort as they start (Metal's nil device
architecture, docs/qemu.md), and the host, still compiling pipelines for
earlier execs, reaches their last execs after the lists are gone. Most
lookups then fail and fault the exec, but two answered nil where nil ends
the process:
- A pipeline descriptor's function: Metal aborts on a render descriptor
  with no vertex function, and QEMU died at Setup Assistant on a new
  install (2 of 10 boots on an RTX 5080 Laptop GPU host). A function whose
  entry is empty now raises the function lookup's failure.
- A resource named by UseResources in a concurrent compute encoder, where
  Metal ends the process at a nil entry. Such a reference whose entry is
  empty now raises too. Serial encoders, barriers and the render lists
  keep the nil, which Metal skips.
The Vulkan platform ended the process at a nil entry of
useResources:count:usage:stages:, which nothing had measured on Metal.
Metal skips it (measured here), and so does the platform now.

reims-ctl adds dump-guest-core=off to the q35 machine on Linux hosts. With
guest RAM in the core, a crash took QEMU 26 s to go away (a 2.7 GB core)
while its window stayed frozen; with the option, 1 to 4 s. QEMU refuses
the option on macOS, so the vmapple command line is unchanged.

What the guest and host observe: an exec whose pipeline function, or whose
concurrent UseResources reference, has an empty entry faults instead of
ending the process. interplay_lifetime_held_pipeline_function_retyped is
recorded again; interplay_lifetime_emptied_resource and
interplay_lifetime_emptied_resource_render are new. Six boots of the new
install to Setup Assistant on the fixed builds kept QEMU alive, though
none reached an empty function entry. docs/qemu.md records the race's
measurements and why no value the host answers avoids the nil
architecture.
2026-10-13 01:24:15 +03:00
Anees Iqbal 4a8bfb4ebd 🆕 Give x86-64 guests VMX where the host's KVM offers it
With VMX in its CPU, a macOS guest's Hypervisor.framework works, so Docker,
UTM and other VMs run inside it. reims-ctl adds vmx=on to -cpu only where
kvm_intel is loaded with nested on, the one place KVM can give it: AMD's KVM
offers SVM, which macOS does not drive, and HVF offers neither. Elsewhere the
command is unchanged, so QEMU's check never drops the flag with a warning.

It is vmx=on, not +vmx, so a VM's vmx=off or -vmx in cpu_flags takes it away:
QEMU applies name=value flags in order and + and - ones after them, so a +vmx
would outlive a vmx=off.

Booted on homelab-ms01 (i9-13900H, nested Y) from overlays of its macOS 26.6.1
guest, on Haswell-noTSX and on Skylake-Client-noTSX-IBRS: no dropped feature,
kern.hv_support 1 in the guest, and a clean desktop and shutdown
(docs/qemu.md).
2026-10-12 22:30:53 +03:00
Anees Iqbal 39d6ca78ef 🆕 Make new x86-64 VMs from reims-util's macOS downloads
A new x86-64 VM needed an OpenCore image and an installer made by hand with
OSX-KVM or ULTMOS. reims-ctl now runs reims-util for both: pick a macOS
version (n in the interface, create --macos on the command line) and it
downloads the installer from Apple, makes the VM's OpenCore image with OVMF
and a Mac identity of its own, and makes the disk.

- create --macos VERSION downloads Apple's recovery image (about 1 GB), or
  with --offline an installer of one release (13 to 20 GB). Installers are
  kept in the data directory's installers for the next VM, one reims-util at
  a time writes there, and a stopped download continues. The download comes
  before the VM's directory, so stopping it leaves no VM half made, and
  reims-util ends with reims-ctl on Linux. What create is given (a disk, an
  installer, an OpenCore image and the OVMF beside it, reims-util itself) is
  checked before the download and the disk's copy, and the VM list is read
  again before the VM joins it, so VMs made or deleted during a download
  stay as they are.
- --opencore is optional: without it reims-util makes the image, with the
  VM's MAC as its ROM, and an iMacPro1,1 for macOS 10.13 and 10.14. An image
  of the user's brings OVMF_CODE.fd and OVMF_VARS.fd beside it, as
  reims-util writes them.
- The interface's form asks where macOS comes from, the version first; with
  no name, the VM takes the version's, skipping names a VM or a leftover
  directory has. A VM with an installer says in its details, and create
  prints, how to install macOS from it; one made from a disk is reminded to
  set Metal's error mode.
- A new disk needs an installer or a download: a VM of an empty disk and no
  installer is refused.
- Every installer attaches as a read-only disk (snapshot=on), a DMG
  converted to a raw image in the VM's directory, so the CD drive is gone: a
  change of installer applies at the next start. vm.toml's installer_kind
  is no longer written, and is ignored where an older vm.toml has it. A
  missing installer says how to eject it.
- reims-ctl __record-install, which scripts/install-ctl.sh runs last,
  installs reims-util at the commit reims_util.rs pins, so the update that
  brings this reims-ctl installs it too, though it runs the script it
  started with. doctor checks for it in place of the system's OVMF, and the
  install no longer adds the ovmf or edk2-ovmf package.
- vm.max_map_count: a new VM's default of up to 16 GiB needs about 1.13
  million mappings, more than the 1048576 suggested (CachyOS's stock
  value). The README, the install script, doctor and the start warning
  suggest 2097152, which covers 30 GiB, and check against what the VM, the
  largest VM or a new one's default needs.
- Updating from the interface while a create runs says the restart stops
  it, as quitting does.

Dropped, as reims-util's images leave nothing for them to cover:
- create --from-script and the interface's launch-script import, which read
  OSX-KVM's and ULTMOS's QEMU scripts. A VM made from one keeps working; its
  vm.toml names its own copies.
- The search for OVMF beside a user's OpenCore image in those projects'
  layouts, QEMU's edk2 build and the distributions' packages, and
  --firmware-code and --firmware-vars.
- create --disk-mode overlay: copy, a reflink where the file system can, or
  in-place covers an existing disk. A VM made with an overlay keeps working.
- --cpu-model and --cpu-flags on create and set, and the edit form's CPU
  fields: new VMs take Skylake-Client-noTSX-IBRS. vm.toml keeps cpu_model
  and cpu_flags, so an older VM keeps its model; docs/qemu.md says how to
  change it there.
- --installer's --iso and --cdrom aliases.

README, the help and the docs no longer point at OSX-KVM or ULTMOS. README
step 3 describes reims-util's OpenCore picker (5 seconds, which an arrow key
stops, measured on homelab-ms01), and architecture.md 11.4 counts its image
among those that keep AvoidRuntimeDefrag on.
2026-10-12 19:37:12 +03:00
Anees Iqbal 8b00782076 📝 Record why x86-64 guests' WindowServer dies above 2048 px
A tester's x86-64 macOS 26 guest crashed WindowServer at boot at 2736x1704,
with METAL_ERROR_MODE set. The cause is the guest's own: x86-64 SkyLight
draws a large window in 1024-pixel tiles over a no-copy buffer, the guest's
Metal plugin refuses every bottom-row tile but the first, and SkyLight then
indexes its shorter texture list unchecked. At three tiles across the reads
leave the list's allocation and WindowServer dies.

Record the code read, the plugin's refusals in the guest's log and the
measured death rates by width, so that the 2048-pixel limit has its reason.

[ci skip]
2026-10-12 14:49:21 +03:00
Anees Iqbal 24b37c9ac5 🐛 Keep host-copied textures out of incoherent memory on Intel
Arrow Lake-S's iGPU shares no last-level cache with the host, and ANV's one
host-cached memory type there is not coherent. metal2vulkan placed Shared and
Managed textures in it for their host copies, and the GPU read stale 64-byte
lines of them: an x86-64 macOS guest showed sparse, fully transparent 4x4-pixel
blocks in its boot logo, Dock icons and widgets, a third of the logo's interior.

metal2vulkan edb5ffd8cc takes a host-cached type for those textures only where
it is also coherent, and never one the host maps without coherence; on such a
GPU they lie in its coherent type, whose host reads are slower. Every GPU whose
cached types are coherent (NVIDIA's, RADV's, MoltenVK's, lavapipe's) keeps its
placement. A cold boot of the guest on that iGPU shows no blocks; docs/qemu.md
records the measurements.
2026-10-12 13:47:08 +03:00
Anees Iqbal dd1934ca1f 🐛 Give new x86-64 VMs the Skylake-Client-noTSX-IBRS CPU model
Haswell-noTSX is model 60, stepping 1, and XNU panics on Haswell steppings
below 3. It booted only behind an OpenCore that replaces CPUID leaf 1, as
ULTMOS's image does; OSX-KVM's current image, which the README points to
first, does not. Skylake-Client-noTSX-IBRS is a model XNU knows, so the guest
boots with or without that spoof, and it is what OSX-KVM's launcher now uses.

Cascadelake-Server, the other model suggested, was ruled out: on AMD hosts
it exposes AVX-512, whose state XNU saves at Intel's XSAVE offsets only, and
a macOS 26 guest on a Zen 4 host lost mask registers across a signal handler.
docs/qemu.md records the measurements.

Existing VMs keep the model their vm.toml names.
2026-10-12 13:09:33 +03:00
Anees Iqbal 36102ed710 Merge branch 'development' into steelbrain/x86-metal-error-mode-docs 2026-10-12 11:54:05 +03:00
Anees Iqbal 88c9d3e72d 🐛 Import pages RADV refuses as host memory as udmabuf dma-bufs
RADV imports host memory as an amdgpu userptr, which Mesa asks for with
AMDGPU_GEM_USERPTR_ANONONLY, so the kernel refuses every page with a file
behind it. The guest's RAM and every view the library makes are memfd pages,
so on an AMD GPU a macOS guest died at its first no-copy buffer.

The runtime (metal2vulkan 11715e2a3f) now asks the caller for dma-bufs of
the pages wherever the pointer import is refused, on any driver. The library
answers with /dev/udmabuf: it resolves the range through the backing table,
gives the shared block of zeros' pieces a file of the import's own, cuts the
runs into chunks within udmabuf's limits as the host has them (1024 pieces
and 64 MiB by default, which no one is asked to raise) at the runtime's bind
granule, and pads several chunks to the granule. The runtime binds them
behind one sparse buffer, and asks again for a texture's own pages. Its own
memfds are sealed against shrinking, which udmabuf requires. A refusal names
its cause in the death line.

reims-ctl and the installer warn when a VM that would run on an AMD GPU
cannot open /dev/udmabuf (the kvm group's on Ubuntu), and reims-ctl's logs
show the device and its limits.

On the Radeon 780M (RADV of Mesa 26.0.8, udmabuf at its defaults) the guest
now cold-boots to its desktop, and Safari loads a page and quits: 5,119
dma-buf requests, none refused. NVIDIA, which imports the pointer, and macOS
are unchanged.
2026-10-12 11:50:33 +03:00