{
  "$type": "com.whtwnd.blog.entry",
  "theme": "github-light",
  "title": "Notes re: Exclaves",
  "content": "## Apple OSS code\n\nXNU readme contains references to internal `ExclaveKit` and `ExclaveCore` platform SDKs:\n\n```\nAdd your header file to the correct file list depending on where you want to install it. The default locations where the header files are installed from each file list are -\n(...)\nj. `EXCLAVEKIT_DATAFILES` : To make header file available to Apple internal ExclaveKit SDK -\n   `$(DSTROOT)/System/ExclaveKit/usr/include`\n\nk. `EXCLAVECORE_DATAFILES` : To make header file available to Apple internal ExclaveCore SDK -\n   `$(DSTROOT)/System/ExclaveCore/usr/include`\n```\n\n`TARGET_OS_EXCLAVEKIT` is used in numerous Darwin repositories (xnu, dyld, objc4, libmalloc, libc) and even `swiftlang/swift-foundation`, mostly to *exclude* code from this target.\n\n### Internal tool/header references in OSS code\n\nobjc4/scripts/exclave-run\n```\nExclavesEngineeringRuntimeInternal.dmg\n/Volumes/ExclavesEngineeringRuntimeInternal/System/ExclaveCore/usr/local/bin/prototype-sample-exclavekit-launcher\nusr/local/bin/ExclaveVisor (in the internal macOS SDK)\nSystem/ExclaveCore/usr/local/standalone/cL4/l4.EVP.DEBUG (in the internal ExclaveCore-macOS SDK)\n```\n\nHeaders referenced by various repos:\n\n\"kern/exclaves.tightbeam.h\" (not present on github, `tightbeam.h` referenced by xnu/iokit/Exclaves/Makefile as presumably codegen output, see also https://github.com/upx/upx/issues/612#issuecomment-1819180475)\n\n<Tightbeam/tightbeam.h> and <Tightbeam/tightbeam_private.h>\n\n<xnuproxy/exclaves.h> and <xnuproxy/messages.h>\n\n<xrt_hosted_types/types.h>\n\n## Things said by others\n\n**Guilherme Rambo on Mastodon:**\n\nhttps://mastodon.social/@_inside/112440596781136013\nand \n\nhttps://mastodon.social/@_inside/112552696723119626 (re: Secure Indicator Light)\n\n**Saagar Jha on Hacker News, re: Secure Indicator Light**\n\nhttps://news.ycombinator.com/item?id=40581723\n\n\"It’s not a separate chip but a bit of code isolated from the main OS.\"\n\n\"It’s not a physical LED, it’s essentially a piece of software isolated from the OS that draws to the screen\"\n\n\"Exclaves run on the AP\"\n\n\"A good starting point for thinking about exclaves is by looking at ARM Realms or how pKVM is designed in Android.\"\n\n**Siguza on infosec.space**\n\n\"L4 was gone from the AP (as of iOS 8). I think it's only now returning in ExclaveCore in GL1 under SPTM in GL2.\"\n\nhttps://infosec.space/@siguza/112539155816247609 - Thread talks about historical uses of L4 in iOS\n\n**Asahi Linux IRC**\n\nhttps://oftc.irclog.whitequark.org/asahi-dev/2024-10-24\n```\n14:44 <nickchan> sven: Don't think the exclaves stuff is deployed on macOS yet but after that happens running macOS in hypervisor is going to be... interesting to say at least\n14:44 <nickchan> especially on m1\n14:45 <nickchan> because with exclaves, sptm and txm macOS by default would have stuff in EL2, EL0, GL2, GL1(!) and GL0\n14:46 <nickchan> can do nested on m2 at least but m1, uh idk\n14:46 <nickchan> I expect m4 macs to get it so we should see soon\n14:48 <chaos_princess> Is there a writeup on exclaves anywhere, cause eclecticlight's is kinda... light on the details.\n14:52 <nickchan> chaos_princess: Exclave is its own little OS\n14:52 <nickchan> cL4 kernel, runs in GL1, called exclaveCore\n14:53 <nickchan> exclave userland is called exclaveOS, has a rootfs dmg, dyld, libsystem all that\n14:53 <nickchan> I think it's like 230 MB in size at least for M4 iPad\n14:53 <chaos_princess> how is it different from the old ppl/whatever it is called now?\n14:54 <nickchan> chaos_princess: sptm is the ppl replacement\n14:54 <nickchan> both runs in GL2\n14:55 <nickchan> the kicker here is that Exclave is essentially SPTM's VM so to run it properly under m1n1 nested virt is required\n14:55 <chaos_princess> no i mean, what extra stuff does the exclave thing do, compared to what gl2 did previously?\n14:58 <nickchan> note: TXM runs in GL0 too, and in this sense TXM is SPTM's userland\n14:59 <nickchan> chaos_princess: Don't think there's much research on that besides eclecticlight's blog\n```\n\nhttps://oftc.irclog.whitequark.org/asahi-dev/2024-07-14#\n```\n08:44 <nickchan> A15-A17: SPTM introduced in iOS 17; M4: SPTM launched with iPadOS 17.5; M2: SPTM introduced in iOS 18/macOS 15\n08:45 <nickchan> it is expected that it will eventually be introduced to M1/A14+\n08:45 <jannau> sounds like it is part of the exclave handling present for tons of intersting devices in the ipad pro m4 ADT\n08:47 <nickchan> yeah every exception level is used now GL2: SPTM; EL2: XNU; GL1: ExclaveCore; EL1: Guest Kernel; GL0: ExclaveOS; EL0: macOS userland\n08:47 <nickchan> need SPTM as the hypervisor to run Exclave\n```\n\n## Private iOS Frameworks\n\nCoreSpeechExclave.framework\n\nExclaveFDRDecode.framework (FDR is \"Factory Data Restore\" and refers to various hardware calibration data being signed as boot objects)\n\nEXDisplayPipe.framework\n\nIsolatedCoreAudioClient.framework (This links Tightbeam)\n\nISPExclaveKitServices.framework\n\nlibmalloc_exclaves_introspector.framework\n\nMobileAssetExclaveServices.framework\n\nSILManager.framework (Links Tightbeam, refers to \"Secure Indicator Light\"\n\nTightbeam.framework\n\n## Exclave OS/ExclaveKit\n\nInformation from`iPhone17,1_18.3.1_22D72_Restore.ipsw` \n \nExclaveOS: Disk image in iOS 18 builds for A18/M4 hardware (doesnt seem to be present in macOS nor pre-2024 device builds yet). \n\nEntire mounted filesystem resides in `/System/ExclaveKit/` which is about 500MB uncompressed.\n\nExclusively dylibs/frameworks - no executables besides `System/ExclaveKit/usr/bin/tightbeam_stub`. These frameworks are not in any shared cache currently, though this could change if the comment in (1) is telling the truth.\n\n(1) https://github.com/apple-oss-distributions/dyld/blob/b492ac15734277d89795b6f97f0e2feb1aa45595/cache_builder/mrm_shared_cache_builder.cpp#L927\n\nInfo plists for bundled frameworks have a target platform of `ExclaveKit.iPhoneOS` and are built against an `exclavekit.iphoneos18.3.internal` SDK. The value for `DTSDKBuild` is blank. \n\n## Exclave Core\n\n\n\n## Tightbeam\n\nSome kind of message passing format. `Tightbeam.framework` exists in both the main and exclave system disk images.",
  "createdAt": "2025-02-13T04:45:11.309Z",
  "visibility": "author"
}