Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Merge branch 'main' into shader-cache

Brandon Lekai8ae9f9f41729
diff --cc Research/0_binary_patch_comparison.md
index 4d6c1130,2d950861..bb0f3981
--- a/Research/0_binary_patch_comparison.md
+++ b/Research/0_binary_patch_comparison.md
@@@ -3238,79 -3295,20 +3297,96 @@@ before keep Apple's SEP ROM; `vm confi
without a restore. `Firmware/opensep_sep_rom.md` has the contract and the
validation.
+## Guest Metal caches survive a reboot (2026-10-19)
+
+Row 29. `system-systemhook-cfw-metal_cache_reuse`, declared in the Guest
+System set, is on in `standard` and `experimental` and blocked in both Apple TV
+presets (they carry no SystemHook). Its target is the marker
+`/usr/lib/vphone-metal-cache-reuse`: `cfw install` and `cfw update-environment`
+write it when the patch is selected and remove it when it is not, so it is
+revertible. While the marker exists, SystemHook's constructor sets
+`FS_CACHE_REUSE_ON_REBOOT=1` before anything else unless the variable already
+has an explicit value, so `libCoreFSCache` can keep
+each Metal cache stamped by an earlier boot instead of resetting it. No system
+binary, shared cache or kernel byte changes.
+
+Verified on `Lychee` (iPhone, iOS 27.0.1, cloudOS 26.4) with real reboots:
+backboardd's `functions.list` keeps its boot UUID header and size across three
+boots, guest compiles for backboardd during five Settings rounds fall from
+about 145 to 0, no GPU restart, and the first go-home goes from about 31% to
+37–44% on time. Numbers and method: `Guest/gpu_acceleration.md`, "Real reboots
+with the patch (2026-10-19)".
+
+Host cache storage (2026-10-20): the launcher keeps a durable whole-directory
+snapshot in `<machine>/ShaderCache`, seeds Apple's normal ECID working cache
+before boot, and checkpoints after guest shutdown and again in the parent CLI
+after vphone-vm exits. A symlink experiment was rejected after sandbox denials
+and repeated compilation; the working root remains a real directory. This adds
+no binary patch and changes no Task3 key bytes. Index/data pairs stay together;
+copies are staged before whole-directory replacement and never merged across
+independent trees. Permissions use the shared symlink-safe host-file walker.
+The final bundle passed two Settings/Camera boot cycles with zero host GPU task
+compiles and zero GPU resets, including restoration after moving aside Apple's
+working directory. All 14 cache file checksums matched after each shutdown.
+Migration checks and runtime evidence are in `Guest/gpu_acceleration.md`,
+"Cache location and migration".
+
+Deletion correction: a missing machine snapshot now clears an already managed
+host working copy on the next boot, instead of importing it again. A shutdown
+checkpoint does not recreate a deleted snapshot. The working copy's existing
+`.host-ecid` marker distinguishes this reset from the first-use import. This
+resets host caches only; guest caches inside `Disk.img` remain. Frame-counter
+gaps in the earlier measurements do not independently demonstrate visible
+animation stutter; the user reports smooth warmed animations.
+The corrected bundle's reset/reboot test recorded 607 then seven host GPU task
+compilation events (129 then one during Settings), with zero GPU resets on both
+boots. Fourteen cache/permission tests and the complete bundle build pass.
+
+Standard promotion (2026-10-20): JB-32 is now enabled by Standard as
+`kernel-cfw-paravirt_gpu_task3`; all four record suffixes and kernel writes are
+unchanged. The shipped plist and catalog fallback agree. tvOS presets retain
+an explicit block. The old `kernel-exp-paravirt_gpu_task3` identifier migrates
+in VM selections, plans and receipts, including explicit opt-outs. New template
+keys include the enabled kernel patch, so a pre-Task3 template cannot satisfy
+the new Standard plan. Existing VMs bind the new bundle and run
+`cfw update-environment` and `cfw update-kernel` while stopped, keeping data.
+See `Documents/Guides/shader-cache.md` and the Standard promotion section in
+`Guest/gpu_acceleration.md`. The previous opt-in notes describe development
+validation; older host compatibility remains untested.
+Promotion validation: 62 focused tests passed, as did the full `VPhone` bundle
+build and admission check. The built CLI recognized Lychee's old Task3 receipt
+under the new name as applied, enabled by its preset and not pending.
+
+Review fixes (2026-10-21): JB-32 is declared for cloudOS 26.4 only. On the
+cloudOS 26.1, 26.2 and 26.3 research kernels the owning-task anchor in the
+superclass initializer does not resolve, and an ungated Standard patch made
+`fw patch` and `cfw update-kernel` abort for every iOS 18.6.2–26.3.1 machine.
+The `.features` site no longer loads a fixed 245: it branches to
+`.features_code` (`sub x0,xV,#246; tbnz x0,#63; tbnz wV,#31; mov w0,#245`,
+else `mov x0,xV`), which passes the granted version through when it is the
+kext's own or lower, and a refusal unchanged. A host that does not know the
+requested version grants its own maximum without the refusal bit
+(`-[_PGDevice setBinaryVersion:]`: macOS 15.6.1 → 209, 26.0 → 233,
+26.4 → 245, 27.0.1 → 252), so the fixed 245 had claimed 8 feature flags on a
+15.6.1 host and 4 on 26.0 that the host never enabled. The clamp uses only
+existing Keystone-checked encoders; the Task3 fixture test executes it for
+252, 246, 245, 233, 209 and a refusal. The persistent host shader cache is no
+longer required to launch: a VM that cannot prepare one logs a warning and
+boots without it.
+ ## Apply selected Preboot identity during guest updates (2026-10-21)
+
+ `preboot-exp-devicetree_identity` was advertised as an `update-environment`
+ guest patch but its installer call enabled identity only for full installs.
+ Launchpad's Apply to Guest therefore completed with the identity still pending.
+ Environment updates now run the existing identity rewrite when the current
+ resolved plan selects it, using the installed tree without a restore directory.
+ The patch bytes, presets, board-presenting guest guard, post-identity repair
+ backup and existing off-state behavior are unchanged. This fixes the same
+ delivery path for CLI updates, bundle changes and template guest-patch steps;
+ other Preboot repairs already used it. It does not enable the eight firmware
+ DeviceTree identity edits or establish that Apple will deliver Photos models.
+
+ Validation on `upstream/main` `047642f8` (2.10.1): 77 existing tests in eight
+ suites pass, covering guest device trees, patch resolution/catalogue/drift,
+ board audio, microphone-array removal, iPhone product properties and haptics.
+ The complete `VPhone` Debug build and bundle admission also pass.
diff --cc VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareGuestSystemPatchSet.swift
index 22cac1ff,c5cbb79e..42338bab
--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareGuestSystemPatchSet.swift
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareGuestSystemPatchSet.swift
@@@ -21,9 -21,8 +21,10 @@@ public enum FirmwareGuestSystemPatchSe
public static let installCoordinationPersona = "system-installcoordination_proxy-cfw-persona_lookup"
public static let installCoordinationPersonaMarker = "/usr/lib/vphone-installcoordination-persona-lookup"
+ public static let metalCacheReuse = "system-systemhook-cfw-metal_cache_reuse"
+ public static let metalCacheReuseMarker = "/usr/lib/vphone-metal-cache-reuse"
public static let gyroscope = "system-backboardd-cfw-gyroscope"
+ public static let accelerometer = "system-backboardd-cfw-accelerometer"
public static let attitude = "system-apps-cfw-attitude"
public static let arm64eX1DyldBootstrap = "system-dyld-boot-arm64e_x1_bootstrap"
public static let arm64eX1CacheBootstrap = "dyld-boot-arm64e_x1_bootstrap"
diff --cc VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
index 00879028,7dc24966..9b911b41
--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
@@@ -1620,20 -1677,11 +1677,23 @@@ struct VPhoneCustomFirmwareInstaller
}
}
+ // SystemHook sets FS_CACHE_REUSE_ON_REBOOT while this marker exists.
+ let metalCachePatch = FirmwareGuestSystemPatchSet.metalCacheReuse
+ let metalCacheMarker = String(FirmwareGuestSystemPatchSet.metalCacheReuseMarker.dropFirst())
+ isolate([metalCachePatch]) {
+ if on(metalCachePatch) {
+ try system.writeFile(metalCacheMarker, contents: Data("1\n".utf8), mode: 0o644, owner: Self.guestOwner)
+ live.insert(metalCachePatch)
+ } else {
+ try system.removeItem(metalCacheMarker)
+ }
+ }
+
if !failures.isEmpty {
print("[!] \(failures.count) guest patch(es) failed and were left in their prior state: \(Set(failures).sorted().joined(separator: ", "))")
+ if strict {
+ throw ValidationError("OTA compatibility patches failed; the private disk clone was discarded: \(Set(failures).sorted().joined(separator: ", "))")
+ }
}
return live
}
diff --cc VPhoneExecutable/VPhoneVirtualization/Resources/patches_presets/tvos-4k.plist
index f07b8b56,75dc76bc..028e632c
--- a/VPhoneExecutable/VPhoneVirtualization/Resources/patches_presets/tvos-4k.plist
+++ b/VPhoneExecutable/VPhoneVirtualization/Resources/patches_presets/tvos-4k.plist
@@@ -67,8 -67,8 +67,9 @@@
<string>Block</string>
<key>Patches</key>
<array>
+ <string>system-exp-ota_userland</string>
<string>kernel-exp-frida_thread_set_state_entitlement_flag</string>
+ <string>kernel-cfw-paravirt_gpu_task3</string>
<string>kernel-exp-frida_vm_map_delete_immutable_code</string>
<string>kernel-exp-hv_vmm</string>
<string>dyld-exp-hv_vmm</string>