Run a virtual iPhone on an Apple Silicon Mac.
Swift
Rewrite the DeviceHub research note as a reference
Jackyac8268bd3739
diff --git a/Research/0_binary_patch_comparison.md b/Research/0_binary_patch_comparison.mdindex 890dac39..8160aa36 100644--- a/Research/0_binary_patch_comparison.md+++ b/Research/0_binary_patch_comparison.md@@ -550,7 +550,7 @@ do NOT execute these).| 8 | (removed — was: standalone-binary mangle in 6 rootfs Mach-Os via SSH) | n/a | Removed in the blacklist-flip redesign. With the EXP kernel rename in place, the 6 rootfs binaries (MobileActivationMigrator, CheckerBoard, StoreKitUISceneService, storekitd, appstored, CorePrescriptionService) get the desired "cache 0 / not in a VM" behavior for free: they keep their original cstring, hit ENOENT on the renamed kernel sysctl, defensive `cbnz w0, skip` leaves the cached byte at BSS-zero. No SSH-time standalone patch needed. | - | - | - || 9 | `mov w3,#<size>` -> `mov w3,#<base-size>` in `_kern_SwapEnd` — **26.0/26.0.1 and 18.x** | DSC `IOMobileFramebuffer` | Fixes host VZ GUI black-screen with the available PCC vphone600 userclient: the userclient does an exact `checkStructureInputSize` check on external-method-5 (SwapEnd) input, so a userland whose `_kern_SwapEnd` sends a different-sized state gets `kIOReturnBadArgument` and the host display stays black (guest still renders — the Apple logo is visible over VNC, just not in the vphone-cli view). **The accepted size is a property of the base kernel, not the userland**: 26.1 base -> **0x560**, 26.4 base (xnu-12377) -> **0x588**. The 0x588 value is confirmed two ways: the sole dispatch-shaped entry in `kernelcache.*.vphone600` with `checkStructureInputSize==0x588` (scalarIn=0, scalarOut=0, structOut=0, preceded by a ptrauth code ptr, at decompressed file offset 0x9c7228), and empirically — native 26.5 userland sends 0x588 and displays correctly on this stack. Source (userland-sent) sizes observed: 18.6.2 = 0x514, 26.0/26.0.1 = 0x548, 27.0 (24A5380h) = 0x6e0. The patcher is semantic (anchors on `mov w1,#5` -> `mov w3,#imm` -> `mov x4,#0`/`mov x5,#0` -> `bl` inside `_kern_SwapEnd`) and idempotent — rewrites the size to `--target-size` regardless of source and re-attests the modified DSC page. Install gate: `26.0*` / `18.*` -> 0x560 (26.1 base). Validated after host install on `17,3_26.0_23A341`, `17,3_26.0.1_23A355`, and `17,3_18.6.2_22G100` (Apple logo renders) against the 26.1 base. **CORRECTION (2026-07-15): iOS 27.0 is NO LONGER handled here.** 27 presents the paravirt display via IOMFB's `_virt_*` callback path — external method 5 is NEVER called — so no SwapEnd *size* change can help 27 (confirmed by kernel trace + live AppleParavirtGPU idle scheduler). iOS 27 now uses **force-kern (item 11)** to route present back onto method 5; this row applies to 26.0/26.0.1/18.x only. | Y | Y | Y || 10 | Zero `maxSlide` in `dyld_cache_header` (`@0xF0`) — **iOS 27.0 / any userland whose cache overflows the 6 GiB region** | DSC `dyld_shared_cache_arm64e` header | Fixes pid-1 `launchd` panic at boot on the vphone600 26.x kernel. The kernel reserves `SHARED_REGION_SIZE_ARM64 = 0x180000000` (6 GiB) and, at map time, needs room for the cache's mapped span **plus** the header `maxSlide` (ASLR range). iOS 27.0's cache (span `0x17c830000` ≈ 5.95 GiB) + `maxSlide 0x20000000` = `0x19c830000` > 6 GiB, so `_shared_region_map_and_slide` returns `ENOMEM`, dyld cannot map `libSystem.B.dylib`, and `launchd` panics (`initproc failed to start`). Zeroing `maxSlide` (LE u64) in the main chunk maps the cache at slide 0 (fits with ~58 MiB spare). Install gate: **`27.*`** (hard-gated in `cfw_install.sh` as of 2026-07-20 — an 18.x/26.x base skips it entirely). The patcher additionally self-gates (`patch-dsc-maxslide`): no-op unless span + maxSlide > `0x180000000`, kept as defense-in-depth so 26.x / 18.x are untouched even if the install gate were removed. **The non-27 opt-in is gone** (2026-09-30): `FORCE_DSC_MAXSLIDE=1`, later `--force-dsc-maxslide`, no longer exists on any command or in Launchpad. `dyld-boot-maxslide` is declared `iOSBase: .major(27)`, so non-27 bases keep their native slide. `patch-dsc-maxslide --force` remains on the standalone verb for hand use; `cfw install` never passes it. **24A435 (27.0 RC) checked 2026-09-30** for issue #531: the pristine SystemOS cryptex header reads `sharedRegionStart 0x180000000`, `sharedRegionSize 0x17D504000`, `maxSlide 0x20000000`, so span + slide is `0x19D504000`. `vphone-cli cfw patch-dsc-maxslide --dry-run` (2.1.6) reports `overflow` and would zero it; an installed 24A435 guest reads `maxSlide 0x0` and boots. The self-gate therefore patches 24A435 without force. The 512 MiB slide is the cache builder's fixed iOS arm64 value, so every 27 cache overflows this region. Source check (xnu-12377, `shared_region_map_and_slide_2_np`, `vm_shared_region_map_file_setup`, `vm_map_locate_space_fixed`): the kernel picks a 16 KiB-aligned slide strictly below `maxSlide` and maps each range FIXED inside the `0x180000000` submap. With no twig rounding and no reserved area, `size + maxSlide <= 0x180000000` is a sufficient test, one 16 KiB page stricter than needed. The #531 panic therefore came from a guest whose cache was never patched. Most likely its CFW install had not completed, because `cfw install` swaps in its clone only on success. It did not come from the gate. **No** page re-attestation (header metadata, not a `cs_validate`'d code page — confirmed empirically). Validated on `17,3_27.0_24A5380h` + cloudOS 26.4 (`c0ecdb4b…`): `dyld cache mapped system-wide`, launchd reaches first unlock, vphoned connects as iOS 27.0.0, 0 panics. See `scripts/patchers/cfw_patch_dsc_maxslide.py`. | Y | Y | Y |-| 11 | Retarget public `_IOMobileFramebufferSwap*` trampolines -> `b _kern_Swap*` (force-kern) — **iOS 27.0** | DSC `IOMobileFramebuffer` | **iOS-27 VZ-view (host paravirt-GPU scanout) fix, userland half.** The host `VZVirtualMachineView` is fed by the guest `AppleParavirtGPU` scanout, which the 26.4 kernel drives ONLY from the IOMFB userclient SwapEnd (external method 5) — the `_kern_Swap*` path. iOS 27 defaults the paravirt display's present to IOMFB's parallel `_virt_Swap*` path (`_virt_SwapEnd` does no userclient call — it invokes an in-process callback `blraaz [conn+0xe68]` and hands the IOSurface to a virtual-display consumer), so the paravirt GPU never scans out → host VZ window black (guest still composites; GUI visible over in-guest TrollVNC; AppleParavirtGPU `SchedulerState` idle). The public `_IOMobileFramebufferSwap*` entrypoints are thin trampolines (`cbz x0; ldr xN,[x0,#slot]; cbz xN; braaz xN`) that tail-call the per-connection swap fp (kern or virt impl). This patch rewrites each trampoline's first insn to `b _kern_Swap<Name>`, forcing present onto method 5 regardless of how 27 classified the display (tail-call, args intact → behaviourally identical to selecting the kern fp). Fully dynamic: public + `_kern_` addrs resolved by name via `ipsw dyld symaddr`, trampoline shape verified by Capstone, branch bytes from Keystone `asm_at()`, modified DSC code pages re-attested. Requires ≥{SwapBegin,SwapEnd,SwapSetLayer} or raises (dry-run retargets 31 entrypoints on 24A5380h, skips 4 non-trampolines). **Pairs with the JB kernel patches (`patchIomfbSwapEndVariableSize` + `patchIomfbSwapEndHandlerSize`)** which relax the 26.4 userclient's two exact `0x588` size gates to accept 27's native `0x6e0` IOMFBSwapRec (prefix matches 26.x, so the paravirt swap handler reads valid fields). Install gate: `27.*`. See `scripts/patchers/cfw_patch_iomfb_force_kern.py`. **VALIDATED on-device (2026-07-15, `17,3_27.0_24A5380h` + cloudOS 26.4 `c0ecdb4b…`, JB): iOS 27 userland renders AND is interactive in the native VZ view (not just TrollVNC); clean boot — no `kIOReturnBadArgument`/SwapEnd rejection/panic.** Runtime confirmed 31 entrypoints retargeted (4 non-trampoline setters left on virt). | Y | Y | Y |+| 11 | Retarget public `_IOMobileFramebufferSwap*` trampolines -> `b _kern_Swap*` (force-kern) — **iOS 27.0** | DSC `IOMobileFramebuffer` | **iOS-27 VZ-view (host paravirt-GPU scanout) fix, userland half.** The host `VZVirtualMachineView` is fed by the guest `AppleParavirtGPU` scanout, which the 26.4 kernel drives ONLY from the IOMFB userclient SwapEnd (external method 5) — the `_kern_Swap*` path. iOS 27 defaults the paravirt display's present to IOMFB's parallel `_virt_Swap*` path (`_virt_SwapEnd` does no userclient call — it invokes an in-process callback `blraaz [conn+0xe68]` and hands the IOSurface to a virtual-display consumer), so the paravirt GPU never scans out → host VZ window black (guest still composites; GUI visible over in-guest TrollVNC; AppleParavirtGPU `SchedulerState` idle). The public `_IOMobileFramebufferSwap*` entrypoints are thin trampolines (`cbz x0; ldr xN,[x0,#slot]; cbz xN; braaz xN`) that tail-call the per-connection swap fp (kern or virt impl). This patch rewrites each trampoline's first insn to `b _kern_Swap<Name>`, forcing present onto method 5 regardless of how 27 classified the display (tail-call, args intact → behaviourally identical to selecting the kern fp). Fully dynamic: public + `_kern_` addrs resolved by name via `ipsw dyld symaddr`, trampoline shape verified by Capstone, branch bytes from Keystone `asm_at()`, modified DSC code pages re-attested. Requires ≥{SwapBegin,SwapEnd,SwapSetLayer} or raises (dry-run retargets 31 entrypoints on 24A5380h, skips 4 non-trampolines). **Pairs with the JB kernel patches (`patchIomfbSwapEndVariableSize` + `patchIomfbSwapEndHandlerSize`)** which relax the 26.4 userclient's two exact `0x588` size gates to accept 27's native `0x6e0` IOMFBSwapRec (prefix matches 26.x, so the paravirt swap handler reads valid fields). Install gate: `27.*`. See `scripts/patchers/cfw_patch_iomfb_force_kern.py`. **VALIDATED on-device (2026-07-15, `17,3_27.0_24A5380h` + cloudOS 26.4 `c0ecdb4b…`, JB): iOS 27 userland renders AND is interactive in the native VZ view (not just TrollVNC); clean boot — no `kIOReturnBadArgument`/SwapEnd rejection/panic.** Runtime confirmed 31 entrypoints retargeted (4 non-trampoline setters left on virt). **Conditional since 2026-10-07 (DeviceHub):** forcing every trampoline also sent the capture display that Xcode's DeviceHub stream adds to the kernel; it has no userclient port, so backboardd logged `display 2 swap_end returned error 10000003` (`MACH_SEND_INVALID_DEST`) and the stream was black. Each trampoline is now `cbz x0, <fail>` / `ldr w16, [x0, #0x14]` / `cbnz w16, _kern_Swap<Name>` / `b _virt_Swap<Name>`: a connection with an IOConnect port (the paravirtual main display) still presents through method 5, a virtual display keeps its in-process path. Only operations with public, `_kern_` and `_virt_` siblings take part (ten on 24A446; `SwapSignal` is not a trampoline). The `0x14` port offset is the one every `_kern_Swap*` passes to the external method, verified on 24A446. The identifier is unchanged, so an installed guest needs the old 31 four-byte sites reverted (`fw set-patches --block dyld-boot-iomfb_force_kern`, `cfw update-environment`) before the new ten 16-byte sites are written. Validated on `iPhone17,3 27.0.1 (24A446)`: VZ scanout unchanged, DeviceHub live. See `Research/Guest/devicehub_screen_viewing.md`. | Y | Y | Y || 12 | NOP `-[_LSDModifyClient clientIsEntitledForEmbeddedRegistrationOperations]` entitlement gate + per-page re-attest — **iOS 27.0** | DSC `CoreServices` (LaunchServices) | **iOS-27 app-registration fix.** lsd gates `-[_LSDModifyClient performPostInstallationRegistration:operationUUID:reply:]` (and the containerized/rebuild registration paths) behind `clientIsEntitledForEmbeddedRegistrationOperations`, which does `xpc_connection_copy_entitlement_value` on the XPC peer for any of `com.apple.private.coreservices.lsaw` / `com.apple.private.installcoordinationd.daemon` / `com.apple.private.coreservices.can-register-install-results`. A client without one gets `NSOSStatusErrorDomain -54` (permErr, `LSDModifyService.mm:1639`), so `registerApplicationDictionary:` / `registerContainerizedApplicationWithInfoDictionaries:` fail and no app can (re)register — blocking vphoned's installer, TrollStore, and uicache/Sileo alike. The entitlement route is a dead end even for a launchd platform daemon (vphoned) whose validated csblob (`csops CS_OPS_ENTITLEMENTS_BLOB`) contains all three: LS registration is proxied, so the XPC peer lsd inspects is not the registering process. Fix: NOP the final `cbz w0, <not_entitled>` (the conditional branch whose fall-through sets the `mov w<reg>,#1` result) so the method always returns YES. Fully dynamic: method resolved via the DSC's own `.symbols` in-image local-symbol table (ipsw `symaddr -a`/`a2s` time out on this cache), gate located by control-flow shape in Capstone, NOP from Keystone `asm("nop")`, modified 16 KiB page re-attested (`cfw_dsc_codesign.py`; TXM enforces per-page). The resulting CDHash change is accepted by the JB always-true AMFI cdhash-trust patch. Install gate: **`27.*`** (hard-gated in `cfw_install.sh` as of 2026-07-20 — an 18.x/26.x base does not apply it). The patcher additionally self-gates (`patch-lsd-embedded-reg`): no-op on pre-iOS-27 userlands where the method is absent. **Pairs with vphoned's `vp_register_path` containerized-registration fallback** (`registerContainerizedApplicationWithInfoDictionaries:...:registrationError:`, treating a nil `registrationError` as success since it returns NO even when it registers). Also paired with **`/cores/vpregister`** (built + deployed by `cfw_install_jb.sh` / `cfw_install_exp.sh`, invoked by `vphone_jb_setup.sh` at first boot — 27-gated by DEPLOYMENT: `cfw_install_jb.sh`/`cfw_install_exp.sh` copy `/cores/vpregister` only when the mounted rootfs `SystemVersion.plist` is `27.*`, and the setup script's `[ -x /cores/vpregister ]` presence check is the runtime gate. Do NOT gate the invocation on a guest `sw_vers` check — the hybrid guest does not reliably report the 27 userland version at first boot, which silently skipped registration): it registers JB app bundles (Sileo) via the same containerized API, because `uicache -a`'s `registerApplicationDictionary:` is a deprecated no-op on iOS 27 (lsd logs *"you cannot use ... to register applications anymore. These interfaces have been deprecated for years."*). **VALIDATED (2026-07-17, `17,3_27.0_24A5380h` + cloudOS 26.4, JB): -54 gone; Sileo registers (`uicache -l` 0→1) via `vpregister`; vphoned installs+registers a test IPA (`com.vphone.vptest`) to `/var/containers/Bundle/Application/` end-to-end. Clean boot (re-attest correct; no CoreServices page rejection).** See `scripts/patchers/cfw_patch_lsd_embedded_reg.py` and `Siblings/VPRegister/vpregister.m`. **FIX (2026-08-10):** `_find_gate` only matched the live `cbz`/`cbnz` branch shape, so re-running `cfw install` (host-mount flow, `myphone` VM, `17,3_27.0_24A5390f`) against a cache where this gate was already NOP'd from a prior pass raised `ValueError: ... entitled-result gate ... not found` instead of recognizing the idempotent state (unlike the Cryptex/IOMFB steps, which log `already ... idempotent` and skip cleanly). Confirmed live via host-mount disassembly: the third check's `bl <check3>` is followed by a bare `nop` at the gate site (exact match against `asm("nop")` bytes) immediately before `mov w20, #1` — i.e. already patched. `_find_gate` now also matches `nop` immediately preceding `mov w<reg>,#1` as an already-patched gate, so a re-run just re-attests the page instead of erroring. | Y | Y | Y || 13 | `mov x0,#1; ret` on `-[DIDiskArb isMountCompleteWithExpectedCount:diskTracker:]` — **iOS 27.0** | `diskimagesiod` | **iOS-27 DDI (`/System/Developer`) auto-mount — mount-gate.** After the personalized DDI attaches (kernel side: JB-28 + JB-09), MobileStorageMounter waits on diskimagesiod's `-[DIDiskArb waitForDAMountWithExpectedCount:diskTracker:]` before it does the real (nobrowse) mount at `/System/Developer`. That wait loops until `isMountComplete` (= `callbackReached \|\| (appearedDiskCount>=expectedCount && mountedDiskCount>=mountableDiskCount)`) is YES; on the 26.4-kernel / 27-userland hybrid it never becomes true (not all of the DMG's IOMedia "appear" to diskimagesiod's DiskArbitration session, and diskarbitrationd never auto-mounts the volume), so the wait hangs and pmd3 times out. diskimagesiod itself does NOT mount the DDI (its `-[DIDiskArb mountWithDeviceName:...]` is dead code) — it only gates MobileStorageMounter. Forcing `isMountComplete` → YES lets the wait return so MobileStorageMounter proceeds. IMP resolved via LC_SYMTAB or ObjC metadata (selector → `__objc_selrefs` → `__TEXT,__objc_methlist` relative method list → IMP); prologue overwritten `mov x0,#1 ; ret` (safe — the method returns to the caller's unsigned LR without pushing a frame). **Gated to 27.\*** in `cfw_install.sh` (same `$IOS_VERSION` as the DSC patches): on a version-matched userland the native wait completes correctly and forcing it early could race the real mount, so it is NOT applied there. Embedded sandbox profile + private DA/apfs entitlements preserved on re-sign (`ldid_sign_ent`). **Validated on `c0ecdb4b` 26.4 + 27.0 userland: `pmd3 mounter auto-mount` → rc=0, DDI at `/System/Developer`, idempotent across fresh boots.** See `scripts/patchers/cfw_patch_diskimagesiod.py`. | Y | Y | Y || 14 | Merge backboard/frontboard launch mach-services into `com.apple.security.exception.mach-lookup.global-name` + `ldid_sign_ent` re-sign — **iOS 27.0** | `/Applications/Campo.app/Campo` | **iOS-27 Campo (wallpaper renderer) crash-loop fix — sandbox half.** Campo declares `com.apple.private.sandbox.profile:embedded = temporary-sandbox` + `no-container`, so it runs under the `temporary-sandbox` profile. On the 26.4 vphone600 kernel that builtin profile predates iOS 27 and DENIES the `mach-lookup` of the backboard/frontboard launch services, so `BKSDisplayServicesStart` (looks up `com.apple.backboard.display.services`) and then `+[BKSHIDEventDeliveryManager sharedInstance]` (HID) fail, log *"backboardd isn't running -- or we couldn't talk to it"*, and `brk #0` ~34 ms after launch → continuous crash-loop, no wallpaper (launchd eventually throttles it off). **JB-02d is NOT sufficient here:** it stops the exec-time container-manager-upcall autobox *KILL*, but Campo is still placed in `temporary-sandbox` (its own declared profile — confirmed the JB-02d `b`-flip is present in the running kernel yet Campo still traps), and that profile still denies the lookups. Fix: append the needed services to Campo's OWN `com.apple.security.exception.mach-lookup.global-name` array — the Apple-sanctioned escape hatch, which `temporary-sandbox` honors (Campo already ships ~20 such exceptions; these launch services simply aren't among them because 27's profile allows them directly). Services added (backboard names exact, from `com.apple.backboardd.plist` MachServices): `com.apple.backboard.display.services`, `com.apple.iohideventsystem`, `com.apple.CARenderServer`, `com.apple.backboard.hid.services`, `com.apple.backboard.hid-services.xpc`, `com.apple.backboard.TouchDeliveryPolicyServer`, `com.apple.backboard.system-app-server`, `com.apple.backboard.watchdog`, `com.apple.backboard.oswatchdog`, `com.apple.backboard.altsysapp`, `com.apple.AttentionAwareness`, `PurpleSystemEventPort`, `PurpleWorkspacePort`, `com.apple.frontboard.systemappservices`, `com.apple.frontboard.workspace`, `com.apple.frontboardservices.systemappmanager`, `com.apple.frontboard.watchdog`. Merge is done by the external helper `scripts/patchers/campo_mach_lookup_exceptions.py` (Python `plistlib`, not `plutil` — the entitlement key contains dots that `plutil` keypaths would mis-split; idempotent, preserves the existing array); re-signed with the JB `signcert.p12` via `ldid_sign_ent` (AMFI enforcement is relaxed on the research VM, so the re-signed cdhash loads and the entitlements are honored). Applied at host-mount build time in `cfw_install_jb.sh` / `cfw_install_exp.sh` step **[JB-3b]**, **hard-gated to `27.*`** via the mounted rootfs `SystemVersion.plist` `ProductVersion` (same gate as the vpregister/DSC patches) — skipped entirely on 26.x/18.x, which don't need it and where `Campo.app` also exists. **VALIDATED on-device (2026-07-21, `17,3_27.0_24A5390f` + cloudOS 26.4, JB): Campo launches and stays up (stable pid, no BKSDisplayServicesStart/BKSHIDEventDeliveryManager trap, no crash-loop); first-cut display-only exception advanced the trap from display→HID, confirming the mechanism, then the full service set cleared it.** See `scripts/cfw_install_jb.sh` / `scripts/cfw_install_exp.sh` step JB-3b and the merge helper `scripts/patchers/campo_mach_lookup_exceptions.py`. | - | - | Y |@@ -565,7 +565,7 @@ do NOT execute these).| 23 | No binary change: `libvcamcaptured.dylib`, which SystemHook already loads into `cameracaptured`, rewrites the `bl PrewarmThreadSafeSBPs` in `__FigCapturePreloadShadersInternal_block_invoke_2` to `nop` in the daemon's own memory. This runs from the dylib's constructor and only when the paravirtual Metal driver is installed — **all bases** | none (guest dylib `VPhoneGuestComponents/VCamCaptured/Prewarm/`, installed at `/usr/lib/libvcamcaptured.dylib`) | **Stop `cameracaptured` crashing at every boot, and the SpringBoard freeze that follows.** At launch the daemon preloads its shaders. `PrewarmThreadSafeSBPs` runs each video processor's `-prewarm`, and NRFV3's reaches `-[ToneMappingCurves initWithWithContext:]`, which fills textures made from a shared `MTLHeap` with `-replaceRegion:…`. The cloudOS 26.4 `AppleParavirtGPUMetalIOGPUFamily` never sets `_dimension` (a texture's CPU layout) in `-initWithHeap:resource:offset:length:descriptor:`, and `-replaceRegion:` loads it unchecked, so the daemon faults with `KERN_INVALID_ADDRESS` at `0xc` (measured on `iPad16,1 26.6.2 (23G90)`, `standard`: launchd at `successive crashes = 6`). While the daemon crash-loops, SpringBoard's main thread blocked in a synchronous XPC to it as soon as an app started recording. The daemon does have a Metal device, so `kernel-exp-paravirt_user_clients` does not help. Prewarming is only an optimisation, and nothing waits on that function: no return value, no global, no signal. The rest of the preload (processor flags, data migration, and the deferred shader cache copy, whose semaphore deferred processing waits on) is kept. The call site is found from the exported `FigCapturePreloadShaders`: its `b` to the internal function, that function's one `adrp/add/pacia x16` block invoke, then the block's one `ldr x0, [xN, #0x20]; bl` into CMCapture's `__text`. That gives `0x1aeb2fd68` on 23G90 and `0x1b0759d10` on 24A435. Any mismatch leaves the prewarm in place and logs the step that failed. Host test: `make -C VPhoneGuestComponents test-vcam-prewarm`. Validation: `vcamcaptured.log` has `gpu prewarm: … skipped`, no new `cameracaptured` crash report, and `successive crashes = 0`. See `Research/Guest/gpu_acceleration.md` ("Heap Textures Have No CPU Layout"). | Y | Y | Y || 24 | No binary change: both spawn hooks insert `libbatteryhealthfix.dylib` into `Settings` (`/Applications/Preferences.app/Preferences`) beside SystemHook, where it interposes `IOPSCopyPowerSourcesInfo`, `IOPSCopyPowerSourcesByType`, `IOPSCopyPowerSourcesByTypePrecise`, `notify_register_check` / `notify_get_state` / `notify_cancel` and `MGGetBoolAnswer` — **all bases** | none (new guest dylib `VPhoneGuestComponents/BatteryHealthFix/libbatteryhealthfix.c`, installed at `/usr/lib/libbatteryhealthfix.dylib`) | **Stop Settings → Battery → Battery Health & Charging loading forever.** The VM's battery is Virtualization.framework's synthetic power source (charge and connectivity only), and the health half of a real battery's description comes from AppleSmartBattery, which no VM has. Measured on `iPhone17,3 27.0 (24A435)`: powerd's internal battery description has one `BatteryPacks` entry holding only `PackID`, `Cycle count` and `Transport Type`, no `Battery Service State`/`Flags` or `Maximum Capacity Percent` anywhere, and `com.apple.thermalmonitor.ageAwareMitigationState` stays 0. `-[BatteryHealthUIController specifiers]` asks `-[BatteryHealthUIInformation batteryDataUnavailable]`, which answers YES while `+getManagementState` is 0, while no pack parses (`-[BatteryHealthUIPackInformation initWithPowerSourceInformation:]` drops a pack without service flags and state), or while the overall genuine status is -1 — and it is -1 because `MGGetBoolAnswer("D6/BMDrlb8V3WSiqL8gL+w")` (HasBatteryModuleAuth, `+[PLGestaltUtilities hasBatteryModuleAuth]`) answers 1 on the guest, sending `+genuineBatteryStatusForPackIndex:` to an `AppleBatteryAuth`/`AppleAuthCPRelay` service that does not exist. The controller then shows its global spinner and re-asks on a timer. iPadOS 26.6.2 (23G90) has the same gate in `+[BatteryUIResourceClass batteryDataUnavailable]`, reading the flat keys of `IOPSCopyPowerSourcesByType`'s array, the same notify name and the same MobileGestalt key. The hook answers as a new battery without battery authentication: each internal-battery description is copied with `Battery Service State` 0, `Battery Service Flags` 0, `Maximum Capacity Percent` 100 and `Cycle count` 0 at the top level, and each of powerd's packs (or one new pack) completed with a `BatteryHealth` dictionary of the same three numbers plus `Date of manufacture`/`Date of first use` (the birth time of `/private/var/mobile`, i.e. the restore); keys already present are never replaced, and a description that already has them is passed through. A mitigation state of 0 on a token registered for the age-aware name reads as 2 ("supporting normal peak performance"). HasBatteryModuleAuth reads as no only while `IOServiceGetMatchingService("AppleBatteryAuth")` finds nothing. Interposing reaches the callers because `BatteryUsageUI.bundle` is a standalone Mach-O bound through dyld's interposing table (cache-to-cache calls are not; see `MISFix/MISFixSignature.c`), and inserting it — rather than SystemHook `dlopen`ing it like row 21 — is what puts the table in place before the bundle loads. `vpInsertedLibraryFor` in `Shared/InjectionEnvironment.h` picks it or libmisfix for a path; the two target sets do not overlap. Ships with `system-launchdaemons-boot-environment`; existing guests get it from the vphoned environment update on their next start with the new bundle (offline `cfw update-environment` only replaces libraries a VM already has). launchd starts Settings itself, so it is the launchd hook that inserts it: a guest updated only by that online sync needs one more reboot before launchd runs the new hook, which the update already reports as `reboot_required`; an offline environment update replaces the hook before boot. **Validated (2026-10-04, `bhtest-iphone`, `iPhone17,3 27.0 (24A435)` + cloudOS 26.4):** before, the page showed only the spinner and the two charging switches; after, Maximum Capacity 100%, Peak Performance Capability "Your battery is currently supporting normal peak performance", the two switches, no spinner; the hook's log shows all three answers taken once per process. Re-checked on the final bundle after a reboot of the same guest, with the launchd hook logging `inserted+batteryhealthfix` for each Settings launch. **iPad16,1 26.6.2 (23G90), `bhtest-ipad`, created with the new bundle:** the hook is inserted and stays inert, and Settings runs without a crash; that iPad has no Battery Health page at all, because `-[BatteryUIController setUpBatteryHealthGroup]` offers the row only on an iPhone or, through `+[PLBatteryUIBackendModel shouldShowModifiedHealthController]`, on an iPad that supports the fixed charge limit with the `PerfPowerServices/battery_health_details` feature on — the model decides, as on hardware. The 26.x gate inside the page is from static analysis; no 26.x iPhone image was at hand to run it. | Y | Y | Y || 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` and the DDI's `dtremotedisplayd`. 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` — **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). Interposing reaches all three because `cryptexd`, `dtremotedisplayd` and `CoreDeviceUtilities` are standalone images; the two Swift symbols are weak flat-namespace imports, resolving to nothing in `cryptexd`. 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):** `dhtest-ipad`, `iPad16,1 26.6.2 (23G90)`: DeviceHub receives `supportedFeatures: 140`, `MediaStreamStart` succeeds and the window shows the live home screen. `dhtest-iphone27`, `iPhone17,3 27.0.1 (24A446)`: the DDI mounts (`F_SETPROTECTIONCLASS EPERM, reported as ENOTSUP`), features 140, `MediaStreamStart` succeeds, but the view stays black — backboardd logs `display 2 get_wireless_surface_options returned error` and `swap_end returned error 10000003` for the capture display; not solved here. | Y | Y | Y |+| 26 | No binary change: both spawn hooks insert `libdevicehubfix.dylib` into `cryptexd` and the DDI's `dtremotedisplayd` and `dtdeviceinfod`. 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 — **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. 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`). Open: latency that grows over a long session and occasional stalls after a cold start, both upstream of the Mac receiver. | Y | Y | Y |### Swift port status — the eight DSC patchers (2026-09-23)@@ -2784,17 +2784,3 @@ re-patched kernelcache and the marker survived. Flow: `fw set-patches` →route a kernel patch through `cfw update-kernel` and the rest of the boot chain(TXM, DeviceTree, LLB, iBSS, iBEC) through the erasing restore. TXM andDeviceTree are also in Preboot and could follow the same path later.--### DeviceHub iOS 27 conditional swap and mask metadata (2026-10-07)--The IOMFB force-kern candidate uses ten public/kern/virt symbol triples on-24A446. Each writes a 16-byte null check, port load, conditional kernel branch,-and virtual branch, followed by re-attestation. Reapply an existing installation-by reverting the old 31 four-byte sites via patch selection first: an unchanged-identifier in the receipt otherwise skips the new implementation.--`libdevicehubfix` also loads in the DDI's dtdeviceinfod. It preserves existing-MobileGestalt answers but supplies mask `4E5532ED-1470-47D1-BDF4-7AA90C26957A`-when FramebufferIdentifier is missing and ChromeIdentifier is phone11. This is-the corresponding Xcode DeviceKit mask, not a hardware device-tree rewrite.-The null mask was observed in dtdeviceinfod; visual validation is pending.diff --git a/Research/Guest/devicehub_screen_viewing.md b/Research/Guest/devicehub_screen_viewing.mdindex 56b3618d..b96d9f07 100644--- a/Research/Guest/devicehub_screen_viewing.md+++ b/Research/Guest/devicehub_screen_viewing.md@@ -2,20 +2,34 @@Xcode 27 ships `DeviceHub.app` (`Xcode.app/Contents/Applications`, bundle id`com.apple.dt.Devices`). It lists vphone guests as "iPad / iPhone — Virtual-Machine" and, for a paired guest with its developer disk image mounted, opens-a live view of the screen. Before the fix the view spun forever for every-guest, 26.x and 27.x alike, and a second window reported "Connection timed-out". The two versions stop at different places: a 27.x guest never mounts-the DDI, and a 26.x guest mounts it and then reports no media stream-features.+Machine" and, for a paired guest with its developer disk image (DDI) mounted,+opens a live view of the screen. Before this work the view spun forever on+every guest, 26.x and 27.x alike.-Measured with Xcode 27.0 (27A266a), CoreDevice 642.16, on `iPad16,1 26.6.2-(23G90)` and `iPhone17,3 27.0.1 (24A446)` guests over cloudOS 26.4.+Measured with Xcode 27.0 (27A266a) and CoreDevice 642.16 on macOS 27.0.1,+against `iPad16,1 26.6.2 (23G90)` and `iPhone17,3 27.0.1 (24A446)` guests+over cloudOS 26.4, 2026-10-06 and 2026-10-07.-## iOS 27: the DDI does not mount+Status: the live view works on both versions. Latency that grows over a long+session, and occasional multi-second stalls after a cold start, are open (see+[Open](#open)).++## What stopped it++Each version stopped at a different place, and a 27.x iPhone stopped at all+four:++| Stage | Symptom | Affects | Fixed by |+| --- | --- | --- | --- |+| DDI mount | "connected (no DDI)" for good | 27.x | `cryptexd` hook |+| Feature query | `supportedFeatures: 0`, view spins | every guest | `dtremotedisplayd` hook |+| Capture display | stream starts, view stays black | 27.x | conditional IOMFB dispatch |+| Display metadata | screen drawn over the bezel corners | 27.x iPhone | `dtdeviceinfod` hook |++### iOS 27: the DDI does not mountCoreDevice personalizes the cryptex DDI (TSS succeeds) and hands it to the-guest, then nothing more happens; the device stays "connected (no DDI)" and+guest, then nothing more happens. The device stays "connected (no DDI)" andDeviceHub logs `No providers can handle Display ID: 1 … (bootState: Booted,ddi: false)`. The guest's `cryptexd` says why:@@ -28,18 +42,17 @@ ddi: false)`. The guest's `cryptexd` says why:In `__protex_stage_continue` (`/usr/libexec/cryptexd`, 27.0.1) each stagedasset is opened `O_RDWR` and given class D with-`fcntl(fd, F_SETPROTECTIONCLASS, 4)`; a failure other than `ENOTSUP` (45)-aborts staging. The guest returns `EPERM`. `cryptexd` already treats-`ENOTSUP` as a filesystem without protection classes, so the hook reports-this one `EPERM` as `ENOTSUP`. iOS 26 guests mount the DDI without it.+`fcntl(fd, F_SETPROTECTIONCLASS, 4)`. A failure other than `ENOTSUP` (45)+aborts staging, and the guest returns `EPERM`. iOS 26 guests mount the DDI+without this.-## Where a mounted guest stops+### Every guest: no media stream featuresDeviceHub asks the device for its media stream features before it starts astream (`MediaStreamGetSupportInfoActionDeclaration`, forwarded to the device-feature `com.apple.coredevice.feature.getmediasupportinfo`). It repeats the-question with backoff (1 s, 2 s, 4 s … 30 s) until the answer is non-empty.-A guest answers every time with+feature `com.apple.coredevice.feature.getmediasupportinfo`) and repeats the+question with backoff (1 s, 2 s, 4 s … 30 s) until the answer is non-empty. A+guest answers every time with```textSupportInfo: supportedFeatures: 0 (No supported features are available: (Raw Value: 0),@@ -48,15 +61,9 @@ SupportInfo: supportedFeatures: 0 (No supported features are available: (Raw Vaand DeviceHub logs `No framebuffer provider found for Display ID: 1 —creators tried: [… AVConferenceDisplayViewFramebufferProviderCreator=-canProvideView:false …]`. The Mac side's own features are fine-(`found supported features: Primary video display mirrored output stream,-System audio output stream, Display information (Raw Value: 140)`).--`devicectl device capture screen-record` is a separate feature-(`com.apple.coredevice.feature.screenrecording`) that a guest does not list,-so it is not a way around this.--## The device side+canProvideView:false …]`. The Mac reports its own features as+`Primary video display mirrored output stream, System audio output stream,+Display information (Raw Value: 140)`.The answer comes from the DDI's `dtremotedisplayd`(`/System/Developer/usr/libexec/dtremotedisplayd`, LaunchDaemon@@ -70,23 +77,24 @@ The answer comes from the DDI's `dtremotedisplayd``current` builds a `CurrentDevice` and calls`forDeviceInfo(osBuildUpdate:platform:deviceType:isVirtualDevice:mode:isProductionFused:hasInternalOSBuild:hasInternalDDI:)`.-Its log strings name the policies; none of them is a capability check:+Its log strings name the policies, and none of them is a capability check:- `Remote control restricted. Device is customer-restricted (production- fused, customer OS, customer DDI) and running pre-27.0 OS (major: …).- Returning no supported features.` The predicate+ fused, customer OS, customer DDI) and running pre-27.0 OS`. The predicate`CurrentDevice.isCustomerRestricted(isProductionFused:hasInternalOSBuild:hasInternalDDI:)`disassembles to `isProductionFused && !hasInternalOSBuild &&hasInternalDDI == false`. Every 26.x guest is refused here.- `Remote control is only available on iOS 27.0, watchOS 27.0, or tvOS 27.0- or later.` — shown when the device is not an iPhone, Apple Watch or Apple- TV. Every iPad guest is refused here whatever its version.-- a per-build table (`MediaStreamSupportedFeatures.MinimumVersions`) keyed by+ or later.`, shown when the device is not an iPhone, Apple Watch or Apple TV.+ Every iPad guest is refused here, whatever its version.+- A per-build table (`MediaStreamSupportedFeatures.MinimumVersions`) keyed bybuild, platform and device type, which also takes `isVirtualDevice`.-The guest does not persist the info-level `inputs:` line, and the hook-replaces the answer on every version, so the branch a 27.x iPhone guest-would take on its own was not observed.+The guest does not persist the info-level `inputs:` line, and the hook replaces+the answer on every version, so the branch a 27.x iPhone would take on its own+was not observed. `current` also returns no features when `CurrentDevice.init`+cannot build the device identity (version number, build update, device type);+there is no compositor-readiness gate in it.Feature bits (`MediaStreamSupportedFeatures` static getters):@@ -99,423 +107,249 @@ Feature bits (`MediaStreamSupportedFeatures` static getters):| `0x100` | video output by display ID || `0x200` | screenshot capture |-## The fix+`devicectl device capture screen-record` is a separate feature+(`com.apple.coredevice.feature.screenrecording`) that a guest does not list,+so it is no way around this.-`VPhoneGuestComponents/DeviceHubFix/libdevicehubfix.c`, installed as-`/usr/lib/libdevicehubfix.dylib`, is inserted by both spawn hooks into-`cryptexd` and `dtremotedisplayd` only (`vpIsDeviceHubFixTarget` in-`Shared/InjectionEnvironment.h`). In `cryptexd` it interposes `fcntl` as-above. In `dtremotedisplayd` it interposes two getters:--- `MediaStreamSupportedFeatures.current` answers `0x8c`, the features a Mac- host reports for itself. The struct is resilient (the framework is built- for library evolution), so the getter returns it indirectly through `x8`;- the replacement is three instructions of assembly. The host intersects the- answer with its own features.-- `CurrentDevice.isCustomerRestricted` answers false.--Interposing works because both `dtremotedisplayd` and `CoreDeviceUtilities`-are DDI images, not shared-cache ones, so dyld binds their imports through the-interposing table. The imports are weak flat-namespace symbols (`-Wl,-U`),-because neither image is in the SDK.--The stream itself is AVConference screen capture inside the guest. It needs-nothing else: once the answer is non-empty DeviceHub's-`MediaStreamStartActionDeclaration` succeeds for audio and video and the view-shows the live screen.+### iOS 27: the capture display is black-## Validation+With the DDI mounted and features reported, a 27.0.1 stream starts but shows+black, and the guest's `FigVirtualDisplayProcessor` reports `Submits 0 /+Encodes 0`. backboardd logs, about fifty times a second:-**`dhtest-ipad`, `iPad16,1 26.6.2 (23G90)` (2026-10-06):** prototype pushed-through the environment update (built in the `libbatteryhealthfix.dylib` slot,-with a SystemHook that inserted that slot into `dtremotedisplayd`). The hook's-log showed `features=0x8c current=interposed isCustomerRestricted=interposed`.-DeviceHub then received `supportedFeatures: 140 (Primary video display-mirrored output stream, System audio output stream, Display information)`,-`MediaStreamStart` returned success, and the window opened with-`devices://device/open?id=<CoreDevice identifier>` showed the guest's home-screen live. The user's own 26.6.2 iPad, without the hook, kept answering 0-throughout.--The same day, on the built bundle (`2.6.1-local`, bound with `vm set-bundle---update-environment`): after a cold start SystemHook logged-`dtremotedisplayd decision=inserted+devicehubfix` and the view came up again.--**`dhtest-iphone27`, `iPhone17,3 27.0.1 (24A446)` (2026-10-06):** without the-hook the DDI never mounted (above). With it `cryptexd` logged-`F_SETPROTECTIONCLASS EPERM, reported as ENOTSUP` once, CoreDevice showed the-device as `connected` with DDI services, DeviceHub received 140 and-`MediaStreamStart` succeeded — and the view stayed black while the guest's own-screen was on and unlocked.--## Open: a black view on iOS 27--**Reverse-engineering result (2026-10-06):** the shared-cache force-kern patch was-reproduced against the local `24A446` cache. `_kern_SwapEnd` and the other-`_kern_Swap*` implementations load the connection's IOConnect port from-`[x0,#0x14]`; a zero value is the exact state that produces-`MACH_SEND_INVALID_DEST` on display 2. The public trampolines now use a-four-instruction dispatcher:+```text+[WindowServer] display 2 get_wireless_surface_options returned error e00002d5 / e00002be+[WindowServer] display 2 swap_end returned error 10000003+```++Display 2 is the capture display the stream adds. `10000003` is+`MACH_SEND_INVALID_DEST`.++The cause is the iOS 27 force-kern patch (row 11 of the guest DSC table in+`Research/0_binary_patch_comparison.md`). iOS 27 presents the paravirtual+main display through IOMobileFramebuffer's in-process `_virt_Swap*` path,+which never reaches the 26.4 kernel's paravirtual GPU. The patch therefore+sent every public `_IOMobileFramebufferSwap*` call to `_kern_Swap*`, which+calls the kernel userclient. The capture display, however, is a genuine+virtual display: it has no userclient port, so its kernel swaps fail, and its+frames never reach the in-process consumer that `_virt_SwapEnd` hands surfaces+to. `get_wireless_surface_options` then has nothing to return+(`e00002be` is `kIOReturnNoResources`, `e00002d5` `kIOReturnBusy`).++Every `_kern_Swap*` implementation loads the connection's IOConnect port from+`[x0, #0x14]`. That port is non-zero for the paravirtual main display and zero+for the capture display.++### iOS 27 iPhone: no framebuffer mask++DeviceHub draws the screen inside a device chrome and clips it with a+framebuffer mask. The DDI's `dtdeviceinfod` (not `dtremotedisplayd`)+implements the DisplayInfo and DisplayInfoUpdates actions. It reads+`MGCopyAnswer("DisplayExtendedProperties")` and otherwise falls back to+`ChromeIdentifier` and `FramebufferIdentifier`. On the 27.0.1 guest these+answer `null`, `com.apple.dt.devicekit.chrome.phone11` and `null`. With a+chrome but no mask, DeviceKit falls back to a rounded rectangle and the+content runs over the bezel corners.++`/Library/Developer/DeviceKit/chrome_map.plist` maps `iPhone17,1` to `phone11`+with mask `4E5532ED-1470-47D1-BDF4-7AA90C26957A` (and `iPhone17,3` to+`phone9` with `A6AC96E7-…`). It has no entry for the guest's `iPhone99,11`.+`DeviceTreeGuestDevicePatches` deliberately keeps the virtual+`framebuffer-identifier` while copying the real board's chrome properties, so+the device tree is not the place to fix this. Matching the guest's resolution+to an iPhone 16 (1179x2556) did not change the overflow either.++## The fix++### `libdevicehubfix.dylib`++`VPhoneGuestComponents/DeviceHubFix/libdevicehubfix.c`, installed as+`/usr/lib/libdevicehubfix.dylib`. Both spawn hooks insert it into three+processes only (`vpIsDeviceHubFixTarget` in `Shared/InjectionEnvironment.h`):++- **`cryptexd`**: interposes `fcntl`. An `EPERM` from `F_SETPROTECTIONCLASS`+ is reported as `ENOTSUP`, which takes the path `cryptexd` already has for a+ filesystem without protection classes. Every other call and failure is+ untouched.+- **`dtremotedisplayd`**: interposes `MediaStreamSupportedFeatures.current`,+ which answers `0x8c` (what a Mac host reports for itself; the host+ intersects it with its own), and `CurrentDevice.isCustomerRestricted`, which+ answers false. The struct is resilient (the framework is built for library+ evolution), so the getter returns it indirectly through `x8`; the+ replacement is three instructions of assembly.+- **`dtdeviceinfod`**: interposes `MGCopyAnswer`. Only when+ `FramebufferIdentifier` is missing and `ChromeIdentifier` is exactly+ `phone11`, it answers with Xcode's matching mask `4E5532ED-…`, retained under+ the Copy ownership rule. Existing answers and other chromes are unchanged.+ This is display metadata, not a change to the guest's hardware identity.++Interposing works because `cryptexd`, `dtremotedisplayd`, `dtdeviceinfod` and+`CoreDeviceUtilities` are standalone images, not shared-cache ones, so dyld+binds their imports through the interposing table. `CoreDeviceUtilities` lives+on the DDI and not in the SDK, so its two symbols are weak flat-namespace+imports (`-Wl,-U`) and resolve to nothing in `cryptexd`.++The library ships with `system-launchdaemons-boot-environment`. An existing+guest gets it from the environment update when it next starts on a bundle+that has it.++### Conditional IOMFB dispatch++`DyldSharedCacheIOMFBForceKernPatcher` now rewrites each public swap+trampoline as:```textcbz x0, <original failure>-ldr w16, [x0, #0x14]+ldr w16, [x0, #0x14] ; IOConnect port, zero for the capture displaycbnz w16, _kern_Swap<Name>b _virt_Swap<Name>```-`x16` is scratch, so the public ABI arguments survive both direct branches.-The patch discovers the public, `_kern_`, and `_virt_` siblings by symbol name,-keeps the original null-connection target, emits the branch and load bytes-through `ARM64Encoder`, and re-attests the full 16-byte write span. It upgrades-an older unconditional force-kern patch in place and is idempotent. On the-local 27.0.1 cache it classified 10 public entry points (including-`SwapBegin`, `SwapEnd`, and `SwapSetLayer`), left `SwapSignal` on its existing-virt implementation because it is not a thin trampoline, updated four code-signature slots, and passed the second-run no-op check.--**Deployment audit correction (2026-10-07):** prior statements that the-conditional patch had reached the guest were not proven. `applyDyldPatches`-skips an enabled patch when its identifier is already in the Guest receipt.-The guest undo log still contains 31 four-byte originals for force-kern,-whereas the new implementation writes ten 16-byte sites. A successful CFW-install and a receipt containing the identifier do not establish the new bytes.-Direct cache readback and an explicit revert/reapply are required next.--The host control socket's `screenshot` command calls the guest screenshot-API; it does not capture the VZ view. DeviceHub's saved screenshot also-shows the home screen, while its live panel is black. Neither screenshot-proves VZ scanout or live-stream success.--The attempted `0xcc` experiment replaced a raw byte sequence without-verifying the function instruction or the installed content. It is invalid-as an A/B test. Disassembly of the read-back guest hook currently confirms-`vpCurrentFeatures: mov x9,#0x8c; str x9,[x8]; ret`.--Actual evidence retained: the 26.6.2 DeviceHub live panel renders, the 27.0.1-panel is black, and a 60-second all-process capture reports-`FigVirtualDisplayProcessor Submits 0 / Encodes 0`. The SDK identifies-`e00002be` as `kIOReturnNoResources` and `e00002d5` as `kIOReturnBusy`.-Static IOMFB analysis shows a no-resources return when all 16 outstanding-surface-token slots are occupied; errors can also propagate from the-provider callback. It does not prove an empty resource table.--The proposed default-surface fallback was removed before guest deployment:-it overwrote the normal allocation block and failed to unwind the caller's-stack before tail-calling. Do not deploy `/tmp/vphone-bundle-fallback`.--During the 27.0.1 stream backboardd logs, about fifty times a second,+`x16` is an intra-procedure-call scratch register, so the arguments reach+either implementation intact. The public, `_kern_` and `_virt_` siblings are+resolved by name; only operations with all three take part, and `SwapBegin`,+`SwapEnd` and `SwapSetLayer` must be covered. Capstone checks the trampoline+shape and the port load's operands, `ARM64Encoder` produces all four words+(`encodeCompareBranch` is new, pinned against keystone), and the 16-byte write+spans are re-attested. On 24A446 it rewrites ten entry points and leaves+`SwapSignal`, which is not a thin trampoline, on its existing path. The+`0x14` port offset was verified on 24A446 only.++### Upgrading an existing iOS 27 guest++The patch identifier did not change, and `applyDyldPatches` skips an enabled+patch whose identifier is already in the guest receipt. A guest installed+with the old unconditional patch therefore keeps its 31 four-byte sites until+they are reverted:++1. Stop the VM and run `fw set-patches --block dyld-boot-iomfb_force_kern`,+ then `cfw update-environment`. This reverts the old sites.+2. Restore the standard selection and update again with the new bundle. It+ writes ten 16-byte sites; the guest's undo log should list ten 16-byte+ originals.++A successful install and a receipt listing the identifier do not prove which+bytes are in the cache; read the undo log or the cache itself. A new+`vm create` needs none of this.-```text-[WindowServer] display 2 get_wireless_surface_options returned error e00002d5 / e00002be-[WindowServer] display 2 swap_end returned error 10000003-```+## Validation-Display 2 is the capture display the stream adds; the 26.6.2 iPad logs none of-this while streaming. The frames die in the IOMobileFramebuffer swap path for-that display, the same layer rows 9 and 11 of-`Research/0_binary_patch_comparison.md` patch for the main display-(`_kern_SwapEnd`, the `_IOMobileFramebufferSwap*` trampolines). That is where-the next step starts. A `locationd` crash (`EXC_ARM_PAC_FAIL`) on the same-guest predates the hook and does not involve it.--## Verified reapplication and remaining display quality (2026-10-07)--The actual reapplication used the existing `devicehub-screen` worktree with-only the conditional IOMFB implementation and compare-branch encoder copied-in. Bundle `2.6.1-local.8aa77f2e` includes the original DeviceHub hook. With the-VM stopped, `fw set-patches --block dyld-boot-iomfb_force_kern` followed by-`cfw update-environment` reverted all 31 old four-byte sites. Restoring the-standard selection and updating with the new bundle wrote ten 16-byte sites,-re-attested four slots, and passed post-write decoding. The running guest's-undo log independently reports ten 16-byte originals. DeviceHub then showed-the home screen and subsequently Settings in its live panel.--The user reports large latency and content extending over the bezel corners.-These remain open. Guest stats now show 41–49 encodes/second rather than zero;-host receiver stats show about 54 fps, a 100 ms jitter buffer, and no transport-queue backlog in the sampled interval. One player sample was roughly 300 ms-behind its display-link timestamp. These are not an end-to-end latency test.--Changing the stopped guest from 1290x2796 to 1179x2556 was tested; the guest-confirmed 393x852 points at scale 3, but the rounded-corner overflow persisted.-The original dimensions are being restored. Matching the iPhone16 dimensions-alone is not a fix. The main VZ window still requires direct visual verification;-guest screenshots must not be used as evidence of host scanout.--Recovery and next discriminators: after restoring the 1290x2796 configuration,-vphoned timed out once although the VZ window visibly showed the home screen.-A controlled stop/start recovered the API, which now reports 430x932 points.-The VZ window was inspected directly through its installed bundle path;-scanout is confirmed, independently of the guest screenshot RPC.--The user measures roughly 1–3 seconds of lag, greater than the sampled-100 ms jitter buffer. Separate HID arrival from video delivery before-changing frame pacing. DeviceKit contains `loadFramebufferMaskAndChrome`,-`FramebufferMaskIdentifier`, and an explicit fallback to RoundedRectangle-when `showFramebufferMask` is true but a mask image is unavailable. Host logs-confirm chrome `com.apple.dt.devicekit.chrome.phone11` loads; they do not yet-prove which mask (if any) was selected. Missing/mismatched mask is a hypothesis,-not yet a verified cause or a reason to edit host Xcode binaries.--Mask lookup evidence: `/Library/Developer/DeviceKit/chrome_map.plist` maps-`iPhone17,3` to `phone9` and mask `A6AC96E7-C5D3-47A6-8967-A8B2D02F1C66`,-`iPhone17,1` to `phone11` and mask `4E5532ED-1470-47D1-BDF4-7AA90C26957A`.-There is no `iPhone99,11` entry. DeviceHub logs requested `phone11` for this-guest. `DeviceTreeGuestDevicePatches` explicitly preserves the virtual-`framebuffer-identifier` while copying real-board chrome properties. Inspect-the DDI display-info mask identifier next; the combination is suspicious but-not proof of the runtime fallback. Do not change the framebuffer identifier-in the device tree before tracing its other consumers.--Current DDI inputs for follow-up: `/tmp/dh-CoreDeviceUtilities` is the full-12,372,992-byte guest binary (`truncated:false`), version 642.16; its arm64e-slice is `/tmp/dh-CDU-arm64e`. Use thin-slice symbol addresses: fat-file `nm`-prints the arm64 slice first, whose addresses differ. The arm64e-`Display.framebufferMaskIdentifier` getter is at 0x33ea54; provider's default-fetch closure is at 0x343a00, async function pointer at 0x4064d0 resolves to-0x343b0c. `FramebufferIdentifier` literal is at 0x425a60. The DDI binary-imports MobileGestalt and has both ChromeIdentifier and FramebufferIdentifier-literals. A targeted xref analysis is running as exec session 95254 with output-`/tmp/dh-mask-xref.txt` (inspect current process state before waiting).--DDI arm64e xrefs completed: function 0x350f94 reads-`MGCopyAnswer("DisplayExtendedProperties", NULL)`, otherwise falls back to-`MGCopyAnswer("ChromeIdentifier", NULL)` at 0x351104 and-`MGCopyAnswer("FramebufferIdentifier", NULL)` at 0x3511a4.-`dtdeviceinfod` contains the DisplayInfo and DisplayInfoUpdates action-implementations, rather than dtremotedisplayd. An observational interpose-in the existing DeviceHub hook now logs only these three answers for-`dtdeviceinfod`, up to 12 queries, without modifying ownership or values.-The dedicated worktree includes its spawn target and negative suffix test;-`test-injection-environment` passes and the complete bundle builds.-Diagnostic bundle: `2.6.1-local.238f9151`; deployment log-`/tmp/dh-diag-update.log`, exec session 37312 (verify status before waiting).--Diagnostic readback from dtdeviceinfod PID 269 confirms:-`DisplayExtendedProperties = null`,-`ChromeIdentifier = com.apple.dt.devicekit.chrome.phone11`,-`FramebufferIdentifier = null`. The next build fills only that missing-FramebufferIdentifier in dtdeviceinfod when chrome is exactly phone11, using-Xcode's matching mask `4E5532ED-1470-47D1-BDF4-7AA90C26957A` and retaining the-CF result under the original Copy ownership contract. Existing answers and-other chrome types are unchanged. This is display metadata, not a change to-virtual hardware identity. Build session 88613, `/tmp/dh-mask-fix-build.log`;-visual validation and latency work remain pending.--**Mask fix verified (2026-10-07 09:02 local):** installed-`2.6.1-local.6a68184b`; dtdeviceinfod PID 272 now returns the phone11 mask UUID.-DeviceHub logged `Found FramebufferMaskIdentifier from displayInfo` with that-UUID at 09:01:54.327. Direct DeviceHub screenshots of both the home screen and-Settings show all four corners clipped inside the chrome. Resolution remains-1290x2796. This closes the corner-overflow issue, not the latency issue.-A Home button observation at roughly 564 ms after the UI action still showed-Settings; subsequent guest foreground query showed no verified app foreground.-It does not yet split HID delivery from capture delay. User follow-up about-remaining 1–3 second lag is pending.--## Cold-start timing audit (2026-10-07)--User reports current stream has no delay, but occasional 1–3 s lag starts at-boot. Healthy baseline player samples differ from last presentation by 3–20 ms.-First cold start settled at 14–16 ms. Second cold start's unlock request timed-out, although subsequent readback was unlocked. Its video session started-09:07:40; at 09:07:50 only six decode alarms had arrived over five seconds and-the previous presentation was 4.683 seconds old. By 09:07:55 it recovered to-5.8 ms and then 6–23 ms. This is a transient absence of frames, not evidence of-a persistently shifted playback clock. Compilation/tests were active during-this run, so repeat without host build load before attributing it to the guest.-Evidence: `/tmp/dh-timing-audit/cold2-host.txt` and `cold2-connect.txt`.--Seven updated real-cache conditional dispatcher tests pass, including dry-run,-idempotence, symbol discovery, and typed branch/port operands. A separate-Keystone parity/range test for compare branches also passes. Logs:-`/tmp/dh-conditional-tests-rerun.log`, `/tmp/dh-encoder-tests.log`.--User explicitly confirms cold2 was visibly stuttering; do not dismiss that-failure because cold3 was healthy. Full host log for 09:07:43–09:07:56 is-`/tmp/dh-timing-audit/cold2-fault-full.txt`. The player repeatedly reports-`alarmsSentForDecodeButNotDisplayedCount=16` at its threshold. Receiver reports-~56 fps, transport maxQueueDelay 0, and at 09:07:51.091 sends FIR with reason-`No video displayed timeout fail safe`. Playback recovers thereafter. This-supports investigating decoder/display scheduling or keyframe recovery, not-assuming no packets were being received or declaring build load the cause.--A temporary local app `com.vphone.devicehub.timingprobe` is installed on only-`dhtest-iphone27`. Source and IPA are under `/tmp/dh-timing-probe`. It displays-current guest epoch milliseconds at 30 Hz and a tap counter/color. It initially-crashed because iOS27 requires Scene lifecycle; the corrected SceneDelegate-build launches. At host capture interval 1791335680959–1791335681133 ms,-both the native VZ and DeviceHub screenshots showed 1791335680351. The common-host/guest offset must not be called DeviceHub latency. The comparative sample-shows no second-scale lag between displays in the healthy state. Remove the-probe after timing work; no production component depends on it.--### Cold4 and decoder-input refinement (2026-10-07 09:24 local)--Cold2 remains a user-confirmed failure. The full log narrows the observation:-VCPDec (1296x2816 HEVC) reports Input_fps=0 and Dec_fps=0 every second from-09:07:46 through 09:07:50, while the receiver's periodic report still records-packets and roughly 56 fps. The image queue's last enqueue is host time-452285.493, so a stale visible frame is established; decoder starvation is-observed, but capture failure versus packet assembly/reference recovery is-not yet separated. The threshold-16 warning also persists after presentation-recovers, so that warning alone is not a reliable failure detector.--Cold4 uses the same deployed bundle (6a68184b), with no build running during-the sample. Logs: `/tmp/dh-timing-audit/cold4-host.txt` and-`/tmp/dh-timing-audit/cold4-guest.json`. The 35-second guest sample contains-200 entries, steady ~30 fps encoding of the 30 Hz timing probe, no encode-drops, and ~9–11 ms encoder time. Host presentation samples remain ~15–18 ms-old. Direct VZ/DeviceHub screenshots both read 1791336178521 within host-capture interval 1791336178929–1791336179321. This is a healthy comparative-sample, not proof that intermittent startup lag is fixed. Other user VMs-remain running; host swap usage was about 17 GB, which is context rather than-a demonstrated cause.--The diagnostic probe now writes the runtime encoding of AVCVideoStream's-configure:error: to its own Documents/avc-types.txt: `B32@0:8@16^@24`.-This verifies BOOL/object/error-pointer shape only; no configuration key or-keyframe interval has been changed. Temporary probe remains installed for-further paired measurements and must be removed when diagnosis ends.--### Cold5–7, guest-side stall evidence (2026-10-07 09:33 local)--User confirms **VZ stayed fluid while DeviceHub stuttered in cold2**. This-is the key comparative observation; do not attribute cold2 to whole-guest-startup without contrary evidence. The temporary probe was rebuilt at 60 Hz.-Cold5 and cold6 paired screenshots show no seconds-scale difference. Cold5-has four host player samples (maximum presentation age 22.824 ms); cold6 has-seven (maximum 12.55 ms), no no-video timeout FIR. Cold5 guest encoding reaches-60 fps with no drops. These are bounded healthy runs, not a latency fix.--Repro script `/tmp/dh-cold-run.zsh` operates only on dhtest-iphone27, captures-host logs, polls actual stopped state, starts the VM, collects guest logs,-then unlocks/launches the probe. Summary script `/tmp/dh-timing-summary.rb`-identifies the latest new player by its tick-zero record. Cold7 unlock timed-out; the script exited and stopped host streaming. The already-running guest-log finished normally. No duplicate VM restart was attempted. Subsequent-unlock and probe launch succeeded (PID 374). Host history recovered the-missing interval into `/tmp/dh-timing-audit/cold7-full-host.txt`.--Cold7 is not yet the same confirmed failure as cold2: an early screenshot-showed VZ still at the boot logo (8 fps), DeviceHub connecting, and the probe-had not launched. Nevertheless paired logs expose a concrete guest-side-anomaly. Guest AVConference encoder/FigVirtualDisplayProcessor reports stop-between 01:31:28Z and 01:31:45Z, while VTP health messages continue. At-01:31:45Z, 22 VTP_Send calls fail with errno 55 (ENOBUFS, verified against-Xcode SDK sys/errno.h), and the encoder reports 124.65 ms encode time. Host-HEVC decoder input drops to 0–4 fps for much of that interval, with player-presentation ages up to ~6.6 seconds. This is evidence of a guest capture /-encoder / send-path interruption; ENOBUFS may be a consequence of the burst-on recovery, not the initiating cause. Detailed timeline:-`/tmp/dh-timing-audit/cold7-encoder-timeline.txt`.--Next investigate the guest encoder/capture thread during a reproduced stall,-including scheduling and queue waits, before altering periodic keyframes.-The keyframe configuration path was statically traced in pristine 24A446:-AVCVideoStreamConfig.dictionary emits vcMediaStreamKeyFrameInterval;-VCVideoStreamConfig.applyVideoStreamClientDictionary reads it;-VCVideoTransmitterDefault.initWithConfig passes it into its transmitter-configuration. A different VT stream-transmitter path maps it to-MaxKeyFrameIntervalDuration, but that alone does not establish semantics of-the active HEVC path. No production keyframe/LTRP configuration was changed.-Evidence disassemblies are `/tmp/dh-avc-*.txt`; no IDA MCP was available, so-local ipsw cache disassembly was used. Do not paste raw disassembly in chat.--### Thread profiling established (2026-10-07 09:44 local)--Used the existing safe guest profiling procedure in-`Research/Guest/display_refresh_rate.md`. Never run a host VM-process sample-at the same time as guest spindump. A temporary launchd job under /var/tmp-runs /usr/sbin/spindump; after each finished capture it is unloaded and-verified not loaded. No production hooks or configuration changed.--Healthy baseline: 8 seconds, `/tmp/dh-healthy-spindump.txt` (5,643,448 bytes,-readback not truncated). avconferenced encoder thread is normally mostly-waiting for work (167/240 samples), with 51/240 samples in frame checksum-pixel transfer through VideoToolbox / IOSurfaceAccelerator. This is normal-baseline evidence, not proof that this path causes the intermittent stall.-Symbolicated excerpt: `/tmp/dh-healthy-avc-symbolicated.txt`.--Cold8: 35-second whole-guest capture, `/tmp/dh-cold8-spindump.txt`-(16,807,571 bytes, readback not truncated), six host player health samples,-maximum presentation age 6.344 ms, no no-video timeout FIR. Probe initially-launched verified PID 378, but the later screenshot showed Home, so this is-not a verified full-duration continuous-probe test. No new TimingProbe crash-report appeared (only the initial 09:12 lifecycle crashes exist).--Cold9 validated a much cheaper targeted capture:-`spindump avconferenced 40 20 -onlyTarget -wait -noBinary -file <report>`.-It exits 0, and the text report is 140,796 bytes, containing 955 samples of-avconferenced. Guest encoding stayed around 58–60 fps; seven host samples-have maximum presentation age 5.656 ms, no timeout FIR. Report:-`/tmp/dh-cold9-avc-symbolicated.txt`. Use this targeted recipe next time so-report transfer and unrelated process sampling do not dominate diagnosis.-The temporary com.vphone.devicehub.spindump job is unloaded.--Symbolication uses pristine 24A446's per-image symbols with runtime cache-base 0x180000000 (zero slide here), via `/tmp/dh-symbolicate.rb`; symbol dumps-are `/tmp/dh-{avc,VideoToolbox,CoreMedia,VideoProcessing,IOSurfaceAccelerator}-symbols.txt`.-Do not reuse zero slide for another guest without checking its report header.-Host currently has 64 GiB RAM, 18 logical CPUs; memory_pressure reported 70%-free, so its ~15 GiB historical swap allocation is not proof of current-memory pressure. Cold7 CoreDevice tunnel history shows old connection-teardown before the new video stream, no established transport root cause.--Settings real-content check: direct guest input.swipe from (215,800) to-(215,300) moved the list, and direct VZ/DeviceHub screenshots showed the same-result with correct masks. This is functional display evidence, not a precise-latency measurement. CUA scroll/drag in DeviceHub itself did not visibly move-the list, so DeviceHub-input verification remains separate and inconclusive;-do not claim that end-to-end interaction passed from the direct guest swipe.-Cold2 remains the user-confirmed VZ-fluid / DeviceHub-stuttering failure;-no current evidence supports closing the intermittent-lag issue.--### Cold10–12 and bounded load comparison (2026-10-07 09:53 local)--Cold10: nine post-start host samples, maximum presentation age 13.658 ms;-guest encoding 59–60 fps; direct VZ and DeviceHub timestamp captures differed-by 34 ms in a 423 ms capture window. Targeted spindump readback was 143,528-bytes, not truncated. No matching fault captured.--Cold11 deliberately reran the same real-cache patch tests that were active-during cold2 (not an arbitrary CPU stressor). All seven tests passed again:-`/tmp/dh-timing-audit/cold11-load-tests.log`. The VM's vphoned did not answer-within 90 seconds and a subsequent ping still said guest not connected. Thus-no guest profiler was loaded in this round. The guest UI itself was alive:-native HID swipe dismissed Lock Screen and both VZ/DeviceHub displayed Home.-Host video samples reached a maximum presentation age of 239.904 ms, not the-cold2 multi-second fault. The guest console logged APFS transaction waits of-~1–1.7 seconds. This cannot establish a cause for cold2. After both test and-startup command were terminal and control stayed offline, cold12 restarted-the same VM without test load; vphoned connected in four seconds.--Cold12: nine new-stream samples, maximum presentation age 10.025 ms, guest-encoding ~58–61 fps; 35-second backboardd capture has 73 entries, not-truncated, and no swap_end / get_wireless_surface_options / invalid-dest-match. Targeted profiling ended and its temporary job was unloaded. Latest-report JSON: `/tmp/dh-cold12-spindump.json`.--The summary parser was corrected to discard all health lines preceding the-last tick-zero initialization, not merely match the player pointer. The-allocator reused the cold11 player address in cold12; a 4-second presentation-age from the old closing stream otherwise falsely contaminated the new run.-Recomputed cold4–10 figures are unchanged. Do not use pointer identity alone-across a stream restart. Health-age samples still do not measure full input-latency or prove the intermittent problem fixed.--Code comments now describe the current conditional dispatcher, its actual-real-cache tests, and the third DeviceHubFix injection target (dtdeviceinfod).-Removed stale claims that Python is executed or current output must match the-old unconditional patch digest. These are comment-only edits. Awaiting the-user's current visual observation before repeating the same cold-start matrix.--Startup-readiness hypothesis checked against current DDI arm64e:-MediaStreamSupportedFeatures.current at 0x392f38 calls CurrentDevice.init at-0x329850 and returns no features if device identity cannot be constructed.-The initializer's required optional inputs are versionNumber, buildUpdate,-and deviceType (0x329c88, 0x32a284, 0x32aacc). This does not establish a-SpringBoard/compositor-ready gate, so do not add an arbitrary startup delay-or claim the support-info interpose skipped such a gate. Disassemblies:-`/tmp/dh-cdu-current-features.txt`, `/tmp/dh-cdu-currentdevice-init.txt`.+- **`iPad16,1 26.6.2 (23G90)`, new test VM.** DeviceHub receives+ `supportedFeatures: 140`, `MediaStreamStart` succeeds for audio and video,+ and the view shows the live home screen, also after a cold start on the+ built bundle. SystemHook logs `inserted+devicehubfix` for `cryptexd` and+ `dtremotedisplayd`. `cryptexd` never takes the `EPERM` path on 26.x. An+ unpatched 26.6.2 iPad kept answering 0 throughout.+- **`iPhone17,3 27.0.1 (24A446)`, new test VM.** Without the hook the DDI+ never mounts. With it the hook logs `F_SETPROTECTIONCLASS EPERM, reported as+ ENOTSUP` once and the device becomes `connected` with DDI services.+ - With the old patch the stream starts but stays black (above).+ - After reverting and reapplying with the conditional dispatch, the VZ+ window still scans out, the guest encodes 41–60 fps, and DeviceHub shows+ the home screen and Settings live.+ - With the mask, DeviceHub logs `Found FramebufferMaskIdentifier from+ displayInfo` with the `phone11` UUID, and the home screen and Settings are+ clipped inside the chrome at all four corners.+ - A swipe sent to the guest moved the Settings list identically in the VZ+ window and in DeviceHub.+- **Tests.** `InjectionEnvironmentTests` covers the three targets and their+ near-miss suffixes. The real-cache force-kern tests cover conditional+ routing, the preserved null check, symbol discovery, dry run and+ idempotence. `ARM64CompareBranchTests` pins the new encoder.++Touch input sent from inside DeviceHub reaches the guest (checked by hand),+but has no automated check.++## Open++### Latency grows over a long session++Measured on the 26.6.2 iPad from a guest screen change (an `apps.launch` RPC)+to the first changed DeviceHub frame; the VM's own window takes about 0.4 s+for the same change:++| Stream age | DeviceHub |+| --- | --- |+| new | 0.48 s |+| about 12 min | 0.55–0.59 s, rising in steps |+| about 50 min | 2.6 s |++Recreating the stream (killing the guest's `avconferenced`) resets it.++Ruled out:++- **Mac receiver.** For the whole session the video jitter queue stays at+ 100 ms (briefly up to 500 ms), one frame is pending, and the playback offset+ is constant. The image queue displays about 25 ms after enqueue. DeviceHub+ and `avconferenced` use a few percent CPU.+- **Guest encoder and transport.** HEVC encoding takes about 5 ms a frame,+ RTT is 2 ms, the one-way delay estimate 9 ms, with no loss.+- **The audio stream.** The audio path is unhealthy (erasures, late packets,+ an audio jitter queue that reached 11.76 s before it was discarded), but a+ video-only stream (features `0x84`) grew at the same rate.+- **Clock drift.** The guest's monotonic clock runs within 3 ppm of the host's.++So the frames already carry late timestamps when they reach the Mac. The+likely place is the guest's mirroring into the capture display, ahead of the+encoder (backboardd to `FigVirtualDisplayProcessor`). Confirming it needs+per-frame timing inside the guest; the logs are too coarse.++### Stalls after a cold start++Separately, on the 27.0.1 iPhone, DeviceHub sometimes stuttered for a few+seconds right after a cold start while the VZ window stayed fluid. In the one+confirmed case the Mac's HEVC decoder received nothing for about five seconds+while the receiver still counted packets. DeviceHub then sent a FIR with+reason `No video displayed timeout fail safe` and recovered. In another cold+start, while the guest was still booting, the guest's encoder and+`FigVirtualDisplayProcessor` reports stopped for about 17 seconds while+transport health messages continued. On recovery, 22 `VTP_Send` calls failed+with `ENOBUFS` and one encode took 125 ms, which looks like a consequence of+the burst rather than its cause. Nine other cold starts were healthy (newest+presentation under 25 ms old), and a run under the same test load as the+failure peaked at 240 ms. This also points at the guest's capture or encode+path.++`alarmsSentForDecodeButNotDisplayedCount=16` stays at its threshold even+after presentation recovers, so that warning is no failure detector.++### Other++- iPad guests on 27.x were not tested.+- The `0x14` port offset in the conditional dispatch is fixed, not derived;+ check it on the next 27.x build.++## Measuring++- **Open a guest in DeviceHub without clicking:** `open+ "devices://device/open?id=<CoreDevice identifier>"`, using `identifier` from+ `xcrun devicectl list devices --json-output -` (not the UDID). It opens or+ raises a viewer window and starts the stream.+- **DeviceHub's windows are not in the accessibility tree.** Capture them+ with `screencapture -x -o -l <CGWindowID>`, the ID from+ `CGWindowListCopyWindowInfo` filtered by DeviceHub's pid.+- **Latency:** take a base frame, change the guest screen through vphoned, and+ capture repeatedly until the centre of the frame differs; repeat on the VM+ window for the baseline. A guest app that draws the guest's epoch+ milliseconds at 60 Hz allows paired VZ/DeviceHub screenshots instead; a+ common host/guest offset is not DeviceHub latency.+- **Host logs:** `/usr/bin/log show` (zsh shadows `log`). In DeviceHub,+ `MediaStreamGetSupportInfo` and `MediaStreamStart` replies. In the Mac's+ `avconferenced`, `Health: VideoReceiver` (`videoJitterQueueSize`),+ `Health: VCVideoPlayer` (presentation times) and `VCPDec` (decoder input).+ Player addresses are reused across streams, so start a stream's series at+ its `displayLinkTickCount=0` line rather than matching the pointer.+- **Guest logs:** vphoned `logs.syslog` takes `level` `all`, `error` or+ `fault`; info lines are not persisted. `avconferenced` prints+ `fvdp_statsReport`, `VCPEnc` and `Health: VideoTransmitter` every second.+- **Guest profiling:** follow `Research/Guest/display_refresh_rate.md` and+ never sample the host VM process at the same time. A targeted capture is+ enough: `spindump avconferenced 40 20 -onlyTarget -wait -noBinary -file+ <report>`.+- **Restarting the stream:** `processes.kill` sends `SIGTERM` by default,+ which `dtremotedisplayd` ignores; pass `"signal": "KILL"`. The stream+ itself lives in `avconferenced`.+- **Screenshots are no evidence of scanout.** vphoned's `screen.screenshot`+ and the control socket's `screenshot` read the guest, and DeviceHub's saved+ screenshot showed the home screen while its live panel was black. Look at+ the VZ window and DeviceHub's live panel directly.diff --git a/VPhoneGuestComponents/DeviceHubFix/libdevicehubfix.c b/VPhoneGuestComponents/DeviceHubFix/libdevicehubfix.cindex 46ac9f86..8aa6dacf 100644--- a/VPhoneGuestComponents/DeviceHubFix/libdevicehubfix.c+++ b/VPhoneGuestComponents/DeviceHubFix/libdevicehubfix.c@@ -1,8 +1,9 @@// libdevicehubfix.c — let Xcode's DeviceHub show a vphone guest's screen.//// DeviceHub (Xcode 27) views a device through the developer disk image's-// dtremotedisplayd. Guest compatibility also requires DDI mounting and display-// metadata from dtdeviceinfod.+// dtremotedisplayd. On a vphone guest it needs three fixes, one per process:+// cryptexd mounts the DDI, dtremotedisplayd reports media stream features,+// and dtdeviceinfod supplies the framebuffer mask.//// ## cryptexd: the DDI does not mount on iOS 27//@@ -55,20 +56,22 @@//// ## dtdeviceinfod: missing framebuffer mask//-// The virtual board reports phone11 chrome with no FramebufferIdentifier.-// Supply the matching Xcode mask only for that missing answer in dtdeviceinfod,-// preserving existing answers and MobileGestalt's Copy ownership contract.+// dtdeviceinfod answers DeviceHub's DisplayInfo from MobileGestalt. The 27.x+// iPhone guest reports `ChromeIdentifier` phone11 but no `FramebufferIdentifier`,+// so DeviceHub falls back to a rounded rectangle and draws the screen over the+// bezel corners. Only that missing answer is filled, with the phone11 mask from+// Xcode's /Library/Developer/DeviceKit/chrome_map.plist; existing answers and+// other chromes pass through, and the result keeps the Copy ownership rule.//// ## Reach//// The interposes reach their callers because cryptexd, dtremotedisplayd,-// dtdeviceinfod and-// CoreDeviceUtilities are standalone images, not shared-cache ones: dyld binds-// their imports through the interposing table. CoreDeviceUtilities is on the-// DDI and not in the SDK, so its two symbols are weak flat-namespace imports;-// in cryptexd they resolve to nothing and dyld skips those entries. The spawn-// hooks insert this into those three processes only — `vpIsDeviceHubFixTarget`-// in Shared/InjectionEnvironment.h.+// dtdeviceinfod and CoreDeviceUtilities are standalone images, not shared-cache+// ones: dyld binds their imports through the interposing table.+// CoreDeviceUtilities is on the DDI and not in the SDK, so its two symbols are+// weak flat-namespace imports; outside dtremotedisplayd they resolve to nothing+// and dyld skips those entries. The spawn hooks insert this into those three+// processes only — `vpIsDeviceHubFixTarget` in Shared/InjectionEnvironment.h.#include <errno.h>#include <fcntl.h>