Skip to content

kboot: withhold aurora,s2r-mailbox on raw boots of execute-window chips - #671

Open
maralcbr wants to merge 1 commit into
mainfrom
kboot/s2r-gate-raw-exec-window
Open

maralcbr wants to merge 1 commit into
mainfrom
kboot/s2r-gate-raw-exec-window

Conversation

@maralcbr

@maralcbr maralcbr commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

What: Withhold /chosen/aurora,s2r-mailbox (and record /chosen/aurora,s2r-unavailable) when an execute-window chip (data/execute-window.json: M4, A18 Pro, M5 and later) boots without an active CTXR execute window (unconfined raw Stage 1), so Linux boots normally and stays on s2idle instead of defaulting to deep sleep on an unqualified raw wake path.
Tested: Host pytest at 2fc0ac9180e3: 91/91 passed across test_s2r_mailbox_gate.py, test_ctxr_exec_probe.py, test_ctxr_exec_window.py, test_t6040_hibernate_fixed_window.py, test_secondary_ro_reservations.py, test_mmu_ctrr_l3.py, and test_smp_forward_rvbar.py.
Risk: two-way door · execute-window Macs (data/execute-window.json: Neo, M4, M5 and later); M1 to M3 (execute_window_expected() == false) and padded Mach-O execute-window boots (ctxr_exec_window() == true) are unchanged.
Not yet: Live Stage 2 boot rows on raw Stage 1 Neo (J700), padded Mach-O M4 Pro (J616s), and M1 Pro (J314s) at 2fc0ac9180e3 (pending lab qualification).

Details
  • src/ctxr_exec.h, src/ctxr_exec.c: expose ctxr_exec_expected(), returning execute_window_expected(chip_id) from the build-generated build/execute_window.h (data/execute-window.json). Placed above #define CTXR_EXEC_AURA_SLOT to preserve existing host test harnesses.
  • src/kboot.c: in dt_set_s2r_mailbox(), after the existing armed-CTXR_D-without-window check, check ctxr_exec_expected() && !ctxr_exec_window(NULL, NULL). When true, log FDT: no S2R mailbox: raw boot of an execute-window chip, set chosen/aurora,s2r-unavailable to "raw boot of an execute-window chip: S2R requires Mach-O Stage 1", and return 0 without publishing aurora,s2r-mailbox.
  • Together with aurora-silicon/aura#647 (which lets raw Stage 1 T8140 boots run unconfined instead of refusing OS handoff), this prevents raw Stage 1 T8140 systems from promoting mem_sleep to [deep] and rebooting on suspend, while keeping padded Mach-O Stage 1 systems and M1 to M3 Macs unchanged.
  • tests/python/test_s2r_mailbox_gate.py: compiles and executes the production ctxr_exec_expected() and dt_set_s2r_mailbox() against the generated execute_window.h across M1–M3 unconfined boots, execute-window padded Mach-O boots, execute-window raw unconfined boots, and armed-CTXR_D-without-window boots.
Evidence
$ pytest -q tests/python/test_s2r_mailbox_gate.py tests/python/test_ctxr_exec_probe.py \
    tests/python/test_ctxr_exec_window.py tests/python/test_t6040_hibernate_fixed_window.py \
    tests/python/test_secondary_ro_reservations.py tests/python/test_mmu_ctrr_l3.py \
    tests/python/test_smp_forward_rvbar.py
91 passed in 6.86s

Head commit: 2fc0ac9180e37196807a8d222d0cd17574185402

Execute-window chips (data/execute-window.json: M4, A18 Pro, M5 and
later) are only qualified for EL2 suspend-to-RAM behind a padded Mach-O
Stage 1 with an active CTXR execute window. When one of those chips
boots an unconfined raw Stage 1 (for example T8140 with aurora#647,
where CTXR_D bounds are populated but ACC_CTXR_D_CTL_EL2 has lock bits
only), dt_set_s2r_mailbox() previously published aurora,s2r-mailbox
despite having no execute window, causing Linux to default mem_sleep to
deep on an unqualified raw wake path and reboot on suspend.

Expose ctxr_exec_expected() from ctxr_exec.c (backed by
data/execute-window.json) and check ctxr_exec_expected() &&
!ctxr_exec_window(NULL, NULL) in dt_set_s2r_mailbox() after the armed
CTXR_D check. On raw boots of execute-window chips, record
chosen/aurora,s2r-unavailable and skip publishing aurora,s2r-mailbox so
Linux boots normally and stays on s2idle.

M1 to M3 chips (below data/execute-window.json) and padded Mach-O
execute-window boots (active ctxr_exec_window) are unaffected.

Signed-off-by: Marcelo Alcantara <maralc@gmail.com>
@maralcbr
maralcbr requested review from a team as code owners December 4, 2026 09:48
@maralcbr
maralcbr requested review from Acelogic and scottjones and a balanced review from Copilot December 4, 2026 09:48
@github-actions github-actions Bot added blast:m1 Macs affected, from Merge risk (bot) blast:m3 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) blast:neo Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Merge readiness at 2fc0ac91: not ready yet

Check Detail
CI at head ok 24 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 2fc0ac91
Conflicts ok none
PR text ok Risk: two-way · execute-window Macs (data/execute-window.json: Neo, M4, M5 and later); M1 to M3 (executewindowexpected() == false) and padded Mach-O execute-window boots (ctxrexecwindow() == true) are unchanged.

Areas: none matched in CODEOWNERS

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Live hardware qualification remains pending on raw J700, padded Mach-O J616s, and legacy J314s, and host harnesses cannot establish actual bootability or Linux sleep-mode selection.

No open issues 🎉

What changed in this PR

Keeps raw boots on execute-window chips bootable while withholding deep-sleep support until a qualified CTXR execute window is active. Legacy chips and padded Mach-O boots remain unchanged.

Changes:

  • Exposes the chip’s expected execute-window status.
  • Withholds the S2R mailbox and records an unavailable reason on unqualified raw boots.
  • Adds host regression coverage for supported and blocked boot configurations.
File Description
tests/​python/​test_s2r_mailbox_gate.py Tests mailbox publication and rejection across boot configurations.
src/​kboot.c Gates mailbox publication on execute-window availability.
src/​ctxr_exec.h Declares the expected-window query.
src/​ctxr_exec.c Implements the query using generated chip data.

Review effort: Balanced

@maralcbr

maralcbr commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Hardware-verified via the carried v1.0.0b18 build (omacom/m1n1 carry/edgeB5-7.3 bddf45414bcf, Stage 2 1.0.0b18-gbddf4541):

  • MacBook Neo (j700, T8140, raw legacy Stage 1 ba130ffb-dirty, OS fw 26.6.2, system fw 27.2):
    • Before this change (1.0.0b18-g3f0fcc9d): /proc/device-tree/chosen/aurora,s2r-mailbox was published with no execute window and /sys/power/mem_sleep defaulted to s2idle [deep].
    • With this change (1.0.0b18-gbddf4541):
      • /proc/device-tree/chosen/aurora,s2r-unavailable = raw boot of an execute-window chip: S2R requires Mach-O Stage 1
      • /proc/device-tree/chosen/aurora,s2r-mailbox absent
      • /sys/power/mem_sleep = [s2idle]
      • Kernel log: apple-sleep 300700000.sleep-controller: no aurora,s2r-mailbox from the boot object: no deep sleep
      • 2/2 live rtcwake -m mem -s 10 cycles (on 7.3.0-6-1-ARCH and 7.3.0-7-1-ARCH) entered s2idle and woke cleanly on the same boot_id (suspend_stats: success=1 fail=0, zero reboot).
  • MacBook Pro 14" M1 Pro (j314s, T6000, Stage 1 v1.6.1-dirty, OS fw 13.5, system fw 27.2):
    • Booted cleanly on 1.0.0b18-gbddf4541 (j1204-205534-120e / j1204-205951-ecb5: boot-health pass, omarchy-m-test 55 pass / 0 regressed).
    • /proc/device-tree/chosen/aurora,s2r-mailbox remains published (unaffected).
  • MacBook Pro 16" M2 Max (j416c, T6021, Stage 1 v1.6.1-dirty, OS fw 13.5, system fw 27.2):
    • Booted cleanly on 1.0.0b18-gbddf4541; /proc/device-tree/chosen/aurora,s2r-mailbox remains published (unaffected).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blast:m1 Macs affected, from Merge risk (bot) blast:m3 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) blast:neo Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants