Skip to content

smp: install reset-vector relay for locked boot RVBAR on A7-M3 - #664

Merged
DjDeveloperr merged 1 commit into
mainfrom
fix/s2r-locked-rvbar-keep-staged
Dec 3, 2026
Merged

DjDeveloperr merged 1 commit into
mainfrom
fix/s2r-locked-rvbar-keep-staged

Conversation

@erikwb

@erikwb erikwb commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

What: Install a reset-vector relay at a verified retired Stage 1 Aura image when smp_point_rvbar_here() finds a core's RVBAR locked on A7–M3, and recognize retired Aura images in smp_old_vector_owned() via their immutable AURALOAD header. Fixes the S2R regression from #554 (3530b019), where keeping Stage 2 staged above a live coprocessor __OS_LOG buffer left CPU 0's locked RVBAR pointing at Stage 1 and caused Aura to withhold /chosen/aurora,s2r-mailbox.
Tested: J313 M1 Air (T8103, OS fw 27.2) at ffaa715a (Stage 2 1.0.0b19-gffaa715a under Stage 1 1.0.0b19-gdfe97a4b): /chosen/aurora,s2r-mailbox published, 16 KiB relay page reserved NOMAP below os-log, 2/2 RTC-woken deep sleep cycles (boot object resumes 0 -> 1 -> 2), SEP/GPU/PCIe/Wi-Fi/CPUs 0–7 recovered cleanly (plus 3/3 cycles on Linux main 5bb2f1eed073 at the prior commit 0a6a22d9); 26/26 SMP/chainload host tests pass; all 5 tools/stage1_size.sh GCC builds pass.
Risk: two-way door · M1, M2, M3 (new S2R relay path) and M4/M5/A18 Pro (shared smp_relay_locked_rvbar() extraction, unchanged behavior)
Not yet: hardware rows on M2, M3, and M4/M5/A18 Pro.

Details

Commit 3530b019 (#554, "chainload: never copy a stage 2 onto a live coprocessor log") keeps Stage 2 staged above the heap on chips with unlocked Apple system registers (M1–M3) whenever copying Stage 2 to Stage 1's load base would overlap a live coprocessor __OS_LOG buffer (on J313, os-log sits +0x178000 above Stage 1's base; on M3, the panel DCP log sits at +0x120000).

Because the running boot core's own RVBAR still carries RVBAR_LOCK pointing at Stage 1's load base (and storing to a locked RVBAR register takes an SError), smp_point_rvbar_here() refused to publish /chosen/aurora,s2r-mailbox (CPU 0 RVBAR is locked at 0x...), disabling deep sleep.

Two changes fix this forward without reverting #554 or writing to a locked RVBAR register:

  1. Reliable retired-image recognition (smp_old_vector_owned()): A Stage 1 that actually ran overwrites its _stack_bot STACKBOT marker with its first stack frame in _start_c, so the 8-byte-aligned STACKBOT scan missed retired Stage 1 images unless a .rodata copy happened to land 8-byte aligned (in 1.0.0b19-gdfe97a4b, .rodata STACKBOT was at 0xd3ddb, mod 8 == 3). Check the immutable AURALOAD load header (CHAINLOAD_HDR_MAGIC + CHAINLOAD_HDR_VERSION) at CHAINLOAD_HDR_OFFSET (0x808) after matching the four vector slot tags (0x0..0x180), keeping the STACKBOT scan as a fallback for older images without a load header.
  2. Verified locked-RVBAR relay in smp_point_rvbar_here(): Extract the relay installer from smp_prepare_rvbar() into smp_relay_locked_rvbar(u64 locked, bool allow_unverified_forward) (also refusing a second distinct locked address so kboot_prepare_dt()'s single smp_rvbar_relay() reservation cannot lose an earlier page). Call it with allow_unverified_forward = false from smp_point_rvbar_here() under #if !defined(CHAINLOADING) || defined(ESP_STAGE2) (matching src/kboot.c:15738), so:
    • the M1–M3 S2R path only writes a branch (or out-of-range absolute veneer via smp_forward_rvbar()) over a verified retired Aura image (smp_old_vector_owned()), never over an unverified page or Mach-O header,
    • Stage 1 builds that omit kboot's relay reservation never install an unreserved relay,
    • smp_prepare_rvbar() keeps allow_unverified_forward = true with unchanged M4/M5/A18 Pro behavior, and
    • kboot_prepare_dt() reserves the 16 KiB relay page after dt_set_chosen().
Evidence
  • Repro before fix (J313 M1 Air, Stage 1 1.0.0b19-gdfe97a4b, Stage 2 1.0.0b19-gdfe97a4b, Linux main d6e13deca924):
    • /proc/device-tree/chosen/aurora,s2r-unavailable: CPU 0 RVBAR is locked at 0x8070a4000
    • apple-sleep 23b700000.sleep-controller: no aurora,s2r-mailbox from the boot object: no deep sleep
    • /sys/power/mem_sleep: [s2idle]
  • After fix at head ffaa715aaf3e (J313 M1 Air, Stage 1 1.0.0b19-gdfe97a4b, Stage 2 1.0.0b19-gffaa715a, Linux 7.3.0):
    • /proc/device-tree/chosen/aurora,s2r-mailbox published; /sys/power/mem_sleep: s2idle [deep]
    • /sys/kernel/debug/memblock/memory: 16 KiB relay page 0x805398000..0x80539bfff reserved NOMAP, 0x178000 below os-log (0x805510000..0x80555bfff), Stage 2 at 0x8073e0000..0x807807fff
    • 2/2 consecutive 15 s RTC-woken (rtc1, apple-pmu-rtc) deep sleep cycles:
      apple-sleep 23b700000.sleep-controller: back from sleep, boot object resumes 0 -> 1
      apple-sleep 23b700000.sleep-controller: wake source: NUB.SPMI0Sw3IRQ
      apple_sep 242400000.sep: the enclave is back from its sleep request
      pcie-apple 690000000.pcie: S2R: /soc/pcie@690000000/pci@0,0 link back, PWREN and PERST# cycled as at probe
      aurora 206400000.gpu: GPU firmware 27.2 back in 7380 us (commit idle=0 160 us, pending=0)
      apple-sleep 23b700000.sleep-controller: back from sleep, boot object resumes 1 -> 2
      apple-sleep 23b700000.sleep-controller: wake source: NUB.SPMI0Sw3IRQ
      aurora 206400000.gpu: GPU firmware 27.2 back in 5714 us (commit idle=0 170 us, pending=0)
      
    • CPUs 0-7 online, /dev/hwrng returns live entropy, 0 new failed units (only pre-existing J313 speaker protection units).
  • Linux main 5bb2f1eed073 check (at 0a6a22d9, before the 1-line Mach-O header gate): 3/3 consecutive 15 s deep sleep cycles (boot object resumes 0 -> 1 -> 2 -> 3, relay page 0x806dd0000..0x806dd3fff reserved NOMAP, SEP/GPU/PCIe/Wi-Fi/CPUs 0–7 recovered cleanly).
  • Host tests (pytest tests/python/test_smp*.py tests/python/test_chainload_run_base.py): 26/26 passed (including new AURALOAD ownership, unowned near/far/header EL2 refusal, owned branch/veneer relay, distinct-address guard, and Stage 1 build omission tests).
  • Size check (sh tools/stage1_size.sh gcc ARCH=aarch64-linux-gnu- BUILTIN_LOGO=aurora):
    • gcc stage1: _file_vital_end 0x104cd0 of 0x120000; room code 888, data 111408; headroom 111408 B
    • gcc esp-stage2: _file_vital_end 0x10cee8 of 0x120000; room code 4144, data 78104; headroom 78104 B

Commit 3530b01 ("chainload: never copy a stage 2 onto a live coprocessor
log") keeps Stage 2 staged above the heap on chips with unlocked Apple
system registers (M1 to M3) whenever copying Stage 2 to Stage 1's load
base would reach a live coprocessor __OS_LOG buffer (for example
os-log@80721c000 at +0x178000 on T8103/J313, or the panel DCP log at
+0x120000 on M3).

Even on those chips, the running boot core's own RVBAR has RVBAR_LOCK
set to Stage 1's load base, and writing that locked register takes an
SError. With Stage 2 kept at its staged address, smp_point_rvbar_here()
saw RVBAR_LOCK pointing at Stage 1's base instead of Stage 2's vectors,
did not install a relay there, and refused to publish
/chosen/aurora,s2r-mailbox ("CPU 0 RVBAR is locked at 0x..."),
disabling deep sleep.

Two pieces are needed to forward that retired Stage 1 vector safely:

1. Recognize a retired Aura image via its immutable AURALOAD load header
   at CHAINLOAD_HDR_OFFSET (0x808) in smp_old_vector_owned(), keeping
   the STACKBOT tail scan as a fallback for older images without a load
   header. A Stage 1 that actually ran overwrites its _stack_bot
   STACKBOT marker with its first stack frame in _start_c, so the
   8-byte-aligned STACKBOT scan missed retired Stage 1 images unless a
   .rodata copy happened to be 8-byte aligned.
2. Extract the locked-RVBAR relay installer from smp_prepare_rvbar()
   into smp_relay_locked_rvbar(locked, allow_unverified_forward) (also
   refusing a second distinct locked address so kboot's single
   smp_rvbar_relay() reservation cannot lose an earlier page), and call
   it with allow_unverified_forward=false from smp_point_rvbar_here()
   in builds that reserve smp_rvbar_relay() (!CHAINLOADING ||
   ESP_STAGE2). The retired Stage 1 vector table gets a branch relay
   (or an absolute veneer via smp_forward_rvbar() when out of branch
   range, only after smp_old_vector_owned() verifies it), the locked
   RVBAR register is never written, and kboot_prepare_dt() reserves the
   relay's 16 KiB page after dt_set_chosen().

Fixes: 3530b01 ("chainload: never copy a stage 2 onto a live coprocessor log")
Signed-off-by: Erik Bourget <erik@ebourget.net>
@erikwb
erikwb requested review from a team as code owners December 3, 2026 19:52
@github-actions github-actions Bot added blast:m1 Macs affected, from Merge risk (bot) blast:m2 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) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Merge readiness at ffaa715a: ready to merge

Check Detail
CI at head ok 24 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok in the PR body at ffaa715a
Conflicts ok none
PR text ok Risk: two-way · M1, M2, M3 (new S2R relay path) and M4/M5/A18 Pro (shared smprelaylockedrvbar() extraction, unchanged behavior)

Areas: none matched in CODEOWNERS
Merge: gh pr merge 664 --merge (Owners and Core through the bypass: add --admin).

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

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed at ffaa715aaf3e. No blocker found, approving. Hardware rows on M2 Pro, M3 Pro and M4 mini are still owed (listed under "Not yet"); kits for them are ready on our side.

What I checked in the code

  • Relay page vs os-log. The relay is one 16 KiB page at the locked reset vector (Stage 1's load base), reserved in kboot_prepare_dt() after dt_set_chosen(). dt_set_s2r_mailbox() is the only caller of smp_resets_return_here(), so the relay is always written before the reservation is made. On J313 and M3 the os-log buffers sit +0x178000 and +0x120000 above that base, so the two never overlap.
  • Recognizing a retired Aura image by its AURALOAD header. A match needs all of these: the address is in RAM, below the inherited top and the firmware RO range, and outside the running image; the four vector slot words (mov x9, '0'..'3', which don't depend on where the image sits) match; and the magic and version are at +0x808. What sits at the locked address is whatever iBoot loaded on this boot, so an image left over from an earlier boot can't be there. A Stage 1 that isn't Aura (m1n1, for example) has no header, falls back to the STACKBOT scan and is refused as before.
  • When the relay can't be installed. Every check runs before anything is written and returns -1. The code then falls through to the old CPU n RVBAR is locked path: no mailbox, aurora,s2r-unavailable is set, and the OS stays on s2idle, the same as today. A failed read-back leaves installed_relay at 0, so no page is reserved. Stage 1 builds compile the call out, matching the #if around the reservation in kboot.
  • M4/M5/A18 Pro. The early returns in smp_prepare_rvbar() are unchanged, and the extracted body runs with allow_unverified_forward = true, so this path gets the same decisions as before with two exceptions. (1) It now refuses a second, different locked address. iBoot locks every core to the same address on these chips, so this can't happen in practice, and it closes a gap where the single reservation could lose the first page. (2) The AURALOAD match can mark an image as owned where the STACKBOT scan used to miss it. The relay then gets a branch instead of the absolute veneer, and both reach the same vectors. T8152 has its own function and is untouched. So "unchanged in effect" holds.

Local checks (exact head; GitHub's refs/pull/664/merge tree is 13b6cb754ed8, the same tree as the head, because the base dfe97a4b9783 is main's tip, so one run covers both):

  • pytest tests/python/test_smp*.py tests/python/test_chainload_run_base.py: 26 passed. The 4 changed test files alone: 8 passed. The same 4 files run against base dfe97a4b: 6 of 8 fail, so they do test the change.
  • The full CI set (pytest tests/python tests/test_t8122_gpu_*.py): 1790 passed, 64 skipped. The 5 tests/run-*.sh scripts all pass.
  • sh tools/stage1_size.sh gcc ARCH=aarch64-linux-gnu- BUILTIN_LOGO=aurora EXTRA_CFLAGS='-Wstack-usage=2048 -Os' (CI's arguments; gcc 16.2.0 here, CI's gcc-stage1-size job is also green): all 5 builds link. esp-stage2 has 78104 B headroom and 3512 B code room.
  • The ESP Stage 2 builds with clang 23.1.3 (BUILDSTD=1 RELEASE=1 CHAINLOADING=1 ESP_STAGE2=1 USE_CLANG=1) as 1.0.0b19-gffaa715a.

Small things, not blocking

  • The header check needs CHAINLOAD_HDR_VERSION to match exactly. If a later version bumps it, a newer Stage 2 over an older Stage 1 falls back to the STACKBOT scan and may quietly lose deep sleep. >= 1 (or the magic alone, since the vector slot words are already checked) would keep working across a bump.
  • The branch path in smp_relay_locked_rvbar() writes without the armed-CTRR check that smp_forward_rvbar() makes. This was already true of the M4+ path, and Stage 1's base isn't in an armed CTRR range on M1 to M3, so the rows will confirm it rather than this needing a change.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 3, 2026
@erikwb

erikwb commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Note in English instead of Neonish: M1 Air deep sleep doesn't work without this in stage2 at aura head. With this commit, it does work.

@RyanTheTide

Copy link
Copy Markdown
Contributor

J615 (MacBook Air 13" M3, T8122), firmware 27.2, no-regression row at exact head ffaa715aaf3e: PASS.

  • Stage 2 = this head (make USE_CLANG=1 BUILDSTD=1 RELEASE=1 CHAINLOADING=1 ESP_STAGE2=1, reports 1.0.0b19-24-gffaa715a). It ran as an aura-try one-shot over the existing Stage 1. Stage 1 and the committed aura/stage2.bin (c9800c1d…, b18) were not touched, and the trial file was removed afterwards. The candidate carries the live U-Boot trailer layout with U-Boot 5c0d5fe1 and the kernel tree's own t8122-j615.dtb.
  • Kernel: linux main e7109a0e (7.3.0-mrowstip), one-shot BLS entry. Saved default unchanged. boot_id 83874432-08e5-4914-b7e8-64098af6365c.
  • Boot: clean to GNOME. /chosen/aurora,trial = aura/triotry.bin. /chosen/aurora,s2r-mailbox present. 0 failed units, DCP 2/2, Wi-Fi up, GPU (glmark2 on Apple M3 (G15G C0)), 8 CPUs online.
  • Sleep: mem_sleep = s2idle [deep] ("deep sleep is the default", sleep-tested node). PMU RTC by name (rtc1 = apple-pmu-rtc).
    • s2idle x2 (trial harness and row): success +1 each.
    • deep x2 (rtcwake -d rtc1 -m mem -s 20): success +1, fail 0, empty last_failed_dev, resume 0.409 s and 0.411 s. Both committed: the sleep controller's post-wake PMGR report ("words on at the commit were off at the wake") appears for each.
    • After both: CPUs 0-7, PCIe devices 3, Wi-Fi connected and pinging, Bluetooth present, panel back, 0 DART faults.
  • Kernel log: brcmfmac/hci_bcm4377 "Unable to change power state from D3hot to D0" once per wake, with Wi-Fi and BT recovering. The same lines show on main kernels with the old Stage 2 (seen 12-04 on 2d24189c), so they are not from this change. Two boot-time ANE lines are also unrelated.

Afterwards the Mac went back to its production state (7.3.0-aurora-edge, Stage 2 1.0.0b18 unchanged, Enforcing, 0 failed units). The J473 row follows when that Mac is free.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

J414s (Mac14,9, M2 Pro, T6020, OS firmware 27.2) row for aura#664 at head ffaa715aaf3e (work/review-aura-664-20261203/kit-j414s, seal 282b3d081595): 21/21 hardware checks PASS (no-regression only on J414s; 1 judge.py /proc/config.gz check artifact).

  • Scope / path taken (no-regression only): aura-console.txt (384 lines) had no "relay installed" line (relay '' | | [ 7.410305] FDT: S2R mailbox at 0x10003655440|). Because J414s already reaches the S2R mailbox without installing an RVBAR relay/veneer, this row verifies no regression on the A7-M3 path and does not exercise the new relay path.
  • Boot & Stage 2:
    • Stage 1 1.0.0b17-g5a244b5b took aurora,trial = m1n1/r664.bin -> Stage 2 1.0.0b19-gffaa715a (r664.bin sha256 8f33be18e3ce79c713bd26761ccf669729a18d042bf60954b536f0ffeb1b5ed6, recomposed byte-for-byte from live stock boot.bin 196da4c6…).
    • Kernel: 7.3.0-j414s-ship-38a2359d+, boot_id = a2b4b139-9316-4d24-99b2-8cb113bdebd6, OS firmware 27.2.
    • /chosen/aurora,s2r-mailbox = 0000010003655440, aurora,s2r-unavailable = '', RuntimeWatchdogUSec = 1min (PID 1 holds /dev/watchdog0), dead-man armed and disarmed cleanly.
  • 2/2 committed deep sleeps (rtcwake -d /dev/rtc0 -m mem -s 20, 23 s each):
    • Pre-sleep: 0 WARN/BUG/Oops/SError, CPUs 0-9, wld0 up, NVMe read_rc=0.
    • Sleep 1: PM: suspend entry (deep) -> back from sleep, boot object resumes 0 -> 1, suspend_stats success 0 -> 1 fail 0 -> 0, same boot_id, CPUs 0-9, wld0 up (5 s), NVMe read_rc=0, PCIe 5d1df6a31b9b31af 5 -> 5 (0 dead), panel connected, 0 WARN/faults, taint 4 -> 4.
    • Sleep 2: PM: suspend entry (deep) -> back from sleep, boot object resumes 1 -> 2, suspend_stats success 1 -> 2 fail 0 -> 0, same boot_id, CPUs 0-9, wld0 up (5 s), NVMe read_rc=0, PCIe 5d1df6a31b9b31af 5 -> 5 (0 dead), panel connected, 0 WARN/faults, taint 4 -> 4.
  • judge.py verdict note: judge.py reported 21 PASS, 1 FAIL solely on FAIL VDM route config on :: 0 because r664.sh checks zcat /proc/config.gz, whereas this Fedora kernel builds with CONFIG_IKCONFIG=n (while CONFIG_TYPEC_TPS6598X_DEBUG_COMMANDS=y is compiled in and verified on this kernel).
  • Stock restore verified: 7.3.0-47.fc45.aurora.aarch64, Stage 2 1.0.0b19-20-gd1327a18 (boot.bin stock 196da4c6…), boot_id = 53fd8092-d62e-4203-bdd0-41650b9d7585.
  • Archive: work/review-aura-664-20261203/kit-j414s/results/row-20261203T203227Z/.

@RyanTheTide

Copy link
Copy Markdown
Contributor

J473 (Mac mini M2, T8112), firmware 27.2, at exact head ffaa715aaf3e: boots and passes everything up to the deep commit. The one committed deep reset the Mac, in the same way as the open commit hang linux#4226, so this row can't tell whether the relay helps T8112 wakes.

  • Stage 2 = this head (1.0.0b19-24-gffaa715a), aura-try one-shot over the existing Stage 1. The committed m1n1/boot.bin (0b7c947b…, b18) was not touched and the trial marker was cleaned afterwards. Kernel: linux main e7109a0e (7.3.0-mrowstip) with its own t8112-j473.dtb (byte-identical to -fw27 in that tree). One-shot BLS entry = production options + apple_sleep.deep=1. boot_id cde18262-ddf0-4655-941f-d1fcaffa5e18.
  • Boot clean. /chosen/aurora,trial = m1n1/triotry.bin. /chosen/aurora,s2r-mailbox present. DCP 2/2 (HDMI), vkcube 300 frames PASS, s2idle (rtcwake -d rtc1, apple-pmu-rtc) success +1.
  • mem_sleep = [s2idle] deep. The deep dry run (untested_commit=N) prepared the 27.2 GPU backend (GPU prepared for deep sleep … pending=0), refused before the commit as designed, and everything came back.
  • One committed deep (untested_commit=Y, rtcwake -d rtc1 -m mem -s 20): the Mac stopped answering from +5 s and came back at +98 s with a new boot ID (684c2866), on its saved default. The previous boot's journal ends at PM: suspend entry (deep). That timing matches the 60 s commit watchdog, and it is the same signature linux#4226 reports for all four of today's J473 committed-deep rows on the b18 Stage 2: the hang is in the commit, before any wake. No second attempt was made.

Afterwards the Mac went back to its production state (7.3.0-aurora-fleet94, m1n1/boot.bin b18 unchanged, marker none, Enforcing, 0 failed units, no extra cmdline left).

@DjDeveloperr

Copy link
Copy Markdown
Contributor

J516s (M3 Pro, T6030, OS firmware 27.2) row at head ffaa715aaf3e (1.0.0b19-gffaa715a): FAIL (cold boot on deep sleep 1 wake; no RVBAR relay installed).

  • Boot chain & kernel: Stage 1 1.0.0b17-gf52d8324 -> trial Stage 2 1.0.0b19-gffaa715a (built at exact head ffaa715aaf3e, replacing only aura in the proven 7.3.0-pwren trial Stage 2; DTB and U-Boot unchanged). Kernel 7.3.0-pwren (main 06a7548b71d8 + linux#4213 a313071a0aad), which previously passed committed deep sleep on this J516s with Stage 2 1.0.0b17-g683a128b.
  • Trial boot ID / window: 8cacaae8-e659-4ad4-a730-c1807c5e03d2 (2026-12-03T20:42:29Z), watchdog 1min + dead-man armed.

Observed at boot (12 PASS pre-sleep):

  • Stage 1 (phys_base 0x10001f98000) reported packed span would overlap protected/live memory; parking firmware block (image 0x430000, firmware block at 0x10007ae8000, high-water 0x100080d8000, next stage at 0x1000850c000).
  • Stage 2 (1.0.0b19-gffaa715a) ran at 0x100080e0000..0x10008497fff (NOMAP in memblock/memory, Heap base: 0x10008498000) and published /chosen/aurora,s2r-mailbox = 0x10008209440 with no /chosen/aurora,s2r-unavailable.
  • Relay / /memreserve/: No SMP: installed RVBAR relay / veneer line appeared in the 384-line aura console log, and /memreserve/ was empty (no 16 KiB reservation at 0x10001f98000).
  • Kernel probed apple-sleep 3642d4000.sleep-controller: deep sleep is the default: boot object resumes 0, mem_sleep = s2idle [deep], 0 WARN/BUG/Oops, PCIe/Wi-Fi/NVMe/GPU all clean before sleep.

Failure (1 FAIL):

  • Entered deep sleep 1 at uptime 70.24 s (rtcwake -m mem -s 20, alarm 2026-12-03T20:43:47Z).
  • On wake, J516s immediately cold-booted into a new boot (a6b77433-1205-470b-a0dd-3420fb43be78 on stock 7.3.0-f3822, macsmc-rtc at 2026-12-03T20:44:04Z = +17 s after the RTC alarm, consistent with an immediate reset at wake rather than the 60 s watchdog).
  • Verdict: VERDICT FAIL (12 PASS, 1 FAIL, 0 INCOMPLETE).

@DjDeveloperr

Copy link
Copy Markdown
Contributor

The J516s FAIL above wasn't caused by this PR: #664's new code never ran on that boot.

What the M3 Pro boot did:

  • Stage 1 (b17) copied Stage 2 to its own base 0x10001f98000 and parked the firmware block (parking firmware block, high-water 0x100080d8000). It didn't take chainload: never copy a stage 2 onto a live coprocessor log #554's keep-staged path: on this boot the DCP __OS_LOG buffers sit at 0x10003e24000..0x10003e9bfff, past the end of the copy (0x100023c8000). Parking also only happens when keep-staged is off.
  • Stage 2's start.S then moved itself up to 0x100080e0000 (top_of_kernel_data rounded up to 64 KiB), wrote its absolute veneer over the old vectors at 0x10001f98000, and set relocated_from.
  • When the mailbox was published, smp_point_rvbar_here() found CPU 0's RVBAR locked at 0x10001f98000. smp_rvbar_reaches_here() returned true from relocated_from && locked == old_vectors_start(), so the loop moved on before it reached smp_relay_locked_rvbar(). No relay was needed, and none was installed. The console agrees: there is no SMP: line before FDT: S2R mailbox at 0x10008209440.
  • Main 8cf2ffc6 has the same start.S move, the same check and the same kboot reservation, so main publishes the mailbox on this chain too. This PR changes nothing on this path: its relay call comes after that check, and smp_prepare_rvbar() still returns early on M3.

So this cold boot belongs to main, not to #664. Every earlier J516s deep-sleep row booted the installed Stage 2 (b17 683a128b, from 11-25). This was the first J516s deep sleep with a main Stage 2 that has #639/#659 and the other reset-path changes since then.

One thing seen along the way: in Linux's memblock, the old-base page 0x10001f98000 (where CPU 0 comes back in on wake) is ordinary RAM (0x10001f98000..0x10003c87fff NONE), even though kboot asks for a 16 KiB /memreserve/ there. The b17 row that woke cleanly at 18:09Z shows the same layout, so this doesn't explain the failure on its own, but it is a weak spot on the wake path.

Fix: none in this PR. Next is a control row on J516s with a plain main 8cf2ffc6 Stage 2, built the same way, with the same kernel, DTB and U-Boot. That kit is sealed. If main cold-boots the same way, #664 is cleared and the regression is in main.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Control row on MacBook Pro 16-inch (M3 Pro, J516s, T6030, OS firmware 27.2) booting aura:main 8cf2ffc6ecad (1.0.0b19-g8cf2ffc6, without #664) over Stage 1 1.0.0b17-gf52d8324, on the same 7.3.0-pwren kernel (main 06a7548b71d8 + linux#4213):

  • Trial boot: 114c9df7-0ae9-4862-908d-43bc70b6820a (1.0.0b19-g8cf2ffc6, aura.bin 4e19265db697, aurora,trial=m1n1/r664m.bin)
  • Result: FAIL (cold boot on deep sleep 1 wake) — identical failure to #664:
    • Booted cleanly with mem_sleep = s2idle [deep], /chosen/aurora,s2r-mailbox = 0x10008809440, no aurora,s2r-unavailable, no relay line (384 console lines), 0 WARN/BUG/Oops pre-sleep, GPU/NVMe/Wi-Fi/PCIe pre-sleep checks passed (12/12).
    • Deep sleep 1 (rtcwake -m mem -s 20, alarm 21:09:43Z) cold-booted into stock 7.3.0-f3822 (15fc17e7-b27f-48a4-83f3-b3f2d5d50f38).
  • /memreserve/ and memblock for Stage 1 base (0x10001f98000):
    • phys_base: 0x10001f98000, FDT: Usable memory is 0x10001f98000..0x10459a78000
    • FDT /memreserve/: empty (stripped by EFI stub).
    • memblock/memory: 0x10001f98000 is not NOMAP — it is exposed as ordinary RAM (4: 0x0000010001f98000..0x000001000427ffff 0 NONE), whereas relocated Stage 2 at 0x100086e0000..0x10008a97fff is NOMAP (entry 11).
    • memblock/reserved: 0x10001f98000 is not reserved (first reserved region begins at 0: 0x0000010004178000..0x00000100041fbfff).

Conclusion: aura:main (8cf2ffc6ecad) cold-boots on J516s deep-sleep wake in the exact same way; #664 is cleared of causing the J516s regression (the regression is on aura:main between 1.0.0b17-g683a128b and 1.0.0b19-g8cf2ffc6).

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Correction to the J516s control reading above (kit-j516s-v2, main 8cf2ffc6, cold boot on deep wake 1). The RVBAR wake page is reserved, and that reservation isn't what's going wrong.

  • 0x10001f98000 is phys_base, not the RVBAR page. The 16 KiB page sits at Stage 1's base (relocated_from), which was 0x10003c88000 on that boot. Stage 2 found its DTB at 0x10004040000, and payload_start() (src/payload.c) is relocated_from + 0x3b8000 in this ELF.
  • Linux has it as memblock region 5, 0x10003c88000..0x10003c8bfff NOMAP. Path: kboot adds the /memreserve/, U-Boot turns it into an EFI reserved entry (efi_carve_out_dt_rsv()), the EFI stub drops the FDT /memreserve/ block (so it always reads empty from Linux), and Linux maps EFI reserved entries NOMAP. The b17 PASS boot shows the same thing at its own Stage 1 base 0x10003db4000.
  • The start.S M3 relocation block, the reservation and the RVBAR check are byte for byte the same in b17 683a128b and main. The wake path is not: since kboot, pcie, smp: T8103 (G13G) GPU 27.2 handoff and S2R wake PCIe/exception restore #529 (8893cb58, f5ddfff2), smp_s2r_return_to_os() powers ANS and replays aura's boot-time PCIe setup on M1–M3, calling reboot() on any failure (src/smp.c, gate in src/pcie.c). J516s never ran that under b17. On this kernel Linux already sets the J516s PCIe link up again itself after deep sleep (linux#4213 drives PWREN through the SMC), and aura's pcie.c has no PWREN/SMC handling.

That makes #529's wake-time PCIe replay the prime suspect. It's unproven: we have no serial or DockChannel capture of the wake. Next, an A/B on J516s with the same 7.3.0-pwren kernel and Stage 1 b17: arm M is main 8cf2ffc6, arm N is main with only the wake-time replay gated off (diagnostic build 1.0.0b19-g8cf2ffc6-norpl, not for merge), 2 deep sleeps each. If M fails and N passes, the fix is for aura to skip the replay when the OS restores PCIe itself. If both fail, we bisect the other wake changes (cpu_reset I-cache enable, af6b6557, 3526be04). The receipt will go here.

This doesn't change this PR's status: #664 didn't cause the cold boot.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

J773g (Mac mini M4, T8132, OS fw 27.2, stock kernel 7.3.0-j773g-main3685+) no-regression row for aura#664 at head ffaa715aaf3e (Stage 2 1.0.0b19-gffaa715a, kit work/review-aura-664-20261203/kit-j773g, seal 4d6fccb9a859):

  • Verdict: PASS (16 PASS, 0 FAIL, 0 INCOMPLETE)
  • Boot: boot_id=8ffcebd9-a325-4071-ac40-4eb07bf527b6, 2026-12-03T21:23:17Z..21:24:23Z, Stage 2 1.0.0b19-gffaa715a chainloaded via kboot from M5 (USB-C Left-front), stock 7.3.0-j773g-main3685+.
  • FDT / S2R mailbox: /chosen/aurora,s2r-mailbox published at 0x10003615440, no aurora,s2r-unavailable; mem_sleep s2idle [deep], apple-sleep 380700000.sleep-controller: deep sleep is the default: boot object resumes 0.
  • Deep sleep cycle (1/1): rtcwake rc=0 (28 s), PM: suspend entry (deep), same boot_id after wake, apple-sleep: back from sleep, boot object resumes 0 -> 1, suspend_stats success 0 -> 1, fail 0 -> 0.
  • Post-wake health: CPUs 0-9 online, network up (2 s), NVMe read_rc=0, PCIe unchanged (7aa545bad29dafc0, 5 devices, none ffff), GPU recoveries 0 -> 0 (health: failed 0 errno 0 degraded 0), 0 WARN/BUG/Oops/SError, 0 fault/recovery lines, taint 4 -> 4.
  • Restore: returned minihw cleanly to stock 7.3.0-j773g-main3685+ / Stage 2 1.0.0b18-g0745e344 (boot_id=c76b4dc2-828b-4d6c-ac29-f7440d6d2094) and cleaned staging.

@DjDeveloperr
DjDeveloperr merged commit 06c581d into main Dec 3, 2026
26 checks passed
@DjDeveloperr
DjDeveloperr deleted the fix/s2r-locked-rvbar-keep-staged branch December 3, 2026 21:41
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Paired A/B deep-sleep wake diagnostic on J516s (Mac15,7, T6030, OS firmware 27.2, Stage 1 1.0.0b17-gf52d8324, kernel 7.3.0-pwren #4, identical DTB 5d6ab909 and U-Boot tail) isolates the aura main deep-wake cold boot to the wake-time PCIe replay (pcie_needs_sleep_reinit() / smp_s2r_pcie_reinit()):

Arm Stage 2 tag (aura binary sha256) Boot ID Deep sleep 1 Deep sleep 2 Outcome
Arm N (main 8cf2ffc6ecad + pcie_needs_sleep_reinit() = false, diagnostic only) 1.0.0b19-g8cf2ffc6-norpl (9e239d43f619) 2f4ebe02-665f-4666-a34a-5862a6f2c2d6 Woke same boot (resumes 0 -> 1, 21 s, NUB.SPMI0.SW3, CPUs 0-11, GPU 0 recoveries, NVMe/PCIe/Wi-Fi up) Woke same boot (resumes 1 -> 2, 22 s, NUB.SPMI0.SW3, CPUs 0-11, GPU 0 recoveries, NVMe/PCIe/Wi-Fi up) 2/2 deep-sleep wakes PASS (see wake-2 brcmfmac note below)
Arm M (main 8cf2ffc6ecad unmodified control) 1.0.0b19-g8cf2ffc6 (4e19265db697) 14ac1a45-df72-4230-80b4-4d2a65e943c7 Cold boot (14ac1a45 -> stock 7.3.0-f3822 b5f095ea) not reached FAIL (2/2 cold boots on sleep 1 across 114c9df7 and 14ac1a45)

Additional verification from Arm N (2f4ebe02):

  • /chosen/aurora,s2r-mailbox = 0x10007799440, aurora,s2r-unavailable unset.
  • Stage 1 base (DTB payload - 0x3b8000) = 0x1000321c000, verified in /sys/kernel/debug/memblock/memory as region 5: 0x000001000321c000..0x000001000321ffff 0 NOMAP (exact 16 KiB NOMAP reservation intact).
  • Wake-2 note on Arm N: after waking cleanly into Linux on wake 2, brcmfmac on the older 7.3.0-pwren (06a7548b) kernel hit a Broadcom firmware trap (Flowring creation failed, code 4, single apple-dart 594000000.iommu stream 1 NO PTE FOR IOVA, brcmf_pcie_fw_died: resetting the chip, 62 brcmfmac console lines), self-reset the Wi-Fi chip, and restored gateway connectivity in 11 s (0 GPU/AER/WARN/BUG/Oops lines; unrelated to Aura wake).

Conclusion: aura#664 is cleared. The J516s deep-wake cold boot on main 8cf2ffc6ecad is caused by the wake-time PCIe replay (aura#529: smp_s2r_pcie_reinit() / pcie_reinit_after_sleep()). Disabling pcie_needs_sleep_reinit() restores same-boot deep-sleep wake on J516s (2/2 committed deep sleeps in one boot). Stock 7.3.0-f3822 restored and verified clean.

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:m2 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) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants