Repository navigation
proxy_fallback: a plain boot that stops in the proxy restarts unless a host attaches - #547
Conversation
…a host attaches
Stage 1 runs a boot watchdog so that a stop with no host (a read that
fails, a proxy with nobody on it) restarts the Mac instead of staying on
screen. A Stage 2 disarms it at its start, and nothing armed one again
until Linux. A Stage 2 that could not start its payload therefore stayed
in the USB proxy until someone held the power button or sent a USB-C VDM
reset.
On the M4 MacBook Air (J713, macOS 27.2 firmware) that happens on about
one warm boot in eight: the Stage 2 can't start ANS from off ('ANS
didn't start from off; it stays down until a reboot'), finds no payload
and parks in the proxy. The Mac looked hung after a normal Linux reboot,
and Linux's watchdog can't help there: the SoC had already reset. A
later boot brings ANS up.
Before a plain (not aura-try, not debug) boot stops in the proxy, arm
the boot watchdog again with Stage 1's period, unless one is running or
a host has already attached, and say so on the panel. The first proxy
request from a host turns it off, as in Stage 1 (wdt_host_attached(),
which now also records that a host attached), so a debugging session is
never reset under it. Without a host the Mac restarts and the next boot
tries again. Trials keep their bounded host window and reboot.
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 0ec6b94751cae2dd38c8ccd16810ac5a43931baa
Blockers:
none in the code. Before merge, the gate still needs: (1) CI green at this head (at the time of review 17 jobs were queued and 7 older runs cancelled); (2) a hardware row on an image built from this exact head. The rows in the body ran this diff on top of the production bases (4906f86 / b17), not on 0ec6b94 itself. See "Rows needed".
Checked:
- Read the whole diff plus every caller. The new arm only runs inside
proxy_fallback()on a non-trial path, and every such path ends inuartproxy_run(NULL)(main.c:304/320, 501/502, 522/523). No route leads from there to a next stage without a host request, anduartproxy_run()callswdt_host_attached()on every checksummed request before it dispatches it (uartproxy.c:326). So chainload, upload, bulk reads andP_WDT_ARMall run with the boot watchdog already off. A host-armed watchdog (P_WDT_ARM) is not disarmed later, becausewdt_boot_armedis already false. - Hand-off: Stage 1 (CHAINLOADING && !ESP_STAGE2) has
wdt_boot_armedset from start, so the new branch returns early and Stage 1 behaves as before. A Stage 2 that hands off normally never reaches the arm. The NVMe/display handoff-failure stops arm only if no host has synced in this stage (wdt_host_seen), which is what the new flag is for. I found no stage1 -> stage2 -> kernel path where a running watchdog is inherited mid-boot. - Period and units:
WDT_BOOT_SECONDS178 s, the same as Stage 1. 178 * 24 MHz = 4.272e9 fits in u32.wdt_arm()bounds it to 1..178. - Other watchdog blocks:
wdt_arm()picks the channel from the ADT (WD2 + simple-reconfig on wdt-version >= 3 with reg[3]; WD1 RESET_EN on version 2) and refuses any other layout or an armed secondary. Then the new code prints "no boot watchdog, staying in the proxy" and behaves as before. The diff adds no chip-id gate. - T8140:
usb_cdc_arm_watchdog()(170 s) can overwrite the boot watchdog during the USB bring-up that follows. It is only disarmed when a CDC primary opens or a host request arrives, so the Mac still resets without a host. Not a problem. - iBoot failed-boot count: every aura stage clears it (
pmu_clear_panic_counter()), so each wdt restart leaves a count of 1. Stage 1 reads that before it clears and opens its 10 s recovery window. On Macs whose ADT has info-leg_scrpad the loop never escalates to recoveryOS. On one without it, the count would accumulate and iBoot would eventually go to recoveryOS, which seems acceptable. - Built at head with clang + BUILDSTD=1: Stage 1 (RELEASE CHAINLOADING) and Stage 2 (+ESP_STAGE2) build with no new warnings, and the Stage 2 aura.bin is the same size as main.
make format-checkwith clang-format 20.1.8 is clean.- Full pytest (tests/python + t8122): 1255 passed, 27 skipped, 2 failed. The 2 failures are test_loadobjs nm-output fixtures, which fail the same way on main with this machine's binutils, so they are unrelated.
- New tests against the old src/: 3 fail (arms, arm-fails, host-marked-first) and 17 pass, as the body says.
Non-blocking notes:
- There is no retry bound: a persistent failure (missing payload, dead disk) restarts every ~3.5 min forever. This matches Stage 1's existing boot-watchdog behaviour, and each cycle gives Stage 1's recovery window a chance, so I don't consider it a blocker. If a bound is wanted later, it has to come from Stage 1's pre-clear count (the #401/#480 approach), not from a Stage 2 read.
- A Stage 2 that a developer chainloads over a Stage 1 proxy session starts with
wdt_host_seenfalse. If it then stops in the proxy, the host has 178 s to send a request. Use an aura-debug boot for long hands-off sessions. Worth a line in the docs. test_plain_boot_never_arms_under_a_host_or_on_a_debug_bootalso passes on the old code (it guards against a regression; it does not prove the fix).test_a_host_marks_itself_before_the_boot_watchdog_checkis a source-order text check.- Overlaps #503 textually: whichever lands second rebases, as the body says.
Rows needed (exact head 0ec6b94 built into the row image, same production DTB/U-Boot):
- J713 (T8132, WD2/simple-reconfig): forced host-less proxy stop, which must restart by itself within ~185 s; the same stop with a host request, which must log
WDT: host attached, boot watchdog offwith no reset through > 178 s; plus a short plain warm-reboot loop (normal path unchanged). - Another generation on the WD1 RESET_EN path, e.g. J473 (T8112) or M1 Pro (T6000): the same forced host-less stop restarts and returns to the production entry, and a host-attached stop does not.
Evidence
- Head 0ec6b94, base main 26c1a85, not a draft, mergeable.
- Build:
make -j12 USE_CLANG=1 RELEASE=1 CHAINLOADING=1 BUILTIN_LOGO=aurora BUILDSTD=1 [ESP_STAGE2=1]gives s1=0, s2=0; Stage 2 aura.bin is 3997696 bytes at head and on main. - pytest 9.1.1 + requirements.txt:
2 failed, 1255 passed, 27 skipped; on main, test_loadobjs.py gives2 failed, 2 passed. - Old src + new test file:
3 failed, 17 passed.
Review follow-ups: - A BRINGUP build never hands off and stays in the proxy by design, so it does not arm the boot watchdog there. - On T8140 the CDC transition arms the same hardware watchdog for its own period after the fallback armed the boot watchdog. A host request over DockChannel before the transition then turned the CDC watchdog off through wdt_host_attached(). Any watchdog armed through wdt_arm_seconds() (the CDC transition, a host's P_WDT_ARM) now takes over from the boot watchdog, so a later host no longer turns it off. - Say plainly that a host which holds the port open but sends no proxy request is reset like an absent one. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Independent adversarial review (fresh reviewer, code only): no blocking issues. Findings and what changed in b1c638c:
The hardware rows stand. The follow-up changes nothing on the J713/J473 paths: no |
There was a problem hiding this comment.
Verdict: FINISH, then merge.
Blocker: A plain boot with a persistently unavailable payload can rearm the watchdog on every restart. Please provide a finite retry policy using an approved existing mechanism, or obtain the boot owner's explicit disposition of recurring resets before enabling this production fallback. Include an operator recovery path and exact-head hardware evidence that covers a persistent failure as well as a transient failure.
Checked: The BRINGUP path leaves the proxy up. Successful CDC watchdog takeover clears the boot ownership flag, so a later host attach leaves the replacement timer alone. The independent host replay observed one arm per fresh process with a persistent failure and no arms on the host, debug and BRINGUP controls. The hardware row in the PR body cites the prior diff.
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: MERGE at b1c638c6 once CI is green
Blockers: none
Checked (delta 0ec6b947..b1c638c6):
proxy_fallback(): the boot-watchdog arm is now under#ifndef BRINGUP. BRINGUP builds never hand off, so they keep the plain proxy. Production Stage 1/2 builds are not BRINGUP, so their path is unchanged.wdt_arm_seconds()clearswdt_boot_armedonce it successfully arms another period. The CDC transition watchdog on T8140, or a host'sP_WDT_ARM, takes over, and a later host request no longer turns off a watchdog it didn't arm. New host testtest_another_watchdog_takes_over_from_the_boot_watchdog.- The comment no longer overstates "never reset under a host": a host that holds the port but sends nothing is reset.
- Rows: the J713 + J473 host-less restart rows ran at
0ec6b947. They still cover this head for those Macs: neither callswdt_arm_seconds()on that path and neither runs a BRINGUP build, so their behaviour is identical by construction.
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
A plain boot whose payload fails the same way every time restarts every 178 s, as Stage 1's own stop does: no count survives the reset for Stage 2 to read, since the failed storage holds none and Stage 1 clears iBoot's failed-boot count before Stage 2 runs. Say on the panel that a host's proxy request stops the restarts and that the power button chooses another system. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
There was a problem hiding this comment.
Verdict: FINISH, then merge at d429933d98ce.
Blocker: The new panel message explains how to interrupt recurring resets. The fallback still re-arms on every boot with a persistently unavailable payload. Please limit automatic retries or record the boot owner’s explicit acceptance of recurring resets, then attach the current-commit hardware result.
Checked: The delta changes the recovery instructions. Host and power-button recovery are now documented, while watchdog arming and the cross-boot behavior are unchanged. Hosted checks were queued at review.
|
Reply to the CHANGES_REQUESTED review (finite retry policy, operator recovery path, exact-head evidence), now at d429933:
|
There was a problem hiding this comment.
Verdict: MERGE at d429933d98ce once the three gates below are cleared. The code has no blockers.
Blockers: none in the code. Gates that aren't mine to clear:
- The open CHANGES_REQUESTED (recurring resets on a payload that fails every boot) needs the boot owner's decision recorded on this PR. My read, for that decision: the unbounded 178 s restart is the policy Stage 1 already ships for its own stop (21d5d47), and Stage 1 clears iBoot's failed-boot count, so a bounded count needs a Stage 1 change (#480), not this PR. Before, the Mac sat in the proxy until someone acted; after, it still needs someone for a permanent failure (host request or power button, now on the panel), and it recovers by itself from the transient ANS strand this targets. So I see no added harm. It is still a policy call for ORCH5/Ryan, not for a reviewer.
stage1-size(gcc/fedora/nix) is red, identically on main26c1a85b(REVIEW6 compared them). It needs a landing decision, not a fix here.- @DjDeveloperr code-owner ping (aura): no objection by an hour from now and the window is done.
Checked: read the whole diff and every caller: proxy_fallback() from main.c (no payload, NVMe and display handoff failures), and wdt_host_attached() from the three proxy request paths in uartproxy.c. The arm runs only on the non-trial path; debug boots, BRINGUP builds, a running boot watchdog and an earlier host all skip it; a failed arm keeps the old proxy stop. wdt_arm_seconds() hands ownership to any other watchdog (T8140 CDC transition, P_WDT_ARM), so a later host can't turn off a watchdog it didn't arm. Host tests: test_proxy_fallback.py 22/22 at this head; the same file against main fails 5 (the new cases), so the tests detect the change. The exact-head J713 row (production-layout image from d429933d): 10 warm reboots, 2 natural ANS strands each self-restarted (225 s, about 208 s, no VDM), forced host-less stop resets at +183 to +189 s (4/4), and a host request turns the boot watchdog off. No attribution.
Before rollout (FLEET-EDGE): a normal boot of this Stage 2 on a second family (J473) to show the healthy path is untouched; the code only runs on a stop, but the image changes on every Mac that gets it.
There was a problem hiding this comment.
Verdict: MERGE at d429933d98ce. Same verdict as my 09:15 review, now as an approval so point 1 holds; the full adversarial checks are in that review.
Blockers: none in the code.
Checked: whole diff and every caller; skip conditions (trial, debug, BRINGUP, running boot watchdog, earlier host); a failed arm keeps the old proxy stop; watchdog ownership hand-off to the CDC/P_WDT_ARM period; host tests 22/22 at this head (5 fail on main); exact-head J713 row (2 natural ANS strands self-restarted, forced host-less stops reset at +183 to +189 s, host request disarms). No attribution.
Merge still needs, and they are not mine to clear: (1) the boot owner's recorded yes to the recurring 178 s restarts on a payload that fails every boot, so REVIEW6's CHANGES_REQUESTED can be lifted (6-point item 5); (2) a landing decision on stage1-size (gcc/fedora/nix), which fails identically on main 26c1a85b. Dj's code-owner window closed 10:15 with no objection. Before FLEET-EDGE rolls it out: a normal J473 boot of this Stage 2.
|
@DjDeveloperr (code owner, aura): heads-up before a merge under the org's 6-point rule (an App approval can't satisfy the code-owner rule, so an admin merge happens only when all six hold at the exact head). Please object here if you want changes. A blocking review from you stops it. State at
What the change does: a plain boot that stops in the Stage 2 proxy re-arms the boot watchdog Stage 1 already armed for this case (Stage 2's start had dropped it). A host proxy request turns it off. With no host attached, the Mac restarts by itself instead of sitting in the proxy forever. This was the "hang on reboot, the watchdog never fires" seen on J713/J473. Revert: |
|
Merging under the 6-point rule at |
Stage 1 arms its boot watchdog on a plain boot so a stop restarts the Mac, but an ESP Stage 2 disarms it at its start and nothing re-arms one until U-Boot. aurora-silicon#547 re-arms it when Stage 2 stops in the proxy. A stop anywhere else in Stage 2 (storage, display or payload steps that never return) still waits for the power button: a J473 warm-reboot row on b17 + aurora-silicon#547 hung once in 9 boots with no Linux journal and no restart within 420 s, after the reset and before the hand-off. On a plain boot that is not a debug boot or a BRINGUP build, an ESP Stage 2 now arms the boot watchdog with a fresh period right after it disarms iBoot's, and disarms it again just before it vectors to the next stage. U-Boot then starts its own watchdog as before, and U-Boot and GRUB menus that wait for a person are not reset. The first host request still turns it off. proxy_fallback() keeps a running boot watchdog in an ESP Stage 2 and shows the restart text on the panel. Stage 1 behaviour is unchanged. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Stage 1's .init and .text share one read-execute segment that ends on a 64 KiB step. aurora-silicon#547 and aurora-silicon#548 grew .text past what that step had left on three of the toolchains stage1-size checks (text room gcc 3,696 B, nix 3,152 B, fedora 4,008 B, floor 4,096 B); one more step would move .data past _file_limit. The lab dev-audit flavour already did not link. hv_vm.o, hv_virtio.o, hv_vuart.o and hv_wdt.o only run when aura hosts a guest. Link them beside the sptm_virt objects in the executable read-only region ([_base, _rodata_end) is mapped RX, memory.c), which has room to spare. Only the placement changes: the code, its mapping and the DCP log buffer assertion are the same. With Arch clang (USE_CLANG=1 BUILDSTD=1), text room in the default Stage 1 goes from 8,624 B to 20,912 B and rodata room from 30,280 B to 17,936 B; headroom is now the data room, 12,272 B. stage1-dev-audit links again (3,280 B). The secure flavours and the SPTM_VIRT ESP Stage 2 keep their room. Signed-off-by: DjDeveloperr <hey@djdev.me>
Problem. A Stage 2 that can't start its payload stops in the USB proxy with no watchdog running, so the Mac stays dark until someone holds the power button or sends a USB-C VDM reset. Stage 1 has a 178 s boot watchdog for exactly this case ("Without a host, this Mac restarts by itself..."), but a Stage 2 disarms it at its start (
wdt_disable()), and nothing arms one again until Linux. On the M4 MacBook Air (J713, macOS 27.2) this shows up as an intermittent hang onreboot. Linux shuts down normally and the SoC resets. Then the Stage 2 can't start ANS from off (ANS didn't start from off; it stays down until a reboot), finds no payload, and parks in the proxy: 5 times on 11-27/28 across three kernels, and 1 in 8 plain warm boots in today's row. Linux's 1-minute watchdog can't help, because the boot it guarded is already gone. A later boot brings ANS up.Change.
proxy_fallback(): before a plain boot (not aura-try, not a debug boot) stops in the proxy, arm the boot watchdog again with Stage 1's period, unless one is already running or a host has already attached. The panel says so. The first proxy request from a host turns it off, as in Stage 1 (wdt_host_attached()now also records that a host attached), so a debugging session is never reset under it. Without a host the Mac restarts and the next boot tries again. Trials keep their bounded window and reboot as before (#478). The normal path is unchanged: nothing runs unless the boot was going to stop in the proxy anyway.Retry policy (review: no finite bound). A plain boot whose failure repeats restarts every 178 s until a host or the owner stops it. That is the policy Stage 1 already ships for its own stop (21d5d47: "Without a host, this Mac restarts by itself within 178 s to try again", no count), and enforcing secure-boot builds of both stages already reboot at once, with no count, instead of opening a proxy. No approved mechanism gives Stage 2 a count that survives the reset on the recorded failure: the failure is storage itself (ANS down until a reboot, so no ESP marker can be written or read), and the deployed Stage 1 clears iBoot's failed-boot count before Stage 2 runs and does not forward it (on the J713, Stage 1 logs
panic counter ... was 1, clearedafter each self-restart). A bounded count needs a Stage 1 that forwards it (#480) or the Stage 1 NVMe shutdown (#432); this PR adds neither. The disposition of the unbounded case is the boot owner's call, asked for below. Operator recovery path, now on the panel: a host's proxy request within the 178 s stops the restarts (WDT: host attached, boot watchdog off, shown on the exact head below), or hold the power button to shut down and hold it again to choose another system.Testing (exact head d429933, J713 M4 Air, macOS 27.2). Image = aura d429933 (
make BUILDSTD=1 RELEASE=1 CHAINLOADING=1 ESP_STAGE2=1 USE_CLANG=1) + fleet85 DTB + U-Boot 5445237f, the production Stage 2 layout.aura/stage2.bin(original kept as.prev), 10 plain warm reboots out of fleet85: 8 normal (30-33 s to SSH). Cycles 9 and 10 hit the natural strand: the Mac parked inaura uartproxy 1.0.0b17-gd429933dat +90-95 s, then restarted by itself and was back on its own (225 s and about 208 s), no VDM. After cycle 9 Stage 1 logspanic counter at /arm-io/nub-spmi0:0e reg f802 was 1, cleared. Then restored to 5ddde9f6.aura_trial_enabled()returning false, run as a one-shot with no payload): proxy at +12 s, reset by itself at +183/+184/+186/+189 s, back on production at +212-215 s (4 runs).WDT: host attached, boot watchdog off. That host's next action decides what follows; there is no watchdog reset under it.test_proxy_fallback.py22/22.stage1-size(gcc/fedora/nix) fails the same way on main 26c1a85 (headroom 3696/4008/3152 B, below 4096); this PR does not change Stage 1's text room.Tested: J713 M4 Air (27.2) at exact head d429933: two natural ANS strands in 10 committed plain warm reboots each restarted themselves (no VDM), 8/10 normal; forced host-less stop resets at +183-189 s (4 runs); host attach turns the boot watchdog off. J473 M2 Mac mini (T8112, legacy WD1) at exact head d429933: 5/5 trial boots normal, forced host-less stop self-restart at +238 s (earlier 227 s at 0ec6b94's diff)
Risk: two-way · all Macs, only on a plain boot that was going to stop in the proxy; a failure that repeats on every boot restarts every 178 s until a host or the power button stops it (same as Stage 1)
Related. #503 (draft) changes the same function for an explicit
m1n1.wdt=keepboot argument (a non-aura first stage with A/B slots). Whichever lands second rebases: with the token that behaviour applies, and without it this one does. #449 (ANS restart ladder) helps T6040 but did not recover the J713 case (details below). #480 (bounded reboot) needs a new Stage 1. This change needs none.Still to run. Boot owner disposition of the unbounded restart for a failure that repeats on every boot (or a Stage 1 rev for a bounded count).
Evidence and details
systemctl reboot, thenaura uartproxy 1.0.0b15until the VDM. Stage 2 console read over the parked proxy:traces/boot/20261126-j713-reboot-hang/proxy-probe-213447.log(HELLO, no IOP power report, CPU status 0x6e) andtraces/boot/20261128-reboot-hang/j713-plain-dtp2-8db4198d/c8-proxy-probe.log(no HELLO, entry CSTS=0x2)..prev.