Repository navigation
kboot: let an OS at EL2 return from its own sleep - #117
Closed
DjDeveloperr wants to merge 1 commit into
Closed
DjDeveloperr wants to merge 1 commit into
DjDeveloperr wants to merge 1 commit into
Conversation
An OS that aura starts at EL2 has no monitor below it, so it powers cores off and suspends the system itself. From M4 on, the A18 Pro included, iBoot locks every core's reset vector to the boot object, so a wake restarts each core in aura, and the boot core would rerun the boot flow over the live OS. When the OS runs at EL2 and a running secondary's locked RVBAR reaches this image (the address smp_prepare_rvbar() accepted before starting it), publish /chosen/aurora,s2r-mailbox. On a reset with it published, the boot core takes the resume address the OS left there, or reboots if it left none. A secondary needs nothing new: its spin table entry still holds the OS's release address. Reset paths stop printing once the mailbox is out, since the OS owns the UART and the display. The CPUs keep spin-table, which every kernel knows. The property is the whole contract: a kernel that reads it may power its spin-table CPUs off, and one that doesn't ignores it. Whether to deep-sleep stays the OS's choice. Nothing here is chip-specific beyond the locked RVBAR. On A7 to M3 it isn't locked and nothing is published, and a guest at EL1 gets nothing. The mailbox is 32 bytes in aura's .data, inside the image kboot already reserves, so nothing new is reserved. Linux reads it in arch/arm64/kernel/cpu_ops.c and drivers/soc/apple/t8140-sleep.c. The return path is the one every Linux deep sleep on the Neo since 2026-11-06 ran on, from a Stage 2 built on 1.0.0b5 that set the CPUs' enable method instead. Signed-off-by: Diljit Singh <hey@djdev.me>
DjDeveloperr
force-pushed
the
feat/t8140-s2r-return
branch
from
November 8, 2026 09:02
9fc69dd to
0142981
Compare
This was referenced Nov 8, 2026
This was referenced Nov 9, 2026
Merged
Contributor
Author
|
This change is already on main. Its one commit landed as 3089662 ("kboot: let an OS at EL2 return from its own sleep") with #144, and the only difference is a clang-format line wrap. main has since extended the same code (a boot-core-only OS, the T8142/T8152 relay case, the CTXR_D window check and the DockChannel wake line). A rebase onto main leaves nothing, so I'm closing this as merged through #144. |
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.
An OS that aura starts at EL2 has no monitor below it, so it powers cores off and suspends the system itself. From M4 on, the Neo's A18 Pro included, iBoot locks every core's reset vector to the boot object, so a wake restarts each core inside aura. On main the boot core then reruns aura's boot flow over the live OS, so Linux can't deep-sleep (the Neo only gets s2idle).
What it enables
When the OS runs at EL2 and resets come back into this image, kboot publishes
/chosen/aurora,s2r-mailbox, the physical address of a 32-byte mailbox (magic,boot_mpidr,resume_pa,resumes):resume_pathe OS left, at EL2 with the MMU and caches off and interrupts masked. If the OS left none, it reboots.Once the mailbox is published, the reset paths stop printing, since the OS owns the UART and the display.
There's no option. The CPUs keep
spin-table, which every kernel knows, and the property is the whole contract: a kernel that reads it may power its spin-table CPUs off, and one that doesn't ignores it. Whether to deep-sleep stays the OS's choice (mem_sleepon Linux).What's chip-specific
Only the locked RVBAR. "Resets come back into this image" means a running secondary's RVBAR is locked at an address that reaches this image's vectors: the vectors themselves, a relay this stage installed, an earlier stage's branch here, or the old base a relocated stage forwards from. That's the same address
smp_prepare_rvbar()accepted before starting the core. iBoot locks every core's to the same address, the boot core's included. No new hardware is read.Memory
The feature adds only the 32-byte mailbox, in aura's
.datanext to the spin tables. That's inside aura's image, which kboot already reserves for every OS because RVBAR and the spin-table release addresses point into it. Nothing new is reserved.Where it comes from
It's the return path from the T8140 sleep work (
feat/s2r-el2-test5ecf1d8), ported onto main and made generic. Every Linux deep sleep on the Neo since 2026-11-06 ran on that code: hundreds of sleep and wake cycles, including an 8/8 soak. That Stage 2 published the mailbox behind an opt-inchosen.aura,s2r=1line, on T8140 only, and switched the CPUs'enable-methodtoaurora,rvbar-spin-table. A kernel without that method leaves the CPU off, so this keepsspin-tableand lets the mailbox say it instead. That branch also wrote a diagnostic PMU scratch mark on each return; it stays out. Its PCIe tunables stay out too, because #112 replaces them.Depends on
/chosen/aurora,s2r-mailboxis present (arch/arm64/kernel/cpu_ops.c), and its T8140 sleep driver (drivers/soc/apple/t8140-sleep.c) reads the mailbox.Tested
make clean, with clang 23.1.1 and GNU make 4.4.1:CHAINLOADING=1, plus CI's Stage 1 (RELEASE=1 CHAINLOADING=1 BUILTIN_LOGO=aurora) and ESP Stage 2 (RELEASE=1 CHAINLOADING=1 ESP_STAGE2=1 BUILTIN_LOGO=aurora). The ESP Stage 2 has 17388 B of.textleft. clang-format 20.1.8 is clean, and pytest passes (598 passed, 47 skipped).1.0.0b9-g7b25e6d1) booting a kernel of the sleep series plus the generic-mailbox change. aura published the mailbox, the CPUs keptspin-table, and the kernel took the parking ops ("spin-table CPUs can park: the boot object brings them back"). 5 of 5 deep sleeps committed and came back,suspend_statsfail 0, boot object resumes 0 → 5, so the boot core returned through the mailbox every time. Wi-Fi, NVMe, audio and the panel were back after every wake, with no crash lines.🤖 Generated with Claude Code