Repository navigation
wdt: leave an armed watchdog as found under m1n1.wdt=keep - #503
rolotrealanis98 wants to merge 3 commits into
Conversation
Aura disables the SoC watchdog at start. A first stage that is not aura can arm it for the next stage and count on it: the J716s' A/B m1n1 stage 1 arms 150 s before it starts its stage 2 and appends m1n1.wdt=keep, so that a stage 2 or kernel that hangs before Linux's apple_wdt probes resets the Mac, iBoot counts a failed boot and stage 1 boots its fallback slot. Disarming it drops that deadline: a hung boot waits for someone to hold the power button, and the next start boots the same file again. With the exact token m1n1.wdt=keep in the boot arguments, and the primary watchdog armed when aura starts, wdt_disable_at_start() leaves the primary and the secondary as they are and says so; without the token, or with a disarmed watchdog, it disables both as before. The token keeps its m1n1 spelling because the stage that writes it is an m1n1 build. It is read from the command line up to its terminator only, as every other boot option is: nothing past iBoot's string is read, since iBoot defines no bytes there. Nothing in aura feeds the kept watchdog. As on an aura-try trial, a host that needs longer than the period disarms it with P_WDT_DISABLE, and any disarm or re-arm in this stage (the trial watchdog, the Stage 1 boot watchdog) ends the keep. kboot logs "watchdog left armed for the OS" once its log buffer exists, and marks the watchdog u-boot,noautostart, as it does on a trial boot. Tests: test_wdt_keep_option (token matching, every stage, and nothing read past the terminator: not a token 4 bytes in, where a stage with m1n1's unpacked boot_args union writes the command line). Signed-off-by: rolotrealanis98 <122947376+rolotrealanis98@users.noreply.github.com> Signed-off-by: Rolando Trevino <122947376+rolotrealanis98@users.noreply.github.com>
… in the proxy A stage booted with m1n1.wdt=keep has a fallback behind it, in a first stage that is not aura: a reset before the OS counts as a failed boot, and that stage then boots its other slot. When such a stage cannot start its payload, or a hand-off fails, it stops in the proxy, where nobody may be at the Mac to drive it. proxy_fallback() now treats it as it treats an aura-try trial: it waits PROXY_FALLBACK_HOST_MS (15 s) for a host and reboots if none came. This does not depend on the watchdog being still armed: a disarmed one would leave the Mac in the proxy until the power button is held, and a power cycle does not count as a failed boot. A host that attaches keeps the proxy; a watchdog the first stage armed still runs under it, and a host that needs longer disarms it. Without the token and outside a trial, nothing changes. Signed-off-by: rolotrealanis98 <122947376+rolotrealanis98@users.noreply.github.com> Signed-off-by: Rolando Trevino <122947376+rolotrealanis98@users.noreply.github.com>
|
@rolotrealanis98 checking open drafts today. To come out of draft, this still needs:
If it's no longer needed, say so here and we'll close it. Otherwise it stays open as a draft until these are done. |
main reworked src/wdt.c: wdt_disable() and wdt_reboot() now record the watchdog block through wdt_set_addrs(), with the simple-reconfig WD2 channel where the ADT offers it, and the host tests take the whole of wdt.c from '#define WDT_COUNT' on. - src/wdt.c: keep both includes (boot_options.h, memory.h), both sets of statics (wdt_kept; wdt_reconfig and the WD2 helpers) and the keep's reset of wdt_kept in wdt_arm(). wdt_disable_at_start() still keeps only a primary armed with RESET_EN, and now records the block with wdt_set_addrs() as wdt_disable() would, so wdt_reboot() takes the same channel either way. Without the token nothing changes. - tests/python/test_wdt_arm.py, test_wdt_boot_window.py: take main's harness, which compiles wdt.c whole; wdt_kept comes from it now, and a boot_wdt_keep_enabled() stub returns false. Signed-off-by: Rolando Trevino <122947376+rolotrealanis98@users.noreply.github.com>
|
Merged main in (8db4028, a normal merge, no force push). Main reworked Hardware: on my chain the stage 1 writes |
|
Update: beyond the token placement, a loader on current main can't hand off on this J716s chain at all right now ( |
There was a problem hiding this comment.
Verdict: Changes requested at 8db4028e324e.
The new keep path reads base + WDT_CTL after checking only that the decoded base is nonzero. Validate alignment and that the control register fits inside the decoded aperture before the first MMIO access. Add direct coverage of wdt_disable_at_start() for an inherited armed watchdog with no writes, and for an invalid aperture with no read on that path. GitHub currently reports only readiness at this head, and the PR's test description names the earlier revision. Attach current-head CI and owner-approved fallback evidence before merge.
|
Closing as superseded by main's watchdog rework (4f68a25, 0ec6b94, b1c638c). On a plain boot, Stage 2 now takes the boot watchdog over with a fresh period right after its start, a stop in the proxy restarts the Mac unless a host attaches, and the hand-off disarms it. That covers what this PR was for (a hang before the OS on the J716s' m1n1 A/B chain resets the Mac instead of sitting in the proxy). Merged with main, this PR's keep would be re-armed by The review's aperture check (alignment, control register inside the decoded aperture, no wrap, with direct tests of |
What: With
m1n1.wdt=keepin iBoot's boot arguments, leave a watchdog that an earlier, non-aura first stage armed as found instead of disabling it, and reboot after the 15 s host window instead of idling in the proxy, so that a hung boot falls back to that first stage's other slot.Tested: not yet on hardware at f3dc5d0; host test and local CI only (Evidence)
Risk: two-way · all Macs, only when the boot arguments carry the exact token; without it nothing changes
Not yet: a boot with a first stage that writes the token in iBoot's command line; the 15 s fallback reboot; one plain Stage 2 boot without the token (watchdog disabled as today)
Details
Aura disables the SoC watchdog at start. A first stage that is not aura can arm it for the next stage and rely on it: an A/B m1n1 stage 1 arms 150 s before starting its stage 2 and passes
m1n1.wdt=keep, so a stage 2 or kernel that hangs before Linux'sapple_wdtprobes resets the Mac, iBoot counts a failed boot, and stage 1 boots its fallback slot. Disarming it drops that deadline.wdt: leave an armed watchdog as found under m1n1.wdt=keep. With the exact token in the boot arguments and the primary watchdog armed at start (WDT_CTL read first),wdt_disable_at_start()leaves both watchdogs as they are and says so; otherwise it disables them as before. The token is read like every other boot option, from iBoot's command line up to its terminator: no offset scan, nothing past the terminator. Nothing in aura feeds the kept watchdog, and the proxy does not kick it. A host that needs longer disarms it withP_WDT_DISABLE; any disarm or re-arm in the stage ends the keep. kboot logs it and marks the watchdogu-boot,noautostart, as on a trial boot.proxy_fallback: a stage under m1n1.wdt=keep reboots instead of idling in the proxy. It waitsPROXY_FALLBACK_HOST_MS(15 s) for a host, as anaura-trytrial does, and reboots if none came. A host that attaches keeps the proxy. Both share the one window inproxy_fallback(); a trial booted with the token stays a trial (its watchdog is armed before the window, as before). The host tests cover the keep cases.The code is in every stage, Stage 1 included, but acts only when the token is in the boot arguments.
docs/boot-options.mddocuments it and says it does not belong in the NVRAM boot-args.Evidence
test_wdt_keep_option: token matching, every stage, nothing read past the terminator, unterminated and empty lines.apple_wdttook it over, a boot that hung in the kernel was reset about 150 s later and fell back unattended. Not run at this head.Local run of the repository's CI steps (pytest, format check, policy) in a Fedora 43 container, on base d81910e: 13 of 13 steps pass at f3dc5d0, and 13 of 13 on the unmodified base.