Commit Graph
1460 Commits
Author SHA1 Message Date
Anees Iqbal 029fbe1ed7 🐛 Place the bundle only on a volume that takes writes
The placement writes below the VFS, which skips its read-only check, and it
wrote into /System/Library/Caches without making that check itself, where the
BaseSystem's install makes it for /Library. Every release we keep firmlinks that
path to the Data volume, so no boot has reached a read-only place, but where the
path resolved to the sealed system volume the kext would write into it.

rgfx_place.h's steps now ask the file system whether the volume a path resolves
to takes writes (KernelPlace::writable: vfs_isrdonly of the path's mount, or of
its nearest existing ancestor's): placing on a read-only volume writes nothing
there and leaves the tree at /Library/GPUBundles, and a placed tree on one does
not move back, so the install stages nothing and the placement stays as it was.
place_test covers both over a directory whose volume answers read-only while
its writes still succeed, as the kext's do. For the guest: nothing changes on
the releases we keep; the check adds one lookup per pass.
2026-12-03 02:57:54 -08:00
Anees Iqbal 59cb1b53ff 🐛 Answer a release or re-naming of pages after a make's span
A make in place copies a cached surface's pages out and back around its image's
first layout move. A BLOCK_RELEASE of the block, or a SURFACE_PAGES that names
the block's pages again, did not wait for that span: either one's answer lets
the guest take the pages back, and the make's copy back could then write the
bytes it saved over what the guest wrote there next.

Both now wait for the span before they are answered, as a begin that uses the
block does, at most the same bound, and count as the begin's waits do. The
tests take a release and a naming of the pages inside a make's span on a thread
of their own and find each answered only after it.
2026-12-03 02:57:49 -08:00
Anees Iqbal 40dc87b946 🐛 Refuse a make in place over pages that lack the cache's write
A command buffer that writes a surface's device cache can end between the
host's decision to make a texture in place over the surface's pages and the
make's fence. The cache then holds a write the pages lack, and nothing kept a
download of the surface out of the make's span: the download copied the write
into the pages, and the make's copy of the bytes back undid it, while the host
held the pages as having it. The guest's lock then read the old bytes.

The fence now refuses the make as busy wherever the decision's own "behind"
rule holds at the fence: the shape takes the host's own image, and a later
begin moves it in place once the pages hold the write. A block free of that
holds no write the pages lack, so a download inside the span copies nothing.

The test runs the write's begin on a sibling decoder between the decision and
the fence, and a download inside the span, and reads the write in the pages.
2026-12-03 02:57:49 -08:00
Anees Iqbal 94ec584792 📝 Note how a fake's own copy of guest memory hides a race [ci skip]
The first red test of a CPU write lost inside a make in place passed before any
fix (job m3-max-82675): the fake platform's import of the pages was a buffer of
its own, so the make's save and write-back never reached the pages the guest's
lock wrote. docs/lessons.md now says how to spot the next such test.
2026-12-03 02:57:49 -08:00
Anees Iqbal 0b44900694 🐛 Keep guest writes out of a make's copy of a surface's pages
On a host whose GPU shares the CPU's memory, rt makes a texture in place over
a cached surface's pages by copying the bytes under it out and back around the
image's first layout move. A guest write to those bytes inside that span was
lost (the two tests of the commit before), where a Mac keeps it. The make now
runs rt's RestoreFence around the span, which keeps its writers out:

- The guest's read-write locks. A new device feature, FEATURES_EXT bit 1
  (SURFACE_HOLD), is taken in a new register, DRIVER_FEATURES_EXT (0x05c).
  Where the driver took it, the host raises a hold word in the cached block's
  header (offset 8) before the copy out, rereads the surface's CPU generation
  after a full fence, and refuses the make as "unsettled" where a lock moved
  it. A lock that finds the word raised sets WAITED and waits. The host lowers
  the word once the bytes are back and, where a lock waited, posts
  SURFACE_HOLD_LOWERED (0x413), whose vector wakes it.
- The device's own writers. The make is refused as "busy" where a command
  buffer that uses the cache is begun and not ended, or a copy into its pages
  or a fill from them is in flight. Otherwise the block is marked made, and a
  begin that uses it waits for the span's end, at most 100 ms.
- The thread that made a texture over a buffer of its own pages. Where the
  driver took the hold, the host answers each TEXTURE_FROM_BUFFER and
  LINEAR_TEXTURE_FROM_BUFFER over a BUFFER_OVER_PAGES buffer with a COMPLETE
  once carried out, so the thread's writes after its create follow the span.
  This is a device-wide rule (A), not a per-block flag (A'): on Linux, whether
  a block's make restores (its import by address, not as dma-bufs) depends on
  the views' folds at their budget and on rt's refusals, which come after the
  pages are answered, so no answer can carry it exactly. The rule only waits
  more, and its waits are counted (rt-pages-texture-creates-answered, -ns).

A driver that does not take the hold, as the kexts before this change, gets no
make that would copy the bytes out and back: it is declined as no-lock-hold,
and the shape takes the platform's own image. That is decided up front where
every import of pages lies in host memory (a Mac, Windows), and per block on
Linux once a make over the block's import ran the fence.

What the hold does not cover: a guest thread writing those bytes with no lock,
or another device's DMA, inside the span; and a read under a read-only lock
then may see other bytes. docs/known-issues.md says so, with the hosts.

The two red tests pass. New tests cover a lock ahead of the hold, a command
buffer and a copy in flight, a begin inside the span, the device's register
and event, and the answered creates. Each writer kind's tests fail with its
check switched off (job m3-max-82923).
2026-12-03 02:57:38 -08:00
Anees Iqbal 30d1641878 📝 Record the placed update's trap in lessons.md [ci skip]
A step in front of an atomic replace removed the live tree the replace was to keep, and the rename's lookups followed a final link. Both were found in review; the lesson names place_test's red and green runs and how to spot the next one.
2026-12-03 02:32:00 -08:00
Anees Iqbal 95ca58c498 🐛 Correctness fix: keep a whole bundle through a placed update
A failed update on a placed system left no bundle at all. To write at the
bundle's path as before, the install removed the link and the placed tree,
the live bundle, before it staged; a stage or final rename that then failed
(a write error, a full Data volume) left nothing in /Library/GPUBundles or in
the placed directory, so that boot had no Metal device. Before placement the
swap always kept the old tree whole, as installBundle's comment promises.

The install now removes the link and moves the placed tree back to the
bundle's path, so the swap exchanges it whole and a failed install leaves it
there; the pass then places whichever tree is at the bundle's path, the new
one or the old. A link that cannot be removed, or a tree that cannot move
back (the link is made again), leaves the placement as it was and stages
nothing, and a link still at the bundle's path when the staged tree is to go
in stops the rename. A placement that finds no tree at the bundle's path
moves nothing, so a placed tree left by a pass that ended between the move
and the link stays for the next install to move back.

The rename looks both ends up without following a final link, as rename(2)
does: a followed link at the target handed VNOP_RENAME(X) the link's target,
a directory elsewhere, under the link's name and parent. The AppleGVA
preference's atomic write shares the rename.

The steps' order moves to rgfx_place.h, over the file system as a parameter,
and tests/place_test.cpp runs it over real directories with each step made to
fail in turn.
2026-12-03 02:32:00 -08:00
Anees Iqbal 0a7c92abfd 📝 Say what the device answers of samplers, tiles, dylibs [ci skip]
The oracle doc's Q9 "ours" column and Q30, and the register's %spi-no-dylibs
reason, still told what the device answered before the runtime became its
platform. Each now says what the code answers, citing it:

- maxArgumentBufferSamplerCount is 3999, the runtime's sampler indices, not 0;
- the sparse tile sizes are 0x0x0, the AMD's: the runtime has no sparse
  textures, and the device info carries no tile;
- supportsFunctionPointers is the runtime's YES, and supportsDynamicLibraries
  its NO, beside the lane's NO for supportsRaytracing;
- Q30: the device makes no dynamic library: both dylib queries answer NO, and
  a make that reaches the host answers its refusal, where the old paragraph
  said every answer was the AMD's;
- %spi-no-dylibs: the base's NO is the lane's answer, as no dynamic library
  is made, where it said the lane made a compute pipeline's.
2026-12-03 01:22:50 -08:00
Anees Iqbal cca4d4b7e5 📝 List the 3D model previews that quit on Apple silicon guests [ci skip]
On an arm64 guest on macOS 27, Preview and Quick Look quit when they show
a 3D model: macOS draws part of the model's lighting into a texture format
that Metal lets programs write only on a GPU that reports an Apple family,
and our device reports none until it can do everything a family promises
(docs/graphics-kext/design.md, item 10). Intel Mac guests show the models.
2026-12-03 01:22:50 -08:00
Anees Iqbal 55bed1857c 📝 Say rt refuses memoryless textures, in the oracle's Q5 [ci skip]
Q5 said our stack makes memoryless textures. At pin 208360ab6d
metal2vulkan's runtime refuses one at its create (Gap::MemorylessTexture),
and the platform answers the guest nil, counted under rt-refused-gap
(rt_refused_texture_create), so the note says that.
2026-12-03 01:22:50 -08:00
Anees Iqbal 3902b5dbe1 📝 Say the lane carries Apple1's to Apple3's pieces [ci skip]
design.md item 10 still said Apple3 waited on indirect command buffers. The
lane has carried them, with a compute one's memory barriers and binary
archives, since they joined WIRED in device_info.rs, which already says it
carries Apple1's to Apple3's pieces and holds every Apple family at none
until each piece up to Apple7's is carried. The item now says the same, and
names the first pieces it lacks, Apple4's tile pipelines and imageblocks.
2026-12-03 01:22:50 -08:00
Anees Iqbal 174f2a4d4e 🐛 Count the placed bundle's mappings in check-boot's amfi-map
On a full system RgfxGate now places the Metal bundle's tree under
/System/Library/Caches/ai.aneesiqbal.reims-graphics and links
/Library/GPUBundles/reims-graphics.bundle to it, and Metal maps the
executable by the placed path. amfi-map counted WindowServer's mappings of
GPUBundles/reims-graphics.bundle alone, so every arm64 boot with the
placement read "maps the bundle 0 times" and failed, while
windowserver-metal and metal-app passed on the device (arm64 26.6.2 under
TCG on the 780M). It now counts mappings by either path.

The placement was checked by walks that ran no check-boot; docs/lessons.md
gains the trap, and docs/qemu.md says which paths the check reads.
2026-12-03 01:22:18 -08:00
Anees Iqbal 8c6386f0b9 🐛 Place the Metal bundle under /System, linked from GPUBundles
A sandbox profile built on the system's base profile lets its process read
under /System, and /Library/GPUBundles only where it also takes the system's
graphics rules. Sandboxed processes without them were refused our bundle's
files and found no Metal device on our GPU, where on a real Mac they have
one: on arm64 the 3D-preview service, on x86 and arm64 the attributed-string
agent, and other agents.

On a full system RgfxGate now moves the installed tree to
/System/Library/Caches/ai.aneesiqbal.reims-graphics, a Data-volume directory
whose path is under /System, tags it like the bundle, and makes
/Library/GPUBundles/reims-graphics.bundle a tagged symbolic link to it, below
the MAC layer like the install's other writes. The signature pin and the
install writes take the placed directory too. An install or update removes
the link and the placed tree, writes the whole tree at the link's path as
before, and places it again; a pass that finds the link only tags it again.
Base systems keep the tree in /Library/GPUBundles.

For the guest: Metal follows the link and maps the executable by the placed
path, IOGPU trusts it there, and no process is refused a read of either path.
Walks with the placement (m3-max-82522, -82508, -82615), each on its first
boot and, on x86, again after the guest's own restart: arm64 27.0.1; x86
11.7.11, 12.7.6, 13.7.8 and 26.7.2. Every release we keep reads /System in its
base sandbox profile (read from the guests' files: arm64 13.6 to 27.0.1, x86
11.7.11 to 26.7.3). On arm64 the 3D-preview service then reaches the open of
our user client, which its profile still refuses.
2026-12-03 00:55:26 -08:00
Anees Iqbal ac3d0a2804 📝 Say what the docs' Apple claims rest on, not how learned [ci skip]
The docs named sources for Apple's behaviour that this public repository
does not cite. A claim here cites a public header or SDK, or a probe, walk
or test of ours, or states the behaviour plainly.

Each such clause in design.md, dgpu-oracle.md, lessons.md, qemu.md and the
video docs now states the behaviour, with the release it holds on, and
keeps every measurement and boot of ours it cited; dgpu-oracle.md's one
row of that kind is marked unmeasured. testing.md's "read" tag now names
only our code, an open-source driver's, and what a public header or SDK
states.
2026-12-02 21:58:12 -08:00
Anees Iqbal 0b19de3e09 📝 Say which device a shared texture's token names [ci skip] 2026-12-02 21:51:00 -08:00
Anees Iqbal 4614fc15d4 📝 Describe textures shared across processes and FEATURES_EXT [ci skip]
design.md says how a shared texture crosses processes: the token IOSurface
as the capability, the kext's two calls and their names, one host storage
with a view per holder, what holds the name and the storage, the bound on
names, the feature that negotiates it, and the residuals. The register
table gains FEATURES_EXT at 0x058, a guest-visible read, the selector map
gains 23 and 24, and the kext's word gains SharedTextures.
2026-12-02 21:51:00 -08:00
Anees Iqbal c0a9aa89d3 🆕 Share textures across processes in the guest's Metal bundle
What changes for the guest: where the device offers shared texture names
(FEATURES_EXT) and the kext offers its calls, newSharedTextureWithDescriptor:
makes a Private texture by SHARED_TEXTURE_CREATE, newSharedTextureHandle
answers Metal's own handle over the texture's token IOSurface, which the
kext names at the first handle, and newSharedTextureWithHandle: opens the
texture the token names through the kext, with its descriptor and the
handle's label. supportsSharedTextureHandles answers YES there, as Metal's
devices do, where the IOGPU base answered NO, and a shared or opened texture
is shareable. Each was nil before, so the image viewer's 3D window stayed
white: HydraRenderingService draws into a shared texture and hands it over.

A host or kext without them, or any storage but Private, still gives nil
and posts none of the four messages; the creators take the plain create's
nil rules, as Metal's devices answer both alike (oracle_shtex). The
withResourceIndex: twin stays unsupported: the device picks every resource
id itself. The ledger row now says the platform's own shared textures stay
unbuilt and the guest's do not take them.
2026-12-02 21:51:00 -08:00
Anees Iqbal 6ae98ac228 📝 Name in D30 the shape kind rt refuses in place on the M3 [ci skip]
The census's kind lines named the one kind of shape whose move in place rt
refused on the M3, as host-memory: RGBA8Unorm, 18 by 18, of usage 0x7 in all
its textures. D30 names it, so it is not found again.
2026-12-02 21:47:26 -08:00
Anees Iqbal 8ad2f6c454 📝 Say in D30 where shapes lie in place and where O still copies [ci skip]
With the shapes' images in place over their pages on a device of one memory,
and a deferred surface's shapes moved there once its pages hold them, D30's
straight download is left on discrete and virtual GPUs, where rt makes no
image in place over host memory, and for the shapes rt refuses in place. The
entry now says so, with the M3 census: 3,729 straight downloads without the
images in place against 24 with them, and the restore copies each make costs.
2026-12-02 21:47:26 -08:00
Anees Iqbal 5c91a5b507 🆕 View a video plane from a texture that writes it
A recording's colour conversion writes its NV12 (or P010) through R8Uint and
RG8Uint (R16Uint and RG16Uint) textures declaring ShaderWrite. Each took the
storage shape of its plane's extent, an image of its own beside the plane, so
rule 1 copied every write into the plane (rt-shape-order-case,
rt-shape-order-copies). The red test lays its surface out as an RTX 3090
recording boot's (m3-max-81235).

On Unix hosts a video cache's surface's planes are now asked ShaderRead |
ShaderWrite | RenderTarget | PixelFormatView (0x17, was 0x15), and a texture
over a plane whole that takes storage while declaring ShaderWrite and no use
the plane's image lacks is a view of the plane (Caches::writable_plane): no
storage shape and no order copy. Such a writer asks the surface where it comes
first. ShaderAtomic and the Unknown usage keep the storage shape, and so does
every texture of an extent whose storage shape the cache holds. The platform
picks the surface's form for that usage: in place, or rt's copy form where the
device holds no linear image for it (NVIDIA's dma-buf route); the path takes
the images rt answers and assumes neither.

The Windows drawn planes keep 0x15 under their own constant, DRAWN_USAGE:
their Direct3D 11 textures are bound RENDER_TARGET | SHADER_RESOURCE, without
UNORDERED_ACCESS, and rt refuses ShaderWrite on such an import, so a texture
that writes one keeps the storage shape and its counted copies, now ledger
line D31 in docs/video/bugs.md.

What changes for the host: the planes' usage the device asks of the
platform's exported surfaces on Unix hosts. For the guest: the same pixels,
through one image where there were two.
2026-12-02 20:05:33 -08:00
Anees Iqbal 0ed439f58c 🐛 Keep the accelerator's region and registers until it is freed
A CPU lock of an IOSurface in any process (the surfaces' control function,
RgfxAcceleratorLocks.cpp) and the release worker reach the accelerator with
no client of their own, and write a block's runs through its region
(writeRuns), which can come after the accelerator's stop. The stop's
teardown released the region and the registers' mapping, so such a write
would reach a released mapping, a kernel panic.

No path in the lab was shown to run this stop while such a write is due:
kmutil refuses to unload the kext from the boot kernel collection, QEMU
refuses device_del, and a restart was not shown to reach stop(). The hole is
in the teardown the tree ships, so it is closed now rather than once a guest
meets it.

The region and the registers' mapping now go at free(), and a failed start
leaves them to it too. Nothing changes for a guest: boots, a restart and a
shutdown, on the fixes' own kext set (potluck job m3-max-80704), are
unchanged.
2026-12-02 20:01:57 -08:00
Anees Iqbal be40fe5013 🐛 Keep the framebuffer's device mappings until it is freed
The accelerator and its user clients are the framebuffer's siblings on the
PCI device, not its clients, so IOKit stops them in no set order. The
framebuffer's stop released its rings, control data, cursor slot, registers
and region while an accelerator client could still post: tryPost reads the
ready flag outside submitLock and the doorbell is rung outside it, so a post
that read it ready as the framebuffer stopped would write through a released
mapping, a kernel panic.

No path in the lab was shown to run this stop with clients alive: kmutil
refuses to unload the kext from the boot kernel collection, QEMU refuses
device_del, and a restart was not shown to reach stop(). The hole is in the
teardown the tree ships, so it is closed now rather than once a guest meets
it.

Teardown now resets the device and lets the work loop go, and the mappings
go at free() (releaseMappings), once nothing holds the framebuffer; a head's
region goes there too. Nothing changes for a guest: boots, a restart with
clients holding the device, and a shutdown, on the fixes' own kext set
(potluck job m3-max-80704), are unchanged.
2026-12-02 20:01:57 -08:00
Anees Iqbal 868ae658ba 🐛 End the process where an encoder goes without its end
Metal ends the process where a blit, compute or render encoder is let go
without its endEncoding, on the M3 Max, the AMD 5300M and the Intel 630, in
_MTLCommandEncoder's dealloc; a parallel render encoder's sub-encoder let go so
ends it at its release on the x86 Macs and at the parallel encoder's end on
the M3 (dgpu-oracle.md, Q53). The bundle's encoders let go silently, and the
buffer went to the host with the encoder open at its commit.

Each encoder now ends the process in its dealloc where its command buffer's
hold, which only its end lets go, is still there, with Metal's words, before
anything reaches the host. A sub-encoder is held by its parallel encoder to
that encoder's end, so one let go without its end ends the process there, as
on the M3. What changes for the guest: such a process ends as the encoder
goes, as on a Mac, where it used to go on until its commit.
2026-12-02 20:01:57 -08:00
Anees Iqbal 1c90b78fb3 🐛 End the process at an encoder made with another open
The M3 Max and the Intel 630 end the process where a command buffer makes an
encoder while one of its encoders is open, a blit in a blit and a compute in a
render encoder measured; the AMD 5300M makes it, and fails the buffer of a
compute encoder made in a render encoder (dgpu-oracle.md, Q53). The bundle
began the second encoder inside the first, so the buffer's stream went to the
host with nested encoders, which it faulted.

Every encoder maker now ends the process there, before the buffer's stream
reaches the host, in the M3's words on every guest: the M3 is the
latest-macOS target, and no guest is given the AMD's second encoder (the
planner's ruling, 12-02). What changes for the guest: such a process ends as
the encoder is made, as on the M3 and the Intel 630, where its buffer used to
reach the host and fault.
2026-12-02 20:01:57 -08:00
Anees Iqbal 47e5f26fb0 🐛 End the process at a commit with an encoder open
Metal ends the process at a commit made with an encoder of the buffer open,
on the M3 Max, the AMD 5300M and the Intel 630, for a blit, compute, render or
parallel render encoder, and at the commit after a parallel render encoder
let go without its end (dgpu-oracle.md, Q53). The bundle posted the buffer,
whose stream then ended with the encoder open, which the host faulted.

The commit now ends the process there with Metal's words, the M3's on a
device that answers as an Apple GPU and the x86 Macs' otherwise, before the
buffer is posted. What changes for the guest: such a process ends at the
commit, as on a Mac, where its buffer used to reach the host and fault.
2026-12-02 20:01:57 -08:00
Anees Iqbal 1008f10458 🐛 End the process at an event call with an encoder open
Metal ends the process at encodeSignalEvent:value: and encodeWaitForEvent:value:
called with an encoder of the buffer open, on the M3 Max, the AMD 5300M and the
Intel 630, for a blit, compute, render or parallel render encoder and a shared
or a plain event, and the M3 at encodeSignalEventScheduled:value: too
(dgpu-oracle.md, Q53). The bundle kept no record of an open encoder, so the
call wrote its event op inside the encoder and the buffer's stream went to the
host, which faulted it as malformed.

The encoder stream now records whether an encoder is open (a begin op to its
end), and the three calls end the process there with Metal's words, the M3's
on a device that answers as an Apple GPU and the x86 Macs' otherwise, before
anything reaches the host. What changes for the guest: such a process ends at
the call, as on a Mac, where its buffer used to reach the host and fault. The
test's death cases fail where the submission ring holds anything.
2026-12-02 20:01:57 -08:00
Anees Iqbal 9d7ee77db0 🆕 Add oracle_cmdbuf's open-encoder cases and Q53
Metal ends the process at some command-buffer calls made with an encoder of
the buffer open, while the bundle keeps no record of an open encoder and sends
the buffer's stream to the host, which faults it as malformed. The probe asks
each GPU what Metal does with an encoder open at the event calls (a shared
event and a plain one, with a blit, compute, render and parallel render
encoder), at encodeSignalEventScheduled:value:, at the commit, at a second
encoder made, at an encoder let go without its end (a parallel encoder's
sub-encoder among them), and at the calls that pass (enqueue, the handlers, a
debug group). Q53 records its answers on the AMD 5300M, the Intel 630 and the
M3 Max, which the four commits after this one follow.
2026-12-02 20:01:57 -08:00
Anees Iqbal 5338b7f585 🐎 Copy dirty shapes straight into the pages at a download
A download or a release of a per-shape cache wrote its dirty shapes into
the cache's buffer, then copied the buffer out: on the rt platform, whose
IOSurface blocks take no view, the GPU into Shared staging pieces and the
host's CPU into the pages. Census B on the M3 (m3-max-81170) counted 3,772
such write-backs, two a recorded frame, each 3.1 MB a 1080p picture, and
the downloads made 119 deferred buffers' memory for them.

Where the buffer holds nothing the pages lack beyond those shapes' writes
(its record of the host's copies is empty, no texture lies over it, its
pages are a view or copied, laid out as the pages), the shapes' rows now
go straight into the pages' view or a staging piece that holds their
extent, and the CPU moves the rows alone into the pages: one GPU copy
less a plane a read-back, and no memory made for the buffer. The pages
take the same bytes as before. The buffer then lacks the shapes' writes,
as after a straight fill, so a copy through it takes the pages first.
The shapes copied are counted as rt-shape-downloads and
rt-shape-download-bytes; docs/video/bugs.md D30 records the copies left.

This is not a keeper: the batch that lays a Mac's surfaces' shapes in
place over an import of their pages deletes it, unless another caller is
named then. Its entry is SurfaceCaches::write_back's, with its own counts
and a test knob, Caches::set_no_straight_downloads, which the twelve
tests of the copy through the buffer now set: the caches still make that
copy wherever a straight one does not go. The red tests take the counts,
and a third holds the copy through the buffer after a write over it and a
release that goes straight.
2026-12-02 19:16:41 -08:00
Anees Iqbal 2221a41c20 📝 Record the slots boot's reading in the memory slots row [ci skip]
The memory slots row said what an iMac20,1 VM's System Information lists with
reims-ctl's slots; this records the boot that read it: one slot before
(m3-max-80826), and with the installed reims-ctl's command four, DIMM 1 to 3
"Empty", on um870's 780M (m3-max-80887).
2026-12-02 17:23:00 -08:00
Anees Iqbal 3e8cbbff4a 🐛 List an iMac20,1 VM's four memory slots, not QEMU's one
An x86-64 guest's System Information listed one memory slot, "DIMM 0": QEMU
makes only the memory devices RAM fills, one on current machines, and
OpenCore copies them into the guest's SMBIOS. An iMac20,1 has four SO-DIMM
slots.

reims-ctl gives -smbios type=17's slots=4,form_factor=13 for an iMac20,1,
read from the VM's OpenCore image at each start, as it gives the memory's
error correction: vendor/qemu's 445170b5 makes the slots past the RAM's
empty. A guest given four such devices lists DIMM 0 with the VM's RAM and
DIMM 1 to 3 as "Empty" (m3-max-80846; with reims-ctl's command,
m3-max-80887). The options go only to a QEMU that takes them, asked once
per binary; another model, an iMacPro1,1 among them, and another QEMU keep
one slot, the command as before.
2026-12-02 17:23:00 -08:00
Anees Iqbal 4ce2543a5e 🆕 Let reims-ctl's resolution give each display a size
A VM's resolution was one size, every window's first size and, on a
headless start, every display's mode, so a VM of displays on screens of
different sizes opened every window at the same size. The resolution
setting now takes one size for every display, as before, or one for each
display, comma-separated in the displays' order (--resolution
2560x1440,1920x1080 on create and set, and the same in the interface's
form). Another count of sizes than the VM's displays is refused with a
message that says what to give. It applies at the next start: the fork's
1d614106 lets reims-graphics-pci's resolution take the list, which
reims-ctl writes with each comma doubled (resolution=2560x1440,,1920x1080).
One size, or sizes that are all one, gives the device string reims-ctl gave
before, byte for byte (each_display_s_size_reaches_the_device). A VM's
summary names each window's size where they differ.

What the user sees: each display's window opens at its own size, and a
headless start offers each display its own mode.
2026-12-02 17:19:47 -08:00
Anees Iqbal dc87082ea8 🆕 Let a windowless device give each display its own first mode
A device without a window offered every display the one headless mode its
config gave (headless_mode_width and _height), so a host could not give a
VM's displays different sizes without windows. RvgGraphicsDeviceConfig's
eighth version appends headless_modes: NULL, or an array of display_count
sizes, display i's at i, each taken as the one mode is (a 0 in either side
is 1920 x 1080), in its place. NULL, and a host built before the field,
keeps every display at the one mode; with a window the field is unread, as
the one mode is. The Rust API's GraphicsConfig gains headless_modes beside
headless_mode, and refuses a list of another count than the displays.

What a host sees: a new optional field; a host that leaves it NULL gets the
device it got before.
2026-12-02 17:19:47 -08:00
Anees Iqbal c5a3079426 📝 Drop indexed patch draws from the unbuilt render commands [ci skip]
The accuracy ledger listed drawIndexedPatches, direct and indirect, under
rt-unbuilt-render-command. The platform draws them through rt since the
commit before this one, so the row lists only what is still not built.
2026-12-02 17:04:32 -08:00
Anees Iqbal 179324bb46 🐛 Write an Accumulate pass's visibility results as a Reset pass does
At pin I the runtime writes a visibility mode's result in a pass whose
visibilityResultType is Accumulate as it does in a Reset pass, in place of the
word at the mode's offset. Until now such a mode was rt's gap: it encoded
nothing, was counted under rt-refused-gap, and the guest's buffer kept its
bytes.

What the guest sees: an occlusion query in an Accumulate pass now answers its
count, or a non-zero Boolean, at its offset. That is Metal's answer on a
Radeon Pro 5300M and a UHD Graphics 630. Metal on an Apple M3 Max adds a
Counting result into the word and ORs a Boolean one; the accuracy ledger
records the difference. The render test that held the gap now holds the
written results with no gap counted.
2026-12-02 16:08:20 -08:00
Anees Iqbal 260cdc8789 🐛 Give an x86-64 VM's memory the presented Mac's ECC, not QEMU's
System Information showed an x86-64 guest's memory as "ECC: Enabled": QEMU's
SMBIOS type 16 says multi-bit ECC on every machine, and OpenCore copies it
into the guest's tables, where an iMac20,1, the Mac a VM presents for macOS
10.15.6 and later, has RAM without ECC. vendor/qemu's d72b4ac3 lets
-smbios type=16,error_correction set the field, and reims-ctl now gives the
presented Mac's: 3, none, for an iMac20,1, and 6 for an iMacPro1,1, whose RAM
has ECC. It reads the model from the OpenCore image's PlatformInfo at each
start, gives nothing for a model whose RAM it does not know, and asks each
QEMU once whether it takes the option (-smbios type=16,error_correction=3
-version), as it asks for memory_type; another QEMU's guest keeps ECC.

What the guest sees: an iMac20,1 VM's memory reads "ECC: Disabled" in
System Information. The part number stays OpenCore's "Unknown": a made-up
one would be a false answer.
2026-12-02 15:53:57 -08:00
Anees Iqbal 6317f0e84f 🐛 Keep a guest's emulated TPR write under WHPX without irqchip
The fork's 79d47edf: under WHPX with QEMU's own APIC (kernel-irqchip=off),
a TPR the guest wrote through an instruction QEMU emulates (a
read-modify-write of the xAPIC's TPR, an x2APIC WRMSR) never reached CR8,
and the next exit put the old TPR back, so the guest's write was undone.
reims-ctl starts WHPX with the in-kernel irqchip, which keeps the TPR in
Hyper-V's APIC, but QEMU keeps its own APIC on a Windows 10 host, where the
machine has a PIC, and on a Hyper-V that offers no local APIC emulation; a
command that turns the irqchip off gets it too. Those hosts' guests lost
such TPR writes. Now the TPR the guest wrote stays, as it does under
kernel-irqchip=on.

Checked on an i7-8700B under Windows 11 with QEMU built as install-ctl.sh
builds it in MSYS2's CLANG64, and a guest of our own that ORs 0x50 into the
TPR and reads it back: kernel-irqchip=off read 0x00 in 3 of 3 runs before
(m3-max-80368) and 0x50 in 3 of 3 after; kernel-irqchip=on read 0x50 in
every run (m3-max-80485).
2026-12-02 15:32:21 -08:00
Anees Iqbal 4a61b65037 🆕 Add oracle_aborts and Q52, where Metal ends what the bundle refused
The probe asks each GPU what Metal answers at the calls where the bundle
answered nil or refused while Metal may end the process: the linear SPI at more
than one level, a texture over a buffer of rows shorter than its texels' bytes
by every form, a pipeline of a function made by name that declares a constant
(compute, render, mesh, a binary archive's add) and one linking such a
function, a view with a lowest level of detail, and the format view of a
linear 2D array's every slice, each against a control. Q52 records its answers
on the AMD 5300M, the Intel 630 and the M3 Max, which the five commits before
this one follow, and Q11's rows it corrects: a texture buffer's short rows end
the process on the three, and the M3 ends it at that format view.
2026-12-02 15:12:02 -08:00
Anees Iqbal bcd48cd69f 📝 Record that Metal orders no write across aliased no-copy buffers
The host's runtime holds two imports of the same guest pages for two pages
blocks that overlap, and its hazard tracking does not tie them together
(row 403). oracle_aliasbuf asks what Metal does with a write through one
no-copy buffer and a read through another over the same pages: the M3 Max
never orders the read after the write, not even in the next command buffer
of the queue; the 5300M does not before a blit's read; the UHD 630 orders
every encoder (m3-max-80200, 80202 and 80204). Metal's tracking is the
resources', and the Macs differ past it, so the runtime's answer is the
M3's. dgpu-oracle.md Q51 holds the table, and overlaps.rs's doc the fact.
Nothing changes in what the host does.
2026-12-02 14:31:10 -08:00
Anees Iqbal 054f8a71d0 🐛 Pause a VM where an NVMe or firmware-variable write fills the disk
The fork's nvme device completed a write that found the host disk full to the
guest as Write Fault, and pflash_cfi01 logged 'Could not update PFLASH' and
dropped the variable. Both now follow the drive's error action: under -drive's
default werror=enospc the VM pauses (io-error, the drive's io-status nospace,
which reims-ctl reads to name the file), and the resume runs the write again
(fork 51d47e28, 1e223049, 0beafad0).
2026-12-02 14:31:10 -08:00
Anees Iqbal 81c12ee542 🐛 Give a context's number out again once its close is answered
The kext gave each process's context a number once, counting up from 1, and
never again. A number is the top 24 bits of the context's 64-bit object ids
(RGFX_CONTEXT_OBJ_ID_SHIFT) and of its doorbell page's bind, so the 2^24th open
of a boot carried ids past 64 bits, onto other contexts' ids.

Numbers now run below 2^24, in turn from where the last was taken, wrapping
past the last to 1 and skipping those held. A number is held from its open
until both the device has answered its close OK (no framebuffer started, or a
late answer, counts as well; a refused close keeps it) and its user client is
freed, so no call of the client's, and no create it posted behind its close,
can reach the device once another process takes the number. Where every number
is held, or the 2048 the kext keeps, the open is refused with
kIOReturnNoResources, as when no unit of GPU addresses is free: the bundle
answers that process no Metal device, and a later open takes a number once one
is given back. A live number is never given out twice.

context_numbers_test pins it near the top: the last numbers below 2^24, the
wrap to 1 past those held, a number reused only after both holds drop, and
every number held refused with nothing changed.
2026-12-02 14:31:03 -08:00
Anees Iqbal 7399b4fc60 🐛 End the process at a view of several slices of a linear array
A view of a range of more than one slice of a 2D array over a buffer, made
by the linear form, answered nil. Metal asserts at it on the M3 Max and an M4,
plain and validated ("sliceRange.length == 1", measured by metal2vulkan), and
neither x86 Mac makes such an array, so every Mac on record ends the process
there. The bundle now ends it too, before anything is sent, after the view
rules both x86 Macs share.

A view of every slice named by its pixel format alone still answers nil:
Metal's answer for that form is not measured, and it goes to the oracle
probe.

For the guest: a process that asks for such a view now ends at the call, as
on a Mac, where it went on with nil. The shell test that held the nil keeps
only the pixel-format form, and a death test checks the range.
2026-12-02 14:03:22 -08:00
Anees Iqbal 4b7790b4ef 🐛 Make a linked function with its constant values, none too
A linked function made with constant values that set none of the constants
it declares, or by a descriptor without values, options or a specialized
name, reached the host with no constants. The host then made it by its name,
and the Vulkan runtime refused the pipeline that linked it, where Metal makes
that pipeline and the function reads its unset constants as undefined. Stage
functions were fixed the same way in e6d1572dd5. This was the last path that
still made a function by name.

The host now makes each linked function as it makes a stage's function: with
its constant values, even when there are none. That covers pipelines and
function handles. A function made by name that declares constants would then
be made with them undefined. So the bundle now refuses a pipeline that links
such a function, as it refuses one of such a stage function, in the same
words with the role "linked function", and sends nothing. Metal's answer for
a linked function made that way is not measured; the host's runtime refused
that pipeline before this change too.

For the guest: a pipeline that links a function made with values that set
none is made, and the function reads its unset constants as undefined, as on
Metal. The decoder test links tests/shaders/linked_optional.metal's function
by name, sent with no constants and then with one, on the Vulkan platform.
The two fake-platform tests that held the by-name make now expect the make
with constant values. The bundle's shell test checks the refusal in each list
of each creator, and the record sent for a function made with no values.
2026-12-02 14:03:22 -08:00
Anees Iqbal 5b1067a787 📝 Say Metal leaves a write into read-only memory undefined [ci skip]
No header of the macOS 27.2 SDK states what a GPU write into memory a
process maps read-only, or into a no-copy buffer of bit 24, does:
MTLDevice.h says only that newBufferWithBytesNoCopy wraps an existing part
of the address space, and bit 24 is no public MTLResourceOptions value. The
accuracy ledger's read-only-pages-written entry now says so, and words the
known gap as the planner ruled it: a GPU write into memory the guest mapped
read-only stays visible until the next commit that uses the copy.
2026-12-02 13:57:07 -08:00
Anees Iqbal 5deffb45a2 📝 Record the arm64 guest's boot on the M3 for the Mac arm [ci skip]
An arm64 macOS 27.0.1 guest's boot on the M3 (m3-max-80121) decoded seven
H.264 and HEVC streams to ffmpeg's MD5s on the arm and played and recorded a
movie of each codec with no bad frame, so formats.md's H.264 and HEVC Main and
Main 10 cells name it, and D29 gives its count of GPU-copied pictures and KiB.
formats.md also names the arm's caps_of among the arms' caps.
2026-12-02 13:55:34 -08:00
Anees Iqbal c83dc74d31 📝 Say which video caps the Mac arm writes [ci skip]
devices.md's Mac arm paragraph now says which caps entries the arm writes and
that the arm64 kext serves its paravirtual decoders from them.
2026-12-02 13:55:34 -08:00
Anees Iqbal f9af79118f 📝 Document the VideoToolbox arm on Mac hosts [ci skip]
devices.md says what the arm offers, how the host answers it and how a
picture lands; formats.md fills the M3 Max's column and narrows N2 to what is
not built; bugs.md records the GPU copy as D29 with its bytes a picture; and
conventions.md and answer.rs name the arm's counts' codes.
2026-12-02 13:55:34 -08:00
Anees Iqbal cba3a88875 📝 Say a pinned bit-24 buffer takes writes as the x86 Macs do
A no-copy buffer or heap of option bit 24 pinned in a known block of
writable pages keeps the GPU's writes. The docs and the line counted under
rt-no-copy-read-only said Metal's GPU drops them, which is the M3 Max's
answer alone: on the 5300M and the UHD 630 bit 24 does nothing, and every
GPU write lands in the buffer's pages (dgpu-oracle.md, Q38). The case is
inside what the Macs answer, so nothing changes in what it does; the docs,
the accuracy ledger and the line now say whose answer it is.
2026-12-02 13:51:13 -08:00
Anees Iqbal 0898313d14 🐛 Answer raster order groups only where rt orders them
The device answered areRasterOrderGroupsSupported yes on every host, the
M3 Max's answer. But rt's translator orders a fragment function's raster
order groups only inside the fragment shader pixel interlock, and refuses
a pipeline of them on a device without it. An RX 550 on RADV (Mesa
26.2.6) reports no pixel interlock, so a guest there that was told yes
had its raster-ordered pipelines refused.

The device now answers yes where rt's device creation enabled
fragmentShaderPixelInterlock, and no elsewhere, as Metal has a GPU
without raster order groups answer; the bundle's SPI raster order groups
feature follows the same flag. The answer stays yes on the 780M, the RX
7900 XTX, the Iris Xe and the NVIDIA cards, and is now no on the RX 550
(RADV POLARIS12) and on a Mac host over KosmicKrisp, which lists neither
VK_EXT_fragment_shader_interlock nor the feature. x86-64 and arm64 guests
read the same flag, so both are told no there.
The AMD Radeon Pro 5300M and the Intel UHD 630 answer yes (macOS 26.7.1,
oracle_caps, potluck jobs m3-max-79873 and 79874); neither lacks them.
raster_order_groups_are_rt_s_answer holds the answer; no test held the
old one.
2026-12-02 13:49:00 -08:00
Anees Iqbal 65cbf3220e 🐛 Make a pages block's view after its answer on a worker of its own
Where the guest took IMPORT_ADDRESSES_LATER, a pages block's SURFACE_PAGES was
answered as soon as its runs were carried out, and its view was then mapped
and imported on the same surface worker job before the block settled. The
surface worker runs at most four threads, so four blocks' view makes held
every thread, and the next block's SURFACE_PAGES waited for one behind them,
however short its own carry-out. On the RTX 3090's gcl boot (rowb-3090,
m3-max-79853) carry-outs took at most 2.1 ms, view makes 14.9 ms at the
median and up to 351 ms, and 64 answers took over 50 ms, up to 133 ms: of the
225 over 20 ms, 163 waited while four or more other blocks' views were being
made.

The view made after the answer now runs on the views worker
(reims-vgpu.graphics-views-<i>), a worker of its own under the block's key,
which holds the block's settle until the view is made: the messages that
name the block wait for it as before, and the surface worker's thread goes
on to other blocks' SURFACE_PAGES. A job of the block's on the surface worker
(its BUFFER_OVER_PAGES, or its next SURFACE_PAGES) that finds one of the
block's on the views worker runs behind it there (Worker::behind, one step
under the worker's lock), so the block's jobs keep their order across the two
workers; a SURFACE_PAGES run there makes its view itself, so no views
worker's job hands one to the views worker. The views worker runs at most
POOL_THREADS (4) threads, as every worker does, and holds at most
VIEWS_WAITING (256) jobs waiting (Worker::bounded): a hand-over that finds
that many waits on its surface worker's thread until one is taken, counted
and logged at debug. The busiest 100 ms of the same boot carried out 140
SURFACE_PAGES. No setting changes either number. The view's make takes the
reset gate shared, recursively, as the surface worker's jobs do, and where
the device was reset since the SURFACE_PAGES' begin it makes nothing.

What the guest observes: a LATER SURFACE_PAGES is answered without waiting
for other blocks' views; its own block's later messages wait for its view as
before. What the host observes: raise_interrupt may come on a views worker's
thread (a SURFACE_PAGES or a BUFFER_OVER_PAGES run behind a view there posts
its answer or its command buffer's failure), named in reims_vgpu.h, api.md
and RAISE_THREADS. QEMU's raise_interrupt callback takes a call from any of
the library's threads (the irqfd's write, the WHPX request under msi_lock, or
a BH), as it does from the surface workers', so its side needs no change.
Nothing changes where the guest did not take IMPORT_ADDRESSES_LATER.

Tests:
- a_pages_block_s_answer_waits_for_no_other_block_s_view: four blocks' view
  imports held, a fifth block's SURFACE_PAGES is answered, no surface worker
  cap hit, the views worker at four threads, and a BUFFER_OVER_PAGES over a
  held block made only after its view.
- a_reset_ends_pages_views_made_after_their_answers_cleanly: a reset waits
  for the view being made; the view waiting on the views worker and the
  buffer behind it make nothing after the reset; both blocks settle.
- a_device_released_while_pages_views_are_made_after_their_answers_ends_clean:
  the release waits for neither view, and the device's control goes once
  both views' jobs end.
- worker: a_bounded_worker_s_hand_over_waits_for_room,
  a_job_behind_a_key_runs_after_its_jobs_or_here_where_it_has_none.
2026-12-02 13:39:08 -08:00
Anees Iqbal 3d37c928b4 🐛 Keep every write the kext refuses in order until it goes
A refused write into an object was lost. An indirect command buffer's
records and slots and a visible function table's entries were dropped with a
log line, and a shared event's setSignaledValue: was dropped with none. The
kext refuses a control-ring post once its ring has stayed full for 5 s, or
once the device has stopped. Later command buffers then ran the ICB's old
commands or the table's old entries. A buffer already posted that waited on
the event's value never ran, even once the host read again.

Row 318's queue of refused Managed notes now holds every such write, in one
first-in-first-out order: ICB_WRITE, ICB_SLOTS(_IN_PAGES), FUNCTION_TABLE_SET
and SHARED_EVENT_SET_VALUE besides the range, region and didModifyData. A
waiting write is posted before the next write, a destroy or a commit, and
from a timer once a second while any waits. The timer means an event's value
still reaches the host when nothing else is posted. A destroy now waits behind
the waiting writes, since a record or a table entry may name its object, and
drops the writes into its own object. A refused ICB_SLOTS of several buffers
waits as one message for each buffer. The device's stop ends the timer and
drops what waits.

What changes for the guest: while such a write waits, a commit fails its
command buffer unposted with MTLCommandBufferStatusError and
MTLCommandBufferErrorInternal, as for a refused Managed note before. Once the
kext takes posts again, the writes go in order before the next buffer. At
most 4096 writes or 16 MiB wait. Past that, a write is lost and every later
commit fails Internal. After the device's stop every commit fails the same
way. A write is never dropped while later work runs. Nothing changes where
the kext takes every post.
2026-12-02 13:39:07 -08:00