Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Translate iOS 18's multi-buffer command submits for 26.1

Jackydf2444e119fe
diff --git a/Research/0_binary_patch_comparison.md b/Research/0_binary_patch_comparison.md
index 6f52710b..9ca68e43 100644
--- a/Research/0_binary_patch_comparison.md
+++ b/Research/0_binary_patch_comparison.md
@@ -1801,7 +1801,7 @@ do NOT execute these).
| 34 | Remove four point-size reflection guards that suppress valid `GL_POINTS` submissions — **iOS 26.6 / cloudOS 26.4** | AppleMetalGLRenderer's direct and primitive-buffer draw paths, guest dyld shared cache | **Submit points despite missing PV pipeline usage flags.** `dyld-cfw-gles_point_draw` replaces only the four bit-7 `TBZ` guards with NOPs, preserving other gates and the native shader/rasterizer. Semantic discovery and transactional DSC undo; cloned-cache apply/repeat/revert restores all 85 files exactly. Process-local diagnostics restore point footprints but expose a separate coordinate Y-flip transport gap. Development-build guest validation passes all 21 point cases on the restored old default cache and a warm repeat; see "Native GLES follow-up (2026-11-02)". | Y | Y | Y |
| 35 | Derive the paravirtual driver compiler cache identity from the installed plugin — **iOS 26.6 / cloudOS 26.4** | AppleParavirtGPUMetalIOGPUFamily | **Invalidate shader output after plugin updates.** `system-paravirt_gpu-cfw-compiler_cache` replaces only two eight-byte SHA-256 seed inputs with a 96-bit plugin content identity. Changes compose with the other driver patches on its pristine backup. Requires row 36 when cross-boot reuse is enabled; installer verifies it actually applied before refreshing the plugin. Private APFS clone and fatal identity-failure handling prevent inconsistent publication. Development-build guest validation rejects stale default-cache shaders and passes all 21 point cases. | Y | Y | Y |
| 36 | Retain cache-key validation when cross-boot reuse is enabled — **iOS 26.6 / cloudOS 26.4** | libCoreFSCache in the guest dyld shared cache | **Reject stale compiler output while retaining warm caches across boots.** The original `FS_CACHE_REUSE_ON_REBOOT=1` skips both the key and boot checks. `dyld-cfw-metal_cache_reuse_key` routes only that path through the key comparison; the no-reuse path remains intact. Development-build guest validation passes all 21 point cases on the restored old default cache and a warm repeat; actual-cache apply/repeat/undo restores all 85 files. | Y | Y | Y |
-| 37 | No Apple binary change: SystemHook detours IOKit's `IOServiceOpen`/`IOServiceClose`/`IOConnectCallMethod`/`IOConnectCallAsyncMethod` while `/usr/lib/vphone-ios18-gpu` exists, and `fw prepare` stages the iOS release's own cloudOS GPU driver — **iOS 18.6 / cloudOS 26.1** | none (`VPhoneGuestComponents/SystemHook/VPhoneIOS18GPU.c`; driver from cloudOS 18.6; marker written by `cfw install` only over that driver) | **An iOS 18 guest gets a Metal device.** The 26.1 driver does not load on iOS 18, and the 18.6 one is refused by the 26.1 kernel: IOGPU device method 6 is gone and 7–255 moved down by one, the resource-create reply gained 8 bytes at 0x18, and AppleParavirtGPU method 265 grew from 0x10c to 0x118. The transport renumbers and repacks for IOGPU device connections only. `system-systemhook-cfw-ios18_gpu_transport`; see "iOS 18 GPU transport (2026-11-05)" and `Research/Guest/ios18_gpu_transport.md` | Y | Y | Y |
+| 37 | No Apple binary change: SystemHook detours IOKit's `IOServiceOpen`/`IOServiceClose`/`IOConnectCallMethod`/`IOConnectCallAsyncMethod` while `/usr/lib/vphone-ios18-gpu` exists, and `fw prepare` stages the iOS release's own cloudOS GPU driver — **iOS 18.6 / cloudOS 26.1** | none (`VPhoneGuestComponents/SystemHook/VPhoneIOS18GPU.c`; driver from cloudOS 18.6; marker written by `cfw install` only over that driver) | **An iOS 18 guest gets a Metal device.** The 26.1 driver does not load on iOS 18, and the 18.6 one is refused by the 26.1 kernel: IOGPU device method 6 is gone and 7–255 moved down by one, the resource-create reply gained 8 bytes at 0x18, the multi-buffer submit takes 0x30-byte entries instead of 0x28 and returns a scalar iOS 18 does not ask for, and AppleParavirtGPU method 265 grew from 0x10c to 0x118. The transport renumbers and repacks for IOGPU device connections only. `system-systemhook-cfw-ios18_gpu_transport`; see "iOS 18 GPU transport (2026-11-05)" and `Research/Guest/ios18_gpu_transport.md` | Y | Y | Y |
### Swift port status — the eight DSC patchers (2026-09-23)
diff --git a/Research/Guest/ios18_gpu_transport.md b/Research/Guest/ios18_gpu_transport.md
index d0a192a0..7cc42f6d 100644
--- a/Research/Guest/ios18_gpu_transport.md
+++ b/Research/Guest/ios18_gpu_transport.md
@@ -33,6 +33,7 @@ Found by tracing each IOKit user-client call in a test process, then diffing all
| IOGPU device method 6 (`IOGPUDeviceCreateWithAPIProperty`: a 16-byte API name, result ignored) | removed | answered locally with success |
| IOGPU device methods 7–255 (7 = command queue create, 9 = resource create, … 0x37) | one lower (6, 8, … 0x36) | selector − 1 |
| Resource create reply: 0x50-byte header + driver tail | 8 bytes inserted at 0x18 | ask for 8 more, drop `[0x18, 0x20)` |
+| Command-buffer submit, method 26 (25 on 26.1), taken when several command buffers go at once: 0x28-byte entries (`cmdBufArgsSize`), entry size in input scalar 3, no scalar output | 0x30-byte entries (same fields, last 8 bytes zero), one scalar output; refused with 0xe00002c2 otherwise | widen each entry with zeros, pass 0x30, supply a one-scalar output and drop it |
| AppleParavirtGPU method 265 (`-[AppleParavirtDevice setupDeviceInfo]`), 0x10c-byte reply | 0x118 bytes, refused with 0xe00002c2 when asked for 0x10c | ask for 0x118, keep `[0, 0xd8)` and `[0xdc, 0x110)` |
Request layouts did not change: the command queue create struct is 0x408 bytes on
@@ -83,7 +84,10 @@ Do not widen the gate without repeating the measurement:
1. Extract IOGPU.framework from both shared caches
(`ipsw dyld extract … IOGPU`), disassemble with symbols, and list each
- `bl _IOConnectCall*` with the selector in `w1` and the size arguments.
+ `bl _IOConnectCall*` with the selector in `w1`, the size arguments and the
+ scalar counts (`w3` in, `x6`/`x7` out). The submit method's new output
+ scalar was missed by a first pass that compared only selectors and sizes; it
+ fails only submissions too big for the one-buffer trap.
2. Pair the sites by caller symbol. Any change other than the shift above needs
a new rule.
3. For the driver, probe each paravirt method's accepted struct sizes against the
@@ -121,10 +125,23 @@ Open:
(`compilerTargetInfo.shaderVersionMajor >= 2`). That field comes from the
device-info reply, so that call was not translated there. It did not recur in
the next two boots and could not be started on demand. The cause is unknown.
-- cameracaptured aborts in `MPSLibrary::MPSKey_Compile` (`MTLReportFailure`)
- while prewarming its matting inference, three to five times in some boots and
- not at all in others. That is an MPS kernel compile failure under a working
- device. Not yet explained.
+- `com.apple.MapKit.SnapshotService` has not aborted again in the six boots since.
+
+cameracaptured (2026-11-05): it aborted in `MPSLibrary::MPSKey_Compile` three to
+five times in some boots while prewarming its matting inference. A temporary
+`MTLReportFailure` detour in a debug SystemHook recorded the messages: two
+command buffers "aborted due to an error during execution. Internal Error
+(00000001)", then "unable to load function mps_stgf_applyCoefficients3_2d.
+Compilation failed: (null)". The same functions load, specialize and build
+pipelines from a probe, so the compile failure followed the GPU errors. Logging
+failing device calls showed iOS 18 method 26 refused with 0xe00002c2, an 0x50-byte
+submission of two command buffers. Re-diffing every call site with its scalar
+counts, and then `cmdBufArgsSize` (0x28 on iOS 18, 0x30 on 26.1) and
+`fillCommandBufferArgs:commandQueue:` (the same stores in both), gave the submit
+row above. With the scalar output alone the kernel still refused the call; with
+the entries widened it accepts it. On the bundle built from this branch plus PR
+#822 without the debug code, cameracaptured kept its pid through a boot and a
+Camera launch, with no report.
Settings icons (2026-11-05): an icon probe got a non-placeholder, fully
transparent 87×87 image for `com.apple.graphic-icon.gear` at
diff --git a/VPhoneGuestComponents/SystemHook/VPhoneIOS18GPU.c b/VPhoneGuestComponents/SystemHook/VPhoneIOS18GPU.c
index 2c7735d6..b30414e9 100644
--- a/VPhoneGuestComponents/SystemHook/VPhoneIOS18GPU.c
+++ b/VPhoneGuestComponents/SystemHook/VPhoneIOS18GPU.c
@@ -119,6 +119,23 @@ static kern_return_t vpCallMethodHook(mach_port_t connection, uint32_t selector,
if (result == KERN_SUCCESS) *outputStructSize = legacySize;
return result;
}
+ if (selector == VP_IOS18_GPU_SUBMIT && input && inputCount == VP_IOS18_GPU_SUBMIT_SCALARS_IN && inputStruct &&
+ (!outputCount || *outputCount == 0)) {
+ uint64_t scalars[VP_IOS18_GPU_SUBMIT_SCALARS_IN], stamp[VP_IOS18_GPU_SUBMIT_SCALARS_OUT] = {0};
+ memcpy(scalars, input, sizeof(scalars));
+ size_t size = (size_t)scalars[2] * VP_IOS18_GPU_SUBMIT_ENTRY_MODERN;
+ uint8_t *entries = scalars[2] <= VP_IOS18_GPU_SUBMIT_MAX_ENTRIES ? malloc(size ? size : 1) : NULL;
+ if (!entries) return kIOReturnBadArgument;
+ kern_return_t result = kIOReturnBadArgument;
+ if (vpIOS18GPUSubmitEntries(entries, inputStruct, inputStructSize, scalars)) {
+ scalars[3] = VP_IOS18_GPU_SUBMIT_ENTRY_MODERN;
+ uint32_t count = VP_IOS18_GPU_SUBMIT_SCALARS_OUT;
+ result = vpCallMethod(connection, modern, scalars, inputCount, entries, size,
+ stamp, &count, outputStruct, outputStructSize);
+ }
+ free(entries);
+ return result;
+ }
if (selector == VP_IOS18_GPU_DEVICE_INFO && outputStruct && outputStructSize &&
*outputStructSize == VP_IOS18_GPU_DEVICE_INFO_LEGACY) {
uint8_t reply[VP_IOS18_GPU_DEVICE_INFO_MODERN] = {0};
diff --git a/VPhoneGuestComponents/SystemHook/VPhoneIOS18GPUTransport.c b/VPhoneGuestComponents/SystemHook/VPhoneIOS18GPUTransport.c
index 46815236..d98f35f5 100644
--- a/VPhoneGuestComponents/SystemHook/VPhoneIOS18GPUTransport.c
+++ b/VPhoneGuestComponents/SystemHook/VPhoneIOS18GPUTransport.c
@@ -22,3 +22,16 @@ void vpIOS18GPUDeviceInfoReply(uint8_t legacy[VP_IOS18_GPU_DEVICE_INFO_LEGACY],
memcpy(legacy, modern, 0xd8);
memcpy(legacy + 0xd8, modern + 0xdc, 0x34);
}
+
+bool vpIOS18GPUSubmitEntries(uint8_t *modern, const uint8_t *legacy, size_t legacySize,
+ const uint64_t scalars[VP_IOS18_GPU_SUBMIT_SCALARS_IN]) {
+ uint64_t count = scalars[2];
+ if (scalars[3] != VP_IOS18_GPU_SUBMIT_ENTRY || count == 0 || count > VP_IOS18_GPU_SUBMIT_MAX_ENTRIES ||
+ legacySize != count * VP_IOS18_GPU_SUBMIT_ENTRY)
+ return false;
+ memset(modern, 0, count * VP_IOS18_GPU_SUBMIT_ENTRY_MODERN);
+ for (uint64_t index = 0; index < count; index++)
+ memcpy(modern + index * VP_IOS18_GPU_SUBMIT_ENTRY_MODERN, legacy + index * VP_IOS18_GPU_SUBMIT_ENTRY,
+ VP_IOS18_GPU_SUBMIT_ENTRY);
+ return true;
+}
diff --git a/VPhoneGuestComponents/SystemHook/VPhoneIOS18GPUTransport.h b/VPhoneGuestComponents/SystemHook/VPhoneIOS18GPUTransport.h
index ba565055..ba6fc11e 100644
--- a/VPhoneGuestComponents/SystemHook/VPhoneIOS18GPUTransport.h
+++ b/VPhoneGuestComponents/SystemHook/VPhoneIOS18GPUTransport.h
@@ -31,6 +31,26 @@ enum {
};
bool vpIOS18GPUResourceReply(uint8_t *legacy, size_t legacySize, const uint8_t *modern, size_t modernSize);
+// iOS 18's command-buffer submit method (26, 25 on 26.1), used when the
+// submission does not fit the one-buffer trap: several command buffers at
+// once. Its scalars are the queue, flags, the entry count and the entry size,
+// and its struct the entries. 26.1 describes a command buffer in 0x30 bytes,
+// iOS 18 in 0x28 (`cmdBufArgsSize`); both fill the same fields and 26.1
+// leaves its last eight bytes zero. 26.1 also returns one scalar and refuses
+// a call that asks for none; iOS 18 asks for none.
+enum {
+ VP_IOS18_GPU_SUBMIT = 26,
+ VP_IOS18_GPU_SUBMIT_SCALARS_IN = 4,
+ VP_IOS18_GPU_SUBMIT_SCALARS_OUT = 1,
+ VP_IOS18_GPU_SUBMIT_ENTRY = 0x28,
+ VP_IOS18_GPU_SUBMIT_ENTRY_MODERN = 0x30,
+ VP_IOS18_GPU_SUBMIT_MAX_ENTRIES = 256,
+};
+// Widens `count` entries into `modern`, which holds count * 0x30 bytes.
+// False when the scalars and the struct do not describe iOS 18 entries.
+bool vpIOS18GPUSubmitEntries(uint8_t *modern, const uint8_t *legacy, size_t legacySize,
+ const uint64_t scalars[VP_IOS18_GPU_SUBMIT_SCALARS_IN]);
+
// AppleParavirtGPU's device-info method. Each of its two blocks gained fields
// at its end: 0xd8 -> 0xdc and 0x34 -> 0x3c.
enum {
diff --git a/VPhoneGuestComponents/Tests/IOS18GPUTransportTest.c b/VPhoneGuestComponents/Tests/IOS18GPUTransportTest.c
index 60365016..c34337e4 100644
--- a/VPhoneGuestComponents/Tests/IOS18GPUTransportTest.c
+++ b/VPhoneGuestComponents/Tests/IOS18GPUTransportTest.c
@@ -13,6 +13,7 @@ int main(void) {
// Command queue create, resource create and the last base method measured.
assert(vpIOS18GPUSelector(7, &modern) == VPIOS18GPURenumbered && modern == 6);
assert(vpIOS18GPUSelector(9, &modern) == VPIOS18GPURenumbered && modern == 8);
+ assert(vpIOS18GPUSelector(VP_IOS18_GPU_SUBMIT, &modern) == VPIOS18GPURenumbered && modern == 25);
assert(vpIOS18GPUSelector(0x37, &modern) == VPIOS18GPURenumbered && modern == 0x36);
assert(vpIOS18GPUSelector(255, &modern) == VPIOS18GPURenumbered && modern == 254);
for (uint32_t selector = 256; selector < 270; selector++) {
@@ -35,6 +36,27 @@ int main(void) {
for (size_t index = 0; index < 0xd8; index++) assert(legacy[index] == info[index]);
for (size_t index = 0; index < 0x34; index++) assert(legacy[0xd8 + index] == info[0xdc + index]);
+ // Two command buffers: each 0x28-byte entry moves to a 0x30 slot, tail zero.
+ uint8_t entries[2 * VP_IOS18_GPU_SUBMIT_ENTRY], widened[2 * VP_IOS18_GPU_SUBMIT_ENTRY_MODERN];
+ for (size_t index = 0; index < sizeof(entries); index++) entries[index] = (uint8_t)(index + 1);
+ memset(widened, 0xEE, sizeof(widened));
+ uint64_t scalars[VP_IOS18_GPU_SUBMIT_SCALARS_IN] = {0x1234, 0, 2, VP_IOS18_GPU_SUBMIT_ENTRY};
+ assert(vpIOS18GPUSubmitEntries(widened, entries, sizeof(entries), scalars));
+ for (size_t entry = 0; entry < 2; entry++) {
+ for (size_t byte = 0; byte < VP_IOS18_GPU_SUBMIT_ENTRY; byte++)
+ assert(widened[entry * 0x30 + byte] == entries[entry * 0x28 + byte]);
+ for (size_t byte = VP_IOS18_GPU_SUBMIT_ENTRY; byte < VP_IOS18_GPU_SUBMIT_ENTRY_MODERN; byte++)
+ assert(widened[entry * 0x30 + byte] == 0);
+ }
+ // Anything that is not count iOS 18 entries is refused, not guessed at.
+ assert(!vpIOS18GPUSubmitEntries(widened, entries, sizeof(entries) - 1, scalars));
+ scalars[3] = VP_IOS18_GPU_SUBMIT_ENTRY_MODERN;
+ assert(!vpIOS18GPUSubmitEntries(widened, entries, sizeof(entries), scalars));
+ scalars[3] = VP_IOS18_GPU_SUBMIT_ENTRY; scalars[2] = 0;
+ assert(!vpIOS18GPUSubmitEntries(widened, entries, 0, scalars));
+ scalars[2] = VP_IOS18_GPU_SUBMIT_MAX_ENTRIES + 1;
+ assert(!vpIOS18GPUSubmitEntries(widened, entries, sizeof(entries), scalars));
+
puts("IOS18GPUTransportTest: ok");
return 0;
}