Skip to content

payload: start a post-M4 ANS an earlier stage powered off before any payload - #213

Merged
RyanTheTide merged 1 commit into
mainfrom
fix/payload-post-m4-ans-live
Nov 13, 2026
Merged

RyanTheTide merged 1 commit into
mainfrom
fix/payload-post-m4-ans-live

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Since adf5580 (in 1.0.0b11 through 1.0.0b13) an aura stage that used a post-M4 ANS powers it off and passes its SART entries on as nvme.sart=. An ESP Stage 2 that boots its embedded U-Boot never runs nvme_init(), so ANS stays off and kboot only writes the entries to the DT as apple,sart-entries. The U-Boot we embed (aurora-wip 25cbb0f0) adopts a running post-M4 ANS and has no start from off, so a Stage 1 from b11 on plus any b11 to b13 Stage 2 leaves U-Boot without NVMe on M4, M4 Pro/Max, T8140 and T6050:

Failed to probe 'nvme@3cdcc0000': err=-19
AURORA_UBOOT_BOOT_FAIL: no bootable entry

A Stage 1 from b10 or earlier passes ANS on running (nvme.adopt) and isn't affected.

Change

In payload_run(), when nvme.sart= arrived and this stage hasn't started ANS (nvme_post_m4_passed_off()), start it with nvme_init() and hand it on running for every payload, as the boot= path already does for Linux:

  • kboot_prepare_dt() sees a running session: it reserves the SART ranges and writes no apple,sart-entries.
  • main()'s nvme_shutdown() leaves the controller enabled and RTKit running, which U-Boot's apple_nvme_adopt() takes (CC.EN set, so T6040/T6050 skip the handshake path too).
  • If the start fails, the payload isn't booted.

Without nvme.sart= nothing changes: ANS goes on as this stage found it, or powered off with the entries passed on if this stage used it. M1-M3 and T8152 never get nvme.sart=.

aurora-silicon/u-boot#38 (U-Boot starts ANS from apple,sart-entries) is the other way to close this. With this change in Stage 2, U-Boot with or without #38 gets a running session.

Compatibility scope: this is a bridge to the existing running-session consumers, not completion of the preferred restart-based handoff design. The new branch applies to every non-boot= kernel+FDT payload with saved off-session SART state, including a directly embedded Linux payload; it is not restricted to U-Boot. boot= keeps its own existing path, and chainload= returns through its earlier path.

The bridge cannot be retired merely because U-Boot #38 or #40 merges. The receiving restart paths and supported old/new Stage 1, Stage 2, U-Boot and Linux pairings need qualification first. U-Boot #40's current removal of running-session adoption is incompatible with this head.

Tests

  • tests/python/test_m3_defaults_optout.py: the real payload_run() on the host, both builds (plain and CHAINLOADING+ESP_STAGE2): with nvme.sart= on a post-M4 part the payload gets a started ANS with no shutdown before the handoff; a failed start stops the handoff; without nvme.sart=, and on pre-M4, the old path.
  • Coverage limits: the payload harness stubs nvme_post_m4_passed_off() and does not exercise the real predicate. Its new ANS tests cover initialization failure, but not boot_failed cleanup after a successful ANS start. Those paths were source-reviewed; passing this harness is not dynamic proof of them. Joshua reports a surviving cleanup mutation; this review did not independently rerun that mutation.
  • Full tests/python: 668 passed, 50 skipped.
  • Hardware: J616s/M4 Pro one-shot A/B report. Production Stage 1 remains b10; an intermediate packaged b13 ESP Stage 2 reads the ESP, powers ANS off and passes nvme.sart= to the second Stage 2, simulating the newer Stage 1 contract. Old second Stage 2 f0f180a fails NVMe and falls back after the trial watchdog; exact aaec599 reaches Linux with root on NVMe in51s. The b10 running-session path also boots unchanged. The reported extra47.5MiB reservation is the intermediate stage's retained heap, not measured normal-chain overhead. This was not an enrolled Stage 1 replacement.
  • Current-head GCC CI job131782399536 reports724 passed/25 skipped; the668/50 above is the separate local run.
  • Neo/T8140 confirmation of the same chain remains pending. Installer/catalogs with b11+ Stage 1 stay held through qualification and a released fix. U-Boot#40 removes the running-session adoption required by this change and remains incompatible; no U-Boot pin change is needed for this fix.

…payload

Since adf5580 a stage that used a post-M4 ANS powers it off and passes
its SART entries on as nvme.sart=. An ESP Stage 2 that boots its
embedded U-Boot never runs nvme_init(): it only writes the entries to
the DT as apple,sart-entries and leaves ANS off. The U-Boot we embed
adopts a running post-M4 ANS and can't start one from off, so with a
Stage 1 that passes nvme.sart= it fails to probe NVMe:

  Failed to probe 'nvme@3cdcc0000': err=-19

When nvme.sart= arrived and this stage hasn't started ANS, start it in
payload_run() and hand it on running for every payload, as the boot=
path already does for Linux. kboot_prepare_dt() then sees a running
session and passes no apple,sart-entries, and main()'s nvme_shutdown()
leaves the controller and RTKit running. A payload with no nvme.sart=
gets ANS as before: as this stage found it, or powered off with the
entries passed on if this stage used it. M1-M3 and T8152 never get
nvme.sart= and don't change.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Tested on a J616s (M4 Pro, T6040), Stage 1 1.0.0b10-g2296392f, with aura-try one-shot trials. Each trial loads an intermediate stage in place of the configured Stage 2: a packaged 1.0.0b13 ESP Stage 2 (f0f180a) with a chainload= line. It adopts Stage 1's session, reads the ESP, powers ANS off and chainloads a second Stage 2 with nvme.sart=, as a b11+ Stage 1 does. That second Stage 2 carries the live image's DTB and U-Boot (aurora-wip) tail, unchanged.

Second Stage 2 Result
1.0.0b13 f0f180a no boot: U-Boot gets no NVMe, the 178 s trial watchdog resets and the Mac falls back to its configured Stage 2 (232 s)
this PR, aaec599 Linux from NVMe in 51 s, root on nvme0n1p6

Stage 2 log from the passing trial:

Found variable nvme.sart
nvme: entry RUN=0 BOOT_STATUS=0x0 saved SART entries=9
nvme: ANS started from off
nvme: initialized at 0x44dcc0000
FDT: ANS buffer [0x100123b4000, 0x100123bc000) reserved
...
nvme: leaving controller and RTKit running for Linux adoption

The Linux rows match the production boot: Enforcing, no failed units, no AVCs, no DART faults, NVMe namespaces 1 to 3, 4 USB buses with 8 devices, eDP and DP, Wi-Fi, H.264 and HEVC encode. The one difference is that iomem shows 47.5 MiB more reserved (375.9 vs 328.4 MiB). That is the retained heap of the extra aura stage, which holds ANS's buffers.

With the old Stage 1 (nvme.adopt, no intermediate stage), this PR's Stage 2 boots the same as before. Stage 2 runs no nvme_init() on that path, and the rows are unchanged.

Still to do: the same chain on a T8140 (J700).

@RyanTheTide
RyanTheTide marked this pull request as ready for review November 13, 2026 09:49

@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.

Codex (GPT-6.1 Sol), reviewing on @DjDeveloperr’s behalf.

Source review at aaec599, with a second independent review: no blocker found. The new predicate is a saved off-session handoff check; nvme_init() still validates the actual hardware state. The embedded-payload branch starts ANS before preparing the DT, boot= retains its existing path, and chainload= returns through its unchanged path. Successful initialization precedes setting the keep-running flag. The DT reserves the live SART ranges without advertising an off-session, and final main() shutdown validates the live controller/ASC before preserving it. Initialization failure prevents the payload handoff; existing DMA-retention/reboot-required guards remain, and later preparation failure clears keep-running before shutdown.

Verified successful build, Stage 1 size, format, policy and pytest jobs. The GCC job131782399536 actually reports 724 passed/25 skipped; the description's668/50 is the author's separate local run. The new payload harness cases run in that suite; I performed no local build or physical trial.

Ryan's6849586907 J616s report is useful affected-hardware evidence: one-shot b13 intermediate Stage 2 simulates the b11+ off-session handoff, the old second Stage 2 fails to boot NVMe, exact aaec599 boots Linux from NVMe, and the old b10 running-session path still boots. This is not an enrolled Stage 1 replacement test. The extra47.5MiB reservation is attributed to the intermediate-stage retained heap, not a measured cost of the normal two-stage chain.

Leaving this pending the already planned Neo/T8140 result before final merge review. The existing installer/catalog hold through a released fix remains; this review changes no distribution pin or loader. U-Boot#40's current removal of apple_nvme_adopt() contradicts the live-session contract here and remains incompatible; #38 retains that adoption path. No new hardware run requested by this review.

@joshuaswarren

Copy link
Copy Markdown
Contributor

[Joshua's agent] Review at aaec599: no blocking defect, OK as a compatibility bridge.

Checked:

  • Warm start, SART save/restore and failure paths in payload_run() / nvme_post_m4_passed_off(): SART buffer sizes match; a failed start leaves ANS marked so nothing reuses it; a failure after a good start powers ANS off, so a retry works.
  • CI green on this head; tests/python/test_m3_defaults_optout.py passes locally.

Two notes, neither needs code beyond a comment:

  1. This re-adds the live ANS handoff that nvme: power a post-M4 ANS off after use, and start it from off #107 removed, and it relies on U-Boot adopting a running session. u-boot#40 removes that adoption, so payload: start a post-M4 ANS an earlier stage powered off before any payload #213 and Release aura 1.0.0b2 #40 cannot ship on one chain. Suggest saying so in the PR text, with a shortcut: comment at the new block naming u-boot#38/Release aura 1.0.0b2 #40 as the point to remove it.
  2. The condition fires for any non-boot= kernel+fdt payload that arrives with nvme.sart=, not only the embedded U-Boot, so a Linux payload there also gets a live ANS. Fine for a bridge if intended.

Not covered by tests: the boot_failed cleanup after a successful ANS start (a mutation there survives), and the real nvme_post_m4_passed_off() predicate (the harness stubs it).

Not verified: hardware beyond the author's T6040 run. We have no T6050 result for this change; our M5 boots b12 straight to Linux, not via U-Boot.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants