An x86-64 guest's hardware HEVC encoding never reached our GPU: macOS's HEVC
encoder plug-in drives only an Intel GPU's driver, found by name, so an app that
required hardware failed at its create (-12908) and others encoded in software
(m3-max-77632, development's set on this host). What the guest sees now, where
the host's video arm lists an HEVC encoder of Main and Main 10 with a constant
QP that codes a frame in place of the last (Linux hosts' VA-API, and NVENC where
its driver codes a frame without advancing its state):
- the accelerator publishes an IntelAccelerator child of its own with
IOGVAHEVCEncode and IOGVAHEVCEncodeCapabilities (Main and Main 10, up to
the encoder's level), so VideoToolbox lists a hardware HEVC encoder
(hevc.gva);
- RgfxGate keeps the Intel driver path the plug-in loads from
/Library/GPUBundles a hard link to the bundle's executable, at every boot;
- the bundle's video driver takes the plug-in's encode commands (function
0x20, sub-ID 0x1000), codes each frame on the host (ENCODE_H265) at the QP
the plug-in's rate control chose, an IRAP picture as a keyframe, Main from
an 8-bit source and Main 10 from a 10-bit one, and hands back the access
unit with 4-byte start codes, whose VPS, SPS and PPS make the session's
format description;
- a frame the plug-in codes again over its data rate limit, at a higher QP,
is sent in place of the last one (RGFX_VIDEO_ENCODE_IN_PLACE): a P
picture of the last frame's order count and source surface; a keyframe
coded again is sent as a new IDR picture;
- a session of a size the host does not encode is refused at its create,
so an app that allows software encodes in software as before.
A host whose encoder has Main alone gets no nub: VideoToolbox hands the
plug-in a Main 10 session whatever profiles the nub lists, and the driver
learns a session's profile only from its first frame. Nor does one that
codes no frame in place, where a retry would predict from the frame it
replaces. H.264 encode and both decodes are as before on either. The
plug-in's per-CTU QP map (its pool 27) is not applied, and its frame
statistics record is not supplied. The route is macOS 26.7.1's plug-in's,
booted on 26.7.2. Windows hosts list no encoder, so encode in software as
before.
Rows (macOS 26.7.2 guest, 1080p, 300 frames at 8 Mbit/s, decoded back by
VideoToolbox; the rate band is vboot's RATE_BAND_PCT, 6%, both codecs), the
same with the frames in place (m3-max-77615, m3-max-77613, m3-max-77614),
byte for byte but for 205 bytes of the Iris Xe's Main stream:
- RX 7900 XTX (m3-max-77475): Main 105.1%, 45.02 dB; Main 10 104.8%, 45.17 dB
- Iris Xe (m3-max-77476): Main 103.5%, 48.04 dB; Main 10 98.1%, 48.86 dB
- RTX 3090 (m3-max-77477): Main 100.7%, 44.81 dB; Main 10 106.1%, 45.06 dB,
where NVENC's own lands 104.6%: known-issues and video/bugs.md B97
At a data rate limit of 1 Mbyte a second, the plug-in coded 2 to 30 frames
of a session again, each sent in place: no gap in the order counts, all 300
frames decoded back, and the most bytes in a second 1.7% to 3.0% over the
limit (RX 7900 XTX m3-max-77611, RTX 3090 m3-max-77609, Iris Xe
m3-max-77627; video/bugs.md B100, to be read on a user's report). With a
keyframe every frame the stream comes to 4.1 to 5.0 times the asked rate, as
a real Intel Mac's comes to 5.7 times with the same QPs frame for frame
(m3-max-77635; design.md, known-issues); every frame decodes back.
Main 10 from a retained pool and from the app's own 8-bit buffers decodes as
from the pool taken per frame on all three. A real Intel Mac's hevc.gva
(macOS 26.7.1, m3-max-77481) replaces the session's pool at the third Main 10
frame, as ours does. Speed (Iris Xe, m3-max-77497): 94 to 118 fps at 1080p
against software's 3.3; 10.3 to 10.8 at 8K against 0.5 (B98, B99).
Tests: the kext's publish condition and its pairing with a host that codes
no frame in place (video_codecs_test: the caps of both decoders and encoders
without the flag publish no HEVC encode and the rest as before), the link's
update on real files (rgfxgate alias_test), and the driver's listing, create
refusals, settings, keyframes, write-back, failures, refused sources and the
frames it sends in place, and those it does not: never a keyframe, so a
session of keyframes from one reused surface sends none (video_driver_tests;
m3-max-77590). Development's set on this host (m3-max-77632) encodes H.264 to
the same bytes as this one and decodes as before. Docs: design.md and
devices.md, video/bugs.md B97 to B100, and known-issues.md's HEVC encoding
line, which now says which GPUs encode HEVC for an Intel Mac guest, and its
section on HEVC over the bitrate asked.
An x86-64 guest's HEVC stream smaller than the host decoder's least size (64x64
and 128x96 on the RTX 3090's NVDEC, lane vhevcenc's leg m3-max-77366) got a
session, and the host refused each picture at its schedule: AppleGVA reports
that as kVTVideoDecoderMalfunctionErr for the frame and every frame after it,
so a client that allows software decoding got no frame at all. CreateContexts
names the coded size, so the driver now refuses HEVC there as it refuses
H.264 (cffc93097), and VideoToolbox decodes such a stream in software. The
per-picture check stays for a stream whose SPS changes its size.
For the guest: an HEVC VTDecompressionSessionCreate of a coded size the host
does not decode fails at create, so VideoToolbox falls back to its software
decoder where the client allows it; before, the session was made and every
frame failed with -12911. checkDecodeSizeAtCreate replaces
checkH264SizeAtCreate, which held that an HEVC create of any size is made.
Every line of the Metal bundle's (rgfxLogLine) went to the unified log and also
to the process's stderr wherever NSLog writes there. So a command-line program
in a guest that joins its stderr to its output printed the bundle's lines among
its own: a user's script showed "RGFX: feature profile 10002: ..." in its
output. A Mac's Metal writes nothing there of its own.
rgfxLogLine now logs to the unified log alone. The words of a death, which the
process ends at next and which Metal writes on stderr at the same calls, go
through rgfxLogDeathLine, which still writes them there; the death checks read
them.
shell_tests runs itself again with --log-line, its stderr a pipe, and checks
that a logged line writes nothing there. It fails with the old rgfxLogLine.
What changes for the guest: a program's stderr carries none of the bundle's
lines except a death's words; the unified log keeps them all, as before.
A class's next slab doubled with each slab it made, up to kSlabMax, and never
came down once its slabs went. A buffer of a page that came after its class
had grown and let go took a slab of the largest size the class reached: 2 MiB
from the region or the process's pages, and 16 MiB from the Shared pool, which
the host zeroes as it gives it. Keeping empty slabs (the commit before) stops
this for a buffer made and freed again and again, but not for one that comes
more than 2 s after its class's last slab went.
Now a class left with no slab, none holding a buffer and none kept, starts
again from kSlabFirst (128 KiB), over every source. While it keeps an empty
slab it goes on growing as before.
What changes for the guest: after an idle let-go, a class's next slab is 128
KiB, or twice its buffer, rather than the size the class grew to, so its
heap's size and the buffers' GPU addresses in it differ, and the host takes
and zeroes a smaller block. test_slab_class_starts_again_once_empty holds it
over the test's source and the pool's; the pool tests that took the grown size
now read 128 KiB.
The guest sets (guest/prebuilt, guest/prebuilt-arm64e) are rebuilt here from
the bundle of this commit and the one before, which changed it too.
A class's slab of the Shared pool went back the moment its last buffer did
(RgfxPoolSlabSource::keepsFreed() answered false), and a large buffer's own slab
skipped the cache. A process that makes one buffer and frees it again and again
in an otherwise empty class then took a pool block for each buffer: a take the
thread waits for, a HEAP_OVER_POOL, the host zeroing the block, then the heap's
destroy and the block's give. Each new slab doubles its class's next one, so
after seven rounds every block was 16 MiB, for a buffer of one page. A user's
guest logged one process making and giving back about 17 such slabs a second,
none of them taken from again. The serialiser test of that pattern at
805c93a65 counted 100 small slabs (1539968 KiB) and 100 large slabs for 100
rounds of each, and 200 pool takes.
keepsFreed() is gone, so every source's slabs follow the one form. Each class
keeps two empty slabs, and large buffers' own slabs are cached, each for
kCacheIdleMs (2 s) at most. The pool source now takes a capacity, as the pages
source does, and the device passes the guest's RAM: the kext tells the bundle
nothing of the pool's length, so the pool's cache holds a sixteenth of the
guest's RAM at most. A refused take still lets the process's own kept and
cached slabs go first.
What changes for the guest: a buffer of the pool may lie in a slab an earlier
buffer emptied, at that heap's GPU address and offset, rather than in a new
block's heap, and the host sees fewer POOL_TAKE, HEAP_OVER_POOL,
OBJECT_DESTROY and POOL_GIVE messages. A kept block is its process's alone for
up to 2 s after its last buffer goes. A new buffer still reads zeros: the test
writes 0xa5 over each buffer before its free and reads zeros in the next.
test_pool_slab_churn_is_bounded holds the bound: one small slab, one large one
and two takes for those rounds. The pool tests that held the old let-go now
let kept slabs go through the idle clock or reclaim(). The guest sets are
rebuilt with the next commit, which changes the bundle too.
The kext answers an ask in place it does not carry out with one status for
three reasons: the device uses no surface in place (no SURFACE_PAGES), an ask
with no device cache meets a device that caches every surface (the kext's
`uncacheable`), and the device refused the surface's pages. The bundle counted
all three as "unsupported", and the first copy's line said "the device uses no
surface in place, or refused its pages", which named neither the uncacheable
refusal nor told the other two apart.
The bundle now tells them apart by the ask and by the device's SURFACE_PAGES
and SURFACE_CACHE_EVERY, and counts each under its own name. The guest's
surface copies line gains two counts, "asked uncached where every surface is
cached" and "refused by the device", and "unsupported" now counts only a
device that uses no surface in place. No Metal answer changes. The in-place
fallback test covers each reason.
Both guest sets are rebuilt with it: RgfxGate in guest/prebuilt and
guest/prebuilt-arm64e; Graft and ReimsGraphics keep their bytes.
tests/bundle_sync_check.sh fails where the x86-64 bundle or the native build
of the bundle's sources imports objc_sync_enter or objc_sync_exit, the
runtime's object lock that every @synchronized takes and an app's
@synchronized on the same object takes too. A grep of src/ covers the device
shell's arm64 code, which neither build compiles. `make test` runs it beside
bundle_files_check.sh. Over the sets and sources of the commit before the
locks' fix it fails on the x86-64, arm64 and arm64e bundles. The guest sets'
records take the Makefile's new hash; their kexts are unchanged.
An app may hold @synchronized on an object Metal hands it while it waits for
Metal's work on that object. A 2D game on a common engine holds its command
buffer's lock across the buffer's commit and waitUntilCompleted. The bundle
took @synchronized(self) in the command buffer, the queue and the function,
and @synchronized(device) for the CPU copies' queue, and the buffer's
completion took the buffer's lock (rgfxLetResidencySetsGo, on both devices).
So the completion waited for the app and the app for the completion: the
buffer never completed and the app never showed a window.
What changes for the guest: an app holding a command buffer's, a queue's, a
function's or the device's @synchronized no longer stalls the bundle's work
on that object on another thread, as on Metal. oracle_locks, measured on the
M3 Max under macOS 27.0.1, finishes each such step on Metal.
Each object keeps a std::mutex of its own: the command buffer's for its
residency sets and user dictionary, the queue's for its pools and residency
sets, the function's for its stand-in hash, and a static one for the device's
copy queue. None is recursive, as nothing done under one takes it again. No
block, handler, release or raise runs under one: the sets a removal lets go
are kept past the lock, and a nil set raises the counted set's exception from
a counted set of its own after the lock. The queue's barrier slots take no
lock: the fences never change, and the count is atomic. rgfxCopyQueue is
declared in RgfxTexture.h for the tests.
The tests (tests/queue_tests.mm, AN APP'S LOCKS) hold each lock and wait,
each case in a child that must end within 10 s; all five timed out on the
code before. The guest sets are rebuilt from these sources.
The bundle's app-lock tests hold @synchronized on a command buffer, a queue,
a function and the device while another thread does Metal's work on it.
oracle_locks runs the same steps on Metal, each in a child that must end
within 10 s, so the tests' expectation is Metal's answer. On the M3 Max under
macOS 27.0.1 every step finishes, except one that is the app's own deadlock:
a completed handler that takes the lock the buffer's waiter holds, where
Metal's wait never returns.
The files test runs the bundle's file calls under a sandbox that asks the
kernel to kill the process at each of the 97 file system calls some
WebContent list leaves out. Its utimes control ran to its end. Each of the 97
calls, made under that sandbox on macOS 27.0.1 (arm64, and x86_64 under
Rosetta), shows the kernel kills at 67 of them. It lets through the 30 that
write: links, owners, flags, times, positioned writes, extended attributes,
fsctl, ACL modes and snapshots. So the sandbox proves nothing about those 30.
bundle_files_check.sh now bans the bundle's imports of the library calls
that make those 30. The test's controls are the calls the kernel does kill:
setattrlist and open_dprotected_np. The test's, RgfxFiles.hpp's and the
lesson's text say what the sandbox covers, and the lesson adds how to spot
a sandbox that lets a call through.
A dynamic library's serializeToURL: wrote through Foundation's atomic write
before 70d6be8d84, so a write the system refused answered Foundation's own
error. The bundle's own write answered only its domain, code, path and POSIX
cause; Foundation's has more, which this Mac's Foundation shows (measured on
macOS 27.0.1, x86_64 and arm64). Every refusal names the file's URL as well.
A refusal of the file made in the folder (a folder the process may not write
in, a read-only volume) also names the folder (NSUserStringVariant
"Folder") and carries a debug description. A directory at the path answers
NSFileNoSuchFileError over ENOENT, not a write error over EISDIR.
RgfxWriteFileWhole now says whether it got as far as making its file, and
the dynamic library's error takes each of these shapes, with a debug
description in our own words. What changes for the guest: those errors'
user info and, for a directory at the path, their code, as Foundation
answered them before. The test pins three refusals against Foundation: the
read-only folder, a name too long and a directory at the path. It compares
their domain, code, keys, path, URL, folder variant, description and cause.
On macOS 11, every Safari page that used WebGL lost its WebContent
process. WebKit's WebContent profile there kills the process (SIGKILL) at
any system call its list leaves out, and the GL store wrote its entries
with Foundation's atomic write, which makes its file with
open_dprotected_np, a call that list leaves out. 12's list kills the same
way and leaves out setattrlist, which the store's touch could make
through Foundation.
The bundle now writes every file of its own through RgfxFiles: plain
POSIX calls (open, read, write, close, stat, rename, unlink, mkdir,
opendir) whose system calls every WebContent profile read takes, from
11.7.11, 12.7.6, 13.7.8, 14.8.9, 15.8.2 and 26.7.2 on x86-64 to 27.0.1 on
arm64. The GL store reads, writes, lists, touches and removes its entries
through it, and a binary archive's and a dynamic library's
serializeToURL: check their directory and write through it. A touch
writes the entry's first byte over itself, since no call that sets a
file's times is on every list.
What changes for the guest: a WebGL page in Safari on 11 is no longer
killed when the GL store writes. A dynamic library's write the system
refuses answers the error Foundation's atomic write answers for it, which
a new test pins against this Mac's Foundation; every other answer of the
two serializers is as before.
The bundle now imports open(2), so bundle_files_check.sh allows open
itself and bans instead the file calls a WebContent list leaves out, and
Foundation's file-writing selectors. tests/files_tests.mm checks the file
calls, and runs them and the store in a child under a sandbox that kills
at every file call some list leaves out; its controls (utimes,
setattrlist, open_dprotected_np) are killed.
Several of the bundle's refusals said "(none on the wire)" where the wire has
the thing, or where the wire is not why. Each now names the reason, read from
the code. Diagnostics only: each refusal stays a refusal, and what the guest
sees is unchanged but for the log line's and the error's text.
- encodeStartWhile:, encodeStartIf:, encodeStartElse, encodeStartDoWhile and
encodeEndDoWhile:: the wire has ENCODE_START_WHILE, _IF, _ELSE and
_DO_WHILE, and the host decodes them, but the host's runtime has no command
predication (the Vulkan platform's Unbuilt::Predication). The texts now say
that.
- newIndirectComputeCommandEncoderWithBuffer: and
newIndirectRenderCommandEncoderWithBuffer:: the wire carries indirect
command buffers; the bundle answers nil as Metal's device does.
- A pipeline's texture write rounding mode other than the default, render and
compute: the bundle sends none, and the host's pipeline rounds as its
default.
- newLogStateWithDescriptor:error:: neither the wire nor the host's runtime
has shader log states.
- dispatchThreadsPerTile:inRegion:'s comment: the wire has its op, but the
bundle makes no tile pipeline to run one, and the host's runtime has no
tile dispatch.
tests/protocol_members.txt repeats the texts and follows them.
For the guest: a new command queue now reads GPU priority 1 (getGPUPriority,
GPUPriority) and background GPU priority 2 (getBackgroundGPUPriority), where it
read 0 and 0. A new queue on the Intel 630 and the AMD 5300M reads 1 and 2
under macOS 26.7.1 (dgpu-oracle.md Q50), and RenderBox reads both back as it
sets up its queue. The setters and their readbacks are unchanged, and nothing
is sent to the host.
Q50's getters read no offset back, so the offsets' first values are not
measured, and they stay 0. Q50 also set the background priority only to 2, a
new queue's own value, so the bundle's readback of other background values is
unchanged and not pinned.
test_queue_priorities_read_back_as_metals runs Q50's readback sequence: a new
queue, setBackgroundGPUPriority: 2, then setGPUPriority: 2, a second queue's
setGPUPriority: 0, and the two offset forms.
On the Iris Xe, a guest's late frames come from the window server's writers
waiting on the GPU behind long buffers of the guest's background media-analysis
service. The guest marks that service's heavy queues setBackgroundGPUPriority: 2
and then setGPUPriority: 2, and WindowServer's setGPUPriority: 0. Our bundle
keeps the marks and answers them back, and nothing reaches the host. Before any
priority work is sized, the question was what an Intel Mac does with the marks.
oracle_prio answers first which of the four setters a queue answers and what its
getters read back. Then a second process commits a short compute buffer while
the first process's queue of 60 ms compute buffers runs, with that queue
unmarked, marked as the service marks its queues, both queues marked, and the
short buffer's queue alone marked as WindowServer marks its own.
Jobs m3-max-68129 and m3-max-68139 ran it on the MacBookPro16,1 oracle's Intel
UHD Graphics 630, and m3-max-68137 on its AMD Radeon Pro 5300M, under macOS
26.7.1. dgpu-oracle.md's Q50 records the answers:
- A new queue reads GPU priority 1 and background priority 2 on both GPUs, so
the service's marks change only its GPU priority, to 2.
- The 630 runs queues of one GPU priority first in, first out. When the short
buffer's queue has the lower value, it preempts the running long buffer and
starts the short one within 0.44 ms.
- The 5300M runs the short buffer beside the long one within 0.44 ms, marked
or not.
Our one VkQueue runs it after them all, in every case.
design.md's queue rings paragraph now says so, citing Q50. The oracle README
lists the probe, and build.sh builds it with the others.
Docs and the source of a probe built only for the oracle Mac: no check reaches
it ("docs and comments" in AGENTS.md). The probe was built with build.sh's flags
in jobs m3-max-68121 and m3-max-68136, with 0 warnings.
The command objects' header said the render, compute and blit SPI-only ops had
no encoder op yet. Each has one, and the host decodes each. The objects send
three of them (line width, provoking vertex, primitive restart) and answer the
rest as Metal's x86 encoders do, or refuse and log them. The comment now says
which is which, and what rt builds of the ops.
The register's note on supportsCommandBufferJump said what the query gates was
not established. It is read now: MPSGraph's if and while ops and MPSImage's
while loops encode GPU-side control flow only on YES. The device's compute
encoder refuses that control flow, so the base's NO stays.
A GL variant the bundle lowers was written into the app's store on the app's
own thread: the entry's hash, its atomic write and, past the cap, a trim of
the directory. Heaven's first run on macOS 26.7.2 over an RTX 3090 spent 39 ms
of its main thread in those writes at one scene change.
RgfxGLLowerKept now hands the entry to putLater, which queues it on the
store's own serial queue at utility QoS and returns. The queue's writes are
put()'s, so the cap and its least-recently-used trim hold as before. The bytes
queued and not yet written are bounded by the cap; a write past them is
dropped, and its variant is lowered again in a later run. A write the process
ends before loses only its own entry: each entry is a file of its own,
renamed into place whole. The store's off flag is atomic now, so a read on
the app's thread never waits on a trim the queue holds the lock for.
The tests wait for the queue (drain) where they read what a lowering wrote,
and new ones hold the queue (holdWrites) to check that a store opened
meanwhile misses the queued entries and reads the written ones whole, that
the queued bytes are bounded and the cap kept, and that queued writes from
threads stay whole beside direct ones.
The comments on the store's and the memo's caps gave Heaven's variants as
9.5 MB: the sum of their IR, plugin data and lowered bytes, read from the
bundle's log. The store Heaven made in a guest holds 332 entries of 22.3 MB
(macOS 26.7.2, an RTX 3090), as each entry carries its whole key, a stage-in
kernel's its variant's too, and a patch kernel keeps its module's text. So
the 64 MiB cap holds Heaven's variants three times over, not at several
settings, and the memo's 32 MiB is above Heaven's 22.3 MB, not three times
its size. The caps stay as they are.
The comments keep their line counts, and both guest sets are rebuilt for the
sources' record.
A GL app's variants were lowered again in each of its runs, on the app's own
thread: the GL code generator, our text round trip and the metallib's
writing. Heaven on 26.7.2 (an RTX 3090) lowers 411 variants in each run, the
second as many as the first, 2 ms at the median and up to 37 ms, 2.1 s in
all, and a scene change waits on the lowerings of its variants. Metal's
compiler service keeps what it compiled for an app in the app's cache
directory; the device lowers GL variants in the app's process, so the bundle
keeps them itself, beside Metal's.
The store (src/RgfxGLStore.hpp) keeps each lowered variant and stage-in
kernel in a file of its own under the user's cache directory, the app's
bundle identifier (or its program name) and ai.aneesiqbal.reims-graphics/gl:
the path Metal's own cache takes (com.apple.metal there), which a sandboxed
app can write too, measured in a 26.7.2 guest. The key holds everything the
lowering reads: the variant's IR and plugin data, its bitcode and function
types, and the identity of the bundle, the generator, the system's LLVM, the
OS build, the builtins file and the generator's environment variables. An
entry carries its key and the SHA-256 of its bytes, which a read checks; an
entry that does not read whole is removed and the variant lowered again.
Writes are atomic (a file of their own, renamed into place). Past 64 MiB an
app's least recently used entries go first: Heaven's 298 variants and 34
stage-in kernels take 9.5 MB, so the cap keeps an app's variants at several
settings. Any failure leaves the variant to the lowering, as before, and the
first is logged once per process.
A run asks for some variants more than once: Heaven asks for 75 of its 298
again, 113 lowerings and 490 ms a run, and for 8 of its 34 stage-in kernels
again. A memo (RgfxGLMemo, 32 MiB) answers a variant the process asks for
again with the bytes it answered first, with or without a store.
What the guest reads does not change: a hit answers the bytes the lowering
answered (tests/gl_store_tests.mm, a hit and a memo's answer equal to the
lowering's byte for byte).
tests/bundle_files_check.sh's rule changes on purpose: the bundle now writes
a second kind of file of the app's own, in the app's own cache directory,
through Foundation as its binary archive is, and still imports none of
open(2)'s family.
The GL code generator declares the AIR functions a variant calls in an order
that changes from one lowering to the next, in one process and across runs,
and the bitcode writes the functions in the module's order. Run twice in one
boot on 26.7.2 (an RTX 3090), Heaven lowered 24 of its 135 fragment variants
to other bytes in its second run, and 6 or 7 of the variants it lowered twice
in a run to other bytes the second time: the same length and the same
reflection, with only the order of their air.sample_texture_* declarations
changed. The order of declarations changes nothing a module does, but bytes
that differ for equal inputs cannot be kept and answered again as the
lowering's own.
RgfxGLSortDeclarations puts a module's declarations in the order of their
names, each in the place of one, before the text is parsed again, so equal
inputs write equal bytes. What the guest draws does not change.
tests/gl_tests.mm: orders of three declarations sort to one text, a sorted
text is left as it is, and, through the system's LLVM, a kernel whose two
declarations come in either order writes other bytes unsorted and the same
bytes sorted.
A Placement heap's newBufferWithLength:options:offset: and
newTextureWithDescriptor:offset: placed a resource anywhere it was asked, a
Private heap's with no bound at all, and the host then refused the placement
past the heap, so the app held a resource its command buffers could not use.
Both x86 Macs answer nil under macOS 26.7.1, their processes going on
(oracle_errors bounds, in a 1 MiB Private heap: a buffer at its last 64 KiB
made, one of 128 KiB there and one of 1 MiB + 64 KiB at 0 nil; a texture at the
last offset of its alignment that holds it made, one alignment on nil).
For the guest: such a placement is nil, posting nothing, where it was an
object the host refused. A texture's bytes are the host's answer to its size,
which the serialiser keeps per descriptor; with no answer the host's refusal
stands as before. The nil is logged with the device's note of a nil, now in
RgfxLog so the heap logs it too. No test held the old answer; a new one holds
the bound.
newBufferWithBytesNoCopy: made a buffer of any length, and the host then
refused its BUFFER_OVER_PAGES past the device's maxBufferLength, so the app
held a buffer whose uses in its command buffers the host dropped. Metal's
answer, measured with oracle_errors bounds under macOS 26.7.1: the Intel 630
makes one at its maxBufferLength and answers nil one byte and one page past
it, its process going on; the AMD 5300M makes both. Nil is inside what the two
answer and is the one that keeps the app's view true, so the bundle now
answers nil past the device's maxBufferLength, posting nothing, with its
noteNil line, wherever the bytes lie. The tiled no-copy texture goes through
the same factory and follows.
For the guest: a no-copy buffer or tiled texture past maxBufferLength is nil
where it was an object the host refused. The factory takes the limit
(maxLength, 0 for none), so the tests that made no-copy buffers pass 0 and
hold what they held; a new test holds the bound. The host's comments that said
the bundle made such buffers at any length now say what it does.
The oracle's jobs reserve at most 2 GiB, and a job whose processes' phys
footprint passes its reservation is ended. The caller's bytes are now a
sparse file's pages, mapped shared, which the footprint does not count, so
a no-copy create that wires them stays inside the job. The buffer of bytes
at maxBufferLength, which commits its bytes where it is made, is not asked,
and the one past it runs last. Each line gives the footprint after the
create.
oracle_errors' bounds case asks each create whose length or size Metal
bounds for one at its bound and one past it, each step in a child process,
so a step that ends its process shows how: buffers of a length, of bytes
and over the caller's bytes at maxBufferLength, one byte and one page past
it, a no-copy length off the page, a Private heap there, a Placement heap's
buffer and texture at its end and past it, and the tiled texture SPI over
the caller's bytes. The bundle answers the no-copy form without a bound,
and nothing measured what the x86 Macs answer there.
The guest driver's comment said AppleGVA makes its frames' IOSurfaces as
GetPixelBufferInfo answers. A walk on an x86-64 macOS 26.7.2 guest over an
RX 550 measured otherwise: an H.264 decoder's 1080p request was answered
pitches of 2048 at an alignment of 256, and its outputs' rows stayed 1920
bytes, the first plane 32 bytes in; HEVC decoders never asked. The comment
and docs/video/devices.md now say the outputs are CoreVideo's own layout.
The guest's 1080p decoder outputs on radeonsi keep 1,920-byte rows even
where the device answers a cached layout at 256 bytes, and nothing in the
guest's log says why: whether AppleGVA's request names a sub-ID the driver
takes for a codec, and whether the surfaces its pool makes take the pitch
the driver answered. Two lines now say so.
GetPixelBufferInfo logs each request once a process, by its fields and
status: the function and sub-ID it names, its unnamed words, the frame's
size, format and planes, the codec and host layout the driver took it for,
and on success each plane's size, pitch and alignment. A decode context
logs its first output surface: its size, format, and each plane's bytes
per row, first byte and rows. Both are diagnostics alone; what AppleGVA
is answered is unchanged.
Built with build.sh's flags on the M3 (Xcode 27.2), the oracle tools printed
two kinds of warning, for x86_64 and arm64 alike:
- oracle_bundle.m: @('420v') boxed the multi-character constant as a char, so
iosurf.buffer.420v asked IOSurfaceCreate for pixel format 118 ('v'), not
'420v' (-Wconstant-conversion). It now boxes the four characters as a
uint32_t, as probe_surface takes its fourcc.
- oracle_readonly.m: cpuShape's two texel arrays were sized by a static const
NSUInteger, which C does not take as a constant expression, so clang folded
each variable-length array to a constant one as an extension
(-Wgnu-folding-constant). kSide is now an enum constant.
The tools are not among the sources of the prebuilt kext sets, so the sets
are unchanged.
The guest's GPU benchmark scene keeps about 3.4 to 3.8 frames of command buffers
in flight on our device, against about 1.7 on the 5300M Mac. The question was
whether an answer of ours lets the app run further ahead than a Mac would.
oracle_depth measures how many buffers one queue keeps uncompleted in front of a
busy GPU, where -commandBuffer blocks, whether commit or
commitAndWaitUntilSubmitted blocks before that, and when each buffer is
scheduled. oracle_gldepth hooks the Metal device's queue creators and the
queues' command-buffer creators under a CGL context that draws into an FBO, so
it reads what Apple's GL renderer over Metal asks for and how many buffers it
keeps in flight.
Q49 holds what they found:
- On the 5300M, the 630 and the M3, a queue keeps its maxCommandBufferCount of
buffers uncompleted (34 on the 630 for an ask of 32), and blocks only in
-commandBuffer.
- Each buffer is scheduled within 0.8 ms of its commit, 32 deep. The M3 alone
schedules at most 36 of a queue ahead.
- Apple's GL renderer asks for 32 and keeps 32 in flight when the GPU is the
slower side, as the guest's does on our device.
- The 5300M's 1.7 frames belong to AMD's own GL driver, which is not over Metal.
WindowServer died while QuickTime Player played a 4K video full screen: a
user's 780M host, and measured here on a 780M (macOS 26.7.2 and 15.8.2) and on
an Iris Xe (26.7.2), each time on a walk's second clip. Read from their code,
SkyLight's compositor takes a Metal device whose name holds "Intel" for an
Intel GPU, and scales a full-screen video's YUV layer through Intel's video
pixel processor (AppleGVACore). That keeps only plugins of Intel's renderer
IDs, so with ours it has none and asserts. The naming rule gave integrated
hosts "Intel - ", and an Intel host's own name holds "Intel" under any prefix.
What an x86-64 guest sees now, on every host (the owner's rule):
- MTLDevice.name, and the GPU's `model` that System Information shows as its
Chipset Model, are "AMD - " and the host's name with "Intel" and "NVIDIA"
taken out, in any case, each with a mark directly after it ("(R)", "(TM)",
"®", "™") and one space:
- 780M: "AMD - AMD Radeon 780M Graphics (RADV PHOENIX)" (was "Intel - ...")
- Iris Xe: "AMD - Iris(R) Xe Graphics (RPL-P)" (was "Intel - Intel(R) ...")
- UHD 630: "AMD - UHD Graphics 630 (CFL GT2)", on Windows "AMD - UHD
Graphics 630"
- Arc A770: "AMD - Arc(tm) A770 Graphics (DG2)"
- RTX 3090: "AMD - GeForce RTX 3090" (was "AMD - NVIDIA GeForce RTX 3090")
- 7900 XTX and llvmpipe: unchanged, "AMD - " and the host's name
The kext's `model` was the host's name whole, and none for no name; it is
now the same name as Metal's, "AMD - reims-graphics" for no name.
- vendorName is "AMD" on every host (was "NVIDIA" or "Intel(R)" by the host
name's first word), so the GL renderer takes NVIDIA's settings on every
host, as on a 5300M, where an Intel host's guest took Intel's
(design.md, "The renderer's settings").
- SkyLight's NVIDIA name test finds nothing on an NVIDIA host either: it takes
an AMD GPU's path there (MetalTiledBacking's +0x71 now set).
The device info's `integrated` byte stays on the wire and the host still
writes it; nothing in the guest reads it now, as its docs say. arm64 guests
see what they saw. The ROM's bytes are unchanged: its record changes for the
wire header's comment alone.
Tests: serializer_tests' test_metal_names, test_vendor_names and
test_metal_answers_hold_no_vendor_word; the kext's device_name_test, now built
for the x86-64 kext's rules and, as device_name_arm64_test, the arm64e kext's.
A Shared or Managed newBuffer in the guest could answer nil while the process's
own memory was on its way back to the region. A create that found no room let
the process's empty, cached and doomed slabs go, waited for the slabs other
threads were giving back at that moment, and asked once more. Under CPU load the
slabs' background thread, at utility QoS, falls behind on its drops: the slabs
other threads let go while the wait lasted stayed doomed, their memory out of
the source, and the second ask was refused while 26 to 52 of them held it.
A create now goes round again for as long as a round gave memory back, so its
answer is nil only where the region, or the pool, is full. A round after the
first asks again only where it gave something back, so a create in a quiet
process does what it did.
test_slab_take_gives_back_slabs_let_go_while_it_waited holds the slabs' releases
at the test source's gate while a create waits, so the slabs let go meanwhile
stay doomed: it failed in 20 of 20 runs on the old code and passes in 20 of 20.
test_slab_thread, which saw it once under Rosetta beside a 16-job cargo build,
refused a 3 MiB take in 6 of 3,828 runs beside 48 busy loops and 8 dd copies on
the M3 Max's 16 CPUs before, and in none of 3,144 after.
Both prebuilt sets are rebuilt from the change.
The guest's Metal device answered maximumConcurrentCompilationTaskCount with
the host's compile threads from the device info, clamp(cores, 2, 4) = 4. A 3D
modelling app's renderer starts max(2, count - 1) compile threads, so an 8-vCPU
guest compiled its kernels on 3 threads.
What the guest sees now:
- maximumConcurrentCompilationTaskCount answers the guest's own hw.logicalcpu,
at both states of shouldMaximizeConcurrentCompilation, on x86-64 and arm64e
guests alike: 8 on an 8-vCPU guest and 4 on a 4-vCPU one, so the renderer's
rule gives 7 threads on 8 vCPUs in a background render and an interactive
launch alike.
- shouldMaximizeConcurrentCompilation is the device's own: NO in each new
device, then what its setter set. The setter still passes the value on to
_MTLDevice's, which took every call before.
Why one rule: at YES both Macs measured answer their hw.logicalcpu (the M3 Max
16; the 2019 MacBook Pro 12, on its AMD 5300M and its Intel UHD 630). At NO
they differ: the MacBook Pro's GPUs answer 2 and the M3 Max its 16. Nothing
documented promises a smaller count at NO, so the device takes the wider answer
at both. One query binary, built in m3-max-64460, read both Macs: m3-max-64461
(M3 Max, macOS 27.0.1) and m3-max-64462 (MacBook Pro, macOS 26.7.1). The base's
setter and its encodings were read in m3-max-64488.
The host is unchanged: the device info still carries its compile threads in
the same slot, which the bundle no longer reads, so the wire, the option ROM
and the kexts keep their layout. Both guest sets are rebuilt.
An x86-64 guest's MTLDevice.name is now the host GPU's name, whole, after a
prefix: "Intel - " where the host's Vulkan driver reports the physical device's
type as INTEGRATED_GPU, and "AMD - " for every other type (discrete, virtual,
CPU, other). An RTX 3090 now reads "AMD - NVIDIA GeForce RTX 3090", a Radeon
780M "Intel - AMD Radeon 780M Graphics (RADV PHOENIX)" and llvmpipe "AMD -
llvmpipe ...". The rule reads the device type alone, with no list of vendors,
drivers or devices. The name keeps its spaces as the driver gives them, and an
empty name reads "AMD - reims-graphics" or "Intel - reims-graphics".
A 3D modelling app chooses its GPU by a vendor word in the device's name
(Intel, AMD, Apple), and on a host GPU of another vendor it listed only the
CPU (walk m3-max-61607).
What stays: arm64 guests' name; the Metal device's vendor and family names, by
which the GL renderer picks its settings; and System Information's Chipset
Model, the kext's IOPCIDevice model, which stays the host's name, whole.
The device info carries the type in its byte at 0x453, reserved and zero
before, now `integrated`: 1 for INTEGRATED_GPU. Its layout and wire version
stay, and a host older than the field writes 0, which reads as not
integrated. The firmware's record and both prebuilt sets follow the header and
the bundle; the option ROM's bytes are unchanged.
Q16 measured another process's access to an IOSurface behind one long pass.
It left open whether a read waits out the writing process's whole queue of
work ahead of the write, whether it also waits for what that queue commits
after the write, and whether a writer committed by a plain commit is ordered
at all.
oracle_backlog asks those three, as arms 1 to 3, each against control rounds
in which the read has nothing to wait for. Job m3-max-64081 ran it on the
MacBookPro16,1 oracle's AMD Radeon Pro 5300M and Intel UHD Graphics 630
under macOS 26.7.1, and dgpu-oracle.md's Q48 records the answers. On both
GPUs the read waits out the writer's queue ahead of the write, as our surface
order makes it. The 5300M orders the read by the surface alone and lets it
pass buffers the writer committed after the write; the 630 runs both
processes' work first in, first out, as our one VkQueue does. On the 5300M a
read after a plain-commit writer ran ahead of the write in 1 of 3 rounds;
our order, which never lets it, matches the 630 and is kept.
design.md's "Surface order" and surface_order.rs's module doc cite Q48 beside
Q16, the oracle README lists the probe, and build.sh builds it with the
others.
Docs, a doc comment and the source of a probe built only for the oracle Mac:
no check reaches it ("docs and comments" in AGENTS.md), and nothing was built
or run for this commit.
The host's runtime keeps a destroyed object for the command buffers
committed before its destroy, but a new object made with the old one's
resource id or at its GPU address takes them at once. A buffer still running
there then read the new object in place of the old one.
What a destroy gives back now waits until the host has completed every
command buffer the process committed before the object was let go, a failed
buffer included: its resource id and GPU address, its heap's bytes, its
region and pool blocks, its pages and its ICB slots
(RgfxRetireGate in RgfxSerializer.hpp). Every RgfxSerializer::destroy
`after` goes through the gate, stamped at the call. A command buffer takes a
serial at its commit and gives it back at its completion, or at its dealloc
where no completion came. makeAliasable still gives a heap range back at
once.
What the guest sees: ids and ranges are reused later than before. A texture
made while a buffer committed before another texture's release is in flight
takes a different resource id. A new buffer's address and a heap's usedSize
can differ the same way. With nothing in flight, everything goes back at once
as before. Under the game step's -r, no id is reused before frame f+3.
The serialiser's end, the context's, runs whatever still waits and logs once
the most that waited at once. A guest context ends only with its process, so
a new peak is also logged at each power of two from 64.
guest/prebuilt and guest/prebuilt-arm64e are rebuilt from these sources.
The two race tests of 21e637db25 passed against the two-hold code they guard:
on libpthread's default mutex policy the committing thread took the held
messages' mutex again before the thread waiting on it, so the window between
the holds was never met. Each now runs in a child of its binary on the
fair-share policy (PTHREAD_MUTEX_DEFAULT_POLICY=1, rgfxRunFairShare), where an
unlocked mutex goes to its waiter, and checks that the child has it. The
protocol test's kext now refuses a held destroy, as a post that took every
held message leaves the old check a lock-free answer that waits for nothing.
Against the sources before the fix both fail, the serializer's at
postHeldCreates and the protocol's at the buffer missing from its ring; on
the fixed tree `make -C guest test` passes. The trap is in docs/lessons.md.
The bundle's tests are not among the sets' sources, so the sets stay as built.
The shell tests' build failed with -Wmissing-field-initializers: the two
commit tests brace-initialise PublishingKext, and its new `once` hook had no
default member initializer, as the fields before it have.
A command buffer whose commit posts the control ring's held messages first
failed with MTLCommandBufferErrorInternal ("an object made before it never
reached the device") when another thread held a create between the post of the
held messages and the check of what stayed held. The check took a second hold
of the held messages, saw the other thread's create, which no post had been
asked to take yet, and counted it as refused. A sample app that makes textures
on other threads while one thread commits met it in four walks since 11-14,
the check's first day, on Intel, NVIDIA and AMD hosts alike.
The commit's post with its publish (RgfxRingWriter::flushPublishing) and
RgfxSerializer::postHeldCreates now tell whether a held create was refused in
the post's own hold. A create another thread holds after that is posted later:
the buffer, whose commit began before it was made, cannot name it.
For the guest: such a command buffer is posted and completes, where it failed.
A buffer behind a create the kext did refuse still fails as before. The tests
hold a create on another thread while the kext takes the held messages.
A pipeline create waited 60 s for its reflection. On a slow host or a cold
compile the app got nil, and the destroy posted behind the create cancelled a
compile that would have succeeded. Other waits for host answers had the same
problem. A queue's create (30 s), SURFACE_PAGES (30 s), shared events (60 s),
a CPU lock's wait for its surface's writes and the host's copies (2 s), a new
block's wait for a write-back (10 s) and the bundle's library chunk acks
(10 s) all sit behind the context's earlier work on the host, a compile among
it. At their bounds a lock read whatever bytes the pages held.
Each of those waits now has no deadline, as Metal's own calls wait for the
GPU's driver (RgfxAnswerWait.hpp). It sleeps THREAD_INTERRUPTIBLE, so a caught
signal never ends it, and it ends only:
- at the answer;
- at the device's stop: quiesce wakes every waiter, and the waiter finds the
device stopped;
- at the thread's abort (SIGKILL, a fatal signal, exit), returning
kIOReturnAborted.
An aborted create still gets its destroy posted behind it. A CPU lock waits
with no deadline for the device to complete its writes' buffers. Its 2 s bound
now counts only from that completion to the bundle's retire, so a process
that locks a surface on the thread that would retire it still goes on.
The 64 lifecycle waiters are split by kind: 32 for the processes' creates and
shared events, 16 for surface pages and downloads, and 16 for the device's
own asks (queue create, close, pool takes, kept answers, video). Creates
waiting on compiles can no longer take the waiters WindowServer's surface,
queue and close asks need. A waiter take that ends unanswered returns
kIOReturnBusy, so a caller never mistakes an unposted message for a posted
one.
The waits that do not depend on host work keep their deadlines, each with its
reason in a comment: ring room, display commands, the start's kept answers,
a context's close, the display pipe, arm64 video sends and the region-room
wait.
What the guest now sees: a lock or present behind a slow compile waits for
it, and a create returns its pipeline however long the compile takes.
An Automatic heap's make asks the device for its texture's size first, a
call to the host, then makes the texture. To split the bloom chain's makes
into that query and the rest, the tool now asks the device's
heapTextureSizeAndAlignWithDescriptor: alone after its measured window, as
many times as the window's bloom makes, and adds their count, p50, p90 and
worst to the GAMELOAD calls line. Nothing in the window changes.
The heap shape makes 10 objects a frame (two stream slots and the 1 MiB
vertex buffer placed in the placement heap, the 7 bloom textures in the
frame's automatic heap) and lets 10 go. To tell whether the calls themselves
hold the frame's extra time or what they cause later does, the tool now
times each make in the measured frames, and prints a GAMELOAD calls line:
their count, p50, p90, the worst and their time a frame.
Releases happen where the last reference goes, most of them as a command
buffer that holds them completes, off the encoding thread. -r holds each
frame's heap objects until the frame FRAMES_IN_FLIGHT + 1 frames later
starts, after its command buffers completed, and releases them there one at
a time, each timed; the line then gives the same numbers for them, and how
many another reference still held. Without -r every object goes where it
went before, and every other output line is unchanged.
gameload made the ICB pass's pipeline (supportIndirectCommandBuffers on the
scene's variant 0) and its encode kernel's pipeline, and the compute ICB's
encode kernel and its supportIndirectCommandBuffers pipeline, whatever --off
said. So `--off icb,cicb` still made pipelines for indirect command buffers,
and a device that builds no ICBs refused the first one and the run ended.
Now each of those is made only when its shape is on, beside the ICB, its
argument buffer and the compute ICB's buffers, which already were. With both
on, the tool makes the same objects in the same order as before, and every
other shape's work and output lines are unchanged. The header says what --off
now leaves out.
A texture over an IOSurface plane is sent at the plane's place in its view,
shadow->planes[plane], and the plane was checked against the surface's plane
count, not against the view's own planes. A view that laid out fewer planes
than its surface has sent plane 1 out of bounds. On the UHD 630 under Windows
(winpics d1-c1, m3-max-59780/59893), the video decoder's chroma texture over a
4K '420v' output went at offset 0, rows 0 bytes apart, with facts of two
planes and plane 1 at offset 0, 0 bytes a row. The host refused the create,
the picture's decode that names it was dropped, and every picture after it up
to the next IDR was wrong (207 of 240 matched).
shadowFor now gives a view only where it lays out the surface's planes as
they are now (describes). One that does not gives way to a new view in the
registry, and lives on for the textures that hold it. The texture's make
checks its plane against the view, once more after a view made again, and
makes none where the view still does not lay out the surface. The first few
such views of a process are logged with the surface as the view was made of
it, its own surface now and the surface asked, since how such a view arises is
not yet known. Every other index of a view's planes is a texture's own plane,
which its make bounds, or rgfxIOSurfaceRowsHeld's, which checks it.
The residency set's checks name the generation the refill test leaves in the
block's header, which is 18 now that the refill test plays a lock for each of
its cases.
The bundle's refill test expected a settled record to ask the kext again
after a GPU write, which the shared rule does not do and need not: a settled
cache holds the generation as the CPU left it, and the GPU's writes are the
cache's own. The write that asks is one under a lock still held, where the
record is owed; the test now plays that, and the rule's header says so.
A cached surface's device cache could hold the pages as they were mid-write
with no refill ever asked: the bundle recorded the surface's unlock seed only
as a commit first named a generation, so a fill the bundle never saw (a
present's, the first fill a block owes, a block named again) made while the
CPU held its read-write lock stood until the next lock. Such a present also
left the record to be made after the unlock, which then never asked.
The kext now writes each generation's refill record into the block's header
itself, as it caches the block and at each read-write lock, before the
generation, with the surface's unlock seed then (RgfxSurfaceRefill.hpp,
which the bundle shares). The first commit, in any process, once the unlock
seed has moved past the record's carries RGFX_SURFACE_USE_REFILL and settles
it; a commit while the lock is held or being taken asks nothing and leaves it
owed. For the host: a use after each read-write lock's unlock now carries the
flag, including the first use of that generation; the host ignores it where
the cache holds an older generation, as before, so a generation never filled
mid-write costs no extra fill. The record is one 64-bit word written by
compare-and-swap, so a holder never writes over a newer generation's record.
The file-pages test named the second mapping of its sole-holder memory
`second`, the name the same scope's copy-on-write case gives its source
buffer, so the test did not compile.
The bundle and the sole-holder probe named mach/vm_page_info.h, which the
macOS SDK does not ship: VM_PAGE_INFO_BASIC and its struct come from
mach/vm_region.h, which both files already include.
The bundle now names read-only anonymous memory unchanging where its maximum
protection has no write, the kernel answers it SM_PRIVATE at a shadow depth of
0, and mach_vm_page_info's VM_PAGE_INFO_BASIC answers its object's count as 1
at depth 0 with the region's object id (kRgfxAnonymousPrivate). The kext takes
such a block (kRgfxPagesSoleHolder, 1 << 3, where it sets
kRgfxKextFeatureSoleHolderPages, 1 << 20) and marks its SURFACE_PAGES
RGFX_SURFACE_PAGES_UNCHANGING without COPY_ON_WRITE, so the host reads its
pages once, as the view is imported. On P2's guest (macOS 26.7.2, the Windows
mini) the 4K block over such memory was copied whole at each commit that used
it.
A wire holds no reference, so the count leaves out wires for writing taken
while the memory was writable. The kext knows its own: it refuses the block
(kIOReturnNotPermitted) where, once its pages are wired, a writable block of
its own in the table or an in-place surface block covers a page of them, or a
block of writable memory is being made (writableMakes), and the bundle then
asks a read-only block, why RGFX_PAGES_WHY_REFUSED. The check sorts the
block's runs and walks every writable wire's segments under contextLock, once
per such make. What is left is a write another driver started before the app
removed write for good, still landing after the make.
The clause is on for every guest kernel, with no release gate. The facts it
rests on, read in xnu's published source at each tag from macOS 11.0.1 to
26.5, osfmk/vm/ lines:
xnu- cnt pid rid fake prot upl clamp iopl walk id
7195.50.7.100.1 19154 19264 14459 19126 6172 6459 17037 9030 14915 1209
7195.60.75 19074 19184 14406 19046 6156 6459 16984 9030 14862 1209
7195.81.3 19074 19184 14413 19046 6157 6459 16984 9030 14869 1209
7195.101.1 19119 19229 14290 19091 5915 6457 17020 9010 14749 1190
7195.121.3 19158 19268 14329 19130 5916 6457 17059 9010 14788 1190
7195.141.2 19158 19268 14329 19130 5916 6517 17059 9070 14788 1190
8019.41.5 19330 19440 14493 19302 6007 6551 17227 9137 14952 1190
8019.61.5 19330 19440 14493 19302 6007 6551 17227 9137 14952 1190
8019.80.24 19330 19440 14493 19302 6007 6551 17227 9137 14952 1190
8020.101.4 19330 19440 14501 19302 6003 6543 17247 9143 14960 1188
8020.121.3 18885 18995 14245 18857 5918 6541 16960 9131 14704 1168
8020.140.41 18945 19055 14305 18917 5909 6542 17019 9135 14771 1168
8792.41.9 19527 19637 14780 19499 5939 6701 17519 9294 15246 1166
8792.61.2 19538 19648 14791 19510 5939 6753 17530 9346 15257 1167
8792.81.2 19538 19648 14791 19510 5939 6753 17530 9346 15257 1167
8796.101.5 19669 19779 14872 19641 5926 6750 17650 9273 15338 1164
8796.121.2 19669 19779 14872 19641 5926 6750 17650 9273 15338 1164
8796.141.3 19738 19848 14911 19710 5940 6774 17695 9297 15377 1164
10002.1.13 19897 20007 15074 19869 6032 6791 17854 9316 15540 1163
10002.41.9 19910 20020 15087 19882 6032 6771 17867 9296 15553 1165
10002.61.3 19910 20020 15087 19882 6032 6771 17867 9296 15553 1167
10002.81.5 20023 20133 15121 19995 6041 6771 17980 9296 15587 1167
10063.101.15 20254 20364 15180 20226 6098 6774 18210 9299 15646 1355
10063.121.3 20357 20467 15247 20329 6123 6774 18308 9299 15714 1355
10063.141.1 20359 20469 15249 20331 6125 6774 18310 9299 15716 1355
11215.1.10 20139 20249 14984 20111 5692 6843 18096 8188 15442 771i
11215.41.3 20139 20249 14984 20111 5692 6843 18096 8188 15442 771i
11215.61.5 20501 20611 15230 20472 5759 6817 18384 8162 15693 765i
11215.81.4 20507 20617 15236 20478 5765 6817 18390 8162 15699 765i
11417.101.15 20646 20756 15393 20617 5804 6766 18487 8111 15856 765i
11417.121.6 20694 20804 15441 20665 5843 6781 18535 8129 15904 766i
11417.140.69 20703 20813 15449 20674 5841 6777 18546 8124 15913 766i
12377.1.9 20960 21070 15518 20931 5974 6988 18734 8331 16004 776i
12377.41.6 22004 22114 16433 21975 6174 7198 19709 8562 16933 807i
12377.61.12 22037 22147 16463 22008 6204 7203 19742 8567 16963 808i
12377.81.4 22109 22219 16534 22080 6275 7209 19813 8573 17034 808i
12377.101.15 18688 18805 13571 18677 5743 7659 16128 8765 14068 824i
12377.121.6 18686 18803 13569 18675 5722 7659 16126 8765 14066 824i
cnt vm_map.c, vm_map_page_range_info_internal: the top object's count,
less the query's own reference to 12377.81.4, read before it after
pid there: the id, VM_KERNEL_ADDRPERM to 10063.101.15, ADDRHASH after
rid vm_map.c, vm_map_region_recurse_64: the region's id, VM_OBJECT_ID
id vm_object.h (i: vm_object_internal.h): VM_OBJECT_ID, the low 32 bits
of pid's macro in each tag
fake vm_map_page_range_info_internal: a footprint query's count of 1 and
an id of no object (task_self_region_footprint)
prot vm_map.c, vm_map_protect (its preflight from 12377.101.15): no
protection the maximum lacks
upl vm_pageout.c, vm_map_create_upl: no write UPL where the entry's
protection lacks write; from 12377.1.9 through vme_allows_upl_write,
whose test is at 6786, 6986, 6991, 6997, 7413 and 7413
clamp vm_map.c, vm_map_remap_extract: a share's maximum is the source's at
most, which memory entries take through vm_map_copy_extract
iopl vm_pageout.c, vm_object_iopl_request: the UPL keeps the object with
no reference of its own
walk vm_map.c, vm_map_region_walk: the count less one while paging, so
the share mode alone leaves it in doubt
Later releases are checked by test: guest/bundle/tools/sole_holder_probe.c,
which the lane gate's info phase (item sole-holder) and Ambrosia's
check-boot.sh (check sole-holder) run on each guest they boot, reads the count
as 2 with a memory entry or a second mapping holding the memory and 1 once it
goes, sees a footprint query answered otherwise, the kext's writable wire of
memory whose maximum lacks write refused, a sole holder's block made, and
refused while a writable block of the kext's covers it. A release where it
fails is a red leg. The kext's tests cover the wiring and the runs' sort and
search, and the bundle's a sole holder's block named and refused.
Anonymous memory read SM_PRIVATE is not provably unchanging: the region walk
takes one from the object's reference count while paging on it is in
progress (osfmk/vm/vm_map.c:16002-16005), and a wire holds no reference
(vm_object_iopl_request, osfmk/vm/vm_pageout.c:8331; upl_destroy, 5683-5685),
so a driver's wire for writing taken while the memory was writable, our own
kext's for a writable block among them, still writes its pages after the
maximum protection lost write, under a count of one. A once-made copy would
then be wrong for the block's life. Such memory is read-only again, why not a
file, and its blocks are copied whole at each commit as before.
What stays unchanging is SM_COW at shadow depth 0, with no write in the
maximum protection, which is sound against wires too (xnu main as read on
2026-11-20):
- such a pending copy is vm_object_copy_quickly's of an object whose copy
strategy is still symmetric (osfmk/vm/vm_object.c:3586-3605), and a wire
makes its object's strategy a delayed copy (vm_pageout.c:8404-8423), so the
object was not wired before the copy;
- a wire through either side after it resolves that side's pending copy
first, shadowing it (vm_map_create_upl, vm_pageout.c:7140-7188), as a write
fault does (vm_map_lookup_and_lock_object, vm_map.c:14866-14897) and a share
does (vm_map_remap_extract, vm_map.c:18314-18396), so the other side's writes
and wires land in a copy of its own.
What the host sees: blocks of anonymous memory SM_PRIVATE no longer carry
RGFX_SURFACE_PAGES_UNCHANGING; those with a copy pending carry it with
RGFX_SURFACE_PAGES_COPY_ON_WRITE. The bundle's classification line drops the
private clause. The tests hold both.
A no-copy buffer over anonymous memory the process mapped read-only, with
no write in its maximum protection, was a read-only block not unchanging
(why 1, not a file): the host copied its pages whole into its copy at every
commit that used it. On the Windows host's 4K desktop that is a 4K block of
ImageIO's (share mode SM_PRIVATE, ref 1, shadow depth 0), 7.93 ms and
31,007 KiB a present.
The bundle now names two share modes of such memory unchanging, read from
xnu's main as of 2026-11-20 (osfmk/vm/vm_map.c's vm_map_region_walk,
16088-16098; the modes' values osfmk/mach/vm_region.h:129-130):
- SM_PRIVATE, the object held by the region alone; a share of it takes no
protection past its maximum (vm_map.c:18037-18058, 18733-18734), and
VM_PROT_COPY maps a copy in its place (vm_map.c:5832-5905);
- SM_COW at shadow depth 0, a copy pending on the region's own object
(vm_object.c:3586-3605; vm_map.c:12727, 14046, 18604), where the other
side's writes go to a copy of its own (vm_map.c:14866-14897,
18314-18396), marked copy-on-write.
A depth of 1 or more, and every other mode, stays neither, why not a file.
SM_PRIVATE's one doubt is documented: the walk takes one from the object's
reference count while it pages (vm_map.c:16002-16005).
What the host sees: such blocks now carry RGFX_SURFACE_PAGES_UNCHANGING
(and _COPY_ON_WRITE for the pending copy), so the host reads their pages
once, as the view is made, instead of at every commit; the GPU's writes
there are dropped as before. The bundle's classification line counts the
two new clauses. The wire, kext and host docs say so.