Files
reims-vgpu/scripts/internal/lane-gate
Anees Iqbal 83c4898877 🆕 Name a sole holder's anonymous memory unchanging
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.
2026-11-20 14:02:42 -08:00
..