Run a virtual iPhone on an Apple Silicon Mac.
Swift
experiment: stage isolated iPhone 14 Pro iOS 16.6.1 bring-up
黑曜猫25259268dcb8
diff --git a/Research/0_binary_patch_comparison.md b/Research/0_binary_patch_comparison.mdindex b8cf435b..f089ed23 100644--- a/Research/0_binary_patch_comparison.md+++ b/Research/0_binary_patch_comparison.md@@ -5993,3 +5993,10 @@ vertex outputs, render targets); an argument kind the reflection reads in alayout the completion does not produce could still crash the compilerservice. With primitive restart no longer sent, an OpenGL ES 2 strip that drawsvertex 65535 is cut there.+## Local iPhone 14 Pro / iOS 16.6.1 experiment++The isolated experiment uses iPhone15,2 16.6.1 (20G81) with cloudOS 26.1 (23B85).+Existing older-userland SwapEnd, thread-guard and paravirtual-user-client patch+gates and the BSD-only Skywalk boot argument are enabled for this experiment.+The iOS 17 SpringBoard workaround remains gated to 17 until 16's own startup+blockers are measured. No boot or display success is claimed at this stage.diff --git a/Research/Guest/ios16_bringup.md b/Research/Guest/ios16_bringup.mdnew file mode 100644index 00000000..677cef50--- /dev/null+++ b/Research/Guest/ios16_bringup.md@@ -0,0 +1,32 @@+# Local iOS 16.6.1 bring-up experiment++Status: original IPSW restored; guest custom-firmware installation and normal+boot are still under investigation. No desktop success is claimed yet.++- Guest: iPhone 14 Pro, iPhone15,2/d73ap, 1179x2556 at 3x.+- Userland: iOS 16.6.1, 20G81.+- Boot chain and kernel: cloudOS 26.1, 23B85, vphone600.+- VM: 6 CPUs, 6144 MB RAM, 64 GB disk, no NIC.+- Apple IPSW: `https://updates.cdn-apple.com/2023SummerFCS/fullrestores/042-44327/EDD9D5D2-E1C0-4B64-B6B1-642E087BB595/iPhone15,2_16.6.1_20G81_Restore.ipsw`.+- IPSW SHA-1: `1d80ba85912850bb6cc62540730652b29e4c3e8e` (verified after download).++This branch enables the existing older-userland SwapEnd, thread-guard and+paravirtual-user-client declarations for 16, plus the BSD-only Skywalk boot+argument. It does not enable the iOS 17-specific SpringBoard library on 16.+Firmware preparation is restricted to this exact experimental pairing.++Initial validation: complete native bundle build and admission passed;+69 selected firmware/patch-model tests and 20 guest-device tests passed.+The original IPSW restore completed. Guest installation was then refused by+the host helper while walking the external library path, even though that+directory exists. A separate internal-disk copy is being used to distinguish+host path access from guest compatibility.++On the pristine 20G81 seputil, the existing patch resolved the complete+`%s/%s.gl` literal at 0x10001D3A4 through a code reference at 0x10000BEC4.+It changed only the filename field to `AA` and an immediate second run was+idempotent. This is an offline binary check, not evidence of a normal boot.++The internal copy and its bundle binding are ready. The full guest install is+currently waiting for the user's macOS administrator authentication. The UI+tool cannot access SecurityAgent. Normal boot remains untested.diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareGuestDisplayPatchSet.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareGuestDisplayPatchSet.swiftindex 25742dc1..353a0ddb 100644--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareGuestDisplayPatchSet.swift+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareGuestDisplayPatchSet.swift@@ -30,7 +30,7 @@ public enum FirmwareGuestDisplayPatchSet {summary: "Resizes the swap-end structure a 26.0, 18.x or experimental 17.7 userland submits.",target: .dyldSharedCache,applicability: VPhonePatchApplicability(- iOSBase: .oneOf([.release(major: 26, minor: 0), .major(18), .major(17)]),+ iOSBase: .oneOf([.release(major: 26, minor: 0), .major(18), .major(17), .major(16)]),),bootEssential: true,),diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareKernelBasePatchSet.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareKernelBasePatchSet.swiftindex 710ab1f2..2ba707ed 100644--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareKernelBasePatchSet.swift+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareKernelBasePatchSet.swift@@ -158,7 +158,7 @@ public enum FirmwareKernelBasePatchSet {the UI.""",target: .firmware(.kernelcache),- applicability: VPhonePatchApplicability(iOSBase: .oneOf([.major(18), .major(17)])),+ applicability: VPhonePatchApplicability(iOSBase: .oneOf([.major(18), .major(17), .major(16)])),bootEssential: true,),],diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareKernelCustomFirmwarePatchSet.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareKernelCustomFirmwarePatchSet.swiftindex 8c0477ef..bdd78f4c 100644--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareKernelCustomFirmwarePatchSet.swift+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareKernelCustomFirmwarePatchSet.swift@@ -322,7 +322,7 @@ public enum FirmwareKernelCustomFirmwarePatchSet {prewarm its shaders and crash-loops at every boot.""",target: .firmware(.kernelcache),- applicability: VPhonePatchApplicability(iOSBase: .oneOf([.major(26), .major(18), .major(17)])),+ applicability: VPhonePatchApplicability(iOSBase: .oneOf([.major(26), .major(18), .major(17), .major(16)])),),// MARK: Displaydiff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/Pipeline/FirmwarePipelineComponents.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/Pipeline/FirmwarePipelineComponents.swiftindex fc720c5d..8426c821 100644--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/Pipeline/FirmwarePipelineComponents.swift+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/Pipeline/FirmwarePipelineComponents.swift@@ -122,7 +122,7 @@ extension FirmwarePipeline {// Network.framework uses the BSD path (the 26.1-kernel skywalk// channel-create traps in the 18.x Network.framework and crash-loops// mDNSResponder → no DNS). Empty on 26.x bases (stock boot-args).- let extraBootArgs = (baseIs18 || iOSBase?.major == 17) ? "if_attach_nx=0x3" : ""+ let extraBootArgs = (baseIs18 || iOSBase?.major == 17 || iOSBase?.major == 16) ? "if_attach_nx=0x3" : ""// 1. AVPBooter — Apple's ROM, in the VM root. Patched when the plan keeps// the boot chain set. A machine booting OpenAVB has nothingdiff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/PatchSets/FirmwarePatchSetCatalogTests.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/PatchSets/FirmwarePatchSetCatalogTests.swiftindex 25e29d1b..578330a5 100644--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/PatchSets/FirmwarePatchSetCatalogTests.swift+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/PatchSets/FirmwarePatchSetCatalogTests.swift@@ -19,7 +19,7 @@ import VPhonePatchKitstruct FirmwarePatchSetCatalogTests {@Test func `iOS 17 desktop workaround is opt in and unavailable on other bases`() throws {let id = FirmwareGuestSystemPatchSet.ios17Desktop- for version in ["17.7", "18.6.2", "26.1", "27.1"] {+ for version in ["16.6.1", "17.7", "18.6.2", "26.1", "27.1"] {for enabled in [false, true] {var preset = FirmwarePatchSetCatalog.standardPresetif enabled { preset.selection = preset.selection.allowing([id]) }@@ -32,6 +32,18 @@ struct FirmwarePatchSetCatalogTests {}}+ @Test func `Local iOS 16 experiment selects older userland boot compatibility without the iOS 17 hook`() throws {+ let plan = try VPhonePatchPlan.resolve(+ preset: FirmwarePatchSetCatalog.standardPreset,+ patchSets: FirmwarePatchSetCatalog.bundled,+ iOSBase: VPhoneVersion("16.6.1"), cloudOS: VPhoneVersion("26.1")+ )+ #expect(plan.isEnabled("dyld-boot-iomfb_swapend"))+ #expect(plan.isEnabled("kernel-boot-thread_guard_violation"))+ #expect(plan.isEnabled(FirmwarePatchSetCatalog.paravirtUserClientsPatch))+ #expect(!plan.isEnabled(FirmwareGuestSystemPatchSet.ios17Desktop))+ }+@Test func `Experimental iOS 17 selects the older userland boot compatibility patches`() throws {let plan = try VPhonePatchPlan.resolve(preset: FirmwarePatchSetCatalog.standardPreset,diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swiftindex 15710bb1..9686ec12 100644--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift@@ -1753,7 +1753,7 @@ struct VPhoneCustomFirmwareInstaller {("dyld-boot-xpc_lwcr", "patch-xpc-lwcr", [dsc]),("dyld-boot-lockdown_mode", "patch-lockdown-mode", [dsc]),]- } else if version.hasPrefix("26.0") || version.hasPrefix("18.") || version.hasPrefix("17.") {+ } else if version.hasPrefix("26.0") || version.hasPrefix("18.") || version.hasPrefix("17.") || version.hasPrefix("16.") {dyld.append(("dyld-boot-iomfb_swapend", "patch-iomfb-swapend", [dsc, "--target-size", "0x560"]))}dyld += [diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneFirmwarePreparer.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneFirmwarePreparer.swiftindex 10a6f857..fd7824cf 100644--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneFirmwarePreparer.swift+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneFirmwarePreparer.swift@@ -101,6 +101,10 @@ enum VPhoneFirmwarePreparer {!(phone.version == "17.7" && device.productType == "iPhone15,4" && cloud.version == "26.1") {throw ValidationError("Experimental iOS 17 bring-up is limited to iPhone15,4 17.7 with cloudOS 26.1. Other pairings have not been validated.")}+ if phone.version.hasPrefix("16."),+ !(phone.version == "16.6.1" && device.productType == "iPhone15,2" && cloud.version == "26.1") {+ throw ValidationError("The local iOS 16 experiment is limited to iPhone15,2 16.6.1 with cloudOS 26.1.")+ }let ota: (file: URL, key: String?, version: String, build: String)?if device.restoreBase != nil || (device.family == .homePod && otaSource != nil) {ota = try resolveOTA(diff --git a/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestDevice.swift b/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestDevice.swiftindex bf27dc48..58232ed2 100644--- a/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestDevice.swift+++ b/VPhoneKit/VPhoneCoreKit/VirtualMachine/VPhoneGuestDevice.swift@@ -120,6 +120,9 @@ public struct VPhoneGuestDevice: Sendable, Equatable {/// Experimental iPhone 15 / iOS 17.7 desktop bring-up on cloudOS 26.1.public static let iPhone15_4 = iPhone("iPhone15,4", "d37ap", "iPhone 15", width: 1179, height: 2556)+ /// Local iOS 16.6.1 bring-up experiment on cloudOS 26.1.+ public static let iPhone15_2 = iPhone("iPhone15,2", "d73ap", "iPhone 14 Pro", width: 1179, height: 2556)+/// iPhone 16 Pro: 1206x2622, 402x874 points.public static let iPhone17_1 = iPhone("iPhone17,1", "d93ap", "iPhone 16 Pro", width: 1206, height: 2622)/// iPhone 16 Pro Max: 1320x2868, 440x956 points.@@ -291,7 +294,7 @@ public struct VPhoneGuestDevice: Sendable, Equatable {iPhone17_4, iPhone17_1, iPhone17_2, iPhone17_5,iPhone18_3, iPhone18_4, iPhone18_1, iPhone18_2, iPhone18_5,iPhone19_2, iPhone19_4,- iPhone11_6, iPhone15_4,+ iPhone11_6, iPhone15_4, iPhone15_2,iPad16_1,iPad15_7,iPad15_3, iPad15_5,diff --git a/VPhoneKit/VPhoneCoreKitTests/VirtualMachine/GuestDeviceTests.swift b/VPhoneKit/VPhoneCoreKitTests/VirtualMachine/GuestDeviceTests.swiftindex 4689657a..742b2833 100644--- a/VPhoneKit/VPhoneCoreKitTests/VirtualMachine/GuestDeviceTests.swift+++ b/VPhoneKit/VPhoneCoreKitTests/VirtualMachine/GuestDeviceTests.swift@@ -6,6 +6,15 @@ import Testing/// VM's `config.plist` keeps it.@Suite("Guest device")struct GuestDeviceTests {+ @Test func `local iOS 16 device preserves iPhone 14 Pro board and screen`() throws {+ let device = try #require(VPhoneGuestDevice.named("iPhone15,2"))+ #expect(device.deviceClass == "d73ap")+ #expect(device.screen.width == 1179 && device.screen.height == 2556)+ #expect(device.screen.scale == 3)+ #expect(VPhoneGuestDevice.detect(buildManifest: ["SupportedProductTypes": ["iPhone15,2"]]) == device)+ #expect(VPhoneGuestDevice.default == .iPhone17_3)+ }+@Test func `experimental iPhone 15 keeps its board and display through manifest encoding`() throws {let device = try #require(VPhoneGuestDevice.named("iPhone15,4"))#expect(device.deviceClass == "d37ap")