Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Send every paravirtual GPU indexed draw with 64-bit offsets

Batchhh9b1684af6680
diff --git a/Research/0_binary_patch_comparison.md b/Research/0_binary_patch_comparison.md
index 9556cec3..ef17ad14 100644
--- a/Research/0_binary_patch_comparison.md
+++ b/Research/0_binary_patch_comparison.md
@@ -656,6 +656,7 @@ do NOT execute these).
| 25 | No binary change: `libvcamcaptured.dylib` stops every other thread in `cameracaptured` (`task_threads` + `thread_suspend`, self excluded, one patcher at a time) around each `vcc_patch_word` / `vcc_patch_two_nops` text rewrite — **all bases** | none (guest dylib `VPhoneGuestComponents/VCamCaptured/Image/VCamCodePatch.m`, installed at `/usr/lib/libvcamcaptured.dylib`) | **Stop the hook's own runtime patching from crashing `cameracaptured`, which froze the whole VM when the camera was opened.** The hook rewrites CMCapture shared-cache `__text` through `vm_protect(RW|COPY)` → write → `vm_protect(RX)`; for the whole flip the 16K page carries no execute permission, and the pages it touches (the `-12783` error-code sites, the master-clock gate, the prewarm call) are live XPC server code. Two crash reports caught a thread fetching an instruction in a page mid-flip while the patching thread was in `vcc_patch_word` on the same boot: `ipad-mini-01` `cameracaptured-2026-10-03-045638.ips` died in `__FigFlashlightGetClassID_block_invoke` on `com.apple.coremedia.flashlight(34)-messages`, and `ipad-pro-13` `cameracaptured-2026-10-04-225558.ips` died in `captureSourceServer_handleRegisterNotificationForProprietaryDefaultChangesMessage` on `com.apple.coremedia.capturesource(523)-messages` — the register-for-source-changes XPC that camera enumeration itself sends. Both are `EXC_BAD_ACCESS (SIGBUS)`, `KERN_PROTECTION_FAILURE` on an instruction fetch, in a region snapshotted `r-x/rwx`, `SM=COW` (the rwx max-protection is the flip's fingerprint). The card: with row 23 removing the boot crash, any later `cameracaptured` restart (jetsam, another crash) while a camera client reconnects sends its first XPCs straight into the +3 s reinstall window; one SIGBUS → launchd throttles → every AVCapture client, SpringBoard's main thread included, blocks forever in a synchronous XPC — the "VM 卡死" report of 2026-10-05. The stopped section is exactly two `vm_protect` calls, the word write and `sys_icache_invalidate`: no locks, no allocation, no logging, so a frozen thread holding any userspace lock cannot deadlock the patcher; every `vcc_log` moved after the resume, and a mutex serialises patchers (constructor prewarm patch vs the +3 s install block). All five runtime text-patching call sites (`vcc_scan_and_patch` ×2, the prewarm NOP, the session-hook pair, the source-installation NOPs) funnel through the two fixed functions. Validation: kill-and-relaunch stress with Camera.app auto-reconnecting (the same collision that produced both crashes) produces no new `cameracaptured` crash report, and the boot log's `patch_word OK` lines are unchanged. See `Research/Guest/virtual_camera_transport.md` ("The patch race that froze the whole VM"). | Y | Y | Y |
| 26 | No binary change: both spawn hooks insert `libdevicehubfix.dylib` into `cryptexd`, the DDI's `dtremotedisplayd` and `dtdeviceinfod`, and `avconferenced`. In `cryptexd` it interposes `fcntl` and reports an `EPERM` from `F_SETPROTECTIONCLASS` as `ENOTSUP`; in `dtremotedisplayd` it interposes `MediaStreamSupportedFeatures.current` (answers `0x8c`) and `CurrentDevice.isCustomerRestricted` (answers false) from the DDI's `CoreDeviceUtilities`; in `dtdeviceinfod` it interposes `MGCopyAnswer` and fills a missing `FramebufferIdentifier` for `phone11` chrome; in `avconferenced` it replaces `VCPSideCarMetal`'s two band reads through the Objective-C runtime and runs one synchronous scaler transform before the first read of each frame — **all bases** | none (new guest dylib `VPhoneGuestComponents/DeviceHubFix/libdevicehubfix.c`, installed at `/usr/lib/libdevicehubfix.dylib`) | **Let Xcode 27's DeviceHub show the guest's screen.** On iOS 27 `cryptexd` stages each DDI asset with `open(O_RDWR)` + `fcntl(F_SETPROTECTIONCLASS, 4)` and accepts only `ENOTSUP` as a failure; a guest answers `EPERM` (`set protection class: [1: Operation not permitted]`, `staging failed`), so CoreDevice shows the device as "connected (no DDI)" for good. With the DDI mounted, DeviceHub asks `dtremotedisplayd` for its media stream features and gets 0 from CoreDeviceUtilities' policy: `isCustomerRestricted` (`isProductionFused && !hasInternalOSBuild && hasInternalDDI == false`) refuses every pre-27.0 device, and remote control is limited to iPhone, Apple Watch and Apple TV, which refuses every iPad. `0x8c` is what a Mac host reports for itself (mirrored primary display 0x4, system audio 0x8, display information 0x80). The 27.x iPhone guest reports `phone11` chrome with no `FramebufferIdentifier`, so DeviceHub drew the screen over the bezel corners; the hook answers only that missing key with Xcode's matching mask `4E5532ED-1470-47D1-BDF4-7AA90C26957A` from `/Library/Developer/DeviceKit/chrome_map.plist`. Interposing reaches all of them because `cryptexd`, `dtremotedisplayd`, `dtdeviceinfod` and `CoreDeviceUtilities` are standalone images; the two Swift symbols are weak flat-namespace imports, resolving to nothing outside `dtremotedisplayd`. On 27.x the view also needs row 11's conditional dispatch, or the capture display stays black. A stream that splits each frame into four bands (`tilesPerFrame` 4) deadlocked the host GPU within 16–35 s of screen activity: `VCPSideCarMetal` reads every frame once per band while the paravirtual scaler's write of that frame can still be unregistered on the host, and a band read that registers the first of the frame's two planes before the write and the second after it waits on the write, which waits on it (`Timeout in timestamp wait`, the guest loses its GPU). Waiting for one synchronous transform puts the band reads behind the frame's write. `VideoProcessing` is in the shared cache, so this part is a method replacement, not an interpose. Ships with `system-launchdaemons-boot-environment`; an existing guest gets it from the environment update. Details: `Research/Guest/devicehub_screen_viewing.md`. **Validated (2026-10-06/07):** `iPad16,1 26.6.2 (23G90)`: DeviceHub receives `supportedFeatures: 140`, `MediaStreamStart` succeeds and the view shows the live home screen. `iPhone17,3 27.0.1 (24A446)`: the DDI mounts (`F_SETPROTECTIONCLASS EPERM, reported as ENOTSUP`), and with row 11's conditional dispatch DeviceHub shows the home screen and Settings live, clipped inside the chrome (`Found FramebufferMaskIdentifier from displayInfo`). **Band reads validated (2026-10-07/08, `iPhone17,3 27.0.1 (24A446)`):** a four-band stream with screen activity deadlocked after 18 s without the barrier and ran 60, 180 and 300 s with it without a GPU error; in the host trace of the 180 s run no IOSurface access waited, and every band read of 6258 frames registered after the frame's write was released, a median 0.76 ms after it. Open: latency that grows over a long session and occasional stalls after a cold start, both upstream of the Mac receiver. | Y | Y | Y |
| 27 | No binary change: both spawn hooks insert `libdevicename.dylib` into `configd` and `lockdownd` (after `libmisfix.dylib`, the first process to take two inserted libraries). In `configd` it interposes `SCDynamicStoreSetMultiple` and `SCDynamicStoreSetValue` and pins `Setup:/System`'s `ComputerName`; in `lockdownd` it interposes `SCPreferencesSetComputerName`, `SCPreferencesSetHostName` and `SCPreferencesSetLocalHostName` and refuses every rename with `kSCStatusAccessError`. Inert unless `/var/db/vphone/devicename.plist` holds a valid `DeviceName` — **all bases** | none (new guest dylib `VPhoneGuestComponents/DeviceName/libdevicename.c`, installed at `/usr/lib/libdevicename.dylib`; vphoned `device.name.get`/`device.name.set`) | **Pin the guest's device name to the VM's name.** The name is `System/System/ComputerName` in `preferences.plist`; configd's PreferencesMonitor (`updateConfiguration`, 24A435 `0x100062098`) flattens it into `Setup:/System` with one `SCDynamicStoreSetMultiple`, and every reader (`SCDynamicStoreCopyComputerName` in lockdownd's `copy_device_name`, MobileGestalt `UserAssignedDeviceName`, `UIDevice.name`) reads the store. The hook rewrites that publication, not the preferences read: the monitor's model-change path (`sub_10006155c`) writes the `kSCPrefSystem` value it reads back to disk, and the publication route leaves `preferences.plist` with the guest's own name. A publication that leaves `Setup:/System` out as unchanged gets the store's value pinned; one that removes it gets the pinned name instead. `vphone-vm` sends the VM's name to vphoned's `device.name.set` after every connect; vphoned writes the file (one rename, 0644) and applies the preferences unchanged, so configd publishes again and the new pin, or the guest's own name when the file is removed, is live within a second. The file outlives a reboot, so configd's first publication at boot carries it. The library re-reads the file when its inode, size or mtime change. lockdownd's `set_device_name` (`0x1000073b0`) is the only caller of the three setters; it logs their failure and still commits, and the `SetValue DeviceName` handler ignores the result, so a host rename reports success and the name stays. The pinned name itself is refused too: lockdownd runs `set_device_name(copy_device_name())` whenever it starts, and a lockdownd restarted after configd published would otherwise write the pinned name and derived host names into `preferences.plist` (seen once). An NVRAM variable was the first channel and never reached the guest: iBoot keeps only the variables it knows (even `vphone-vm`'s `boot-args` write is replaced). Interposing works because both daemons are standalone images. Ships with `system-launchdaemons-boot-environment` and the environment update; takes effect at the next boot. Verified on iOS 27.0 (24A435) on 2026-10-07: pin at boot and live, host rename refused, `vm rename` followed, preferences untouched. CoreDevice (`devicectl`, DeviceHub) reads the name when the device appears and can lag one boot after a rename. Details: `Research/Guest/device_name_pinning.md`. | Y | Y | Y |
+| 28 | `cbz`/`cbnz` -> `b` at the four compact-command choices in `-[PGSerializerRenderCommandEncoder drawIndexedPrimitives:…]` (`0x140b0`, `0x1421c`, `0x143b4`, `0x143c4` in 23E5207q) — **cloudOS 26.4** | `AppleParavirtGPUMetalIOGPUFamily` (`/System/Library/Extensions/AppleParavirtGPUMetalIOGPUFamily.bundle`) | **Heap index buffer fix.** The compact command stores `parentResourceOffset + indexBufferOffset` in 16 bits but is chosen by testing `indexBufferOffset` alone, so an index buffer 64 KiB or more into an `MTLHeap` is read from the wrong address and meshes (Unity games) draw with another mesh's indices. Every indexed draw takes the 64-bit command instead. `system-paravirt_gpu-cfw-heap_index_offset`; see "Heap index buffers reach the host whole (2026-10-14)" and `Research/Guest/gpu_acceleration.md` | Y | Y | Y |
### Swift port status — the eight DSC patchers (2026-09-23)
@@ -2983,3 +2984,49 @@ keep 60 Hz until `cfw update-kernel` or a restore writes it.
**Opting out.** `vphone-cli fw set-patches <vm> --block
kernel-cfw-display_promotion`, then `cfw update-kernel`.
+
+## Heap index buffers reach the host whole (2026-10-14)
+
+New guest patch **`system-paravirt_gpu-cfw-heap_index_offset`**, on in
+`standard`, gated to cloudOS 26.4: four words in the paravirtual GPU driver.
+
+**Symptom.** Unity games (Wing Fighter on iOS 27.0.1, Subway Surfers on iPadOS
+26.6.2) drew meshes with the right vertices and the wrong triangles. A probe
+from a launchd job showed every plain-buffer path correct and every index
+buffer sub-allocated 64 KiB or more into an `MTLHeap` wrong, unless the draw's
+own `indexBufferOffset` forced the 64-bit command.
+
+**Cause.** `-[PGSerializerRenderCommandEncoder drawIndexedPrimitives:…]` picks
+a compact command with 16-bit fields when the draw's arguments fit in 16 bits,
+then stores `[indexBuffer parentResourceOffset] + indexBufferOffset` in one of
+those fields (`strh`). The heap offset is never part of the test, so it wraps.
+
+**Patch.** The selecting `cbz`/`cbnz` in each of the three methods (two in the
+`baseVertex:baseInstance:` one) becomes a `b` to the full command:
+
+| Offset (23E5207q) | Before | After |
+| --- | --- | --- |
+| `0x140b0` | `dc0000b5` `cbnz x28, +0x18` | `06000014` `b +0x18` |
+| `0x1421c` | `db0000b5` `cbnz x27, +0x18` | `06000014` `b +0x18` |
+| `0x143b4` | `540100b5` `cbnz x20, +0x28` | `0a000014` `b +0x28` |
+| `0x143c4` | `78010034` `cbz w24, +0x2c` | `0b000014` `b +0x2c` |
+
+The sites are found by content, not offset: the compact command's `mov w2,
+#size ; mov w3, #command` pair is unique in `__text`, the word before it must
+be the `cbz`/`cbnz`, and its target must hold the full command's pair. The
+patched 23E5207q driver hashes to
+`5c172ab9ff049e7107ea9e4bd276c6b024f6b31e4556f9a847e5be5e6692cf2d` before
+signing (pristine `29ba36c7…aedbc`); `CustomFirmwareParavirtGPUIndexOffsetTests`
+checks it against `VPHONE_MACHO_PRISTINE`.
+
+**Where.** `cfw install`, right after the GPU bundle step, through the
+`patch-paravirt-gpu-index-offset` verb, from a `.bak` beside the driver, then
+`codesign` over the bundle as for `VirtualAudio.plugin`. Off restores the `.bak`.
+A bundle the same run reinstalled from the restore tree is already pristine, so
+off then needs nothing and the receipt does not keep the patch live. An existing
+VM gets it from its next `cfw install`; `cfw update-environment` runs no patches.
+
+**Not covered.** `drawPatches:…`, `drawIndexedPatches:…` and
+`-[PGSerializerBlitCommandEncoder copyFromTexture:…toBuffer:…]` store
+`parentResourceOffset` in 16 bits too. They were not measured and are left as
+they are.
diff --git a/Research/Guest/gpu_acceleration.md b/Research/Guest/gpu_acceleration.md
index 8f8e9f19..05851793 100644
--- a/Research/Guest/gpu_acceleration.md
+++ b/Research/Guest/gpu_acceleration.md
@@ -331,6 +331,88 @@ On a guest, check these:
This does not fix the driver. NRF or RawDF processing during a real capture,
or any other heap texture upload, would still fault.
+## Heap Index Buffers
+
+Unity games drew their meshes scrambled: the right vertices joined into the
+wrong triangles, so scenes broke into spikes and stretched faces, and a
+full-screen quad came out as one triangle. Textures were correct. Seen on
+2026-10-14 in Wing Fighter on iPhone17,3 iOS 27.0.1 and in Subway Surfers on
+an iPad16,1 iPadOS 26.6.2 guest, both on the cloudOS 26.4 (23E5207q) driver,
+bundle 2.9.4, host macOS 27.0.1 on an M4. It is not the userland version: both
+bases showed it.
+
+### Measured
+
+A probe run from a launchd job draws a quad that should cover a 64×64 target
+and counts the lit pixels. Every path through plain buffers covered 100%:
+indexed and non-indexed draws, 16- and 32-bit indices, `indexBufferOffset`
+from 0 to 128 and unaligned, `baseVertex`, instancing, `stage_in` layouts with
+strides 12 to 44 and attribute offsets, half, short-normalised and
+uchar-normalised formats, several streams, per-instance step functions,
+`setVertexBytes`, shared buffers rewritten between frames, a 4 MiB
+write-combined ring, blit uploads into private buffers, a 64 MiB buffer read
+16 and 64 MiB in, and `newBufferWithBytesNoCopy`.
+
+Buffers carved from an `MTLHeap` split by role. A shared heap of 8 MiB, its
+first buffer filled with decoys, then six 64 KiB buffers each holding the
+quad's vertices at 0 and its indices at 1024:
+
+```
+heap buf#1..#6 vb only (plain ib) cover 100.0% OK
+heap buf#1..#6 ib only (plain vb) cover 0.0% BAD
+heap ib, indexBufferOffset 70000 (64-bit cmd) cover 100.0% OK
+heap ib, indexBufferOffset 1000 (16-bit cmd) cover 0.0% BAD
+heap ib instanceCount:1 variant cover 0.0% BAD
+heap ib baseVertex variant cover 0.0% BAD
+```
+
+Vertex buffers from a heap work at any offset; index buffers from a heap fail,
+unless the draw's own `indexBufferOffset` is large. Compute kernels read and
+write heap buffers correctly, so the memory is right and the draw is wrong. One
+more symptom points the same way: every heap buffer reports `heapOffset` 0.
+
+### Why
+
+`-[PGSerializerRenderCommandEncoder drawIndexedPrimitives:…]` has two
+encodings per method: a compact command with 16-bit fields and a full one with
+64-bit fields. In the 23E5207q driver:
+
+| Method | Compact / full command | Choice | Truncating store |
+| --- | --- | --- | --- |
+| `…indexBufferOffset:` | 0x7 / 0x6 | `0x1421c cbnz x27` | `0x14284 strh w8, [x25, #0xa]` |
+| `…indexBufferOffset:instanceCount:` | 0x9 / 0x8 | `0x140b0 cbnz x28` | `0x14120 strh w8, [x26, #0xa]` |
+| `…instanceCount:baseVertex:baseInstance:` | 0x1d / 0x1c and 0xb / 0xa | `0x143b4 cbnz x20`, `0x143c4 cbz w24` | `0x14450 strh w8, [x26, #0x8]` |
+
+The choice tests only the draw's own arguments: `indexCount`,
+`indexBufferOffset` and, where the method has them, the instance and base
+values must each fit in 16 bits. The stored value is `[indexBuffer parentResourceOffset]
++ indexBufferOffset`, and `parentResourceOffset` is a sub-allocated buffer's
+offset in its heap, which the test never sees. An index buffer 64 KiB or more
+into a heap is read from `(heapOffset + indexBufferOffset) mod 65536`: another
+mesh's indices, which reference vertices that exist, so nothing faults. Vertex
+bindings go through `setBuffers:offsets:…` with 64-bit offsets, and the
+indirect `drawIndexedPrimitives:indexType:indexBuffer:indexBufferOffset:indirectBuffer:…`
+has only a 64-bit form.
+
+Two more methods store `parentResourceOffset` in 16 bits and are not patched:
+`drawPatches:…:patchIndexBuffer:…` and `drawIndexedPatches:…` (tessellation),
+and `-[PGSerializerBlitCommandEncoder copyFromTexture:…toBuffer:…]` at
+`0x230e0`. Mobile games rarely tessellate; the blit was not measured.
+
+### The patch
+
+`system-paravirt_gpu-cfw-heap_index_offset` turns each selecting branch into an
+unconditional `b` to the full command, which the driver already sends whenever
+a value does not fit, so the host accepts it. Each site is found by the
+compact command's `mov w2, #size ; mov w3, #command` pair, unique in `__text`,
+and the branch must lead to the full command's own pair; a driver laid out
+otherwise is refused unchanged (`CustomFirmwareParavirtGPUIndexOffset`). The
+cost is 12 to 28 bytes more per indexed draw.
+
+Verified on the iPad guest with the patched driver in place: every heap row
+above covers 100%, the plain-buffer probe is unchanged, and Subway Surfers
+draws its menu scene and gameplay correctly.
+
## Settings That Do Nothing Here
Both are private properties of `VZMacGraphicsDeviceConfiguration`, tried on
diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CustomFirmware/ExecutablePatches/ParavirtGPU/CustomFirmwareParavirtGPUIndexOffset.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CustomFirmware/ExecutablePatches/ParavirtGPU/CustomFirmwareParavirtGPUIndexOffset.swift
new file mode 100644
index 00000000..7d46779a
--- /dev/null
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CustomFirmware/ExecutablePatches/ParavirtGPU/CustomFirmwareParavirtGPUIndexOffset.swift
@@ -0,0 +1,239 @@
+// CustomFirmwareParavirtGPUIndexOffset.swift — send every indexed draw with 64-bit offsets.
+//
+// What the driver does. `AppleParavirtGPUMetalIOGPUFamily`, the guest Metal
+// driver `fw prepare` copies out of the cloudOS image, serialises each draw for
+// the host's ParavirtualizedGraphics task. Every direct
+// `-[PGSerializerRenderCommandEncoder drawIndexedPrimitives:…]` has two
+// encodings: a compact command whose fields are 16 bits wide and a full one with
+// 64-bit fields. It takes the compact one when
+//
+// (indexCount | indexBufferOffset | instanceCount | baseVertex | baseInstance) >> 16 == 0
+//
+// and then writes `[indexBuffer parentResourceOffset] + indexBufferOffset`
+// into a 16-bit field:
+//
+// bl objc_msgSend$parentResourceOffset
+// add w8, w0, w22
+// strh w8, [x26, #0xa] <- truncates
+//
+// `parentResourceOffset` is a buffer's offset inside the `MTLHeap` it was
+// carved from, and the size test never looked at it. An index buffer 64 KiB or
+// more into a heap is therefore read from `(heapOffset + indexBufferOffset) mod
+// 65536`: another mesh's indices. Unity keeps mesh index buffers in heaps, so
+// its games draw every such mesh with the right vertices and the wrong
+// triangles — spikes, stretched faces, a full-screen quad drawn as one
+// triangle. Vertex buffers are bound through 64-bit offsets and are not
+// affected; neither is the indirect variant, which only has a 64-bit form.
+// `Research/Guest/gpu_acceleration.md` ("Heap Index Buffers") has the
+// measurements.
+//
+// The patch. The branch that picks the compact command becomes an
+// unconditional `b` to the full command, in each of the three methods (the
+// `baseVertex:baseInstance:` one has two such branches, one per host feature
+// path). The full commands are the ones the driver already sends whenever a
+// value does not fit in 16 bits, so the host accepts them; the cost is 12 to 28
+// bytes more per indexed draw in the command stream.
+//
+// Finding the sites. Each compact command is set up as
+//
+// cbz/cbnz <reg>, <full> ; mov w2, #<size> ; mov w3, #<command> ; …
+//
+// and the `mov w2`/`mov w3` pair is unique in `__TEXT,__text`: it names the
+// command. The word before the pair must be the selecting `cbz`/`cbnz`, and its
+// target must begin with the full command's own `mov w2`/`mov w3` pair. Nothing
+// is written unless every site resolves that way. A site whose word is already a
+// `b` to that target is this patch's own output and is left alone, so a re-run
+// writes nothing.
+//
+// The command numbers come from the cloudOS 26.4 (23E5207q) driver, the only
+// cloudOS release that carries the `vphone600ap` identity a guest boots from
+// (`Documents/Guides/compatibility.md`). A driver laid out differently fails to
+// resolve and is refused unchanged.
+
+import Foundation
+import VPhonePatchKit
+
+public enum CustomFirmwareParavirtGPUIndexOffset {
+ public static let stdoutLog: @Sendable (String) -> Void = { print($0) }
+
+ /// One compact-command selection: the command it avoids and the one it
+ /// takes instead. Sizes are the bytes `getCommandBytes:forCommand:` reserves.
+ public struct Site: Sendable, Equatable {
+ public let method: String
+ public let compactSize: UInt32
+ public let compactCommand: UInt32
+ public let fullSize: UInt32
+ public let fullCommand: UInt32
+ }
+
+ public static let sites: [Site] = [
+ Site(method: "drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:",
+ compactSize: 0x0C, compactCommand: 0x07, fullSize: 0x18, fullCommand: 0x06),
+ Site(method: "drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:",
+ compactSize: 0x10, compactCommand: 0x09, fullSize: 0x20, fullCommand: 0x08),
+ Site(method: "drawIndexedPrimitives:…:instanceCount:baseVertex:baseInstance: (correct base vertex)",
+ compactSize: 0x14, compactCommand: 0x1D, fullSize: 0x30, fullCommand: 0x1C),
+ Site(method: "drawIndexedPrimitives:…:instanceCount:baseVertex:baseInstance:",
+ compactSize: 0x14, compactCommand: 0x0B, fullSize: 0x30, fullCommand: 0x0A),
+ ]
+
+ public enum SiteState: Sendable, Equatable {
+ case patched
+ case alreadyPatched
+ }
+
+ public struct ResolvedSite: Sendable, Equatable {
+ public let site: Site
+ /// File offset of the selecting branch.
+ public let fileOffset: Int
+ /// File offset of the full command's setup, the branch target.
+ public let targetFileOffset: Int
+ public let state: SiteState
+ }
+
+ public struct Report: Sendable, Equatable {
+ public let sites: [ResolvedSite]
+ public var sitesWritten: Int {
+ sites.count(where: { $0.state == .patched })
+ }
+ }
+
+ /// Patch the driver binary at `url` in place. The file is rewritten only
+ /// when a site changes.
+ @discardableResult
+ public static func patch(
+ fileAt url: URL,
+ log: ((String) -> Void)? = stdoutLog,
+ ) throws -> Report {
+ guard FileManager.default.fileExists(atPath: url.path) else {
+ throw PatcherError.fileNotFound(url.path)
+ }
+ var data = try Data(contentsOfFileToRewrite: url)
+ let report = try patch(&data, log: log)
+ if report.sitesWritten > 0 {
+ try data.write(to: url)
+ }
+ return report
+ }
+
+ /// In-memory form. `data` is left untouched unless every site resolves.
+ @discardableResult
+ public static func patch(
+ _ data: inout Data,
+ log: ((String) -> Void)? = stdoutLog,
+ ) throws -> Report {
+ if data.startIndex != 0 {
+ data = Data(data)
+ }
+ let resolved = try resolve(in: data)
+ for item in resolved {
+ switch item.state {
+ case .patched:
+ guard let branch = ARM64Encoder.encodeB(from: item.fileOffset, to: item.targetFileOffset) else {
+ throw PatcherError.patchVerificationFailed(
+ "\(item.site.method) — cannot encode b from 0x\(hex(item.fileOffset)) to 0x\(hex(item.targetFileOffset))",
+ )
+ }
+ data.replaceSubrange(item.fileOffset ..< item.fileOffset + 4, with: branch)
+ log?(" [+] 0x\(hex(item.fileOffset)): \(item.site.method) — compact command 0x\(hex(item.site.compactCommand)) -> b to full command 0x\(hex(item.site.fullCommand))")
+ case .alreadyPatched:
+ log?(" [·] 0x\(hex(item.fileOffset)): \(item.site.method) — already sends the full command")
+ }
+ }
+ return Report(sites: resolved)
+ }
+
+ /// Resolve every site, or throw without having changed anything.
+ public static func resolve(in data: Data) throws -> [ResolvedSite] {
+ let sections = MachOParser.parseSections(from: data)
+ guard let text = sections["__TEXT,__text"] else {
+ throw PatcherError.invalidFormat("not a 64-bit Mach-O with a __TEXT,__text section")
+ }
+ let start = Int(text.fileOffset)
+ let end = start + Int(text.size)
+ guard start >= 0, end <= data.count, start < end else {
+ throw PatcherError.invalidFormat("__TEXT,__text lies outside the file")
+ }
+ return try sites.map { try resolve($0, in: data, text: start ..< end) }
+ }
+
+ static func resolve(_ site: Site, in data: Data, text: Range<Int>) throws -> ResolvedSite {
+ let setups = offsets(of: setup(size: site.compactSize, command: site.compactCommand), in: data, range: text)
+ guard setups.count == 1, let setupOffset = setups.first else {
+ throw PatcherError.patchSiteNotFound(
+ "\(site.method) — expected one compact command 0x\(hex(site.compactCommand)) setup in __text, found \(setups.count); this is not the cloudOS 26.4 (23E5207q) driver",
+ )
+ }
+ let branchOffset = setupOffset - 4
+ guard branchOffset >= text.lowerBound else {
+ throw PatcherError.patchSiteNotFound("\(site.method) — compact command setup starts __text")
+ }
+ let word = data.loadLE(UInt32.self, at: branchOffset)
+ let state: SiteState
+ let displacement: Int
+ if let compareBranch = compareBranchDisplacement(word) {
+ state = .patched
+ displacement = compareBranch
+ } else if let branch = branchDisplacement(word) {
+ state = .alreadyPatched
+ displacement = branch
+ } else {
+ throw PatcherError.patchSiteNotFound(
+ "\(site.method) — 0x\(hex(branchOffset)) holds 0x\(hex(word)), not the cbz/cbnz that picks the compact command",
+ )
+ }
+ let target = branchOffset + displacement
+ let full = setup(size: site.fullSize, command: site.fullCommand)
+ guard text.contains(target), target + full.count <= text.upperBound,
+ data[target ..< target + full.count] == full
+ else {
+ throw PatcherError.patchVerificationFailed(
+ "\(site.method) — the branch at 0x\(hex(branchOffset)) does not lead to the full command 0x\(hex(site.fullCommand))",
+ )
+ }
+ return ResolvedSite(site: site, fileOffset: branchOffset, targetFileOffset: target, state: state)
+ }
+
+ // MARK: - Encoding
+
+ /// `mov w2, #size ; mov w3, #command` — the arguments of
+ /// `getCommandBytes:forCommand:`.
+ static func setup(size: UInt32, command: UInt32) -> Data {
+ movz(register: 2, immediate: size) + movz(register: 3, immediate: command)
+ }
+
+ static func movz(register: UInt32, immediate: UInt32) -> Data {
+ ARM64.encodeU32(0x5280_0000 | (immediate & 0xFFFF) << 5 | register)
+ }
+
+ /// The byte displacement of a `cbz`/`cbnz` (32- or 64-bit), or nil.
+ static func compareBranchDisplacement(_ word: UInt32) -> Int? {
+ guard word & 0x7E00_0000 == 0x3400_0000 else { return nil }
+ let imm19 = Int32(bitPattern: (word >> 5 & 0x7FFFF) << 13) >> 13
+ return Int(imm19) * 4
+ }
+
+ /// The byte displacement of an unconditional `b`, or nil.
+ static func branchDisplacement(_ word: UInt32) -> Int? {
+ guard word & 0xFC00_0000 == 0x1400_0000 else { return nil }
+ let imm26 = Int32(bitPattern: (word & 0x03FF_FFFF) << 6) >> 6
+ return Int(imm26) * 4
+ }
+
+ /// Every 4-byte-aligned offset in `range` where `needle` starts.
+ static func offsets(of needle: Data, in data: Data, range: Range<Int>) -> [Int] {
+ var hits: [Int] = []
+ var offset = range.lowerBound
+ while offset + needle.count <= range.upperBound {
+ if data[offset ..< offset + needle.count] == needle {
+ hits.append(offset)
+ }
+ offset += 4
+ }
+ return hits
+ }
+
+ static func hex(_ value: some BinaryInteger) -> String {
+ String(value, radix: 16)
+ }
+}
diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareGuestSystemPatchSet.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareGuestSystemPatchSet.swift
index 14befecd..2b73497c 100644
--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareGuestSystemPatchSet.swift
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareGuestSystemPatchSet.swift
@@ -24,6 +24,10 @@ public enum FirmwareGuestSystemPatchSet {
public static let gyroscope = "system-backboardd-cfw-gyroscope"
public static let attitude = "system-apps-cfw-attitude"
+ public static let paravirtGPUIndexOffset = "system-paravirt_gpu-cfw-heap_index_offset"
+ public static let paravirtGPUDriverPath =
+ "System/Library/Extensions/AppleParavirtGPUMetalIOGPUFamily.bundle/AppleParavirtGPUMetalIOGPUFamily"
+
public static let locationdCohorting = "system-locationd-cfw-disable_auto_cohort"
public static let jetsamDisableAllowed = "system-jetsamproperties-cfw-disable_allowed"
@@ -210,6 +214,18 @@ public enum FirmwareGuestSystemPatchSet {
target: .guestFile(path: "/System/Library/Extensions"),
bootEssential: true,
),
+ VPhonePatchDeclaration(
+ identifier: paravirtGPUIndexOffset,
+ title: "GPU heap index buffers",
+ summary: """
+ Makes the paravirtual GPU driver send every indexed draw with 64-bit offsets. Its \
+ compact command keeps an index buffer's heap offset in 16 bits, so meshes whose \
+ indices sit 64 KiB or more into an MTLHeap (Unity games) draw with another \
+ mesh's indices.
+ """,
+ target: .guestExecutable(path: "/\(paravirtGPUDriverPath)"),
+ applicability: VPhonePatchApplicability(cloudOS: .release(major: 26, minor: 4)),
+ ),
VPhonePatchDeclaration(
identifier: "system-vphoned-boot-install",
title: "vphoned",
diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/CustomFirmware/CustomFirmwareParavirtGPUIndexOffsetTests.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/CustomFirmware/CustomFirmwareParavirtGPUIndexOffsetTests.swift
new file mode 100644
index 00000000..cb481f77
--- /dev/null
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/CustomFirmware/CustomFirmwareParavirtGPUIndexOffsetTests.swift
@@ -0,0 +1,192 @@
+// CustomFirmwareParavirtGPUIndexOffsetTests.swift — the GPU driver's indexed-draw command choice.
+//
+// Two halves. A synthetic Mach-O carries the four selecting branches and both
+// commands' setups, so resolution, the written words, idempotence and every
+// refusal are checked anywhere. The real cloudOS 26.4 (23E5207q) driver is the
+// reference for the bytes: patched, it must hash to what was installed and
+// verified in a guest (heap index buffers at every offset draw correctly).
+//
+// The real driver is required. Point `VPHONE_MACHO_PRISTINE` at a directory
+// holding `AppleParavirtGPUMetalIOGPUFamily` (from `~/.vphone/gpu-drivers/
+// 26.4_23E5207q/`), or put it in `ipsws/ref_extract/macho_pristine/`. Without
+// it the real-driver test FAILS unless `VPHONE_MACHO_FIXTURE_OPTIONAL=1`.
+
+import CryptoKit
+@testable import FirmwarePatcher
+import Foundation
+import Testing
+import VPhonePatchKit
+
+private typealias Patcher = CustomFirmwareParavirtGPUIndexOffset
+
+// MARK: - Fixtures
+
+private enum GPUDriverFixture {
+ static let repoRoot = URL(fileURLWithPath: #filePath)
+ .deletingLastPathComponent()
+ .deletingLastPathComponent()
+ .deletingLastPathComponent()
+ .deletingLastPathComponent()
+ .deletingLastPathComponent()
+
+ static let pristineSHA256 = "29ba36c7bc87d82c40fa1cecdf357e7a383fa70eb46df0d75869f5ac562aedbc"
+ static let patchedSHA256 = "5c172ab9ff049e7107ea9e4bd276c6b024f6b31e4556f9a847e5be5e6692cf2d"
+
+ static var pristine: URL? {
+ let directory = ProcessInfo.processInfo.environment["VPHONE_MACHO_PRISTINE"]
+ .map { URL(fileURLWithPath: $0) }
+ ?? repoRoot.appendingPathComponent("ipsws/ref_extract/macho_pristine")
+ let binary = directory.appendingPathComponent("AppleParavirtGPUMetalIOGPUFamily")
+ return FileManager.default.fileExists(atPath: binary.path) ? binary : nil
+ }
+
+ static var runs: Bool {
+ pristine != nil || ProcessInfo.processInfo.environment["VPHONE_MACHO_FIXTURE_OPTIONAL"] != "1"
+ }
+
+ static let missing: Comment = """
+ the cloudOS 26.4 (23E5207q) AppleParavirtGPUMetalIOGPUFamily is required — put it at \
+ ipsws/ref_extract/macho_pristine/, point VPHONE_MACHO_PRISTINE at its directory, or set \
+ VPHONE_MACHO_FIXTURE_OPTIONAL=1 to skip
+ """
+
+ static func sha256(_ data: Data) -> String {
+ SHA256.hash(data: data).map { String(format: "%02x", $0) }.joined()
+ }
+}
+
+/// A one-section Mach-O: the header, one `LC_SEGMENT_64` holding
+/// `__TEXT,__text`, and the code at ``textOffset``.
+private struct SyntheticDriver {
+ static let textOffset = 0x100
+ static let textSize = 0x400
+ /// Each site gets its own 0x80-byte slot; the full command sits 0x40 in.
+ static let slot = 0x80
+ static let fullCommandDistance = 0x40
+
+ var data: Data
+
+ init(sites: [Patcher.Site] = Patcher.sites) {
+ var file = Data(count: Self.textOffset + Self.textSize)
+ func put(_ value: UInt32, at offset: Int) {
+ file.replaceSubrange(offset ..< offset + 4, with: ARM64.encodeU32(value))
+ }
+ func put64(_ value: UInt64, at offset: Int) {
+ put(UInt32(truncatingIfNeeded: value), at: offset)
+ put(UInt32(truncatingIfNeeded: value >> 32), at: offset + 4)
+ }
+ func putName(_ name: String, at offset: Int) {
+ file.replaceSubrange(offset ..< offset + name.utf8.count, with: Data(name.utf8))
+ }
+ put(0xFEED_FACF, at: 0) // MH_MAGIC_64
+ put(0x0100_000C, at: 4) // CPU_TYPE_ARM64
+ put(1, at: 16) // ncmds
+ put(72 + 80, at: 20) // sizeofcmds
+ let segment = 32
+ put(0x19, at: segment) // LC_SEGMENT_64
+ put(72 + 80, at: segment + 4)
+ putName("__TEXT", at: segment + 8)
+ put64(UInt64(Self.textOffset + Self.textSize), at: segment + 32) // vmsize
+ put64(UInt64(Self.textOffset + Self.textSize), at: segment + 48) // filesize
+ put(1, at: segment + 64) // nsects
+ let section = segment + 72
+ putName("__text", at: section)
+ putName("__TEXT", at: section + 16)
+ put64(UInt64(Self.textOffset), at: section + 32) // addr
+ put64(UInt64(Self.textSize), at: section + 40) // size
+ put(UInt32(Self.textOffset), at: section + 48) // offset
+
+ for (index, site) in sites.enumerated() {
+ let branch = Self.branchOffset(index)
+ // cbnz x28 / cbz w24, alternating, to the full command.
+ let imm19 = UInt32(Self.fullCommandDistance / 4) << 5
+ put(index % 2 == 0 ? 0xB500_0000 | imm19 | 28 : 0x3400_0000 | imm19 | 24, at: branch)
+ file.replaceSubrange(branch + 4 ..< branch + 12,
+ with: Patcher.setup(size: site.compactSize, command: site.compactCommand))
+ let full = branch + Self.fullCommandDistance
+ file.replaceSubrange(full ..< full + 8,
+ with: Patcher.setup(size: site.fullSize, command: site.fullCommand))
+ }
+ data = file
+ }
+
+ static func branchOffset(_ index: Int) -> Int {
+ textOffset + index * slot
+ }
+
+ func word(at offset: Int) -> UInt32 {
+ data.loadLE(UInt32.self, at: offset)
+ }
+}
+
+// MARK: - Synthetic
+
+struct CustomFirmwareParavirtGPUIndexOffsetTests {
+ @Test func `Every selecting branch becomes a b to the full command`() throws {
+ var driver = SyntheticDriver()
+ let report = try Patcher.patch(&driver.data, log: nil)
+ #expect(report.sitesWritten == Patcher.sites.count)
+ for index in Patcher.sites.indices {
+ let branch = SyntheticDriver.branchOffset(index)
+ let expected = ARM64Encoder.encodeB(from: branch, to: branch + SyntheticDriver.fullCommandDistance)
+ #expect(driver.data[branch ..< branch + 4] == expected)
+ }
+ }
+
+ @Test func `A second run recognises its own output and writes nothing`() throws {
+ var driver = SyntheticDriver()
+ try Patcher.patch(&driver.data, log: nil)
+ let once = driver.data
+ let report = try Patcher.patch(&driver.data, log: nil)
+ #expect(report.sitesWritten == 0)
+ #expect(report.sites.allSatisfy { $0.state == .alreadyPatched })
+ #expect(driver.data == once)
+ }
+
+ @Test func `A missing compact command refuses and changes nothing`() throws {
+ var driver = SyntheticDriver(sites: Array(Patcher.sites.dropLast()))
+ let before = driver.data
+ #expect(throws: PatcherError.self) { try Patcher.patch(&driver.data, log: nil) }
+ #expect(driver.data == before)
+ }
+
+ @Test func `A branch that does not reach the full command refuses`() throws {
+ var driver = SyntheticDriver()
+ let full = SyntheticDriver.branchOffset(2) + SyntheticDriver.fullCommandDistance
+ driver.data.replaceSubrange(full ..< full + 4, with: ARM64.encodeU32(0xD503_201F)) // nop
+ let before = driver.data
+ #expect(throws: PatcherError.self) { try Patcher.patch(&driver.data, log: nil) }
+ #expect(driver.data == before)
+ }
+
+ @Test func `A site that is neither cbz/cbnz nor b refuses`() throws {
+ var driver = SyntheticDriver()
+ let branch = SyntheticDriver.branchOffset(1)
+ driver.data.replaceSubrange(branch ..< branch + 4, with: ARM64.encodeU32(0xD503_201F)) // nop
+ #expect(throws: PatcherError.self) { try Patcher.patch(&driver.data, log: nil) }
+ }
+
+ @Test func `Branch decoding round-trips both directions`() {
+ #expect(Patcher.compareBranchDisplacement(0xB500_00DC) == 0x18) // cbnz x28, +0x18
+ #expect(Patcher.compareBranchDisplacement(0x3400_0178) == 0x2C) // cbz w24, +0x2c
+ #expect(Patcher.compareBranchDisplacement(0xB5FF_FFE0) == -4) // cbnz x0, -4
+ #expect(Patcher.branchDisplacement(0x1400_000A) == 0x28)
+ #expect(Patcher.branchDisplacement(0x17FF_FFFF) == -4)
+ #expect(Patcher.compareBranchDisplacement(0x1400_000A) == nil)
+ #expect(Patcher.branchDisplacement(0xB500_00DC) == nil)
+ }
+
+ // MARK: - Real driver
+
+ @Test(.enabled(if: GPUDriverFixture.runs))
+ func `The 23E5207q driver patches to the verified bytes`() throws {
+ let url = try #require(GPUDriverFixture.pristine, GPUDriverFixture.missing)
+ var data = try Data(contentsOf: url)
+ #expect(GPUDriverFixture.sha256(data) == GPUDriverFixture.pristineSHA256)
+ let report = try Patcher.patch(&data, log: nil)
+ #expect(report.sites.map(\.fileOffset) == [0x1421C, 0x140B0, 0x143B4, 0x143C4])
+ #expect(report.sites.map(\.targetFileOffset) == [0x14234, 0x140C8, 0x143DC, 0x143F0])
+ #expect(GPUDriverFixture.sha256(data) == GPUDriverFixture.patchedSHA256)
+ #expect(try Patcher.patch(&data, log: nil).sitesWritten == 0)
+ }
+}
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
index 4067c854..4cf587d1 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
@@ -1300,10 +1300,12 @@ struct VPhoneCustomFirmwareInstaller {
// The paravirtual GPU bundle comes from the restore tree, so an
// environment update cannot (re)install it; an installed guest already
// carries it, so record it live when on and skip with a note.
+ var gpuBundleReinstalled = false
if on("system-extensions-boot-gpu_bundle") {
isolate(["system-extensions-boot-gpu_bundle"]) {
if let restore {
try installGPUBundle(restore: restore, system: system, owner: owner)
+ gpuBundleReinstalled = true
} else {
print(" [·] system-extensions-boot-gpu_bundle: no restore tree; GPU bundle left as installed")
}
@@ -1311,6 +1313,31 @@ struct VPhoneCustomFirmwareInstaller {
}
}
+ // The driver's compact indexed-draw commands truncate a heap index
+ // buffer's offset to 16 bits. After the bundle step on purpose:
+ // `installGPUBundle` replaces the whole bundle, `.bak` included, so the
+ // backup taken here is always the staged driver — and a bundle it just
+ // reinstalled is already pristine, which is what "off" means.
+ let gpuIndexOffset = FirmwareGuestSystemPatchSet.paravirtGPUIndexOffset
+ let gpuDriver = FirmwareGuestSystemPatchSet.paravirtGPUDriverPath
+ let gpuBundle = "System/Library/Extensions/\(VPhonePCCGPUDriver.name)"
+ isolate([gpuIndexOffset]) {
+ if on(gpuIndexOffset) {
+ try patchMachO(
+ system: system, work: work, path: gpuDriver,
+ verbs: ["patch-paravirt-gpu-index-offset"],
+ identifier: "com.apple.driver.AppleParavirtGPUMetalIOGPUFamily",
+ )
+ try sealGuestBundle(system: system, bundle: gpuBundle)
+ live.insert(gpuIndexOffset)
+ } else if try revertMachO(system: system, work: work, path: gpuDriver, bundle: gpuBundle) {
+ print(" [+] \(gpuIndexOffset): restored \(gpuDriver) from backup")
+ } else if priorGuest.contains(gpuIndexOffset), !gpuBundleReinstalled {
+ print(" [!] \(gpuIndexOffset): off now but no backup to revert; leaving the patched driver (not revertible)")
+ live.insert(gpuIndexOffset)
+ }
+ }
+
machO("system-launchd_cache_loader-boot-unsecure_cache_gate", path: "usr/libexec/launchd_cache_loader", verbs: ["patch-launchd-cache-loader"], codeIdentifier: "com.apple.launchd_cache_loader")
machO("system-mobileactivationd-boot-should_hactivate", path: "usr/libexec/mobileactivationd", verbs: ["patch-mobileactivationd"])
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareMachOVerbsCommand.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareMachOVerbsCommand.swift
index 831e84b2..318f310d 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareMachOVerbsCommand.swift
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareMachOVerbsCommand.swift
@@ -508,6 +508,39 @@ struct VPhoneCustomFirmwarePatchVirtualAudioCommand: ParsableCommand {
}
}
+// MARK: - patch-paravirt-gpu-index-offset
+
+struct VPhoneCustomFirmwarePatchParavirtGPUIndexOffsetCommand: ParsableCommand {
+ static let configuration = CommandConfiguration(
+ commandName: "patch-paravirt-gpu-index-offset",
+ abstract: "Send every indexed draw from the paravirtual GPU driver with 64-bit offsets",
+ discussion: """
+ The cloudOS 26.4 AppleParavirtGPUMetalIOGPUFamily picks a compact
+ drawIndexedPrimitives command when indexBufferOffset fits in 16 bits,
+ then stores the index buffer's heap offset plus indexBufferOffset in
+ that 16-bit field. An index buffer 64 KiB or more into an MTLHeap is
+ read from the wrong address, and meshes draw with another mesh's
+ indices. Each selecting cbz/cbnz becomes a b to the full command.
+
+ Each site is found by the compact command's mov w2/mov w3 setup, which
+ is unique in __text, and the branch must lead to the full command's
+ setup. Nothing is written unless all four resolve.
+
+ Idempotent: a site already branching to the full command is reported
+ and the file is not rewritten.
+ """,
+ )
+
+ @Argument(help: "Path to the AppleParavirtGPUMetalIOGPUFamily Mach-O, patched in place", transform: URL.init(fileURLWithPath:))
+ var binary: URL
+
+ func run() throws {
+ try requireUntruncatedMachO(at: binary)
+ // No re-attestation: the caller re-signs.
+ try CustomFirmwareParavirtGPUIndexOffset.patch(fileAt: binary, log: machOVerbLog)
+ }
+}
+
enum VPhoneCustomFirmwareMachOVerbs {
/// Registered into `vphone-cli cfw` by `VPhoneCustomFirmwareCommand`.
///
@@ -526,6 +559,7 @@ enum VPhoneCustomFirmwareMachOVerbs {
VPhoneCustomFirmwarePatchVirtualAudioMuteCommand.self,
VPhoneCustomFirmwarePatchVirtualAudioSPGateCommand.self,
VPhoneCustomFirmwarePatchVirtualAudioVolumeGateCommand.self,
+ VPhoneCustomFirmwarePatchParavirtGPUIndexOffsetCommand.self,
]
}
}