Repository navigation
Boot without SPTM: Mach-O boot object and EL1 OS handoff - #29
Merged
Merged
Conversation
kmutil configure-boot without --raw records the size of the boot object's __TEXT_BOOT_EXEC segment as kcbz. macOS 27.2 iBoot loads and enters SPTM only when kcbz is nonzero; otherwise it jumps to the object's entry as it does in raw mode. make now also writes build/aura-boot.macho: build/aura.bin wrapped in an MH_FILESET with no __TEXT_BOOT_EXEC. The raw image is carried byte for byte in __TEXT_EXEC, every segment is file-backed at its virtual offset, and the entry point is the raw image's own entry, so the code is the same as in raw mode. tools/macho_boot_object.py can also wrap a Stage 1 whose configuration block was already filled in. Stage 1 release archives include the boot object. kmutil from macOS 27.2 and 26.6.2 parses it and derives kcbz 0. Not yet cold-booted on hardware. Assisted-by: Claude Opus 5.5
iBoot counts failed boots in the PMU and drops to recoveryOS once the count gets too high. A proxy test loop on the Neo reached 3 within minutes, and nothing else in that chain clears it. Clear it as on T6040. Assisted-by: Claude Opus 5.5
A boot object with kcbz 0 skips SPTM, but iBoot leaves CTXR windows armed and locked on the secondary CPUs. On T8140 they confine EL2 execution to the boot object, so Linux cannot run at EL2: its secondaries fault as soon as they are released. Add src/monitor.c. Aura stays resident at EL2 and enters the OS at EL1 on every CPU. It decides at kboot by asking a secondary to run code from the heap, so there is no build option and a boot without these windows should keep entering the OS at EL2. It leaves EL2 the way the kernel's init_el2_state would, for the features this chip has. At EL1 the windows invert: executing inside CTXR_D aborts straight to EL2. CTXR_D starts 0xd8000 below our base, where kboot left memory free, so reserve it. Without that reservation Linux died with SIGSEGV storms, kernel faults and instant reboots once userspace got busy. With it the Neo boots to a login and stays up under load. CTXR_D is not the CTRR_D of #15: those registers read 0 in this mode. Assisted-by: Claude Opus 5.5
DjDeveloperr
force-pushed
the
feat/macho-boot-object
branch
from
October 31, 2026 11:03
0f0ca08 to
429c5d9
Compare
Preserve the Stage 1 boot-record read before clearing the T6040 and T8140 failed-boot count, and include both release documentation lists. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Keep the chainload and kboot harnesses in sync with next_stage and monitor_required. Check that chainloading clears a previous monitor request and that kernel handoff publishes the runtime decision. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
GCC -O2 now places essential Stage 1 code and data beyond the DCP log-buffer boundary on current main. Use the same size optimization as the build workflow for normal and release builds, retaining the linker guard and the EXTRA_CFLAGS override. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
This was referenced Oct 31, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
kmutil configure-bootwithout--rawrecords the size of the boot object's__TEXT_BOOT_EXECsegment askcbz. macOS 27.2 iBoot loads TXM, ExclaveOS and SPTM, and enters SPTM, only whenkcbzis nonzero. Withkcbz0 it jumps to the object's entry, as it does in raw mode. This gives M4 and later, including the A18 Pro, the same Stage 1 as raw mode, with GXF writable as on M1 to M3.That boot leaves the secondary CPUs confined at EL2, so this PR also runs the OS at EL1 under a resident Aura.
What changes
makealso writesbuild/aura-boot.macho. It isbuild/aura.binwrapped in anMH_FILESETwith no__TEXT_BOOT_EXEC, built bytools/macho_boot_object.py.__TEXT_EXEC, 64 KiB after the load base. Every segment is file-backed at its virtual offset. The entry point is the raw image's own entry, the one--entry-point 2048selects in raw mode.aura-boot.macho. The details are indocs/macho-boot-object.md.src/el1_os.c, described below.Why the OS runs at EL1
iBoot leaves four CTXR windows armed and locked on the secondaries. The boot CPU reports the same bounds with enforcement off. On T8140:
CTXR_DReads and writes inside the window worked at EL1 with the MMU off. I have not measured them with the MMU on.
Aura stays at EL2 and enters the OS at EL1 on every CPU. There is no build option: at kboot,
el1_os_required()asks a secondary to run two instructions from the heap, and only a fault selects EL1.el1_os_enter()leaves EL2 asinit_el2_stateandfinalise_el2_statewould for the features this chip has (SME2, FGT, HCX, LOR). It has no SVE, GCS, MTE, MPAM, AMU, SPE, TRBE or BRBE, and its PMU is IMPDEF.CTXR_Dstarts 0xd8000 below Aura's base, and kboot only reserved from the base up, so about 448 KiB of it was free for Linux. Executing there from a secondary aborts to EL2, which reboots the machine. kboot now reserves it in this mode.Boots before that reservation died with SIGSEGV storms, kernel faults and instant reboots once userspace got busy. Boots with it have not. I did not catch Linux using a page in the window, so that link is inferred. #15 reports write faults in the same place on J813, which would also explain the SIGSEGVs. This is a separate fix from #15: its
CTRR_Dregisters read 0 in this mode.KVM is not available in this mode yet. Nested virtualization will follow.
Layout
These are kmutil's requirements, found by reading its tag derivation:
__TEXTmust be at file offset 0.__TEXT_EXEC,__PRELINK_INFOand__LINKEDITare required.__TEXT_BOOT_EXEC,__DATA_SPTMand__RECEIPT_INFOare optional.The fileset also has
__PRELINK_TEXTwith acom.apple.kernelmember header, an empty__DATApage and an empty chained-fixup table.Tested
On a MacBook Neo (T8140, J700), with a proxy Stage 1 built this way and this Stage 2 chainloaded over USB. The tested image is byte-identical to this branch's build.
CPU: All CPU(s) started at EL1, 6 CPUs,paca,pacgandsme2present, noarm64.nopauth.apple_seploads at EL1. Trusted keys work and/dev/sep-bioappears. This model has no fingerprint sensor.SP_EL0and the 33 tracked system registers survive, including the PAC keys. WFE wipes nothing. The kernel's existingapple_cpu_wficovers idle.tests/python/test_macho_boot_object.py: 7 pass.kmutil inspectgiveskcbz : 0with kmutil from macOS 27.2 and 26.6.2.Not tested
el1_os_required()returns false on them.wfi. It should lose registers on any Linux here, since these measurements cover EL0 and Linux does not trap EL0 WFI. That is a kernel issue separate from this PR.🤖 Generated with Claude Code