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_IMAGE_SLOTS.md

444 lines · 26567 bytes Raw Blame History Rendered
1# Native image slots: install, update and recovery without Linux (P11 cuts 1, 2a, 2b and 3)
2
3STATUS: cut 1 (format, rules, host tool), cut 2a (SLOTLDR.EFI, a separate
4slot loader in front of the unchanged image, QEMU gate PASS) and cut 2b
5(kernel-side promote / abandon, section 8) and cut 3 (the inactive-slot
6updater and the loader in the package, section 9) done; the owner
7approved the loader on 2026-10-12 (section 2). Nothing here has run on
8hardware (hardware NOT_RUN). The kernel image and its stub are unchanged.
9SECURITY_IMPACT: PERSISTENT_FORMAT + RECOVERY (a new on-disk format and a new
10recovery rule are specified; from cut 2a SLOTLDR.EFI writes the control
11region of the slots partition, and nothing else, before a candidate try;
12nothing has been written to a physical machine).
13
14Program: AIEN native v1 (aien-architecture CURRENT_EXECUTION_PLAN, addendum
152026-10-12), work package P11, gate N7: "Install, update and recovery work
16with no Linux installation or recovery USB required for the supported
17procedure. A BootNext return to Linux is insufficient." Today's rollback is
18the one-time BootNext return to Linux (aienos#273), which N7 rejects.
19
20## 1. The finding P11 was asked to make
21
22The P01 addendum left one question to P11: is an A/B loader "the cheapest way
23to hold two native images"? Answer, after reading what the image already does:
24
25**Yes, two slots in their own partition, selected by the stub.** The reasons:
26
271. The stub already reads raw disk blocks through the firmware's own Block
28 I/O driver before `ExitBootServices` (`native/boot/efi_model.c`: locate
29 the whole disk by GPT disk GUID, `ReadBlocks` in page-aligned pieces).
30 Reading a 4096-byte manifest and an image from a fixed partition offset
31 is the same operation.
322. The image already carries freestanding SHA-512 and Ed25519 verification
33 (`native/sig`) and SHA-256 (`native/argus/sha256.c`). Verifying a signed
34 manifest costs no new primitive. `slot-free` in the kernel Makefile proves
35 the selection code needs nothing else.
363. The kernel already writes a partition crash-safely with the torn-slot
37 region (`native/store/torn_slot.c`): two bodies, two commit headers, the
38 newest valid wins, a torn write can only lose the write in flight. The
39 control record that says "which slot is active, which is the candidate,
40 how many tries remain" fits in one such region.
414. UEFI gives the stub `LoadImage(SourceBuffer)` and `StartImage` (boot
42 services table, `native/boot/efi.h`). A verified slot image can be
43 started from memory with no filesystem, no second boot entry and no
44 firmware variable write. The loader's own PE stays the single BootOrder
45 entry; the images it chooses between live in the slots partition.
46
47What this costs: one new partition, one new loader step (read control, read
48and verify two manifests, pick, chain-load) and the updater on the kernel
49side. What it does not cost: any Linux tool at install, update or recovery
50time, any `BootNext` write, any change to the stub's frozen PE layout.
51
52What it does **not** solve on its own (stated so nobody reads more into it):
53if both slots are invalid, or both are below the security floor, the loader
54can only report `recovery_required` and return to the firmware. Covering that
55case without a Linux USB is the known-good AIENOS recovery image of P11
56(a third, read-only copy of the loader plus a slot image on recovery media
57built by my own tools), which is a later cut. Dual-invalid cannot happen by
58update alone under the rules below (the active slot is never written while
59it is active), only by media failure or a deliberate wipe.
60
61## 2. Owner decision (Drake): approved 2026-10-12, narrow scope
62
63**Decision recorded 2026-10-12.** Drake: "Slot loader APPROVED, narrowly
64scoped: the frozen boot stub may change only for signed A/B image selection,
65boot-success tracking, and rollback. Emulator tests required before hardware:
66successful update, invalid signature, interrupted update, unsuccessful boot."
67Cut 2a meets that without changing the stub at all: the slot logic is a
68separate UEFI application, `SLOTLDR.EFI`, in front of the unchanged stub +
69kernel image (section 7). The four required emulator tests are rows 2
70(a staged update boots, one counted try per boot; it is not yet made
71permanent, that is the kernel promote of cut 2b; after three unsuccessful
72boots the loader goes back to A), 3 and 4 (invalid signature, untrusted key)
73and 6 (interrupted update) of its QEMU gate; rows 5, 7 and 8 add a tampered
74image, both slots invalid and the generation floor. The text below is the request as it was asked.
75
76The loader is frozen: `docs/BOOT_HANDOFF_CONTRACT.md` section 7 says "There
77are no slots and, per Q3, none will be added to this loader", and
78`native/boot/README.md` parks "signature checks, BootNext staging, rollback".
79Those statements stay true after this cut. Changing them is an owner decision
80(ADR 0024 Q3; TRUST-1 Q14 "Loader changes rarely"). This note asks for that
81decision with the design pinned, so the decision is about a concrete thing.
82
83If the owner says yes, cut 2 adds one bounded step to the stub (section 6).
84If the owner says no, the format and tool remain host-side specification and
85N7 needs another path, which this note does not have.
86
87## 3. Sources this design follows
88
89- ADR 0006 (accepted 2026-09-23): "System updates employ transactional A/B
90 slot switching with deterministic kernel health milestone verification";
91 "atomic and safely reversible via hardware-backed A/B slots".
92- TRUST-1 implementation plan, cross-cutting Q14 (loader minimality: "only
93 what may boot, which slot, and what verified facts the kernel receives")
94 and Q19 (slot/manifest: "A=known-good, B=candidate (roles, not names).
95 Manifest minimum: format version, generation, kernel digest, image digest,
96 loader ABI, kernel ABI, signer, commit, provenance, rollback compat, policy
97 generation, timestamp, signature. Health gates before promotion receipt;
98 explicit authenticated promotion"). Every Q19 field is in section 4.
99- `docs/NATIVE_BOOT_ROLLBACK_CONTRACT.md` section 2: "A candidate may consume
100 exactly one boot attempt. It may never promote itself into the persistent
101 default boot path." Kept in a stronger form: a candidate gets a bounded
102 number of attempts (3), each one consumed by the loader before the
103 candidate runs, and promotion is a separate authenticated step by the
104 kernel after health, never by the candidate's own boot.
105- Owner public key format: `tools/ck_owner_gen.c` (`owner_root_ed25519
106 <64 hex>`), the same file the trust path already uses. TEST keys (RFC 8032
107 TEST 1/2/3) are refused for hardware exactly as there.
108
109## 4. On-disk format (native/boot/slot_format.h is normative)
110
111Partition: its own GPT partition, type GUID
112`8B1096CD-7928-4E08-B5E4-C19B6B532760` (new; the existing AIENOS store
113partition `38DAAC89-...` is not touched and keeps its one-partition rule).
114Layout in 4096-byte units, U = partition size in units:
115
116| Units | Content |
117|---|---|
118| 0..3 | control region: a torn-slot region holding the control record |
119| 4 .. 4+CAP-1 | slot A: manifest in the first unit, image from the second |
120| 4+CAP .. 4+2*CAP-1 | slot B: same |
121
122CAP = (U - 4) / 2; an image may be at most (CAP - 1) * 4096 bytes. Current
123images are 155648 (core) and 352256 (full) bytes; a 64 MiB partition holds
124two images 500 times larger than today's.
125
126Manifest, 4096 bytes, little-endian, the first 448 bytes signed:
127magic `AIENSLT1`, version 1, payload kind 1 (one PE, `BOOTAA64`-style image:
128kernel digest equals image digest), loader ABI 1, kernel ABI 3 (the current
129handoff ABI), generation (strictly increasing per release), policy
130generation (<= generation; promotion raises the floor to it), minimum
131rollback generation (<= generation; documentation of compatibility),
132image length, image SHA-512, kernel SHA-512, signer id (SHA-256 of the
133signing public key), commit (40 lower-case hex), provenance (64 printable
134ASCII, zero padded), timestamp, flags 0, reserved 0, Ed25519 signature,
135zero pad to 4096.
136
137Control record, 4096 bytes: magic `AIENSLC1`, version 1, active slot,
138candidate slot (or none), tries remaining (<= 3), flags (bit 0: last
139candidate failed), generation floor, last good generation, reserved 0.
140It is committed through the torn-slot region (`ts_commit`) so a power cut
141during the write leaves the previous record. The digest detects torn writes,
142not intentional forgery or rollback of the disk region.
143
144## 5. Rules (native/boot/slot_select.c is normative; its self-test is the oracle)
145
146A slot is **usable** when its manifest is structurally valid, signed by a
147trusted owner key, its image bytes match the digest, and its generation is
148at or above the control record's floor.
149
150Selection at every boot, with the control record C read from the region:
151
1521. No valid C (blank media, corrupt): recovery required; write nothing.
153 Never infer a floor of zero from a missing record.
1542. C names a candidate with tries remaining and the candidate is usable:
155 commit C with tries - 1 **before** starting it, then boot the candidate.
156 Three failed boots in a row (power cut, panic, hang and reset) therefore
157 end with tries 0 and the next boot falls through to rule 3. No boot loop.
1583. Candidate exhausted or unusable: boot the active slot if usable, write
159 nothing. The kernel sees the exhausted candidate in C and abandons it.
160 An exhausted candidate never boots on its own authority.
1614. Active unusable and the other slot usable and not the candidate: boot the
162 other slot (fallback to the last promoted image). Otherwise: recovery
163 required, loader returns to the firmware.
164
165Transitions (kernel side, after the owner-authorized update is written):
166
167- **stage**: refuses the active slot, a generation below the floor, or not
168 above the last good generation; sets tries 3, clears the failed flag.
169- **promote**: only the staged candidate, only after the booted kernel passed
170 its health milestone; flips active, clears candidate, sets last good, and
171 raises the *disk record's* floor to the manifest's policy generation.
172 That operation never lowers the current record's floor, but does not
173 prevent offline replay of an earlier valid record.
174- **abandon**: clears the candidate and sets the failed flag; the active
175 slot keeps booting.
176
177Releasing an older image requires a newly signed manifest with a higher
178generation. An old signed image below the currently read floor is refused.
179**This is not yet an offline anti-rollback guarantee:** an adversary who
180rewrites the slots partition can replay an older valid control record (or
181forge one with a lower floor and recompute its public torn-slot digest)
182alongside an older signed image. Refusing missing or corrupt control blocks
183the erase-and-boot path, not this replay path. A separately authenticated,
184rollback-resistant anchor checked on every boot and advanced before
185promotion becomes durable is still required; provisioning and recovery for
186that anchor need owner policy before hardware qualification.
187
188## 6. Cuts
189
1901. **This cut (host only).** Format, rules, host tool `ck_slot_tool`
191 (`make -C native/kernel slot-test`: layout, manifest/control mutations,
192 selection including missing/corrupt control refusal, bounded tries,
193 disk-relative floor, transitions, and torn-slot commit/recover with a
194 simulated torn write) and the freestanding proof (`slot-free`). The
195 signing path is offline: `ck_slot_tool tbs M --pubkey HEX64 --out F`
196 emits the 448 signed bytes (the owner public key is required because
197 `signer_id`, its SHA-256, lies inside the signed bytes; aienos#324), the
198 owner signs them on the air-gapped machine with OpenSSL
199 (`pkeyutl -sign -rawin`), `attach-sig` verifies and attaches. No private
200 key ever touches the Spark. The TEST signer exists for tests only.
201 **Cut 1b (merged with this note's follow-up): the package.**
202 `scripts/native_package.sh` builds the image twice from a committed tree,
203 refuses the package if the two builds differ, records `PACKAGE.txt`
204 (commit, variant, image digests, toolchain, component pins, model and
205 firmware digests) and `SHA256SUMS`, and sets the slot manifest's
206 provenance to the SHA-256 of `SHA256SUMS`, so the owner's one signature
207 over the manifest binds the whole package. `docs/NATIVE_PACKAGE.md`.
2082. **Cut 2a (done, QEMU): a slot loader in front of the stub.** Built as a
209 separate loader, `SLOTLDR.EFI`, not inside the stub (section 7), so the
210 qualified image stays byte-identical and its own stub never recurses into
211 slot selection. As first planned: the stub locates the
212 slots partition on the boot disk, reads C, reads both manifests and
213 images, calls `ck_slot_select`, commits the try if asked, and chain-loads
214 the chosen image with `LoadImage(SourceBuffer)` + `StartImage`. The
215 historical QEMU gate used fresh media **with an initialized control
216 record** and booted A; a staged B booted and, after three forced failures,
217 A booted again with B abandoned; a corrupt manifest was refused; a wrong
218 key was refused; a torn control write kept the old record. It did not
219 establish offline anti-rollback or physical qualification.
2203. **Kernel updater.** Writes the inactive slot over the kernel's own NVMe
221 path, verifies by reading back, stages through the torn-slot region, and
222 promotes after its health milestone. Qualifies interrupted updates,
223 tampered images, failed candidates and authorized rollback (the P11 list).
224 **Cut 3 (done, QEMU; section 9).**
2254. **Known-good recovery image.** The same loader plus a slot image on
226 recovery media built by my tools, for the dual-invalid case. Then N7 is
227 run on the physical candidate inside an attended window.
228
229 **Cut 2b (done, QEMU; section 8): kernel-side promote.** After its health milestone the
230 kernel writes the control record over its own NVMe path (promote the
231 candidate, or mark it failed), so a good update becomes the active slot
232 instead of only being tried three times.
233
234The stub itself is unchanged: the statements in BOOT_HANDOFF_CONTRACT
235section 7 and native/boot/README.md hold for it; slots live only in
236SLOTLDR.EFI.
237
238## 7. SLOTLDR.EFI and its gate (cut 2a)
239
240`native/boot/slot_loader.c` builds `$(OUT)/SLOTLDR.EFI`
241(`make -C native/kernel slot-loader`). Why a separate loader and not the
242stub: if the stub chose a slot and chain-loaded an image, that image's own
243stub would choose again; a front loader keeps the qualified image
244byte-identical and keeps the stub frozen. The boot volume's
245`EFI/BOOT/BOOTAA64.EFI` becomes SLOTLDR.EFI; the slot images are the
246unchanged stub + kernel image.
247
248What it does, in order:
249
2501. Finds whole disks (Block I/O), checks each primary GPT (header and entry
251 array CRC32, usable range) and takes the one partition with the slots type
252 GUID (`slot_format.h`). None, or more than one across all disks:
253 recovery required. The backup GPT is not read; a bad primary fails closed.
2542. Reads the control region (units 0-3) and recovers the newest committed
255 record with the torn-slot rules (`native/store/torn_slot.c`), read only.
2563. Reads both manifests and images (bounded by the slot capacity, read in
257 pieces of at most 8 MiB) and verifies each with `ck_slot_verify` against
258 the keys baked in at build time.
2594. Applies `ck_slot_select`. A candidate try commits the control record with
260 tries reduced by one, then reads it back and compares; if that fails the
261 candidate is treated as invalid and the selection runs again. This is the
262 only write, and it lands only in the control region.
2635. Prints `slot_loader: boot=<A|B> reason=<name> gen=<n> tries=<n> floor=<n>`
264 and chain-loads the verified bytes with `LoadImage(SourceBuffer)` and its
265 own device path (so the chained stub still sees the boot volume) and
266 `StartImage`.
2676. Both slots invalid: prints `slot_loader: recovery_required (A: <why>; B:
268 <why>)` and returns `EFI_LOAD_ERROR` to the firmware.
269
270Never: UEFI variables, runtime services, `ExitBootServices` (the chained
271stub leaves boot services itself), `SetWatchdogTimer`, kernel objects (all
272checked at build time).
273
274Keys: `CK_SLOT_KEYS=<file>` bakes the owner's public keys in (same file
275format as `ck_slot_tool --keys`, generated by `ck_slot_tool keys-c`).
276`CK_TEST_SLOT_KEY=1` bakes the RFC 8032 TEST 1 key and the loader prints
277`slot_loader: TEST-ONLY key`; it is refused with `CK_HARDWARE_STAGING=1`,
278and the two options together are refused.
279
280Boot-success tracking in cut 2a is the tries counter: a candidate that is
281never promoted is tried three times and then left; the active slot boots.
282Promotion after a kernel health milestone is cut 2b.
283
284Gate: `scripts/qemu_ck_slot_loader_test.sh` (`AIENOS_CK_SLOT_LOADER`, child
285`slots` of `scripts/ck_gates.sh`), rows 186-193 of `native/kernel/GATES.md`,
286plus the build check row 194 (`make test` runs `slot-loader-check`). Run on
2872026-10-12 at code commit bff20a1: PASS, 8 rows, 11 boots, 76 checks, 126 s
288under QEMU TCG. Hardware NOT_RUN.
289
290Host tool additions for the gate: `ck_slot_tool slots-image` (writes the
291control record and both slots into a slots partition of a disk image),
292`ck_slot_tool keys-c`, `ck_slot_tool sign-test --test2` (a second,
293untrusted TEST key), and `ck_gpt_image` layout `slots`.
294
295## 8. Kernel promotion and abandon (cut 2b)
296
297Cut 2a left two things to the kernel: making a good candidate the active slot,
298and marking a candidate that ran out of tries as failed. Both are now done by
299the service kernel (`CK_SERVICE=1`), in `native/kernel/svc/slot_service.c`,
300with the loader's own rules and commit routine. There is no second
301implementation of the record format.
302
303**How the kernel learns which slot it is.** The control record alone cannot
304tell: "candidate on its last try" and "candidate out of tries, active booted"
305both read `tries=0`. Before `StartImage`, SLOTLDR.EFI therefore allocates
306one page of the OS-loader memory type `0x80000A1E` and writes a 256-byte boot
307record into it (`struct ck_slot_boot_record`, `slot_format.h`): booted slot,
308the loader's reason, tries, the control sequence it read or committed, the
309started manifest's generation, policy generation and image SHA-512, the
310loader commit, and a SHA-256 over the first 224 bytes. The page survives
311`ExitBootServices` and is listed in the memory map the unchanged stub already
312copies into the handoff, so neither the stub nor the handoff format changes.
313The kernel copies it in `ck_kernel_entry` right after `ck_handoff_check`,
314while the firmware identity map is still live (the kernel never maps that
315memory type afterwards, and its frame allocator only hands out conventional
316memory, so the page is never reused). The digest catches a torn or stray
317page; it is not a signature, because the record comes from inside the same
318firmware + loader trust boundary as the handoff itself.
319
320**What the kernel does** (`ck_slot_kernel_action`, `slot_select.c`, pure and
321self-tested):
322
323| Boot record and disk | Action | Write |
324|---|---|---|
325| no record (image not started by SLOTLDR), record fails its checks, no slots partition, no control record, the started slot's manifest on disk differs from the record, or the control sequence moved since the loader read it | refuse, say why | none |
326| reason `candidate_try`, control still names the slot, health reached | **promote**: active = this slot, candidate cleared, floor raised to the image's policy generation (never lowered) | one control commit |
327| reason `candidate_try`, health not reached | wait; at the stop order the kernel says the candidate was not promoted | none (the loader keeps counting tries down) |
328| reason `candidate_exhausted` or `candidate_invalid`, a candidate is set and the booted slot is the active one | **abandon**: candidate cleared, `CANDIDATE_FAILED` flag set, active slot unchanged | one control commit |
329| anything else (steady boot of the active slot) | nothing | none |
330
331Health is the service's own milestone, nothing new: the Store is open,
332continuity committed this boot (PROVISIONED or RESUMED, the self-test
333record the lifecycle already writes) and the lifecycle is READY. It is
334checked when the lifecycle starts and again after a successful `unlock`.
335Abandon is not gated on health: the loader already decided.
336
337**The write.** One control record commit through the torn-slot protocol
338(`ck_slot_control_commit`, `native/boot/slot_control.c`, shared with the
339loader and `ck_slot_tool`): body, flush, commit header, flush, then read back
340and compare. It goes over the kernel's own NVMe path, through a second
341bounded partition view of the slots partition (`ck_dev_slots_disk`, found
342with the same strict GPT validation as the AIENOS partition, primary and
343backup), never a whole-disk handle. A failed commit leaves the previous record
344authoritative and is reported.
345
346**Gate.** Rows 9-11 of `scripts/qemu_ck_slot_loader_test.sh` (GATES.md
347rows 195-197) boot SLOTLDR.EFI and the service image from one NVMe disk
348(`ck_gpt_image` layout `aienos-slots`: the Store partition and the slots
349partition):
350
351- row 9: a healthy candidate B is promoted by the kernel (control
352 `active=1 floor=2`), and the next boot is a steady boot of B with no write;
353- row 10: a candidate that never becomes healthy (the plain service image,
354 whose Store stays locked) spends its last try without promotion; the next
355 boot falls back to A and the kernel abandons B (`flags=0x01`), A stays
356 active and the host tool agrees the next decision is a steady boot of A;
357- row 11 (negative control): the service image started directly, without
358 SLOTLDR, finds no boot record and writes nothing although it is healthy.
359
360Both slots invalid stays row 7: `recovery_required`, no image started, the
361control record untouched. `make -C native/kernel slot-test` adds the boot
362record mutations (each refused with its reason), the kernel-action scenarios
363and the shared commit routine.
364
365Not here: the updater that writes a new candidate into the inactive slot
366(cut 3, section 9) and the recovery image for the dual-invalid case (cut 4).
367Hardware NOT_RUN.
368
369## 9. The inactive-slot updater (cut 3)
370
371The running service kernel writes a new signed image into the slot it is
372NOT running from, then stages it as the candidate; the loader tries it on
373the next boot and the kernel promotes it after its health milestone
374(section 8). One routine does the work, `ck_slot_update`
375(`native/boot/slot_update.c`), shared by the kernel and the host tool's
376self-test, over the same control-commit routine as the loader.
377
378**Source: the update inbox partition.** GPT type
379`58D9C90E-497A-4848-95DD-EB7E22B0CE96` (`CK_SLOT_INBOX_TYPE`), on the same
380NVMe disk, with one slot's shape: the signed manifest in unit 0, the image
381from unit 1. The desk tool fills it from a package
382(`ck_slot_tool inbox-image --m slot/MANIFEST.signed.bin,image/BOOTAA64.EFI`);
383the kernel only reads it. How the inbox is filled on the physical machine
384(an owner-attended step) is not part of this cut.
385
386**Operator verb `update`** (lifecycle READY only: a LOCKED Store, or a
387pending task, refuses it; `core/lifecycle_fsm.c`). The kernel:
388
3891. refuses unless it was started by SLOTLDR.EFI (boot record), a control
390 record exists, no candidate is staged, and the booted slot is the active
391 one; the target is the other slot;
3922. reads the inbox manifest and image and runs the loader's own
393 `ck_slot_verify` (Ed25519 signature by a trusted key, SHA-512 of the
394 image, size within the slot) and a dry run of
395 `ck_slot_stage_candidate` (generation above the floor). Any refusal:
396 **nothing is written**;
3973. zeroes the target's manifest unit and flushes: from here the target is
398 invalid and the loader keeps booting the active slot;
3994. writes the image units, flushes; then the manifest last, flushes;
4005. reads the whole target back and verifies it again from the disk bytes
401 (a mismatch zeroes the manifest unit again and refuses);
4026. stages: one control record commit (candidate = target, three tries).
403
404Every write is bounded to the target slot's unit range; the active slot and
405the control region (except the one commit of step 6) are never written. An
406interruption before step 6 leaves the control record untouched and the
407target invalid (or, only between steps 5 and 6, valid but not staged, which
408the loader ignores until a later `update` stages it).
409
410**Trusted keys.** The service image is built with the same key table as
411SLOTLDR.EFI (`ck_slot_tool keys-c`): RFC 8032 TEST 1 in the TEST-keys
412service image (`CK_SERVICE_TEST_KEYS=1`, QEMU only), the Owner Root from
413`CK_OWNER_PUBKEYS` under `CK_HARDWARE_STAGING`; the plain service image
414has no table and refuses every update. TEST keys under hardware staging
415stay refused by the Makefile (gate row 15) and by `keys-c`.
416
417**Evidence.**
418- `make -C native/kernel slot-test`: 155 checks. The 22 added for cut 3: a
419 positive update (B written, verified from disk, staged, A unchanged, the
420 loader's next decision is a candidate try; exhausted tries and an invalid
421 candidate fall back to A), refusal while a candidate is staged, an
422 injected I/O error at each of the 16 writes of an update (every one
423 refused with A and the control record untouched and B invalid or
424 unstaged), a stop at each step, and ten refusals before any write (bad
425 signature, wrong key, wrong digest, truncated inbox, generation at the
426 floor, booted slot not active, no trusted key, no control record, image
427 larger than the slot, corrupt manifest). Three mutants of
428 `slot_update.c` (writing the active slot, staging before the image,
429 skipping signature verification) each fail these checks.
430- `scripts/qemu_ck_slot_loader_test.sh` rows 12-15 (`docs/GATES.md`):
431 row 12 update from slot A writes and stages B, a second `update` is
432 refused, A's bytes are unchanged, the next boot tries B and the kernel
433 promotes it; row 13 QEMU is killed in the middle of the image write
434 (TEST-only `update halt-after=1`), the control record and A are
435 untouched, the loader refuses the half-written B and boots A, and a new
436 `update` then succeeds; row 14 an inbox signed by the wrong key and one
437 with a flipped image byte are refused with the slots partition
438 byte-identical; row 15 the update is refused while the Store is locked,
439 and a TEST-key updater image is refused under hardware staging.
440- The package carries SLOTLDR.EFI (`docs/NATIVE_PACKAGE.md`, "Slot loader
441 in the package").
442
443Not here: the known-good recovery image for the case where both slots are
444invalid (cut 4). Hardware NOT_RUN: nothing was written to a physical disk.