interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / docs / native / PREFLIGHT-AND-RECOVERY.md

138 lines · 7664 bytes Raw Blame History Rendered
1# Native AIENOS: preflight and recovery for an attended Spark boot
2
3Status: NOT A MASTER PLAN. A checklist and a procedure, nothing more. Nothing in
4the change that adds this page runs on the physical Spark. Every PASS cited in
5the repo for the C kernel is QEMU only, not physical (`native/kernel/GATES.md`).
6
7Related, read first: `docs/NATIVE_BOOT_ONE_TIME.md` (the one-time BootNext
8procedure and its invariants), `docs/NATIVE_BOOT_ROLLBACK_CONTRACT.md`
9(rollback rules), `docs/RECOVERY_MEDIA_MACHINE1.md` (the recovery stick),
10`docs/BOOT_HANDOFF_CONTRACT.md` section 7 (why there are no A/B slots).
11
12## 0. Which "slot": there is none
13
14The operator decision Q3 (ADR 0024) says the loader gets no A/B slots. The
15"slot" is the firmware's one-time BootNext entry (the candidate) against the
16unchanged BootOrder (Linux, Boot0001). A candidate gets one attempt. The next
17boot is Linux again, whatever happened. Boot counters would need a loader that
18reads and writes state, which Q3 freezes (see "Open decision" at the end).
19
20## 1. Reproducible image build (host, no Spark involvement)
21
22Run on any aarch64 or cross-capable Linux host, from a clean checkout:
23
24 git status --porcelain # must print nothing
25 commit=$(git rev-parse HEAD)
26 make -s -C native/kernel OUT=/tmp/ck-a AIENOS_COMMIT="$commit" full
27 make -s -C native/kernel OUT=/tmp/ck-b AIENOS_COMMIT="$commit" full
28 sha256sum /tmp/ck-a/BOOTAA64.EFI /tmp/ck-b/BOOTAA64.EFI
29
30`scripts/ck_repro_build.sh [full|core] [--keep DIR]` does exactly this: it
31refuses a dirty tree, builds twice into two fresh temp folders and prints
32`CK_REPRO_BUILD: PASS <kind> commit=<commit> sha256=<digest>` only when the
33digests are equal. Checked on the Spark host (gcc 13.3.0, GNU ld 2.42) at
34commit ecd12c6: `full` both builds
35`fa48c92029957e0c468b068b4196dde254f80036565b05facc240433b6fd77aa`, `core`
36both builds `7bf5d58ce24ddf57de24cdf0c3240f37f0971eac2689fa63935f7c4732a69038`.
37Negative control: the same tree built with a different `AIENOS_COMMIT` gives
38a different digest, so the comparison can fail. Same-host only: a build on
39another machine or toolchain is UNVERIFIED. The digest changes with every commit because the commit hash is built
40into the image, so no single digest can be written down in advance. The
41digest of the image that is actually staged is printed by the kernel itself on
42the recovery console (`recovery_console: identity build_sha256=<64 hex>
43commit=<commit>`) and recorded by the stage script. Compare the two.
44
45The hardware staging image (the only one for the Spark) needs owner files and
46refuses the TEST keys:
47
48 make -C native/kernel full CK_HARDWARE_STAGING=1 \
49 CK_OWNER_PUBKEYS=<owner public keys file> CK_MACHINE_ID=<machine id file>
50
51Normally use `scripts/stage_one_time_boot_ck_full.sh --dry-run`, which prints
52every command it would run and touches nothing (for the B7b probe boot:
53`scripts/stage_one_time_boot_ck_b7b.sh --dry-run`, same contract).
54
55## 2. Preflight checklist before any attended boot
56
57All of these are read-only checks. Stop at the first one that fails.
58
59`scripts/native_boot_preflight.sh [--image EFI --expect-sha256 HEX]` runs
60items 2, 3, 4, 5 and 8 below. It only reads (`efibootmgr` with no arguments,
61the SecureBoot variable file, `findmnt`, `git status`, the image file, the
62quiet flag), needs no sudo and never stages or reboots; its `--self-test`
63also fails if the script ever gains a writing command. Last line:
64`NATIVE_PREFLIGHT: READY` or `NOT_READY (<n> STOP)`. Items 1, 6 and 7 are
65printed as ASK lines: they are Drake's, a script cannot see them.
66
671. Drake is at the machine, with a display and keyboard attached. (Drake's
68 physical presence and fresh go-ahead are required; see section 5.)
692. The recovery stick `AIENOSRECOV` is plugged in and listed as `Boot0004`
70 (`efibootmgr` with no arguments). If it is absent, stop.
713. Secure Boot state: record it. As of 2026-10-01 it is OFF for development by
72 owner decision, and it is recorded, not changed. A release candidate needs it
73 ON. Never flip it as part of this procedure: flipping changes the TPM
74 measurement and can lock the private storage volumes
75 (`docs/NATIVE_BOOT_ONE_TIME.md`, historical warning).
764. `BootOrder` is the normal one (Linux first, `0001`) and `BootNext` is unset.
775. The working tree is clean and its commit equals the commit the image was
78 built from; the image digest from section 1 is written down.
796. Which "slot": the candidate will be the one-time BootNext entry. Linux stays
80 the permanent default.
817. The pre-boot capture runs first (`scripts/verify_native_rollback.sh
82 --capture-pre`); the stage script does this itself.
838. No other session holds the machine quiet for its own hardware test.
84
85## 3. Getting back to Linux
86
87In plain words: the AIENOS test gets one try. Whatever it does (finishes,
88crashes, freezes, or the computer refuses to start it), the next start of the
89machine goes back to Linux by itself. If the screen stops changing for a full
90minute, hold the power button until the machine turns off, wait ten seconds,
91and press it again; Linux should come up. If Linux does not come up, use the
92recovery stick (section 4). Each of these outcomes was rehearsed with the real
93C image in QEMU (`scripts/qemu_ck_rollback_test.sh`, CK gate M0_ROLLBACK);
94not yet on the Spark itself.
95
96Normal return: do nothing. Firmware deletes BootNext before it starts the
97candidate, so any reset or power-cycle (hold the chassis power button, wait,
98press again) boots the next BootOrder entry, which is Linux. If the candidate
99hangs, wait 60 seconds, then power-cycle.
100
101## 4. Recovery procedure if Linux does not come back
102
1031. At power-on, press the firmware boot-menu key (F11 or the firmware's own
104 hotkey) and pick `AIENOSRECOV` (Boot0004). It runs entirely from RAM.
1052. Mount the internal root and the EFI partition read-only and run the
106 packaged collector exactly as in `docs/RECOVERY_MEDIA_MACHINE1.md`
107 ("Inspect internal storage read-only", "Capture the recovery evidence").
1083. Only with a separate fresh authorization from Drake: repair, or remove the
109 staged files in `\EFI\AIENOS` on the EFI partition. Never edit BootOrder
110 from the stick without that authorization.
1114. After Linux is back: `sudo scripts/verify_native_rollback.sh --pre ...
112 --post ... --verify` (the ten invariants in `docs/NATIVE_BOOT_ONE_TIME.md`).
113
114## 5. What needs Drake's physical action and fresh authorization
115
116Each of these needs Drake present and a new go-ahead for that boot. A past
117approval does not carry over:
118
119- plugging in or removing the recovery stick or any USB stick;
120- any firmware (BIOS) setting, including Secure Boot;
121- any reboot or power-cycle of the Spark;
122- running `--apply` of any stage script (it writes to the EFI partition and
123 sets BootNext);
124- pressing keys at the recovery prompt, and any repair in section 4 step 3.
125
126An agent may do the host-side parts: build the image, run the dry-run, run QEMU
127gates. Nothing in this change was run on the physical Spark.
128
129## Open decision (not made here)
130
131A boot-count A/B scheme with automatic fallback after N failed boots is not
132implemented and not specified here. The accepted spec forbids slots in this
133loader (Q3, ADR 0024; `docs/BOOT_HANDOFF_CONTRACT.md` section 7: "the handoff
134record carries no rollback state, and never will"). Doing it needs Drake to
135reopen Q3 first. The existing one-time BootNext rollback is proven in QEMU
136(M0_NATIVE_ROLLBACK_QEMU, Rust mock candidate), and with the C image as the
137candidate in QEMU (CK gate M0_ROLLBACK, `scripts/qemu_ck_rollback_test.sh`,
138rows 42-46 of `native/kernel/GATES.md`). Neither is a physical result.