Run a virtual iPhone on an Apple Silicon Mac.
Swift
Record experimental iPhone Duo bring-up and compatibility limits
Lakrbf8f7929a063
diff --git a/Research/0_binary_patch_comparison.md b/Research/0_binary_patch_comparison.mdindex 2d30034b..41b8dedb 100644--- a/Research/0_binary_patch_comparison.md+++ b/Research/0_binary_patch_comparison.md@@ -1,5 +1,17 @@# Patch Comparison: Regular / Development / Jailbreak / Experimental+> **iPhone Duo bring-up (2026-10-23, first boot fails):**+> `iPhone19,4` / V68AP, iOS 27.1 (24A94425), is registered with one outer+> display and paired with cloudOS 26.4 (23E5207q). Its device tree reports+> `arm64e.x1`. This exercises the existing standard iOS 27 / ARM64E_X1 patch+> selection on a new userland; it introduces no new instruction patch or+> preset. Restore and CFW install completed, but setup and a windowed boot+> panic with PID 1 SIGILL. Installed dyld still uses CSSC instructions that+> this Mac lacks and current X1 lowering does not cover; exact fault-site+> attribution remains unverified. Four optional VirtualAudio patches also+> failed. Neither successful boot nor dual-display/hinge support is established. See+> [inputs, evidence and boot results](Guest/iphone_duo_bringup.md).+> **Experimental full OTA System update (2026-10-20):**> `system-exp-ota_userland` is off in Standard and the TV presets. For a stopped> iPhone/iPad guest with a snapshot and prepared target firmware, it replacesdiff --git a/Research/Guest/iphone_duo_bringup.md b/Research/Guest/iphone_duo_bringup.mdnew file mode 100644index 00000000..9f29eae7--- /dev/null+++ b/Research/Guest/iphone_duo_bringup.md@@ -0,0 +1,110 @@+# iPhone Duo single-display bring-up++## Scope and inputs (2026-10-23)++This experiment attempts to boot the iPhone Duo userland on the existing+vphone600 virtual hardware. It registers one outer panel, not two displays or a hinge.+The inner panel, folding poses and physical Duo hardware are not emulated.++- Host: Apple Silicon, macOS 27.0.1 (26A434), without CSSC, CPA or PAuth_LR.+- Guest: `iPhone19,4`, board `v68ap`, iOS 27.1 (24A94425).+- IPSW: <https://updates.cdn-apple.com/2026FallFCS/3f41a447-d8a6-48ae-83ae-056a64f57fd4/iPhone19,4_27.1_24A94425_Restore.ipsw>.+- Size: 12,724,731,538 bytes.+- SHA-256, verified after download:+ `58fbfda85615e90221136d55288f64c9f41386510f8cd77feb8c9d20cc0a782e`.+- CloudOS: 26.4 beta (23E5207q), the existing recommended vphone600 image.+- Preset: `standard`; boot ROMs: the bundle's OpenAVB and OpenSEP.+- VM configuration: 8 CPUs, 8192 MiB RAM, 64 GiB disk, created without a template.+- Core Bundle: a local 2.12.0 build; installed and passed execution policy+ and host preflight.++## Evidence and initial implementation++The restore archive's `BuildManifest.plist` and `Restore.plist` both name+`iPhone19,4`, build 24A94425 and device class `v68ap`. Restore.plist records+CPID 33120 (`0x8160`), BDID 14 (`0x0e`), platform `t8160`.++The archive contains `Firmware/all_flash/DeviceTree.v68ap.im4p`. Its `/product`+records `app-macho-architecture = arm64e.x1`, `artwork-device-idiom = phone`,+`artwork-device-subtype = 2034`, `artwork-scale-factor = 3`, plus `display0`+and `display1` children. The former has display index 0, rotation 0 and scale+3; the latter has index 1, rotation 270 and scale 3. Those are source device+properties, not proof that both panels work in the VM.++The initial model entry uses the outer display's 1398 x 2034 pixels at 460+ppi and 3x, as published in [Apple's technical specifications](https://www.apple.com/iphone-duo/specs/).+The catalog adds only the released 27.1 IPSW, paired with the existing+recommended cloudOS. No new instruction patch or preset is introduced;+the current iOS 27 and ARM64E_X1 patches are exercised on this new userland.++`VPhoneCoreKitTests/GuestDeviceTests` and+`VPhoneCoreKitTests/FirmwareCatalogReportTests` passed: 26 tests total.+The complete `VPhone` Debug build passed. Its finished bundle and a ZIP+round-trip both passed strict, nested, all-architecture signature validation+before the local bundle was installed through Launchpad.++## Boot validation++**Result: does not boot to userspace on this host.** Firmware preparation,+boot-chain patching, DFU restore and CFW installation completed. Template+setup failed while waiting for vphoned because the guest panicked. A subsequent+windowed `vm start <name> --wait --timeout 300` reproduced it before any guest+agent connection or SpringBoard UI:++```text+initproc failed to start -- exit reason namespace 2 subcode 0x4 description: none+Panicked task ... pid 1: launchd+Kernel UUID: 784F88D3-2AF5-3D4A-AB00-365607646E44+```++Namespace 2/subcode 4 reports SIGILL. The saved user-space backtrace LR is not+a recovered fault PC or a verified unslid symbol address. Do not infer an+exact instruction from it without the image load address and fault state.+Runtime addresses and local machine identifiers are omitted from this record.+The VM was stopped after preserving the console log. Its disk,+firmware and installed guest environment remain available for investigation.++### Identified instruction compatibility gap++Host feature queries return zero for `hw.optional.arm.FEAT_CSSC`,+`hw.optional.arm.FEAT_CPA` and `hw.optional.arm.FEAT_PAuth_LR`.+The installed, already X1-lowered `/usr/lib/dyld` still contains scalar CSSC+instructions: for example `UMIN X8,X8,X1` at image offset `0x9570`, `UMAX`+at `0x8ba8`, and `CTZ W10,W21` at `0x1af04`. These are measured offsets in+the 24A94425 dyld, for investigation only, never patch-site constants.++`VPhoneArm64eX1Lowering` and the runtime X1 handler currently lower PAuth_LR+and CPA forms, not these CSSC operations. CSSC therefore is a confirmed+compatibility gap and a candidate explanation for the SIGILL, not yet a+proved fault-site attribution. The cache's early-boot closure and later+runtime code also need auditing before claiming 27.1 support. A safe fix+needs correct register width, operand aliasing, NZCV preservation and immediate+forms; replacing a min/max with an unconditional move is not equivalent.++### Other observed gaps++- Four optional VirtualAudio patches failed together because the old reveal+ expected a `retab` after the throw at `0x171cd0`:+ `system-virtualaudio-cfw-mute_set_throw`,+ `system-virtualaudio-cfw-speaker_protection_gate`,+ `system-virtualaudio-cfw-speaker_route_throws`, and+ `system-virtualaudio-cfw-volume_mode_precondition`.+- The shared-region preflight attempted the ordinary arm64e filename and+ skipped its check; later cache patching correctly found 79 X1 chunks and+ measured `sharedRegionSize = 0x17ce04000`, `maxSlide = 0x20000000`, then+ zeroed maxSlide. No cache-size overflow was reported by that later stage.+- Existing X1 lowering reported 2735 instructions in launchd, with zero+ unvisited candidates. This only counts the instruction forms it recognizes;+ it does not establish support for every instruction in the binary.++The registered model and catalog entry are experimental bring-up inputs,+not a claim of successful Duo support. No CSSC or audio patch was added by+this experiment. Supporting this firmware on hosts without CSSC requires+additional instruction compatibility work; emulating both displays and the+hinge is a separate gap. These results establish limitations of the current+implementation, not that supporting the device is technically impossible.++The original manifests and device tree were extracted by HTTP ranges with+the repository's `VPhoneRemoteZip`. Raw logs and scratch artifacts remain+local; host paths, per-machine identifiers and runtime addresses are not+included in this research record.diff --git a/VPhoneKit/VPhoneCoreKit/Firmware/VPhoneFirmwareCatalog.swift b/VPhoneKit/VPhoneCoreKit/Firmware/VPhoneFirmwareCatalog.swiftindex 835f60ea..74e642e0 100644--- a/VPhoneKit/VPhoneCoreKit/Firmware/VPhoneFirmwareCatalog.swift+++ b/VPhoneKit/VPhoneCoreKit/Firmware/VPhoneFirmwareCatalog.swift@@ -341,6 +341,10 @@ public enum VPhoneFirmwareCatalog {(devices: ["iPhone19,2"], releases: [("27.0.1", "https://updates.cdn-apple.com/2026FallFCS/8cd333d4-1025-4e89-99a2-1373d2b5bfcb/iPhone19,2_27.0.1_24A446_Restore.ipsw"),]),+ // Initial single-display bring-up; see Research/Guest/iphone_duo_bringup.md.+ (devices: ["iPhone19,4"], releases: [+ ("27.1", "https://updates.cdn-apple.com/2026FallFCS/3f41a447-d8a6-48ae-83ae-056a64f57fd4/iPhone19,4_27.1_24A94425_Restore.ipsw"),+ ]),]/// iPadOS releases, one entry per iPad IPSW, oldest first. Each IPSW alsodiff --git a/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestDevice.swift b/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestDevice.swiftindex 72a813cd..f02e9291 100644--- a/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestDevice.swift+++ b/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestDevice.swift@@ -124,6 +124,10 @@ public struct VPhoneGuestDevice: Sendable, Equatable {/// iPhone 18 Pro (V63AP): 1206x2622, 402x874 points.public static let iPhone19_2 = iPhone("iPhone19,2", "v63ap", "iPhone 18 Pro", width: 1206, height: 2622)+ /// iPhone Duo (V68AP), using only its outer display for initial bring-up.+ /// The inner display and hinge are not represented by the VM's single panel.+ public static let iPhone19_4 = iPhone("iPhone19,4", "v68ap", "iPhone Duo", width: 1398, height: 2034)+/// iPhone XS Max: 1242x2688 at 458 ppi, 414x896 points. Its IPSW carries the/// iOS 18 releases after 18.6, which the iPhone 16 never got; the research/// board's own iOS 18 kernel boots it (the 18.x kernelcache recipes, `minimal`@@ -226,7 +230,7 @@ public struct VPhoneGuestDevice: Sendable, Equatable {iPhone17_3,iPhone17_4, iPhone17_1, iPhone17_2, iPhone17_5,iPhone18_3, iPhone18_4, iPhone18_1, iPhone18_2, iPhone18_5,- iPhone19_2,+ iPhone19_2, iPhone19_4,iPhone11_6,iPad16_1,iPad15_7,diff --git a/VPhoneKit/VPhoneCoreKitTests/Firmware/FirmwareCatalogReportTests.swift b/VPhoneKit/VPhoneCoreKitTests/Firmware/FirmwareCatalogReportTests.swiftindex f2f1098b..7f9cb51c 100644--- a/VPhoneKit/VPhoneCoreKitTests/Firmware/FirmwareCatalogReportTests.swift+++ b/VPhoneKit/VPhoneCoreKitTests/Firmware/FirmwareCatalogReportTests.swift@@ -132,10 +132,11 @@ struct FirmwareCatalogReportTests {let firstRelease = switch guest.productType {case "iPhone18,5": "iOS 26.3.1"case "iPhone19,2": "iOS 27.0.1"+ case "iPhone19,4": "iOS 27.1"default: "iOS 26.0"}#expect(pairings.map(\.iosName).first == firstRelease)- #expect(pairings.map(\.iosName).last == "iOS 27.0.1")+ #expect(pairings.map(\.iosName).last == (guest.productType == "iPhone19,4" ? "iOS 27.1" : "iOS 27.0.1"))for p in pairings {#expect(p.device == guest.productType)#expect(p.iosURL.hasPrefix("https://updates.cdn-apple.com/"))diff --git a/VPhoneKit/VPhoneCoreKitTests/VirtualMachine/GuestDeviceTests.swift b/VPhoneKit/VPhoneCoreKitTests/VirtualMachine/GuestDeviceTests.swiftindex 0001c4ff..06efe5f0 100644--- a/VPhoneKit/VPhoneCoreKitTests/VirtualMachine/GuestDeviceTests.swift+++ b/VPhoneKit/VPhoneCoreKitTests/VirtualMachine/GuestDeviceTests.swift@@ -164,4 +164,19 @@ struct GuestDeviceTests {#expect(decoded.guestDevice == device)#expect(decoded.screenConfig == .init(width: 1206, height: 2622, pixelsPerInch: 460, scale: 3.0))}++ @Test+ func `iPhone Duo preserves its V68 identity and outer display in the VM`() throws {+ let device = try #require(VPhoneGuestDevice.detect(buildManifest: ["SupportedProductTypes": ["iPhone19,4"]]))+ #expect(device == .iPhone19_4)+ #expect(device.boardDeviceTreePath == "Firmware/all_flash/DeviceTree.v68ap.im4p")+ let manifest = VPhoneVirtualMachineManifest.newVM().updating(guestDevice: device)+ let decoded = try PropertyListDecoder().decode(+ VPhoneVirtualMachineManifest.self,+ from: PropertyListEncoder().encode(manifest),+ )+ #expect(decoded.guestProductType == "iPhone19,4")+ #expect(decoded.guestDevice == device)+ #expect(decoded.screenConfig == .init(width: 1398, height: 2034, pixelsPerInch: 460, scale: 3.0))+ }}