Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Rebuild the research board's kernelcache with the virtualisation kexts

Maximilian Paß64002ce9d4c2
diff --git a/Research/0_binary_patch_comparison.md b/Research/0_binary_patch_comparison.md
index 23350ac7..0845061d 100644
--- a/Research/0_binary_patch_comparison.md
+++ b/Research/0_binary_patch_comparison.md
@@ -3412,6 +3412,42 @@ which gives the same 10-byte header for TXM and the kernel as before and 6
bytes for the SEP image. `SEPResearchBoardTests` checks all of this against
Apple's 26.1 and 26.4 beta images when an IPSW in `ipsws/` carries both.
-`fw prepare` still refuses a cloudOS without vphone600ap
-(`VPhoneIPSWCache.checkPair`): the guest also needs a kernel with the
-iPhone's kexts, which the research board's kernelcache does not have.
+### The research board's kernelcache
+
+**`kernel-boot-vresearch101_kext_mix`** (`KernelCacheMixer`) gives the research
+board's kernelcache the iPhone virtualisation kexts it lacks (paravirtual GPU,
+touch, audio, FairPlay, ...). For the cloudOS's `kernelcache.release.vresearch101`
+it finds the recipe in `Contents/Resources/kernelcache_recipes` by SHA-256, then:
+
+1. extracts the donor, the vphone600 kernelcache of the 26.4 beta (23E5207q,
+ read once from its cloudOS IPSW), and the base into KDKs with
+ `ipsw kernel extract --kdk --symbols`, naming the stripped symbols from the
+ recipe's maps;
+2. keeps the recipe's bundle list: the base without its research-board-only
+ kexts, plus the donor kexts that link against the base kernel;
+3. stages the bundles as a root-owned volume (kmutil reads no other kexts and
+ takes the host's own in their place without a word) and links it with
+ `kmutil create -a arm64e -n boot -s all -z -x --compress --img4-encode
+ --split-ro-rx-tags`;
+4. puts back Apple's CPU subtype if the builder wrote another, and checks that
+ every requested bundle was linked.
+
+The mix replaces both `KernelCache` and `RestoreKernelCache`, so restore boots
+it too. The pipeline keeps kmutil's container (its `PAYP` properties describe
+the new layout) and saves the preset's kernel patches into it
+(`ComponentDescriptor.replacement`); `minimal` adds none. The shipped kernels stay
+in `FirmwareOriginals`. Mixes are cached in `~/.vphone/kernelcache/mix`, keyed
+by the kernelcaches, the maps and bundle list, the `ipsw` binary's hash and the
+builder layout.
+
+Requirements: an `ipsw` with `kernel extract --kdk`, named by `VPHONE_IPSW`
+(vphone-cli does not ship it); root; and for every base here (26.4–26.7, all
+`kernel-last`) the kmutil of macOS 26.4 or later. `fw prepare` now pairs a
+cloudOS without vphone600ap and refuses one whose kernelcache no recipe covers.
+`cfw update-kernel` refuses on a mixed kernel, whose originals are the research
+board's.
+
+Checked on 2026-10-19: a `minimal` VM of iOS 26.6 on cloudOS 26.6 (23G71) restores
+and boots, and vphoned answers. The 26.4 (23E244), 26.5 and 26.7 recipes are the
+ones the research workflow built and validated statically (26.4 also booted
+there); they have not run through this pipeline yet.
diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/KernelCache/KernelCacheKDK.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/KernelCache/KernelCacheKDK.swift
new file mode 100644
index 00000000..a64acfa0
--- /dev/null
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/KernelCache/KernelCacheKDK.swift
@@ -0,0 +1,197 @@
+// KernelCacheKDK.swift — Combine extracted KDKs and stage them as a kmutil volume.
+//
+// A KDK here is what `ipsw kernel extract --kdk` writes: the kernel and every
+// kext of a kernel collection as standalone Mach-Os with their Info.plists, under
+// `KDK_<version>_<build>.kdk/System/Library`.
+
+import Foundation
+import VPhonePatchKit
+
+enum KernelCacheKDK {
+ // MARK: - Bundles
+
+ /// A bundle below System/Library/Extensions; paths are relative to that directory
+ /// (absolute paths from the enumerator may resolve symlinks, e.g. /tmp → /private/tmp).
+ struct Bundle {
+ let path: String
+ let infoPath: String
+ let plist: [String: Any]
+ }
+
+ /// Every .kext below `extensions` with its Info.plist, sorted by path.
+ static func kexts(in extensions: URL) throws -> [Bundle] {
+ guard let enumerator = FileManager.default.enumerator(atPath: extensions.path) else {
+ throw PatcherError.fileNotFound(extensions.path)
+ }
+ var found: [Bundle] = []
+ while let relative = enumerator.nextObject() as? String {
+ guard (relative as NSString).lastPathComponent == "Info.plist" else { continue }
+ let parent = (relative as NSString).deletingLastPathComponent
+ let bundle = (parent as NSString).lastPathComponent == "Contents" ? (parent as NSString).deletingLastPathComponent : parent
+ guard (bundle as NSString).pathExtension == "kext",
+ let plist = try? plist(at: extensions.appending(path: relative))
+ else { continue }
+ found.append(Bundle(path: bundle, infoPath: relative, plist: plist))
+ }
+ return found.sorted { $0.infoPath < $1.infoPath }
+ }
+
+ /// Bundle identifier → path relative to System/Library/Extensions.
+ static func bundles(in kdk: URL) throws -> [String: String] {
+ var result: [String: String] = [:]
+ for bundle in try kexts(in: kdk.appending(path: "System/Library/Extensions")) {
+ if let id = bundle.plist["CFBundleIdentifier"] as? String {
+ result[id] = bundle.path
+ }
+ }
+ return result
+ }
+
+ static func plist(at url: URL) throws -> [String: Any] {
+ let data = try Data(contentsOf: url)
+ return (try PropertyListSerialization.propertyList(from: data, format: nil) as? [String: Any]) ?? [:]
+ }
+
+ // MARK: - Mix
+
+ /// Copy `base` to `output`, drop the bundles not listed in `wanted` and add the
+ /// listed bundles that only `donor` has (at their bundle paths). Nested bundles
+ /// keep their parents' directories.
+ static func mix(base: URL, donor: URL, wanted: [String], output: URL) throws -> (removed: [String], added: [String]) {
+ let fm = FileManager.default
+ let wantedSet = Set(wanted)
+ if fm.fileExists(atPath: output.path) { try fm.removeItem(at: output) }
+ try fm.createDirectory(at: output.deletingLastPathComponent(), withIntermediateDirectories: true)
+ try fm.copyItem(at: base, to: output)
+
+ let outExtensions = output.appending(path: "System/Library/Extensions")
+ let have = try bundles(in: output)
+ var removed: [String] = []
+ // Deepest bundles first, so plug-ins go before their parents.
+ for (id, relative) in have.sorted(by: { $0.value.split(separator: "/").count > $1.value.split(separator: "/").count }) {
+ let path = outExtensions.appending(path: relative)
+ guard !wantedSet.contains(id), fm.fileExists(atPath: path.path) else { continue }
+ let keepsWantedPlugin = have.contains { other in
+ wantedSet.contains(other.key) && other.value != relative && other.value.hasPrefix(relative + "/")
+ }
+ if keepsWantedPlugin {
+ // Keep the directory for its plug-ins, but not the bundle itself.
+ for info in [path.appending(path: "Contents/Info.plist"), path.appending(path: "Info.plist")]
+ where fm.fileExists(atPath: info.path)
+ {
+ try fm.removeItem(at: info)
+ }
+ continue
+ }
+ try fm.removeItem(at: path)
+ removed.append(id)
+ }
+
+ let donated = try bundles(in: donor)
+ let donorExtensions = donor.appending(path: "System/Library/Extensions")
+ var added: [String] = []
+ for id in wantedSet.subtracting(have.keys).sorted() {
+ guard let relative = donated[id] else { continue }
+ // Nested plug-ins are copied for their own identifiers.
+ try copyTree(from: donorExtensions.appending(path: relative), to: outExtensions.appending(path: relative), skipping: "PlugIns")
+ added.append(id)
+ }
+
+ let missing = wantedSet.subtracting(have.keys).subtracting(added)
+ guard missing.isEmpty else {
+ throw PatcherError.fileNotFound("kexts in neither the base nor the donor KDK: \(missing.sorted().joined(separator: ", "))")
+ }
+ return (removed.sorted(), added)
+ }
+
+ /// Recursive copy that merges into existing directories and skips entries named `skipping`.
+ static func copyTree(from source: URL, to destination: URL, skipping: String) throws {
+ let fm = FileManager.default
+ var isDirectory: ObjCBool = false
+ guard fm.fileExists(atPath: source.path, isDirectory: &isDirectory) else { return }
+ let attributes = try fm.attributesOfItem(atPath: source.path)
+ if attributes[.type] as? FileAttributeType == .typeSymbolicLink {
+ let target = try fm.destinationOfSymbolicLink(atPath: source.path)
+ try? fm.removeItem(at: destination)
+ try fm.createSymbolicLink(atPath: destination.path, withDestinationPath: target)
+ } else if isDirectory.boolValue {
+ try fm.createDirectory(at: destination, withIntermediateDirectories: true)
+ for name in try fm.contentsOfDirectory(atPath: source.path) where name != skipping {
+ try copyTree(from: source.appending(path: name), to: destination.appending(path: name), skipping: skipping)
+ }
+ } else {
+ try? fm.removeItem(at: destination)
+ try fm.copyItem(at: source, to: destination)
+ }
+ }
+
+ // MARK: - Volume
+
+ /// Create a minimal volume root for `kmutil create -R <volume>` holding the listed
+ /// bundles, System.kext (KPI pseudo bundles) and a KDK with the kernel. kmutil only loads kexts owned by root:wheel (otherwise it silently
+ /// falls back to the host's /System/Library/Extensions); the caller chowns.
+ /// Returns the kernel path inside the volume.
+ @discardableResult
+ static func makeVolume(kdk: URL, identifiers: [String], output: URL) throws -> URL {
+ let fm = FileManager.default
+ let extensions = kdk.appending(path: "System/Library/Extensions")
+ let wanted = Set(identifiers)
+ var found: [String: Bundle] = [:]
+ for bundle in try kexts(in: extensions) {
+ guard let id = bundle.plist["CFBundleIdentifier"] as? String, wanted.contains(id), found[id] == nil else { continue }
+ found[id] = bundle
+ }
+ let missing = identifiers.filter { found[$0] == nil }
+ guard missing.isEmpty else {
+ throw PatcherError.fileNotFound("bundles missing from \(kdk.lastPathComponent): \(missing.joined(separator: ", "))")
+ }
+
+ if fm.fileExists(atPath: output.path) { try fm.removeItem(at: output) }
+ let outExtensions = output.appending(path: "System/Library/Extensions")
+ for (_, entry) in found {
+ try copyFile(extensions.appending(path: entry.infoPath), to: outExtensions.appending(path: entry.infoPath))
+ if let executable = entry.plist["CFBundleExecutable"] as? String {
+ let infoDir = (entry.infoPath as NSString).deletingLastPathComponent
+ for candidate in ["\(infoDir)/MacOS/\(executable)", "\(infoDir)/\(executable)"] {
+ var isDirectory: ObjCBool = false
+ let source = extensions.appending(path: candidate)
+ if fm.fileExists(atPath: source.path, isDirectory: &isDirectory), !isDirectory.boolValue {
+ try copyFile(source, to: outExtensions.appending(path: candidate))
+ break
+ }
+ }
+ }
+ }
+
+ // KPI pseudo-bundles (com.apple.kpi.*) resolve the kexts' dependencies.
+ let systemKext = outExtensions.appending(path: "System.kext")
+ let sourceSystemKext = extensions.appending(path: "System.kext")
+ if !fm.fileExists(atPath: systemKext.appending(path: "Info.plist").path),
+ fm.fileExists(atPath: sourceSystemKext.appending(path: "Info.plist").path)
+ {
+ try? fm.removeItem(at: systemKext)
+ try fm.copyItem(at: sourceSystemKext, to: systemKext)
+ }
+
+ let systemVersion = kdk.appending(path: "System/Library/CoreServices/SystemVersion.plist")
+ try copyFile(systemVersion, to: output.appending(path: "System/Library/CoreServices/SystemVersion.plist"))
+ let version = try plist(at: systemVersion)
+ let kdkName = "KDK_\(version["ProductVersion"] as? String ?? "")_\(version["ProductBuildVersion"] as? String ?? "").kdk"
+ let volumeKDK = output.appending(path: "Library/Developer/KDKs/\(kdkName)")
+ try copyFile(systemVersion, to: volumeKDK.appending(path: "System/Library/CoreServices/SystemVersion.plist"))
+ let kernel = volumeKDK.appending(path: "System/Library/Kernels/kernel")
+ try copyFile(kdk.appending(path: "System/Library/Kernels/kernel"), to: kernel)
+ // kmutil requires the KDK to have an Extensions directory; share the volume's.
+ try fm.createSymbolicLink(
+ atPath: volumeKDK.appending(path: "System/Library/Extensions").path,
+ withDestinationPath: "../../../../../../System/Library/Extensions"
+ )
+ return kernel
+ }
+
+ static func copyFile(_ source: URL, to destination: URL) throws {
+ try FileManager.default.createDirectory(at: destination.deletingLastPathComponent(), withIntermediateDirectories: true)
+ try? FileManager.default.removeItem(at: destination)
+ try FileManager.default.copyItem(at: source, to: destination)
+ }
+}
diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/KernelCache/KernelCacheMixer.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/KernelCache/KernelCacheMixer.swift
new file mode 100644
index 00000000..92941bed
--- /dev/null
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/KernelCache/KernelCacheMixer.swift
@@ -0,0 +1,354 @@
+// KernelCacheMixer.swift — A vphone600-capable kernelcache from the research board's.
+//
+// A cloudOS without vphone600 components ships only the research board's
+// kernelcache, which lacks the iPhone virtualisation kexts (paravirtual GPU,
+// touch, audio, FairPlay, ...). The mix:
+//
+// 1. extracts the donor kernelcache, the vphone600 one of the 26.4 beta
+// cloudOS, into a KDK, naming its stripped symbols from the recipe's map
+// (cached);
+// 2. extracts the base, the cloudOS's `kernelcache.release.vresearch101`, the
+// same way;
+// 3. keeps the recipe's bundle list: the base without its research-board-only
+// kexts, plus the donor's virtualisation kexts;
+// 4. stages the bundles as a volume and links it with kmutil;
+// 5. restores Apple's CPU subtype if the builder wrote another, checks every
+// bundle was linked, and caches the result.
+//
+// The maps are research results: BinDiff symbolication against a symbolicated
+// KDK of the same family, plus verified fixes (see the README beside the
+// recipes). Extracting needs an `ipsw` with `kernel extract --kdk`, which
+// vphone-cli does not ship: `VPHONE_IPSW` names it.
+
+import Foundation
+import Img4tool
+import VPhoneCoreKit
+import VPhonePatchKit
+
+public final class KernelCacheMixer {
+ let recipes: KernelCacheRecipes
+ let cacheDirectory: URL
+ let verbose: Bool
+
+ /// The length of Apple's build volume name. kmutil records the plug-in
+ /// paths, and the `__PRELINK_INFO` page rounding then matches Apple's builds.
+ static let volumeName = String(repeating: "b", count: 170)
+
+ /// Bump when the steps change, so cached mixes are rebuilt.
+ static let revision = 1
+
+ public static let ipswEnvironmentVariable = "VPHONE_IPSW"
+
+ public init(
+ recipes: KernelCacheRecipes,
+ cacheDirectory: URL = VPhoneResources.userDataRoot().appending(path: "kernelcache"),
+ verbose: Bool = true,
+ ) {
+ self.recipes = recipes
+ self.cacheDirectory = cacheDirectory
+ self.verbose = verbose
+ }
+
+ // MARK: - Identification
+
+ public func base(for kernelcache: Data) throws -> KernelCacheBase {
+ if let base = try recipes.base(forKernelcache: kernelcache) {
+ return base
+ }
+ let supported = (try? recipes.bases().map(\.id).joined(separator: ", ")) ?? "none"
+ throw PatcherError.invalidFormat(
+ "this cloudOS has no vphone600 components, and no kernelcache recipe covers its research board kernelcache "
+ + "(SHA-256 \(KernelCacheRecipes.sha256(kernelcache))) to rebuild with the virtualisation kexts; "
+ + "recipes exist for iOS \(supported)",
+ )
+ }
+
+ /// The recipe for the research board kernelcache `restoreDir` restores
+ /// with. `fw prepare` asks, so a cloudOS no recipe covers is refused before
+ /// anything is patched.
+ public static func recipe(forRestoreTree restoreDir: URL) throws -> KernelCacheBase {
+ try KernelCacheMixer(recipes: .locate(), verbose: false).base(for: kernelcache(inRestoreTree: restoreDir))
+ }
+
+ /// Throws what `mix` would for `restoreDir`, without building anything.
+ /// `vm create` asks as soon as `fw prepare` finds the recipe, not at
+ /// `fw patch` after the restores.
+ public static func checkMixable(restoreTree restoreDir: URL) throws {
+ let mixer = try KernelCacheMixer(recipes: .locate(), verbose: false)
+ let base = try mixer.base(for: kernelcache(inRestoreTree: restoreDir))
+ let cached = try mixer.cachedMix(base: base, ipsw: ipsw())
+ if !FileManager.default.fileExists(atPath: cached.path) {
+ try KernelCollectionBuilder.checkHost(for: base)
+ }
+ }
+
+ static func kernelcache(inRestoreTree restoreDir: URL) throws -> Data {
+ let path = try FirmwarePipeline.manifestComponentPath("RestoreKernelCache", in: restoreDir)
+ return try Data(contentsOf: restoreDir.appending(path: path), options: .mappedIfSafe)
+ }
+
+ // MARK: - Mix
+
+ /// The mixed kernelcache (an IMG4 `krnl` container) for a research board one.
+ public func mix(kernelcache: Data) throws -> Data {
+ let base = try base(for: kernelcache)
+ let donor = try recipes.donor(id: base.donor)
+ let ipsw = try Self.ipsw()
+ let cached = try cachedMix(base: base, ipsw: ipsw)
+ log(" [kc] base \(base.id) (iOS \(base.productVersion)), donor \(donor.id)")
+ if let data = try? Data(contentsOf: cached), !data.isEmpty {
+ log(" [kc] using the cached mix \(cached.path)")
+ return data
+ }
+ try KernelCollectionBuilder.checkHost(for: base)
+
+ // A directory per run: a failed run keeps its logs.
+ let fm = FileManager.default
+ let workRoot = cacheDirectory.appending(path: "work")
+ for stale in (try? fm.contentsOfDirectory(atPath: workRoot.path)) ?? [] where stale.hasPrefix(base.id + ".") {
+ try? fm.removeItem(at: workRoot.appending(path: stale))
+ }
+ let work = workRoot.appending(path: "\(base.id).\(UUID().uuidString.prefix(8))")
+ try fm.createDirectory(at: work, withIntermediateDirectories: true)
+ log(" [kc] work directory \(work.path)")
+
+ let donorKDK = try donorKDK(donor, ipsw: ipsw)
+
+ let payload = try Self.payload(of: kernelcache)
+ try Self.check(payload, base.kernel.decompressedSHA256, "decompressed \(base.kernel.file)")
+ let decompressed = work.appending(path: "\(base.kernel.file).decompressed")
+ try payload.write(to: decompressed)
+ log(" [kc] extracting the base kernelcache with its symbol map")
+ let baseKDK = try extract(
+ kernelcache: decompressed, symbols: base.symbolsURL, kdk: base.kernel.kdk,
+ into: work.appending(path: "base"), ipsw: ipsw.url,
+ )
+
+ let identifiers = try base.kextIdentifiers()
+ let mixKDK = work.appending(path: "mix/\(base.kernel.kdk)")
+ let (removed, added) = try KernelCacheKDK.mix(base: baseKDK, donor: donorKDK, wanted: identifiers, output: mixKDK)
+ log(" [kc] mix: \(identifiers.count) kexts, \(removed.count) research board kexts removed, \(added.count) added from the donor")
+
+ let volume = work.appending(path: "volume/\(Self.volumeName)")
+ let kernel = try KernelCacheKDK.makeVolume(kdk: mixKDK, identifiers: identifiers, output: volume)
+ log(" [kc] linking with kmutil")
+ var output = try KernelCollectionBuilder.link(
+ volume: volume, kernel: kernel, identifiers: identifiers, log: work.appending(path: "kmutil.log"),
+ )
+
+ output = try finalize(output, original: payload, identifiers: identifiers, work: work)
+ try fm.createDirectory(at: cached.deletingLastPathComponent(), withIntermediateDirectories: true)
+ try output.write(to: cached)
+ try? fm.removeItem(at: work)
+ try VPhoneHostFilePermissions.makeAccessible(at: cacheDirectory)
+ log(" [kc] mixed kernelcache: \(output.count) bytes, cached at \(cached.path)")
+ return output
+ }
+
+ // MARK: - Steps
+
+ /// Puts back Apple's CPU subtype (the 26.x builder writes 0xc0000002 where
+ /// some kernelcaches have 0x2) and checks every requested bundle was linked.
+ func finalize(_ im4pData: Data, original: Data, identifiers: [String], work: URL) throws -> Data {
+ guard let im4p = try? IM4P(im4pData) else {
+ throw PatcherError.invalidFormat("kmutil's output is not an IM4P container")
+ }
+ var payload = try im4p.payload()
+ guard payload.count > 12, original.count > 12, payload.prefix(4) == original.prefix(4) else {
+ throw PatcherError.invalidFormat("kmutil's output is not a Mach-O kernel collection")
+ }
+ let missing = identifiers.filter { payload.range(of: Data(">\($0)<".utf8)) == nil }
+ guard missing.isEmpty else {
+ throw PatcherError.invalidFormat("kexts missing from the linked kernelcache: \(missing.joined(separator: ", "))")
+ }
+ let start = payload.startIndex
+ let subtype = payload[start + 8 ..< start + 12]
+ let wanted = original[original.startIndex + 8 ..< original.startIndex + 12]
+ guard subtype != wanted else { return im4pData }
+ log(" [kc] restoring CPU subtype \(Data(wanted).hex) (the builder wrote \(Data(subtype).hex))")
+ payload.replaceSubrange(start + 8 ..< start + 12, with: wanted)
+ let url = work.appending(path: "subtype.im4p")
+ try IM4PHandler.save(patchedData: payload, originalIM4P: im4p, to: url)
+ return try Data(contentsOf: url)
+ }
+
+ /// `ipsw kernel extract --kdk` into `directory`, returning the KDK named
+ /// `kdk`. A kernelcache whose kexts carry no `DTPlatformBuild` gives
+ /// `KDK_<version>_.kdk`; the recipe supplies the build.
+ func extract(kernelcache: URL, symbols: URL?, kdk: String, into directory: URL, ipsw: URL) throws -> URL {
+ let fm = FileManager.default
+ try? fm.removeItem(at: directory)
+ try fm.createDirectory(at: directory, withIntermediateDirectories: true)
+ let log = directory.appending(path: "extract.log")
+ var arguments = ["kernel", "extract", "--kdk", "--force"]
+ if let symbols {
+ let compressed = directory.appending(path: "symbols.json.gz")
+ try fm.copyItem(at: symbols, to: compressed)
+ try Self.run("/usr/bin/gzip", ["-d", compressed.path], log: log)
+ arguments += ["--symbols", directory.appending(path: "symbols.json").path]
+ }
+ arguments += [kernelcache.path, "-o", directory.path]
+ try Self.run(ipsw.path, arguments, environment: ["NO_COLOR": "1"], log: log)
+
+ let produced = try fm.contentsOfDirectory(atPath: directory.path).filter { $0.hasPrefix("KDK_") && $0.hasSuffix(".kdk") }
+ guard produced.count == 1, let name = produced.first else {
+ throw PatcherError.fileNotFound("the KDK `ipsw kernel extract --kdk` wrote into \(directory.path) (found \(produced))")
+ }
+ var url = directory.appending(path: name)
+ if name != kdk {
+ let parts = kdk.dropFirst(4).dropLast(4).split(separator: "_", omittingEmptySubsequences: false)
+ guard parts.count == 2, name == "KDK_\(parts[0])_.kdk" else {
+ throw PatcherError.invalidFormat("extracted \(name), the recipe expects \(kdk)")
+ }
+ let systemVersion = url.appending(path: "System/Library/CoreServices/SystemVersion.plist")
+ var plist = try KernelCacheKDK.plist(at: systemVersion)
+ plist["ProductBuildVersion"] = String(parts[1])
+ try PropertyListSerialization.data(fromPropertyList: plist, format: .xml, options: 0).write(to: systemVersion)
+ let renamed = directory.appending(path: kdk)
+ try fm.moveItem(at: url, to: renamed)
+ url = renamed
+ }
+ return url
+ }
+
+ /// The donor's KDK, extracted once into `donors/<id>`.
+ func donorKDK(_ donor: KernelCacheDonor, ipsw: (url: URL, hash: String)) throws -> URL {
+ let fm = FileManager.default
+ let directory = cacheDirectory.appending(path: "donors/\(donor.id)")
+ let kdk = directory.appending(path: "extract/\(donor.kernel.kdk)")
+ let marker = directory.appending(path: "extract/.complete")
+ var keyMaterial = Data(Self.identity(donor.kernel).utf8)
+ if let symbols = donor.symbolsURL {
+ keyMaterial += try Data(contentsOf: symbols)
+ }
+ keyMaterial += Data(ipsw.hash.utf8)
+ let key = KernelCacheRecipes.sha256(keyMaterial)
+ if (try? String(contentsOf: marker, encoding: .utf8)) == key, fm.fileExists(atPath: kdk.path) {
+ log(" [kc] using the cached donor KDK \(kdk.path)")
+ return kdk
+ }
+ try fm.createDirectory(at: directory, withIntermediateDirectories: true)
+ let payload = try Self.payload(of: donorKernelcache(donor, in: directory))
+ try Self.check(payload, donor.kernel.decompressedSHA256, "decompressed donor \(donor.kernel.file)")
+ let decompressed = directory.appending(path: "\(donor.kernel.file).decompressed")
+ try payload.write(to: decompressed)
+ defer { try? fm.removeItem(at: decompressed) }
+ log(" [kc] extracting the donor kernelcache \(donor.id)")
+ let extracted = try extract(
+ kernelcache: decompressed, symbols: donor.symbolsURL, kdk: donor.kernel.kdk,
+ into: directory.appending(path: "extract"), ipsw: ipsw.url,
+ )
+ try key.write(to: marker, atomically: true, encoding: .utf8)
+ return extracted
+ }
+
+ /// The donor kernelcache, kept in `directory` once read from its cloudOS
+ /// IPSW. Only that one entry is downloaded.
+ func donorKernelcache(_ donor: KernelCacheDonor, in directory: URL) throws -> Data {
+ let local = directory.appending(path: donor.kernel.file)
+ if let data = try? Data(contentsOf: local), donor.kernel.matches(sha: KernelCacheRecipes.sha256(data)) {
+ return data
+ }
+ guard let source = URL(string: donor.cloudOSSource) else {
+ throw PatcherError.invalidFormat("the \(donor.id) recipe has no valid cloudOS URL")
+ }
+ log(" [kc] reading \(donor.kernel.file) from \(source.absoluteString)")
+ let file = donor.kernel.file
+ let data = try vphoneRunBlocking {
+ let zip = try await VPhoneRemoteZip.open(source)
+ return try await zip.read(zip.entry(endingWith: file))
+ }
+ guard donor.kernel.matches(sha: KernelCacheRecipes.sha256(data)) else {
+ throw PatcherError.invalidFormat("the downloaded \(file) does not match the \(donor.id) recipe")
+ }
+ try data.write(to: local)
+ return data
+ }
+
+ // MARK: - Helpers
+
+ /// Where the mix of `base` is cached.
+ func cachedMix(base: KernelCacheBase, ipsw: (url: URL, hash: String)) throws -> URL {
+ let key = try cacheKey(base: base, donor: recipes.donor(id: base.donor), ipswHash: ipsw.hash)
+ return cacheDirectory.appending(path: "mix/\(base.id)/\(key).im4p")
+ }
+
+ /// Everything that decides the output: the kernelcaches, maps and bundle
+ /// list, the extracting ipsw, the layout and this file's steps.
+ func cacheKey(base: KernelCacheBase, donor: KernelCacheDonor, ipswHash: String) throws -> String {
+ var material = Data("\(Self.identity(base.kernel))|\(Self.identity(donor.kernel))|".utf8)
+ for url in [base.symbolsURL, base.kextsURL] + (donor.symbolsURL.map { [$0] } ?? []) {
+ material += try Data(contentsOf: url)
+ }
+ material += Data("\(Self.revision)|\(ipswHash)|\(base.builderLayout.rawValue)|\(Self.volumeName.count)".utf8)
+ return String(KernelCacheRecipes.sha256(material).prefix(16))
+ }
+
+ static func identity(_ kernel: KernelCacheFile) -> String {
+ "\(kernel.file)|\(kernel.sha256)|\(kernel.decompressedSHA256)|\(kernel.kdk)"
+ }
+
+ static func check(_ data: Data, _ sha: String, _ what: String) throws {
+ let actual = KernelCacheRecipes.sha256(data)
+ guard actual == sha else {
+ throw PatcherError.invalidFormat("\(what): SHA-256 \(actual), the recipe expects \(sha)")
+ }
+ }
+
+ static func payload(of data: Data) throws -> Data {
+ if let im4p = try? IM4P(data) {
+ return try im4p.payload()
+ }
+ return data
+ }
+
+ /// The `ipsw` named by `VPHONE_IPSW`, with `kernel extract --kdk`.
+ static func ipsw() throws -> (url: URL, hash: String) {
+ let hint = "The kernelcache mix needs an ipsw with `kernel extract --kdk`; set \(ipswEnvironmentVariable) to its path "
+ + "(under sudo: `sudo \(ipswEnvironmentVariable)=<path> vphone-cli ...`)."
+ guard let path = ProcessInfo.processInfo.environment[ipswEnvironmentVariable], !path.isEmpty else {
+ throw PatcherError.fileNotFound("ipsw. \(hint)")
+ }
+ let url = URL(fileURLWithPath: path)
+ guard FileManager.default.isExecutableFile(atPath: url.path),
+ let help = try? VPhoneProcessRunner.runCapturing(url, ["kernel", "extract", "--help"]),
+ help.stdout.contains("--kdk"), help.stdout.contains("--symbols")
+ else {
+ throw PatcherError.invalidFormat("\(path) is not an ipsw with `kernel extract --kdk --symbols`. \(hint)")
+ }
+ // Its own hash, not `ipsw version`, which a local build leaves empty.
+ let binary = try Data(contentsOf: url, options: .mappedIfSafe)
+ return (url, KernelCacheRecipes.sha256(binary))
+ }
+
+ /// Runs a tool with its output in `log`, which a failure quotes the end of.
+ static func run(_ executable: String, _ arguments: [String], environment: [String: String] = [:], log: URL) throws {
+ let fm = FileManager.default
+ if !fm.fileExists(atPath: log.path) {
+ fm.createFile(atPath: log.path, contents: nil)
+ }
+ let handle = try FileHandle(forWritingTo: log)
+ defer { try? handle.close() }
+ try handle.seekToEnd()
+ let process = Process()
+ process.executableURL = URL(fileURLWithPath: executable)
+ process.arguments = arguments
+ process.environment = ProcessInfo.processInfo.environment.merging(environment) { _, new in new }
+ process.standardOutput = handle
+ process.standardError = handle
+ process.standardInput = FileHandle.nullDevice
+ try process.run()
+ process.waitUntilExit()
+ guard process.terminationStatus == 0 else {
+ let text = (try? String(contentsOf: log, encoding: .utf8)) ?? ""
+ let tail = text.split(separator: "\n", omittingEmptySubsequences: false).suffix(25).joined(separator: "\n")
+ throw PatcherError.invalidFormat("\((executable as NSString).lastPathComponent) failed with exit code \(process.terminationStatus) (log: \(log.path)):\n\(tail)")
+ }
+ }
+
+ func log(_ message: String) {
+ if verbose {
+ print(message)
+ }
+ }
+}
diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/KernelCache/KernelCacheRecipes.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/KernelCache/KernelCacheRecipes.swift
new file mode 100644
index 00000000..2cdd7a95
--- /dev/null
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/KernelCache/KernelCacheRecipes.swift
@@ -0,0 +1,150 @@
+// KernelCacheRecipes.swift — What a kernelcache mix is built from.
+//
+// `Contents/Resources/kernelcache_recipes` holds one directory per supported
+// base, the research board's kernelcache of a cloudOS without vphone600
+// components, and one per donor of the iPhone virtualisation kexts. See the
+// README there for the layout and how a recipe is made.
+
+import CryptoKit
+import Foundation
+import VPhoneCoreKit
+import VPhonePatchKit
+
+/// A kernelcache a recipe names, identified by its SHA-256.
+public struct KernelCacheFile: Decodable, Sendable {
+ /// File name in the cloudOS restore tree.
+ public let file: String
+ /// SHA-256 of the IM4P container as shipped.
+ public let sha256: String
+ /// SHA-256 of the decompressed kernel collection.
+ public let decompressedSHA256: String
+ /// The KDK `ipsw kernel extract --kdk` makes of it.
+ public let kdk: String
+
+ func matches(sha: String) -> Bool {
+ sha == sha256 || sha == decompressedSHA256
+ }
+}
+
+/// One base kernelcache (`bases/<id>/manifest.json`).
+public struct KernelCacheBase: Decodable, Sendable {
+ /// Where the kernel collection builder puts the kernel's `__TEXT_EXEC`. The
+ /// builder of macOS 26.4 and later puts it after the kexts, older ones
+ /// before them, and a kernel only boots in the layout Apple linked it with.
+ public enum BuilderLayout: String, Decodable, Sendable {
+ case kernelFirst = "kernel-first"
+ case kernelLast = "kernel-last"
+ }
+
+ public let id: String
+ public let productVersion: String
+ public let kernel: KernelCacheFile
+ /// Symbol map of the stripped kernelcache: address (decimal) to names.
+ public let symbols: String
+ /// Bundle identifiers of the mix, one per line.
+ public let kexts: String
+ public let donor: String
+ public let builderLayout: BuilderLayout
+
+ public internal(set) var directory = URL(fileURLWithPath: "/")
+
+ enum CodingKeys: String, CodingKey {
+ case id, productVersion, kernel, symbols, kexts, donor, builderLayout
+ }
+
+ public var symbolsURL: URL {
+ directory.appending(path: symbols)
+ }
+
+ public var kextsURL: URL {
+ directory.appending(path: kexts)
+ }
+
+ public func kextIdentifiers() throws -> [String] {
+ try String(contentsOf: kextsURL, encoding: .utf8).split(whereSeparator: \.isWhitespace).map(String.init)
+ }
+}
+
+/// A donor of the virtualisation kexts (`donors/<id>/manifest.json`).
+public struct KernelCacheDonor: Decodable, Sendable {
+ public let id: String
+ public let description: String?
+ public let kernel: KernelCacheFile
+ /// The cloudOS IPSW the donor kernelcache is read from.
+ public let cloudOSSource: String
+ /// Symbol map, for a stripped donor.
+ public let symbols: String?
+
+ public internal(set) var directory = URL(fileURLWithPath: "/")
+
+ enum CodingKeys: String, CodingKey {
+ case id, description, kernel, cloudOSSource, symbols
+ }
+
+ public var symbolsURL: URL? {
+ symbols.map { directory.appending(path: $0) }
+ }
+}
+
+public struct KernelCacheRecipes: Sendable {
+ public static let directoryName = "kernelcache_recipes"
+
+ public let root: URL
+
+ public init(root: URL) {
+ self.root = root
+ }
+
+ /// The recipes beside the running `vphone-cli`: `Contents/Resources` in the
+ /// bundle, or the source tree for a plain Xcode build.
+ public static func locate() throws -> KernelCacheRecipes {
+ let bundled = VPhoneResources.resolve().base.appending(path: directoryName)
+ var candidates = [bundled]
+ var directory = VPhoneResources.runningExecutable().deletingLastPathComponent()
+ for _ in 0 ..< 8 {
+ candidates.append(directory.appending(path: "VPhoneExecutable/VPhoneVirtualization/Resources/\(directoryName)"))
+ directory = directory.deletingLastPathComponent()
+ }
+ guard let root = candidates.first(where: { FileManager.default.fileExists(atPath: $0.appending(path: "bases").path) }) else {
+ throw PatcherError.fileNotFound("the kernelcache recipes (\(bundled.path))")
+ }
+ return KernelCacheRecipes(root: root)
+ }
+
+ public func bases() throws -> [KernelCacheBase] {
+ try manifests(in: "bases").map { url in
+ var base = try JSONDecoder().decode(KernelCacheBase.self, from: Data(contentsOf: url))
+ base.directory = url.deletingLastPathComponent()
+ return base
+ }
+ }
+
+ public func donor(id: String) throws -> KernelCacheDonor {
+ let url = root.appending(path: "donors/\(id)/manifest.json")
+ guard FileManager.default.fileExists(atPath: url.path) else {
+ throw PatcherError.fileNotFound("the kernelcache donor recipe \(url.path)")
+ }
+ var donor = try JSONDecoder().decode(KernelCacheDonor.self, from: Data(contentsOf: url))
+ donor.directory = url.deletingLastPathComponent()
+ return donor
+ }
+
+ /// The recipe for a kernelcache, given as its IM4P or decompressed bytes.
+ public func base(forKernelcache data: Data) throws -> KernelCacheBase? {
+ let sha = Self.sha256(data)
+ return try bases().first { $0.kernel.matches(sha: sha) }
+ }
+
+ private func manifests(in subdirectory: String) throws -> [URL] {
+ let directory = root.appending(path: subdirectory)
+ let entries = try FileManager.default.contentsOfDirectory(at: directory, includingPropertiesForKeys: nil)
+ return entries
+ .map { $0.appending(path: "manifest.json") }
+ .filter { FileManager.default.fileExists(atPath: $0.path) }
+ .sorted { $0.path < $1.path }
+ }
+
+ static func sha256(_ data: Data) -> String {
+ SHA256.hash(data: data).map { String(format: "%02x", $0) }.joined()
+ }
+}
diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/KernelCache/KernelCollectionBuilder.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/KernelCache/KernelCollectionBuilder.swift
new file mode 100644
index 00000000..17ac6aff
--- /dev/null
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/KernelCache/KernelCollectionBuilder.swift
@@ -0,0 +1,61 @@
+// KernelCollectionBuilder.swift — Link a staged volume into an IMG4 kernelcache.
+//
+// kmutil only gathers the inputs; the layout comes from the kernel collection
+// builder in the host's dyld shared cache. The builder of macOS 26.4 and later
+// puts the kernel's `__TEXT_EXEC` after the kexts ("kernel-last"), macOS 15 and
+// 26.0–26.3 put it first ("kernel-first"), and a kernel only boots in the layout
+// Apple linked it with. Every iOS 26.4+ base is kernel-last, so the host links
+// it when it runs macOS 26.4 or later.
+//
+// kmutil reads only kexts owned by root:wheel. Others it skips without a word
+// and takes the host's own from /System/Library/Extensions, so the link runs as
+// root on a volume chowned to root.
+
+import Foundation
+import VPhonePatchKit
+
+enum KernelCollectionBuilder {
+ /// The flags of Apple's boot kernel collections: strip all, IMG4 with split
+ /// read-only and executable tags.
+ static let createFlags = ["-a", "arm64e", "-n", "boot", "-s", "all", "-z", "-x"]
+ static let packageFlags = ["--compress", "--img4-encode", "--split-ro-rx-tags"]
+
+ static func layout(forMacOS version: OperatingSystemVersion) -> KernelCacheBase.BuilderLayout {
+ let atLeast264 = version.majorVersion > 26 || (version.majorVersion == 26 && version.minorVersion >= 4)
+ return atLeast264 ? .kernelLast : .kernelFirst
+ }
+
+ /// Refuses before anything is extracted when this Mac cannot link `base`.
+ static func checkHost(for base: KernelCacheBase) throws {
+ let host = ProcessInfo.processInfo.operatingSystemVersion
+ let layout = layout(forMacOS: host)
+ guard layout == base.builderLayout else {
+ throw PatcherError.invalidFormat(
+ "the iOS \(base.productVersion) kernelcache must be linked \(base.builderLayout.rawValue), "
+ + "and the kmutil of macOS \(host.majorVersion).\(host.minorVersion) links \(layout.rawValue): "
+ + (base.builderLayout == .kernelLast ? "update this Mac to macOS 26.4 or later" : "link it on macOS 15"),
+ )
+ }
+ guard geteuid() == 0 else {
+ throw PatcherError.invalidFormat(
+ "linking the kernelcache needs root: kmutil only reads kexts owned by root. Run this command with sudo.",
+ )
+ }
+ }
+
+ /// Link the volume at `volume` and return kmutil's IMG4 kernelcache.
+ static func link(volume: URL, kernel: URL, identifiers: [String], log: URL) throws -> Data {
+ try KernelCacheMixer.run("/usr/sbin/chown", ["-R", "0:0", volume.path], log: log)
+ let output = volume.deletingLastPathComponent().appending(path: "\(volume.lastPathComponent).kc")
+ try? FileManager.default.removeItem(at: output)
+ var arguments = ["create"] + createFlags
+ + ["-R", volume.path, "-k", kernel.path, "-r", volume.appending(path: "System/Library/Extensions").path]
+ for identifier in identifiers {
+ arguments += ["-b", identifier]
+ }
+ // -B is relative to the volume root.
+ arguments += packageFlags + ["-B", "/../\(output.lastPathComponent)"]
+ try KernelCacheMixer.run("/usr/bin/kmutil", arguments, log: log)
+ return try Data(contentsOf: output)
+ }
+}
diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareResearchBoardPatchSet.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareResearchBoardPatchSet.swift
index 0dd973a8..87ab9847 100644
--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareResearchBoardPatchSet.swift
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/PatchSets/FirmwareResearchBoardPatchSet.swift
@@ -5,7 +5,8 @@
// cloudOS ships the research board alone, vresearch101ap, and `fw prepare` then
// takes its components instead (`FirmwareManifest.generate`). The patches here
// turn those into what vphone600 would have been: the device tree
-// (DeviceTreeResearchBoardConversion.swift) and SEPD (SEPResearchBoardPatcher.swift).
+// (DeviceTreeResearchBoardConversion.swift), SEPD (SEPResearchBoardPatcher.swift)
+// and the kernelcache (KernelCacheMixer.swift).
//
// Every shipped preset names this set. On a cloudOS with vphone600 components
// its patches are not applicable (`FirmwarePipeline.resolveFirmwareApplicability`)
@@ -22,6 +23,8 @@ public enum FirmwareResearchBoardPatchSet {
public static let deviceTreeConversion = "devicetree-boot-vresearch101_conversion"
/// The research board's SEPD, answering one operation as vphone600's does.
public static let sepDispatch = "sep-boot-vresearch101_sepd_dispatch"
+ /// The research board's kernelcache, rebuilt with the iPhone virtualisation kexts.
+ public static let kernelMix = "kernel-boot-vresearch101_kext_mix"
public static let manifest = VPhonePatchSetManifest(
identifier: identifier,
@@ -35,6 +38,13 @@ public enum FirmwareResearchBoardPatchSet {
target: .firmware(.deviceTree),
bootEssential: true,
),
+ VPhonePatchDeclaration(
+ identifier: kernelMix,
+ title: "Virtualisation kexts",
+ summary: "Rebuilds the research board's kernelcache with the paravirtual GPU, touch, audio and other iPhone virtualisation kexts of the 26.4 beta vphone600 kernelcache, from a recipe for that release. Needs root and an ipsw with `kernel extract --kdk` (VPHONE_IPSW).",
+ target: .firmware(.kernelcache),
+ bootEssential: true,
+ ),
VPhonePatchDeclaration(
identifier: sepDispatch,
title: "vphone600 SEPD dispatch",
diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/Pipeline/FirmwarePipeline.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/Pipeline/FirmwarePipeline.swift
index fdaa7a12..015e9237 100644
--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/Pipeline/FirmwarePipeline.swift
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/Pipeline/FirmwarePipeline.swift
@@ -93,6 +93,13 @@ public final class FirmwarePipeline {
/// in-place behaviour and opt out here.
var restorable: Bool = true
+ /// A container standing in for the shipped file, and the record of the
+ /// swap: the patchers run over its payload and are saved into it. The
+ /// research board's kernelcache is replaced by its mix this way
+ /// (KernelCacheMixer), whose container carries kmutil's layout
+ /// properties rather than the shipped kernel's.
+ var replacement: (() throws -> (container: Data, record: PatchRecord))? = nil
+
/// The same descriptor with more patchers appended after the existing ones.
func appending(_ factories: [(Data, Bool) throws -> any Patcher]) -> ComponentDescriptor {
guard !factories.isEmpty else { return self }
@@ -102,6 +109,7 @@ public final class FirmwarePipeline {
searchPatterns: searchPatterns,
patcherFactories: patcherFactories + factories,
restorable: restorable,
+ replacement: replacement,
)
}
}
@@ -226,7 +234,7 @@ public final class FirmwarePipeline {
/// Whether the restore tree boots the research board's device tree, which
/// `FirmwareManifest` takes when the cloudOS has no vphone600ap.
- static func researchBoardStandsIn(restoreDir: URL) -> Bool {
+ public static func researchBoardStandsIn(restoreDir: URL) -> Bool {
(try? manifestComponentPath("RestoreDeviceTree", in: restoreDir))?.contains(".vresearch101") ?? false
}
@@ -320,7 +328,7 @@ public final class FirmwarePipeline {
// is what the restore image patches expect.
let keepsOriginal = component.restorable
- guard !component.patcherFactories.isEmpty else {
+ guard !component.patcherFactories.isEmpty || component.replacement != nil else {
log(" [=] \(component.name): no patches for \(variant.rawValue)")
// The preset dropped this component's whole patch set. If an earlier
// run patched it, the file on disk is now carrying patches nothing
@@ -355,7 +363,17 @@ public final class FirmwarePipeline {
: " original: re-patching the copy in \(Self.originalsDirectoryName)/")
}
}
- let rawData = try loader.load(from: sourceURL)
+ var rawData = try loader.load(from: sourceURL)
+ // The stand-in goes where the shipped file was, so `save` below
+ // repackages into its container.
+ var replacementRecord: PatchRecord?
+ if let replacement = component.replacement {
+ let (container, record) = try replacement()
+ try container.write(to: fileURL)
+ rawData = try loader.load(from: fileURL)
+ replacementRecord = record
+ log(" replaced by the stand-in for \(record.patchID)")
+ }
log(" format: \(rawData.count) bytes")
let currentData: Data
@@ -375,6 +393,17 @@ public final class FirmwarePipeline {
throw staleFirmwareError(component: component.name, underlying: error)
}
+ if let replacementRecord {
+ // Already in place; the patchers' result, if any, is saved into it.
+ if !componentRecords.isEmpty {
+ try loader.save(currentData, to: fileURL)
+ }
+ log(" [+] saved")
+ allRecords.append(replacementRecord)
+ allRecords.append(contentsOf: componentRecords)
+ continue
+ }
+
if componentRecords.isEmpty {
// Every patch for this component is off. Re-sealing an unmodified
// payload would rewrite a signed image for no reason — but if an
diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/Pipeline/FirmwarePipelineComponents.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/Pipeline/FirmwarePipelineComponents.swift
index 2b7098f1..0a5dbc59 100644
--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/Pipeline/FirmwarePipelineComponents.swift
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/Pipeline/FirmwarePipelineComponents.swift
@@ -270,10 +270,38 @@ extension FirmwarePipeline {
// 7. Kernel — the public CFW firmware includes the former EXP
// hv_vmm rename after the base and custom-firmware patches.
+ // On a cloudOS without vphone600 components the research board's
+ // kernelcache has no iPhone virtualisation kexts: its release kernel
+ // is rebuilt with them first (KernelCacheMixer), and the patchers
+ // run over that.
+ let kernelMixPatch = FirmwareResearchBoardPatchSet.kernelMix
+ let mixesKernel = includesSet(FirmwareResearchBoardPatchSet.identifier)
+ && isEnabled(kernelMixPatch, fallback: true)
+ && !notApplicablePatches.contains(kernelMixPatch)
+ let restoreKernelPath = try? Self.manifestComponentPath("RestoreKernelCache", in: restoreDir)
+ let kernelMix: (() throws -> (container: Data, record: PatchRecord))? = mixesKernel ? { [self] in
+ guard let restoreKernelPath else {
+ throw PatcherError.fileNotFound("RestoreKernelCache in the restore tree's BuildManifest.plist")
+ }
+ // As shipped: the stash once a run has put it aside.
+ let shipped = try Data(contentsOf: pristineInput(for: restoreDir.appending(path: restoreKernelPath)).url)
+ let mixer = try KernelCacheMixer(recipes: .locate(), verbose: verbose)
+ let base = try mixer.base(for: shipped)
+ let record = PatchRecord(
+ patchID: kernelMixPatch,
+ component: "kernelcache",
+ fileOffset: 0,
+ virtualAddress: nil,
+ originalBytes: Data(),
+ patchedBytes: Data(),
+ description: "the \(base.id) research board kernelcache, rebuilt with the \(base.donor) virtualisation kexts",
+ )
+ return try (mixer.mix(kernelcache: shipped), record)
+ } : nil
components.append(ComponentDescriptor(
name: "kernelcache",
inRestoreDir: true,
- searchPatterns: ["kernelcache.research.vphone600"],
+ searchPatterns: [(try? Self.manifestComponentPath("KernelCache", in: restoreDir)) ?? "kernelcache.research.vphone600"],
patcherFactories: {
switch variant {
case .regular:
@@ -308,8 +336,25 @@ extension FirmwarePipeline {
)
}
}(),
+ replacement: kernelMix,
))
+ // 7a. The kernel restore boots. On a cloudOS without vphone600 components
+ // it is the mix as well, with no patcher over it; vphone600's release
+ // kernel is restored as shipped and needs no component.
+ if includesSet(FirmwareResearchBoardPatchSet.identifier),
+ Self.researchBoardStandsIn(restoreDir: restoreDir),
+ let restoreKernelPath
+ {
+ components.append(ComponentDescriptor(
+ name: "RestoreKernelCache",
+ inRestoreDir: true,
+ searchPatterns: [restoreKernelPath],
+ patcherFactories: [],
+ replacement: kernelMix,
+ ))
+ }
+
// 8. DeviceTree — JB includes the former EXP identity and camera
// properties so the guest presents a consistent iPhone17,3 identity.
// A guest that presents its board restores with this tree and boots
diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/Core/KernelCacheMixerTests.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/Core/KernelCacheMixerTests.swift
new file mode 100644
index 00000000..fce040df
--- /dev/null
+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/Core/KernelCacheMixerTests.swift
@@ -0,0 +1,125 @@
+@testable import FirmwarePatcher
+import Foundation
+import Testing
+import VPhonePatchKit
+
+/// The shipped kernelcache recipes, and the steps of the mix that need no
+/// root, kmutil or ipsw.
+@Suite("Kernelcache mix")
+struct KernelCacheMixerTests {
+ static let repoRoot = URL(fileURLWithPath: #filePath)
+ .deletingLastPathComponent()
+ .deletingLastPathComponent()
+ .deletingLastPathComponent()
+ .deletingLastPathComponent()
+ .deletingLastPathComponent()
+
+ static let recipes = KernelCacheRecipes(
+ root: repoRoot.appending(path: "VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes"),
+ )
+
+ // MARK: - Recipes
+
+ @Test("Every recipe has its map, its bundle list and its donor")
+ func recipesAreComplete() throws {
+ let bases = try Self.recipes.bases()
+ #expect(bases.map(\.productVersion) == ["26.4", "26.5", "26.6", "26.7"])
+ for base in bases {
+ #expect(FileManager.default.fileExists(atPath: base.symbolsURL.path), "\(base.id)")
+ let identifiers = try base.kextIdentifiers()
+ #expect(identifiers.count > 100, "\(base.id)")
+ #expect(Set(identifiers).count == identifiers.count, "\(base.id)")
+ #expect(base.builderLayout == .kernelLast, "\(base.id)")
+ let donor = try Self.recipes.donor(id: base.donor)
+ #expect(donor.symbolsURL.map { FileManager.default.fileExists(atPath: $0.path) } == true)
+ #expect(URL(string: donor.cloudOSSource)?.scheme == "https")
+ }
+ }
+
+ @Test("A kernelcache is matched by the SHA-256 of its container or of its payload, and nothing else")
+ func matchesByHash() throws {
+ let base = try #require(try Self.recipes.bases().first)
+ let mixer = KernelCacheMixer(recipes: Self.recipes, verbose: false)
+ #expect(throws: PatcherError.self) { try mixer.base(for: Data("not a kernelcache".utf8)) }
+ #expect(base.kernel.matches(sha: base.kernel.sha256))
+ #expect(base.kernel.matches(sha: base.kernel.decompressedSHA256))
+ #expect(!base.kernel.matches(sha: String(repeating: "0", count: 64)))
+ }
+
+ @Test("A cached mix is keyed by the ipsw binary that extracted it")
+ func cacheKeyFollowsIPSW() throws {
+ let base = try #require(try Self.recipes.bases().first)
+ let donor = try Self.recipes.donor(id: base.donor)
+ let mixer = KernelCacheMixer(recipes: Self.recipes, verbose: false)
+ let first = try mixer.cacheKey(base: base, donor: donor, ipswHash: "1")
+ #expect(try mixer.cacheKey(base: base, donor: donor, ipswHash: "1") == first)
+ #expect(try mixer.cacheKey(base: base, donor: donor, ipswHash: "2") != first)
+ }
+
+ @Test("macOS 26.4 is the first builder that links kernel-last")
+ func builderLayout() {
+ func layout(_ major: Int, _ minor: Int) -> KernelCacheBase.BuilderLayout {
+ KernelCollectionBuilder.layout(forMacOS: OperatingSystemVersion(majorVersion: major, minorVersion: minor, patchVersion: 0))
+ }
+ #expect(layout(15, 6) == .kernelFirst)
+ #expect(layout(26, 3) == .kernelFirst)
+ #expect(layout(26, 4) == .kernelLast)
+ #expect(layout(27, 0) == .kernelLast)
+ }
+
+ // MARK: - KDK
+
+ /// A KDK with one kext per identifier, `<name>.kext/Info.plist` and an executable.
+ static func kdk(at url: URL, kexts: [String: String]) throws {
+ let extensions = url.appending(path: "System/Library/Extensions")
+ for (identifier, path) in kexts {
+ let bundle = extensions.appending(path: path)
+ try FileManager.default.createDirectory(at: bundle, withIntermediateDirectories: true)
+ let name = (path as NSString).lastPathComponent.replacingOccurrences(of: ".kext", with: "")
+ let plist: [String: Any] = ["CFBundleIdentifier": identifier, "CFBundleExecutable": name]
+ try PropertyListSerialization.data(fromPropertyList: plist, format: .xml, options: 0)
+ .write(to: bundle.appending(path: "Info.plist"))
+ try Data(identifier.utf8).write(to: bundle.appending(path: name))
+ }
+ let coreServices = url.appending(path: "System/Library/CoreServices")
+ try FileManager.default.createDirectory(at: coreServices, withIntermediateDirectories: true)
+ try PropertyListSerialization.data(
+ fromPropertyList: ["ProductVersion": "26.6", "ProductBuildVersion": "23G71"], format: .xml, options: 0,
+ ).write(to: coreServices.appending(path: "SystemVersion.plist"))
+ let kernels = url.appending(path: "System/Library/Kernels")
+ try FileManager.default.createDirectory(at: kernels, withIntermediateDirectories: true)
+ try Data("kernel".utf8).write(to: kernels.appending(path: "kernel"))
+ }
+
+ @Test("The mix keeps the wanted base kexts, drops the others and adds the donor's")
+ func mixesKDKs() throws {
+ let root = FileManager.default.temporaryDirectory.appending(path: UUID().uuidString)
+ defer { try? FileManager.default.removeItem(at: root) }
+ let base = root.appending(path: "base/KDK_26.6_23G71.kdk")
+ let donor = root.appending(path: "donor/KDK_26.4_23E5207i.kdk")
+ try Self.kdk(at: base, kexts: [
+ "com.apple.kept": "Kept.kext",
+ "com.apple.research.only": "ResearchOnly.kext",
+ "com.apple.plugin": "ResearchOnly.kext/PlugIns/Plugin.kext",
+ ])
+ try Self.kdk(at: donor, kexts: [
+ "com.apple.kept": "Kept.kext",
+ "com.apple.driver.AppleParavirtGPU": "AppleParavirtGPU.kext",
+ ])
+ let wanted = ["com.apple.kept", "com.apple.plugin", "com.apple.driver.AppleParavirtGPU"]
+ let output = root.appending(path: "mix/KDK_26.6_23G71.kdk")
+ let (removed, added) = try KernelCacheKDK.mix(base: base, donor: donor, wanted: wanted, output: output)
+ #expect(removed.isEmpty) // the research-only parent stays for its wanted plug-in, without its own Info.plist
+ #expect(added == ["com.apple.driver.AppleParavirtGPU"])
+ #expect(Set(try KernelCacheKDK.bundles(in: output).keys) == Set(wanted))
+
+ let volume = root.appending(path: "volume")
+ let kernel = try KernelCacheKDK.makeVolume(kdk: output, identifiers: wanted, output: volume)
+ #expect(kernel.path.hasSuffix("Library/Developer/KDKs/KDK_26.6_23G71.kdk/System/Library/Kernels/kernel"))
+ #expect(Set(try KernelCacheKDK.bundles(in: volume).keys) == Set(wanted))
+
+ #expect(throws: PatcherError.self) {
+ try KernelCacheKDK.mix(base: base, donor: donor, wanted: wanted + ["com.apple.nowhere"], output: output)
+ }
+ }
+}
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
index a883c48c..89d089c6 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneCustomFirmwareInstaller.swift
@@ -550,9 +550,17 @@ struct VPhoneCustomFirmwareInstaller {
let callerUID = invokingUser?.uid
let bundleDirectory = try pinBundle(owner: callerUID)
let bundlePath = try bundleDirectory.path
- if Self.restoredCustomisedSystem(readPatchPlan(in: bundleDirectory)) {
+ let recordedPlan = readPatchPlan(in: bundleDirectory)
+ if Self.restoredCustomisedSystem(recordedPlan) {
throw Self.restoreImageRefusal(mode)
}
+ // Its originals hold the research board's kernel, not the mix.
+ if recordedPlan?.isEnabled(FirmwareResearchBoardPatchSet.kernelMix) == true {
+ throw ValidationError(
+ "This VM boots a kernelcache rebuilt from the research board's (its cloudOS has no vphone600 components), "
+ + "which a kernel update cannot rebuild. Change its kernel patches with `fw patch` and a restore instead.",
+ )
+ }
let disk = try openDiskImage(in: bundleDirectory, path: bundlePath, owner: callerUID)
let diskPath = (bundlePath as NSString).appendingPathComponent("Disk.img")
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneFirmwarePreparer.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneFirmwarePreparer.swift
index 5d467436..5580be7f 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneFirmwarePreparer.swift
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Firmware/VPhoneFirmwarePreparer.swift
@@ -40,6 +40,7 @@ enum VPhoneFirmwarePreparer {
device productType: String? = nil,
otaSource: String? = nil,
otaKey: String? = nil,
+ checksKernelcacheMix: Bool = false,
bundle: VPhoneBundle,
resources: VPhoneResources,
) throws {
@@ -156,6 +157,16 @@ enum VPhoneFirmwarePreparer {
let originalManifest = phoneTree.appendingPathComponent("BuildManifest.plist")
try clone(originalManifest, to: phoneTree.appendingPathComponent("iPhone-BuildManifest.plist"))
try FirmwareManifest.generate(iPhoneDir: phoneTree, cloudOSDir: cloudTree, device: restored, verbose: true)
+ // A cloudOS without vphone600 components restores the research board's,
+ // whose kernelcache `fw patch` rebuilds from a recipe.
+ if FirmwarePipeline.researchBoardStandsIn(restoreDir: phoneTree) {
+ let recipe = try KernelCacheMixer.recipe(forRestoreTree: phoneTree)
+ print("[+] No vphone600 components in this cloudOS: the research board stands in, kernelcache recipe \(recipe.id)")
+ // `vm create` would otherwise stop only at `fw patch`, after the GPU restore.
+ if checksKernelcacheMix {
+ try KernelCacheMixer.checkMixable(restoreTree: phoneTree)
+ }
+ }
let userland = staging.appendingPathComponent(VPhoneOTAArchive.userlandDirectoryName, isDirectory: true)
if let ota {
try stageOTA(ota, device: device, restoreTree: phoneTree, userland: userland)
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineCreator.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineCreator.swift
index 05c85a89..588d939c 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineCreator.swift
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineCreator.swift
@@ -513,6 +513,7 @@ public struct VPhoneVirtualMachineCreator {
device: options.device,
otaSource: options.otaSource,
otaKey: options.otaKey,
+ checksKernelcacheMix: true,
bundle: bundle, resources: resources,
)
print("[+] Firmware prepared (iPhone + cloudOS merged into bundle).")
diff --git a/VPhoneExecutable/VPhoneVirtualization/Build/StageBundle.sh b/VPhoneExecutable/VPhoneVirtualization/Build/StageBundle.sh
index 6b110205..4a87090e 100755
--- a/VPhoneExecutable/VPhoneVirtualization/Build/StageBundle.sh
+++ b/VPhoneExecutable/VPhoneVirtualization/Build/StageBundle.sh
@@ -129,6 +129,9 @@ fi
/bin/mkdir -p "$resources/patches_presets"
/bin/cp "$root/VPhoneExecutable/VPhoneVirtualization/Resources/patches_presets/"*.plist \
"$resources/patches_presets/"
+# What `fw patch` rebuilds a research board kernelcache from; see its README.
+/bin/rm -rf "$resources/kernelcache_recipes"
+/bin/cp -R "$root/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes" "$resources/"
"${0:a:h}/SyncStrings.sh"
/usr/bin/xcrun xcstringstool compile \
diff --git a/VPhoneExecutable/VPhoneVirtualization/Build/ValidateBundle.sh b/VPhoneExecutable/VPhoneVirtualization/Build/ValidateBundle.sh
index 7bef958e..70014892 100755
--- a/VPhoneExecutable/VPhoneVirtualization/Build/ValidateBundle.sh
+++ b/VPhoneExecutable/VPhoneVirtualization/Build/ValidateBundle.sh
@@ -92,6 +92,19 @@ done
for preset in "$resources/patches_presets/"*.plist; do
/usr/bin/plutil -lint -s "$preset" || { print -u2 "Malformed patch preset: ${preset:t}"; exit 1; }
done
+# Every kernelcache recipe has its symbol map and bundle list, and its donor.
+for manifest in "$resources/kernelcache_recipes/bases/"*/manifest.json; do
+ recipe=${manifest:h}
+ for key in symbols kexts; do
+ file=$(/usr/bin/plutil -extract $key raw -o - "$manifest") || { print -u2 "Malformed kernelcache recipe: ${recipe:t}"; exit 1; }
+ [[ -s "$recipe/$file" ]] || { print -u2 "Kernelcache recipe ${recipe:t} lacks $file"; exit 1; }
+ done
+ donor=$(/usr/bin/plutil -extract donor raw -o - "$manifest")
+ [[ -s "$resources/kernelcache_recipes/donors/$donor/manifest.json" ]] || {
+ print -u2 "Kernelcache recipe ${recipe:t} names a missing donor: $donor"
+ exit 1
+ }
+done
# New machines copy this ROM. Without it vm new would fail, and OpenAVB is
# distributed only with its licences. The ROM window is 512 KiB.
for name in OpenAVB.bin LICENSE APSL-2.0.txt; do
diff --git a/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/README.md b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/README.md
new file mode 100644
index 00000000..56a0a24c
--- /dev/null
+++ b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/README.md
@@ -0,0 +1,68 @@
+# Kernelcache recipes
+
+Only the 26.1–26.4 beta cloudOS releases ship vphone600 components. On any
+other cloudOS, `fw patch` takes the research board's (vresearch101) and rebuilds
+its `kernelcache.release.vresearch101` with the iPhone virtualisation kexts of a
+donor kernelcache (`kernel-boot-vresearch101_kext_mix`, `KernelCacheMixer`).
+These recipes say how, one per supported kernelcache. Details are in
+`Research/0_binary_patch_comparison.md` ("The research board's kernelcache").
+
+## Layout
+
+```
+bases/<iOS version>_<iPhone build>/
+ manifest.json the recipe (below)
+ symbols.json.gz symbol map: kernelcache address (decimal) to name(s)
+ kexts.txt bundle identifiers of the mix
+donors/<id>/
+ manifest.json the donor kernelcache and the cloudOS it is read from
+ symbols.json.gz symbol map, for a stripped donor
+```
+
+Base `manifest.json`:
+
+| Key | Meaning |
+|---|---|
+| `kernel.sha256`, `kernel.decompressedSHA256` | identify the research board kernelcache (IM4P or decompressed) |
+| `kernel.kdk` | the KDK its extraction makes; a kernelcache whose kexts carry no `DTPlatformBuild` (26.6, 26.7) takes the build from here |
+| `donor` | `donors/<id>`, which supplies the virtualisation kexts |
+| `builderLayout` | `kernel-last` (iOS 26.4+, kmutil of macOS 26.4+) or `kernel-first` |
+
+The bundle list is the base's kexts without the research-board-only ones
+(CIOMesh, MLX5, Thunderbolt, RDMA, ...), plus the donor kexts that link against
+the base kernel.
+
+The donor `vphone600_26.4_23E5207q` is the vphone600 kernelcache of the 26.4
+beta cloudOS, the last one with vphone600 components. Only that file is read
+from the cloudOS IPSW, once, and kept with its extraction in
+`~/.vphone/kernelcache/donors`.
+
+## Requirements
+
+- An `ipsw` with `kernel extract --kdk` (blacktop/ipsw), named by `VPHONE_IPSW`.
+ vphone-cli does not ship it.
+- Root: kmutil only reads kexts owned by root:wheel, and links the host's own
+ kexts in place of any others without a word.
+- A kmutil of the base's `builderLayout`: macOS 26.4 or later for every base here.
+
+Mixed kernelcaches are cached in `~/.vphone/kernelcache/mix`, keyed by everything
+that decides their bytes.
+
+## Adding a base
+
+A recipe comes from research, not from this repository:
+
+1. Symbolicate the stripped kernelcache with BinDiff against a symbolicated KDK of
+ the same family (`ipsw kernel symbolicate --bindiff <kdk> <kc> --json
+ --aliases`, which writes every name of an address, as step 4 needs).
+2. Fix wrong binds, checked against link symbols, PAC discriminators,
+ same-generation macOS KDKs and C++ vtables, until every donor import binds
+ and the extraction links.
+3. Check the base: its extraction, linked again with Apple's bundle list, must be
+ byte-identical to the shipped kernelcache.
+4. For a stripped donor, put the import names of the donor extraction the maps
+ were built against first in its map. Several names often share an address
+ (folded stubs, inherited `_kc.` placeholders), and an import binds to the
+ first one; another order makes kmutil fail with "could not find a kext which
+ exports this symbol".
+5. Build the mix, boot it, and add the map, bundle list and manifest here.
diff --git a/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.4_23E246/kexts.txt b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.4_23E246/kexts.txt
new file mode 100644
index 00000000..f31526a5
--- /dev/null
+++ b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.4_23E246/kexts.txt
@@ -0,0 +1,160 @@
+com.apple.AUC
+com.apple.AppleFSCompression.AppleFSCompressionTypeZlib
+com.apple.IOTextEncryptionFamily
+com.apple.driver.AppleA7IOP
+com.apple.driver.AppleARMGIC
+com.apple.driver.AppleARMPMU
+com.apple.driver.AppleARMPlatform
+com.apple.driver.AppleARMWatchdogTimer
+com.apple.driver.AppleActuatorDriver
+com.apple.driver.AppleAudioClockLibs
+com.apple.driver.AppleBSDKextStarter
+com.apple.driver.AppleBSDKextStarterTMPFS
+com.apple.driver.AppleBSDKextStarterVPN
+com.apple.driver.AppleCallbackPowerSource
+com.apple.driver.AppleDiagnosticDataAccessReadOnly
+com.apple.driver.AppleDiskImages2
+com.apple.driver.AppleEffaceableStorage
+com.apple.driver.AppleEmbeddedAudioLibs
+com.apple.driver.AppleEmbeddedLightSensor
+com.apple.driver.AppleEmbeddedPCIE
+com.apple.driver.AppleEmbeddedTempSensor
+com.apple.driver.AppleEmbeddedUSB
+com.apple.driver.AppleEmbeddedUSBHost
+com.apple.driver.AppleFirmwareUpdateKext
+com.apple.driver.AppleGameControllerPersonality
+com.apple.driver.AppleHIDKeyboard
+com.apple.driver.AppleHIDKeyboardEmbedded
+com.apple.driver.AppleIISController
+com.apple.driver.AppleInputDeviceSupport
+com.apple.driver.AppleLockdownMode
+com.apple.driver.AppleM2ScalerCSCDriver
+com.apple.driver.AppleM2ScalerParavirtDriver
+com.apple.driver.AppleM68Buttons
+com.apple.driver.AppleMobileApNonce
+com.apple.driver.AppleMobileFileIntegrity
+com.apple.driver.AppleMultitouchDriver
+com.apple.driver.AppleMultitouchSPI
+com.apple.driver.AppleNANDConfigAccess
+com.apple.driver.AppleOnboardSerial
+com.apple.driver.ApplePIODMA
+com.apple.driver.ApplePMGR
+com.apple.driver.ApplePVPanic
+com.apple.driver.AppleParavirtGPUIOGPUFamily
+com.apple.driver.AppleS8000AES
+com.apple.driver.AppleSEPCredentialManager
+com.apple.driver.AppleSEPKeyStore
+com.apple.driver.AppleSEPManager
+com.apple.driver.AppleSMC
+com.apple.driver.AppleSPU
+com.apple.driver.AppleSamsungSerial
+com.apple.driver.AppleSerialShim
+com.apple.driver.AppleStorageDrivers
+com.apple.driver.AppleTopCaseDriverV2
+com.apple.driver.AppleTopCaseHIDEventDriver
+com.apple.driver.AppleTypeCPhy
+com.apple.driver.AppleUSBCardReader
+com.apple.driver.AppleUSBDeviceMux
+com.apple.driver.AppleUSBDeviceNCM
+com.apple.driver.AppleUSBEthernetHost
+com.apple.driver.AppleUSBHostMergeProperties
+com.apple.driver.AppleUSBMassStorageInterfaceNub
+com.apple.driver.AppleVPIOP
+com.apple.driver.AppleVideoToolboxParavirtualization
+com.apple.driver.AppleVirtIO
+com.apple.driver.AppleVirtualPlatform
+com.apple.driver.AvpFairPlayDriver
+com.apple.driver.DiskImages
+com.apple.driver.DiskImages.FileBackingStore
+com.apple.driver.DiskImages.KernelBacked
+com.apple.driver.DiskImages.RAMBackingStore
+com.apple.driver.DiskImages.ReadWriteDiskImage
+com.apple.driver.DiskImages.UDIFDiskImage
+com.apple.driver.ExclavesAudioKext
+com.apple.driver.FairPlayIOKit
+com.apple.driver.IISAudioIsolatedStreamECProxy
+com.apple.driver.IODARTFamily
+com.apple.driver.IOSlaveProcessor
+com.apple.driver.RTBuddy
+com.apple.driver.SCSIDeviceSpecifics
+com.apple.driver.USBStorageDeviceSpecifics
+com.apple.driver.driverkit.serial
+com.apple.driver.mDNSOffloadUserClient-Embedded
+com.apple.driver.usb.AppleEmbeddedUSBXHCIPCI
+com.apple.driver.usb.AppleSynopsysUSBXHCI
+com.apple.driver.usb.AppleUSBCommon
+com.apple.driver.usb.AppleUSBHostCompositeDevice
+com.apple.driver.usb.AppleUSBHostDeviceSupport
+com.apple.driver.usb.AppleUSBHostPacketFilter
+com.apple.driver.usb.AppleUSBHostPlatformProperties
+com.apple.driver.usb.AppleUSBHostiOSDevice
+com.apple.driver.usb.AppleUSBHub
+com.apple.driver.usb.AppleUSBXHCI
+com.apple.driver.usb.AppleUSBXHCIPCI
+com.apple.driver.usb.cdc
+com.apple.driver.usb.cdc.acm
+com.apple.driver.usb.cdc.ecm
+com.apple.driver.usb.cdc.ncm
+com.apple.driver.usb.ethernet.asix
+com.apple.driver.usb.networking
+com.apple.driver.usb.serial
+com.apple.filesystems.apfs
+com.apple.filesystems.hfs.kext
+com.apple.filesystems.lifs
+com.apple.filesystems.tmpfs
+com.apple.iokit.AppleARMIISAudio
+com.apple.iokit.AppleParavirtIOSurface
+com.apple.iokit.AppleVirtIONeuralEngineDevice
+com.apple.iokit.AppleVirtIOStorage
+com.apple.iokit.CoreAnalyticsFamily
+com.apple.iokit.IOAVFamily
+com.apple.iokit.IOAccessoryManager
+com.apple.iokit.IOAccessoryPortUSB
+com.apple.iokit.IOAudio2Family
+com.apple.iokit.IOCECFamily
+com.apple.iokit.IOCryptoAcceleratorFamily
+com.apple.iokit.IOGPUFamily
+com.apple.iokit.IOGameControllerFamily
+com.apple.iokit.IOHDCPFamily
+com.apple.iokit.IOHIDEventDriver
+com.apple.iokit.IOHIDEventDriverSafeBoot
+com.apple.iokit.IOHIDFamily
+com.apple.iokit.IOMobileGraphicsFamily
+com.apple.iokit.IONetworkFamily
+com.apple.iokit.IONetworkingFamily
+com.apple.iokit.IOPCIFamily
+com.apple.iokit.IOPortFamily
+com.apple.iokit.IOReportFamily
+com.apple.iokit.IOSCSIArchitectureModelFamily
+com.apple.iokit.IOSCSIBlockCommandsDevice
+com.apple.iokit.IOSerialFamily
+com.apple.iokit.IOSkywalkFamily
+com.apple.iokit.IOSlowAdaptiveClockingFamily
+com.apple.iokit.IOStorageFamily
+com.apple.iokit.IOStreamFamily
+com.apple.iokit.IOSurface
+com.apple.iokit.IOTimeSyncFamily
+com.apple.iokit.IOUSBDeviceFamily
+com.apple.iokit.IOUSBHostFamily
+com.apple.iokit.IOUSBMassStorageDriver
+com.apple.iokit.IOUserEthernet
+com.apple.kec.AppleEncryptedArchive
+com.apple.kec.Compression
+com.apple.kec.Libm
+com.apple.kec.corecrypto
+com.apple.kec.pthread
+com.apple.kext.AppleMatch
+com.apple.kext.CoreTrust
+com.apple.kpi.bsd
+com.apple.kpi.dsep
+com.apple.kpi.iokit
+com.apple.kpi.libkern
+com.apple.kpi.mach
+com.apple.kpi.private
+com.apple.kpi.unsupported
+com.apple.nke.l2tp
+com.apple.nke.ppp
+com.apple.plugin.IOgPTPPlugin
+com.apple.security.AKSAnalytics
+com.apple.security.AppleImage4
+com.apple.security.sandbox
diff --git a/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.4_23E246/manifest.json b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.4_23E246/manifest.json
new file mode 100644
index 00000000..d84eb98c
--- /dev/null
+++ b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.4_23E246/manifest.json
@@ -0,0 +1,14 @@
+{
+ "builderLayout" : "kernel-last",
+ "donor" : "vphone600_26.4_23E5207q",
+ "id" : "26.4_23E246",
+ "kernel" : {
+ "decompressedSHA256" : "e4de60cdf330adefedcc6d6eae1874cff83f955e9ca25191e31e918def8306d0",
+ "file" : "kernelcache.release.vresearch101",
+ "kdk" : "KDK_26.4_23E235.kdk",
+ "sha256" : "79a43249ea047f23c2046c266ee3419d3223038dae9efe367dbb4fb1b1486cd1"
+ },
+ "kexts" : "kexts.txt",
+ "productVersion" : "26.4",
+ "symbols" : "symbols.json.gz"
+}
\ No newline at end of file
diff --git a/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.4_23E246/symbols.json.gz b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.4_23E246/symbols.json.gz
new file mode 100644
index 00000000..afaf7597
Binary files /dev/null and b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.4_23E246/symbols.json.gz differ
diff --git a/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.5_23F77/kexts.txt b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.5_23F77/kexts.txt
new file mode 100644
index 00000000..f31526a5
--- /dev/null
+++ b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.5_23F77/kexts.txt
@@ -0,0 +1,160 @@
+com.apple.AUC
+com.apple.AppleFSCompression.AppleFSCompressionTypeZlib
+com.apple.IOTextEncryptionFamily
+com.apple.driver.AppleA7IOP
+com.apple.driver.AppleARMGIC
+com.apple.driver.AppleARMPMU
+com.apple.driver.AppleARMPlatform
+com.apple.driver.AppleARMWatchdogTimer
+com.apple.driver.AppleActuatorDriver
+com.apple.driver.AppleAudioClockLibs
+com.apple.driver.AppleBSDKextStarter
+com.apple.driver.AppleBSDKextStarterTMPFS
+com.apple.driver.AppleBSDKextStarterVPN
+com.apple.driver.AppleCallbackPowerSource
+com.apple.driver.AppleDiagnosticDataAccessReadOnly
+com.apple.driver.AppleDiskImages2
+com.apple.driver.AppleEffaceableStorage
+com.apple.driver.AppleEmbeddedAudioLibs
+com.apple.driver.AppleEmbeddedLightSensor
+com.apple.driver.AppleEmbeddedPCIE
+com.apple.driver.AppleEmbeddedTempSensor
+com.apple.driver.AppleEmbeddedUSB
+com.apple.driver.AppleEmbeddedUSBHost
+com.apple.driver.AppleFirmwareUpdateKext
+com.apple.driver.AppleGameControllerPersonality
+com.apple.driver.AppleHIDKeyboard
+com.apple.driver.AppleHIDKeyboardEmbedded
+com.apple.driver.AppleIISController
+com.apple.driver.AppleInputDeviceSupport
+com.apple.driver.AppleLockdownMode
+com.apple.driver.AppleM2ScalerCSCDriver
+com.apple.driver.AppleM2ScalerParavirtDriver
+com.apple.driver.AppleM68Buttons
+com.apple.driver.AppleMobileApNonce
+com.apple.driver.AppleMobileFileIntegrity
+com.apple.driver.AppleMultitouchDriver
+com.apple.driver.AppleMultitouchSPI
+com.apple.driver.AppleNANDConfigAccess
+com.apple.driver.AppleOnboardSerial
+com.apple.driver.ApplePIODMA
+com.apple.driver.ApplePMGR
+com.apple.driver.ApplePVPanic
+com.apple.driver.AppleParavirtGPUIOGPUFamily
+com.apple.driver.AppleS8000AES
+com.apple.driver.AppleSEPCredentialManager
+com.apple.driver.AppleSEPKeyStore
+com.apple.driver.AppleSEPManager
+com.apple.driver.AppleSMC
+com.apple.driver.AppleSPU
+com.apple.driver.AppleSamsungSerial
+com.apple.driver.AppleSerialShim
+com.apple.driver.AppleStorageDrivers
+com.apple.driver.AppleTopCaseDriverV2
+com.apple.driver.AppleTopCaseHIDEventDriver
+com.apple.driver.AppleTypeCPhy
+com.apple.driver.AppleUSBCardReader
+com.apple.driver.AppleUSBDeviceMux
+com.apple.driver.AppleUSBDeviceNCM
+com.apple.driver.AppleUSBEthernetHost
+com.apple.driver.AppleUSBHostMergeProperties
+com.apple.driver.AppleUSBMassStorageInterfaceNub
+com.apple.driver.AppleVPIOP
+com.apple.driver.AppleVideoToolboxParavirtualization
+com.apple.driver.AppleVirtIO
+com.apple.driver.AppleVirtualPlatform
+com.apple.driver.AvpFairPlayDriver
+com.apple.driver.DiskImages
+com.apple.driver.DiskImages.FileBackingStore
+com.apple.driver.DiskImages.KernelBacked
+com.apple.driver.DiskImages.RAMBackingStore
+com.apple.driver.DiskImages.ReadWriteDiskImage
+com.apple.driver.DiskImages.UDIFDiskImage
+com.apple.driver.ExclavesAudioKext
+com.apple.driver.FairPlayIOKit
+com.apple.driver.IISAudioIsolatedStreamECProxy
+com.apple.driver.IODARTFamily
+com.apple.driver.IOSlaveProcessor
+com.apple.driver.RTBuddy
+com.apple.driver.SCSIDeviceSpecifics
+com.apple.driver.USBStorageDeviceSpecifics
+com.apple.driver.driverkit.serial
+com.apple.driver.mDNSOffloadUserClient-Embedded
+com.apple.driver.usb.AppleEmbeddedUSBXHCIPCI
+com.apple.driver.usb.AppleSynopsysUSBXHCI
+com.apple.driver.usb.AppleUSBCommon
+com.apple.driver.usb.AppleUSBHostCompositeDevice
+com.apple.driver.usb.AppleUSBHostDeviceSupport
+com.apple.driver.usb.AppleUSBHostPacketFilter
+com.apple.driver.usb.AppleUSBHostPlatformProperties
+com.apple.driver.usb.AppleUSBHostiOSDevice
+com.apple.driver.usb.AppleUSBHub
+com.apple.driver.usb.AppleUSBXHCI
+com.apple.driver.usb.AppleUSBXHCIPCI
+com.apple.driver.usb.cdc
+com.apple.driver.usb.cdc.acm
+com.apple.driver.usb.cdc.ecm
+com.apple.driver.usb.cdc.ncm
+com.apple.driver.usb.ethernet.asix
+com.apple.driver.usb.networking
+com.apple.driver.usb.serial
+com.apple.filesystems.apfs
+com.apple.filesystems.hfs.kext
+com.apple.filesystems.lifs
+com.apple.filesystems.tmpfs
+com.apple.iokit.AppleARMIISAudio
+com.apple.iokit.AppleParavirtIOSurface
+com.apple.iokit.AppleVirtIONeuralEngineDevice
+com.apple.iokit.AppleVirtIOStorage
+com.apple.iokit.CoreAnalyticsFamily
+com.apple.iokit.IOAVFamily
+com.apple.iokit.IOAccessoryManager
+com.apple.iokit.IOAccessoryPortUSB
+com.apple.iokit.IOAudio2Family
+com.apple.iokit.IOCECFamily
+com.apple.iokit.IOCryptoAcceleratorFamily
+com.apple.iokit.IOGPUFamily
+com.apple.iokit.IOGameControllerFamily
+com.apple.iokit.IOHDCPFamily
+com.apple.iokit.IOHIDEventDriver
+com.apple.iokit.IOHIDEventDriverSafeBoot
+com.apple.iokit.IOHIDFamily
+com.apple.iokit.IOMobileGraphicsFamily
+com.apple.iokit.IONetworkFamily
+com.apple.iokit.IONetworkingFamily
+com.apple.iokit.IOPCIFamily
+com.apple.iokit.IOPortFamily
+com.apple.iokit.IOReportFamily
+com.apple.iokit.IOSCSIArchitectureModelFamily
+com.apple.iokit.IOSCSIBlockCommandsDevice
+com.apple.iokit.IOSerialFamily
+com.apple.iokit.IOSkywalkFamily
+com.apple.iokit.IOSlowAdaptiveClockingFamily
+com.apple.iokit.IOStorageFamily
+com.apple.iokit.IOStreamFamily
+com.apple.iokit.IOSurface
+com.apple.iokit.IOTimeSyncFamily
+com.apple.iokit.IOUSBDeviceFamily
+com.apple.iokit.IOUSBHostFamily
+com.apple.iokit.IOUSBMassStorageDriver
+com.apple.iokit.IOUserEthernet
+com.apple.kec.AppleEncryptedArchive
+com.apple.kec.Compression
+com.apple.kec.Libm
+com.apple.kec.corecrypto
+com.apple.kec.pthread
+com.apple.kext.AppleMatch
+com.apple.kext.CoreTrust
+com.apple.kpi.bsd
+com.apple.kpi.dsep
+com.apple.kpi.iokit
+com.apple.kpi.libkern
+com.apple.kpi.mach
+com.apple.kpi.private
+com.apple.kpi.unsupported
+com.apple.nke.l2tp
+com.apple.nke.ppp
+com.apple.plugin.IOgPTPPlugin
+com.apple.security.AKSAnalytics
+com.apple.security.AppleImage4
+com.apple.security.sandbox
diff --git a/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.5_23F77/manifest.json b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.5_23F77/manifest.json
new file mode 100644
index 00000000..57dfbadd
--- /dev/null
+++ b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.5_23F77/manifest.json
@@ -0,0 +1,14 @@
+{
+ "builderLayout" : "kernel-last",
+ "donor" : "vphone600_26.4_23E5207q",
+ "id" : "26.5_23F77",
+ "kernel" : {
+ "decompressedSHA256" : "622ce55b4363ac9723124f9c627af30d893707820c9ad094589a66ec5fc66dad",
+ "file" : "kernelcache.release.vresearch101",
+ "kdk" : "KDK_26.5_23F68.kdk",
+ "sha256" : "7f656f3cd194b3564dd374161ba10b9af94a20ad41c289f96f1af79b9a1e91ac"
+ },
+ "kexts" : "kexts.txt",
+ "productVersion" : "26.5",
+ "symbols" : "symbols.json.gz"
+}
\ No newline at end of file
diff --git a/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.5_23F77/symbols.json.gz b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.5_23F77/symbols.json.gz
new file mode 100644
index 00000000..6b8a9146
Binary files /dev/null and b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.5_23F77/symbols.json.gz differ
diff --git a/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.6_23G71/kexts.txt b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.6_23G71/kexts.txt
new file mode 100644
index 00000000..f31526a5
--- /dev/null
+++ b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.6_23G71/kexts.txt
@@ -0,0 +1,160 @@
+com.apple.AUC
+com.apple.AppleFSCompression.AppleFSCompressionTypeZlib
+com.apple.IOTextEncryptionFamily
+com.apple.driver.AppleA7IOP
+com.apple.driver.AppleARMGIC
+com.apple.driver.AppleARMPMU
+com.apple.driver.AppleARMPlatform
+com.apple.driver.AppleARMWatchdogTimer
+com.apple.driver.AppleActuatorDriver
+com.apple.driver.AppleAudioClockLibs
+com.apple.driver.AppleBSDKextStarter
+com.apple.driver.AppleBSDKextStarterTMPFS
+com.apple.driver.AppleBSDKextStarterVPN
+com.apple.driver.AppleCallbackPowerSource
+com.apple.driver.AppleDiagnosticDataAccessReadOnly
+com.apple.driver.AppleDiskImages2
+com.apple.driver.AppleEffaceableStorage
+com.apple.driver.AppleEmbeddedAudioLibs
+com.apple.driver.AppleEmbeddedLightSensor
+com.apple.driver.AppleEmbeddedPCIE
+com.apple.driver.AppleEmbeddedTempSensor
+com.apple.driver.AppleEmbeddedUSB
+com.apple.driver.AppleEmbeddedUSBHost
+com.apple.driver.AppleFirmwareUpdateKext
+com.apple.driver.AppleGameControllerPersonality
+com.apple.driver.AppleHIDKeyboard
+com.apple.driver.AppleHIDKeyboardEmbedded
+com.apple.driver.AppleIISController
+com.apple.driver.AppleInputDeviceSupport
+com.apple.driver.AppleLockdownMode
+com.apple.driver.AppleM2ScalerCSCDriver
+com.apple.driver.AppleM2ScalerParavirtDriver
+com.apple.driver.AppleM68Buttons
+com.apple.driver.AppleMobileApNonce
+com.apple.driver.AppleMobileFileIntegrity
+com.apple.driver.AppleMultitouchDriver
+com.apple.driver.AppleMultitouchSPI
+com.apple.driver.AppleNANDConfigAccess
+com.apple.driver.AppleOnboardSerial
+com.apple.driver.ApplePIODMA
+com.apple.driver.ApplePMGR
+com.apple.driver.ApplePVPanic
+com.apple.driver.AppleParavirtGPUIOGPUFamily
+com.apple.driver.AppleS8000AES
+com.apple.driver.AppleSEPCredentialManager
+com.apple.driver.AppleSEPKeyStore
+com.apple.driver.AppleSEPManager
+com.apple.driver.AppleSMC
+com.apple.driver.AppleSPU
+com.apple.driver.AppleSamsungSerial
+com.apple.driver.AppleSerialShim
+com.apple.driver.AppleStorageDrivers
+com.apple.driver.AppleTopCaseDriverV2
+com.apple.driver.AppleTopCaseHIDEventDriver
+com.apple.driver.AppleTypeCPhy
+com.apple.driver.AppleUSBCardReader
+com.apple.driver.AppleUSBDeviceMux
+com.apple.driver.AppleUSBDeviceNCM
+com.apple.driver.AppleUSBEthernetHost
+com.apple.driver.AppleUSBHostMergeProperties
+com.apple.driver.AppleUSBMassStorageInterfaceNub
+com.apple.driver.AppleVPIOP
+com.apple.driver.AppleVideoToolboxParavirtualization
+com.apple.driver.AppleVirtIO
+com.apple.driver.AppleVirtualPlatform
+com.apple.driver.AvpFairPlayDriver
+com.apple.driver.DiskImages
+com.apple.driver.DiskImages.FileBackingStore
+com.apple.driver.DiskImages.KernelBacked
+com.apple.driver.DiskImages.RAMBackingStore
+com.apple.driver.DiskImages.ReadWriteDiskImage
+com.apple.driver.DiskImages.UDIFDiskImage
+com.apple.driver.ExclavesAudioKext
+com.apple.driver.FairPlayIOKit
+com.apple.driver.IISAudioIsolatedStreamECProxy
+com.apple.driver.IODARTFamily
+com.apple.driver.IOSlaveProcessor
+com.apple.driver.RTBuddy
+com.apple.driver.SCSIDeviceSpecifics
+com.apple.driver.USBStorageDeviceSpecifics
+com.apple.driver.driverkit.serial
+com.apple.driver.mDNSOffloadUserClient-Embedded
+com.apple.driver.usb.AppleEmbeddedUSBXHCIPCI
+com.apple.driver.usb.AppleSynopsysUSBXHCI
+com.apple.driver.usb.AppleUSBCommon
+com.apple.driver.usb.AppleUSBHostCompositeDevice
+com.apple.driver.usb.AppleUSBHostDeviceSupport
+com.apple.driver.usb.AppleUSBHostPacketFilter
+com.apple.driver.usb.AppleUSBHostPlatformProperties
+com.apple.driver.usb.AppleUSBHostiOSDevice
+com.apple.driver.usb.AppleUSBHub
+com.apple.driver.usb.AppleUSBXHCI
+com.apple.driver.usb.AppleUSBXHCIPCI
+com.apple.driver.usb.cdc
+com.apple.driver.usb.cdc.acm
+com.apple.driver.usb.cdc.ecm
+com.apple.driver.usb.cdc.ncm
+com.apple.driver.usb.ethernet.asix
+com.apple.driver.usb.networking
+com.apple.driver.usb.serial
+com.apple.filesystems.apfs
+com.apple.filesystems.hfs.kext
+com.apple.filesystems.lifs
+com.apple.filesystems.tmpfs
+com.apple.iokit.AppleARMIISAudio
+com.apple.iokit.AppleParavirtIOSurface
+com.apple.iokit.AppleVirtIONeuralEngineDevice
+com.apple.iokit.AppleVirtIOStorage
+com.apple.iokit.CoreAnalyticsFamily
+com.apple.iokit.IOAVFamily
+com.apple.iokit.IOAccessoryManager
+com.apple.iokit.IOAccessoryPortUSB
+com.apple.iokit.IOAudio2Family
+com.apple.iokit.IOCECFamily
+com.apple.iokit.IOCryptoAcceleratorFamily
+com.apple.iokit.IOGPUFamily
+com.apple.iokit.IOGameControllerFamily
+com.apple.iokit.IOHDCPFamily
+com.apple.iokit.IOHIDEventDriver
+com.apple.iokit.IOHIDEventDriverSafeBoot
+com.apple.iokit.IOHIDFamily
+com.apple.iokit.IOMobileGraphicsFamily
+com.apple.iokit.IONetworkFamily
+com.apple.iokit.IONetworkingFamily
+com.apple.iokit.IOPCIFamily
+com.apple.iokit.IOPortFamily
+com.apple.iokit.IOReportFamily
+com.apple.iokit.IOSCSIArchitectureModelFamily
+com.apple.iokit.IOSCSIBlockCommandsDevice
+com.apple.iokit.IOSerialFamily
+com.apple.iokit.IOSkywalkFamily
+com.apple.iokit.IOSlowAdaptiveClockingFamily
+com.apple.iokit.IOStorageFamily
+com.apple.iokit.IOStreamFamily
+com.apple.iokit.IOSurface
+com.apple.iokit.IOTimeSyncFamily
+com.apple.iokit.IOUSBDeviceFamily
+com.apple.iokit.IOUSBHostFamily
+com.apple.iokit.IOUSBMassStorageDriver
+com.apple.iokit.IOUserEthernet
+com.apple.kec.AppleEncryptedArchive
+com.apple.kec.Compression
+com.apple.kec.Libm
+com.apple.kec.corecrypto
+com.apple.kec.pthread
+com.apple.kext.AppleMatch
+com.apple.kext.CoreTrust
+com.apple.kpi.bsd
+com.apple.kpi.dsep
+com.apple.kpi.iokit
+com.apple.kpi.libkern
+com.apple.kpi.mach
+com.apple.kpi.private
+com.apple.kpi.unsupported
+com.apple.nke.l2tp
+com.apple.nke.ppp
+com.apple.plugin.IOgPTPPlugin
+com.apple.security.AKSAnalytics
+com.apple.security.AppleImage4
+com.apple.security.sandbox
diff --git a/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.6_23G71/manifest.json b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.6_23G71/manifest.json
new file mode 100644
index 00000000..2b91871a
--- /dev/null
+++ b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.6_23G71/manifest.json
@@ -0,0 +1,14 @@
+{
+ "builderLayout" : "kernel-last",
+ "donor" : "vphone600_26.4_23E5207q",
+ "id" : "26.6_23G71",
+ "kernel" : {
+ "decompressedSHA256" : "f76c7ec81a37fb70d813bed3ac11506490263de2120400f937b3e58b08992c10",
+ "file" : "kernelcache.release.vresearch101",
+ "kdk" : "KDK_26.6_23G71.kdk",
+ "sha256" : "a1d94c104efed38d43060568619e6c71875e93d91c59f3f25e022472651f6aaa"
+ },
+ "kexts" : "kexts.txt",
+ "productVersion" : "26.6",
+ "symbols" : "symbols.json.gz"
+}
\ No newline at end of file
diff --git a/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.6_23G71/symbols.json.gz b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.6_23G71/symbols.json.gz
new file mode 100644
index 00000000..50e26881
Binary files /dev/null and b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.6_23G71/symbols.json.gz differ
diff --git a/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.7_23H20/kexts.txt b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.7_23H20/kexts.txt
new file mode 100644
index 00000000..f31526a5
--- /dev/null
+++ b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.7_23H20/kexts.txt
@@ -0,0 +1,160 @@
+com.apple.AUC
+com.apple.AppleFSCompression.AppleFSCompressionTypeZlib
+com.apple.IOTextEncryptionFamily
+com.apple.driver.AppleA7IOP
+com.apple.driver.AppleARMGIC
+com.apple.driver.AppleARMPMU
+com.apple.driver.AppleARMPlatform
+com.apple.driver.AppleARMWatchdogTimer
+com.apple.driver.AppleActuatorDriver
+com.apple.driver.AppleAudioClockLibs
+com.apple.driver.AppleBSDKextStarter
+com.apple.driver.AppleBSDKextStarterTMPFS
+com.apple.driver.AppleBSDKextStarterVPN
+com.apple.driver.AppleCallbackPowerSource
+com.apple.driver.AppleDiagnosticDataAccessReadOnly
+com.apple.driver.AppleDiskImages2
+com.apple.driver.AppleEffaceableStorage
+com.apple.driver.AppleEmbeddedAudioLibs
+com.apple.driver.AppleEmbeddedLightSensor
+com.apple.driver.AppleEmbeddedPCIE
+com.apple.driver.AppleEmbeddedTempSensor
+com.apple.driver.AppleEmbeddedUSB
+com.apple.driver.AppleEmbeddedUSBHost
+com.apple.driver.AppleFirmwareUpdateKext
+com.apple.driver.AppleGameControllerPersonality
+com.apple.driver.AppleHIDKeyboard
+com.apple.driver.AppleHIDKeyboardEmbedded
+com.apple.driver.AppleIISController
+com.apple.driver.AppleInputDeviceSupport
+com.apple.driver.AppleLockdownMode
+com.apple.driver.AppleM2ScalerCSCDriver
+com.apple.driver.AppleM2ScalerParavirtDriver
+com.apple.driver.AppleM68Buttons
+com.apple.driver.AppleMobileApNonce
+com.apple.driver.AppleMobileFileIntegrity
+com.apple.driver.AppleMultitouchDriver
+com.apple.driver.AppleMultitouchSPI
+com.apple.driver.AppleNANDConfigAccess
+com.apple.driver.AppleOnboardSerial
+com.apple.driver.ApplePIODMA
+com.apple.driver.ApplePMGR
+com.apple.driver.ApplePVPanic
+com.apple.driver.AppleParavirtGPUIOGPUFamily
+com.apple.driver.AppleS8000AES
+com.apple.driver.AppleSEPCredentialManager
+com.apple.driver.AppleSEPKeyStore
+com.apple.driver.AppleSEPManager
+com.apple.driver.AppleSMC
+com.apple.driver.AppleSPU
+com.apple.driver.AppleSamsungSerial
+com.apple.driver.AppleSerialShim
+com.apple.driver.AppleStorageDrivers
+com.apple.driver.AppleTopCaseDriverV2
+com.apple.driver.AppleTopCaseHIDEventDriver
+com.apple.driver.AppleTypeCPhy
+com.apple.driver.AppleUSBCardReader
+com.apple.driver.AppleUSBDeviceMux
+com.apple.driver.AppleUSBDeviceNCM
+com.apple.driver.AppleUSBEthernetHost
+com.apple.driver.AppleUSBHostMergeProperties
+com.apple.driver.AppleUSBMassStorageInterfaceNub
+com.apple.driver.AppleVPIOP
+com.apple.driver.AppleVideoToolboxParavirtualization
+com.apple.driver.AppleVirtIO
+com.apple.driver.AppleVirtualPlatform
+com.apple.driver.AvpFairPlayDriver
+com.apple.driver.DiskImages
+com.apple.driver.DiskImages.FileBackingStore
+com.apple.driver.DiskImages.KernelBacked
+com.apple.driver.DiskImages.RAMBackingStore
+com.apple.driver.DiskImages.ReadWriteDiskImage
+com.apple.driver.DiskImages.UDIFDiskImage
+com.apple.driver.ExclavesAudioKext
+com.apple.driver.FairPlayIOKit
+com.apple.driver.IISAudioIsolatedStreamECProxy
+com.apple.driver.IODARTFamily
+com.apple.driver.IOSlaveProcessor
+com.apple.driver.RTBuddy
+com.apple.driver.SCSIDeviceSpecifics
+com.apple.driver.USBStorageDeviceSpecifics
+com.apple.driver.driverkit.serial
+com.apple.driver.mDNSOffloadUserClient-Embedded
+com.apple.driver.usb.AppleEmbeddedUSBXHCIPCI
+com.apple.driver.usb.AppleSynopsysUSBXHCI
+com.apple.driver.usb.AppleUSBCommon
+com.apple.driver.usb.AppleUSBHostCompositeDevice
+com.apple.driver.usb.AppleUSBHostDeviceSupport
+com.apple.driver.usb.AppleUSBHostPacketFilter
+com.apple.driver.usb.AppleUSBHostPlatformProperties
+com.apple.driver.usb.AppleUSBHostiOSDevice
+com.apple.driver.usb.AppleUSBHub
+com.apple.driver.usb.AppleUSBXHCI
+com.apple.driver.usb.AppleUSBXHCIPCI
+com.apple.driver.usb.cdc
+com.apple.driver.usb.cdc.acm
+com.apple.driver.usb.cdc.ecm
+com.apple.driver.usb.cdc.ncm
+com.apple.driver.usb.ethernet.asix
+com.apple.driver.usb.networking
+com.apple.driver.usb.serial
+com.apple.filesystems.apfs
+com.apple.filesystems.hfs.kext
+com.apple.filesystems.lifs
+com.apple.filesystems.tmpfs
+com.apple.iokit.AppleARMIISAudio
+com.apple.iokit.AppleParavirtIOSurface
+com.apple.iokit.AppleVirtIONeuralEngineDevice
+com.apple.iokit.AppleVirtIOStorage
+com.apple.iokit.CoreAnalyticsFamily
+com.apple.iokit.IOAVFamily
+com.apple.iokit.IOAccessoryManager
+com.apple.iokit.IOAccessoryPortUSB
+com.apple.iokit.IOAudio2Family
+com.apple.iokit.IOCECFamily
+com.apple.iokit.IOCryptoAcceleratorFamily
+com.apple.iokit.IOGPUFamily
+com.apple.iokit.IOGameControllerFamily
+com.apple.iokit.IOHDCPFamily
+com.apple.iokit.IOHIDEventDriver
+com.apple.iokit.IOHIDEventDriverSafeBoot
+com.apple.iokit.IOHIDFamily
+com.apple.iokit.IOMobileGraphicsFamily
+com.apple.iokit.IONetworkFamily
+com.apple.iokit.IONetworkingFamily
+com.apple.iokit.IOPCIFamily
+com.apple.iokit.IOPortFamily
+com.apple.iokit.IOReportFamily
+com.apple.iokit.IOSCSIArchitectureModelFamily
+com.apple.iokit.IOSCSIBlockCommandsDevice
+com.apple.iokit.IOSerialFamily
+com.apple.iokit.IOSkywalkFamily
+com.apple.iokit.IOSlowAdaptiveClockingFamily
+com.apple.iokit.IOStorageFamily
+com.apple.iokit.IOStreamFamily
+com.apple.iokit.IOSurface
+com.apple.iokit.IOTimeSyncFamily
+com.apple.iokit.IOUSBDeviceFamily
+com.apple.iokit.IOUSBHostFamily
+com.apple.iokit.IOUSBMassStorageDriver
+com.apple.iokit.IOUserEthernet
+com.apple.kec.AppleEncryptedArchive
+com.apple.kec.Compression
+com.apple.kec.Libm
+com.apple.kec.corecrypto
+com.apple.kec.pthread
+com.apple.kext.AppleMatch
+com.apple.kext.CoreTrust
+com.apple.kpi.bsd
+com.apple.kpi.dsep
+com.apple.kpi.iokit
+com.apple.kpi.libkern
+com.apple.kpi.mach
+com.apple.kpi.private
+com.apple.kpi.unsupported
+com.apple.nke.l2tp
+com.apple.nke.ppp
+com.apple.plugin.IOgPTPPlugin
+com.apple.security.AKSAnalytics
+com.apple.security.AppleImage4
+com.apple.security.sandbox
diff --git a/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.7_23H20/manifest.json b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.7_23H20/manifest.json
new file mode 100644
index 00000000..b04e9769
--- /dev/null
+++ b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.7_23H20/manifest.json
@@ -0,0 +1,14 @@
+{
+ "builderLayout" : "kernel-last",
+ "donor" : "vphone600_26.4_23E5207q",
+ "id" : "26.7_23H20",
+ "kernel" : {
+ "decompressedSHA256" : "fc44fed92afc706dbcf291f0954964c5ab7edb9b56d8a46a1b47f1a48786873d",
+ "file" : "kernelcache.release.vresearch101",
+ "kdk" : "KDK_26.7_23H20.kdk",
+ "sha256" : "bb6e8c5ce03aba84bb185a188413dd09e4165ea8305e875679ecfb8ca0b0d1f1"
+ },
+ "kexts" : "kexts.txt",
+ "productVersion" : "26.7",
+ "symbols" : "symbols.json.gz"
+}
\ No newline at end of file
diff --git a/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.7_23H20/symbols.json.gz b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.7_23H20/symbols.json.gz
new file mode 100644
index 00000000..fb65a9e0
Binary files /dev/null and b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/bases/26.7_23H20/symbols.json.gz differ
diff --git a/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/donors/vphone600_26.4_23E5207q/manifest.json b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/donors/vphone600_26.4_23E5207q/manifest.json
new file mode 100644
index 00000000..188651ae
--- /dev/null
+++ b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/donors/vphone600_26.4_23E5207q/manifest.json
@@ -0,0 +1,12 @@
+{
+ "id": "vphone600_26.4_23E5207q",
+ "description": "vphone600 virtualisation kexts of the 26.4 beta cloudOS (the last one shipping vphone600 before 26.4 release)",
+ "kernel": {
+ "file": "kernelcache.release.vphone600",
+ "sha256": "29b0d67ca805679a705e1558e126cedc64d17ab50f7b48cf9a77847dbe59b338",
+ "decompressedSHA256": "681801fe328b00ff8ec2e94a3d84bf9f9a7a1b954640d0c40f8dd02434270935",
+ "kdk": "KDK_26.4_23E5207i.kdk"
+ },
+ "cloudOSSource": "https://updates.cdn-apple.com/private-cloud-compute/c0ecdb4b310cf5239ab2b248dd3098eec297dc5aa3bbe6ada27273262b0b8b64",
+ "symbols": "symbols.json.gz"
+}
diff --git a/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/donors/vphone600_26.4_23E5207q/symbols.json.gz b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/donors/vphone600_26.4_23E5207q/symbols.json.gz
new file mode 100644
index 00000000..b80b8d39
Binary files /dev/null and b/VPhoneExecutable/VPhoneVirtualization/Resources/kernelcache_recipes/donors/vphone600_26.4_23E5207q/symbols.json.gz differ
diff --git a/VPhoneExecutable/VPhoneVirtualization/Resources/patches_presets/minimal.plist b/VPhoneExecutable/VPhoneVirtualization/Resources/patches_presets/minimal.plist
index f402bd94..3e45412f 100644
--- a/VPhoneExecutable/VPhoneVirtualization/Resources/patches_presets/minimal.plist
+++ b/VPhoneExecutable/VPhoneVirtualization/Resources/patches_presets/minimal.plist
@@ -53,6 +53,7 @@
<string>ibec-boot-bootx_precondition</string>
<string>ibec-boot-image4_callback</string>
<string>ibec-cfw-serial_label</string>
+ <string>kernel-boot-vresearch101_kext_mix</string>
<string>llb-boot-boot_args</string>
<string>llb-boot-image4_callback</string>
<string>llb-boot-panic_bypass</string>
diff --git a/VPhoneKit/VPhoneArchiveKit/Transfer/VPhoneIPSWCache.swift b/VPhoneKit/VPhoneArchiveKit/Transfer/VPhoneIPSWCache.swift
index d798658b..e571c26e 100644
--- a/VPhoneKit/VPhoneArchiveKit/Transfer/VPhoneIPSWCache.swift
+++ b/VPhoneKit/VPhoneArchiveKit/Transfer/VPhoneIPSWCache.swift
@@ -28,7 +28,6 @@ public enum VPhoneIPSWCache {
case swappedSources(iPhone: URL, cloudOS: URL)
case notIPhoneSource(URL, productTypes: [String])
case notCloudOSSource(URL)
- case noVirtualPhoneInCloudOS(URL, version: String, build: String)
public var errorDescription: String? {
switch self {
@@ -46,8 +45,6 @@ public enum VPhoneIPSWCache {
"\(file.lastPathComponent) is not an IPSW vphone can run; it is for \(productTypes.isEmpty ? "no listed product" : productTypes.joined(separator: ", ")). Choose an IPSW for \(VPhoneIPSWCache.guestProductTypes.joined(separator: " or ")) as the iPhone source."
case let .notCloudOSSource(file):
"\(file.lastPathComponent) is not a cloudOS IPSW: it has no \(VPhoneIPSWCache.cloudOSDeviceClass) build identity. Choose a cloudOS IPSW as the cloudOS source."
- case let .noVirtualPhoneInCloudOS(file, version, build):
- "cloudOS \(version) (\(build)) in \(file.lastPathComponent) has no \(VPhoneIPSWCache.guestDeviceClass) build identity to boot the guest from; no cloudOS after the 26.4 beta (23E5207q) has one. Choose the cloudOS `vphone-cli fw catalog` recommends."
}
}
}
@@ -615,10 +612,6 @@ public enum VPhoneIPSWCache {
/// chain matches the VM's DFU hardware. The restore tree needs both.
public static let iPhoneProductType = VPhoneFirmwareCatalog.device
public static let cloudOSDeviceClass = "vresearch101ap"
- /// The cloudOS device class that supplies the guest's kernel, SEP and
- /// device tree. No cloudOS after the 26.4 beta (23E5207q) carries it,
- /// including the 26.4 release (23E244) and every one up to 26.7 (23H20).
- public static let guestDeviceClass = "vphone600ap"
/// Every product whose IPSW can supply the guest OS: the iPhone17,3 the
/// catalog targets, and the iPads and Apple TV `VPhoneGuestDevice` knows.
@@ -652,9 +645,6 @@ public enum VPhoneIPSWCache {
guard cloudOSIsCloudOS else {
throw Error.notCloudOSSource(cloudOS.file)
}
- guard cloudOS.deviceClasses.contains(guestDeviceClass) else {
- throw Error.noVirtualPhoneInCloudOS(cloudOS.file, version: cloudOS.version, build: cloudOS.build)
- }
}
static func cacheName(for url: URL) -> String {
diff --git a/VPhoneKit/VPhoneArchiveKitTests/IPSWCacheTests.swift b/VPhoneKit/VPhoneArchiveKitTests/IPSWCacheTests.swift
index 78d8d901..501827b4 100644
--- a/VPhoneKit/VPhoneArchiveKitTests/IPSWCacheTests.swift
+++ b/VPhoneKit/VPhoneArchiveKitTests/IPSWCacheTests.swift
@@ -516,7 +516,9 @@ struct IPSWCacheTests {
}
}
- @Test func `a cloudOS without the virtual iPhone is refused before extraction`() throws {
+ // `fw prepare` then takes the research board's components and checks that a
+ // kernelcache recipe exists for them.
+ @Test func `a cloudOS without the virtual iPhone pairs, the research board standing in`() throws {
let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true)
defer { try? FileManager.default.removeItem(at: root) }
@@ -525,12 +527,7 @@ struct IPSWCacheTests {
let cloud = try ipsw(in: root, "cloud", productTypes: ["ComputeModule14,1", "Mac14,14"],
deviceClasses: ["j226cap", "j236cap", "vresearch101ap"])
- #expect {
- try VPhoneIPSWCache.checkPair(iPhone: phone, cloudOS: cloud)
- } throws: { error in
- guard case .noVirtualPhoneInCloudOS? = error as? VPhoneIPSWCache.Error else { return false }
- return error.localizedDescription.contains("vphone600ap")
- }
+ try VPhoneIPSWCache.checkPair(iPhone: phone, cloudOS: cloud)
}
@Test func `a known TV donor pairs with cloudOS without admitting unknown TVs`() throws {