Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/patches/33d8f50817ce4c1a # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers ## GitHub aien-dev/aienux#469 (code only) closed derived `33d8f50817ce4c1a` #469 Imported from GitHub aien-dev/aienux#469 (code only) GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed). Base `c93a5f57617e461d36da4f6c4f3af2efb990afd8` · Head `7049c620e689024a818c5cd78fce624545447f93` ### Fetch it A git bundle of the pull request's head, 27783 bytes. ``` curl -fsSL https://interplane.io/drakestapleton/aienux/patches/33d8f50817ce4c1a.bundle -o 33d8f50817ce4c1a.bundle git fetch 33d8f50817ce4c1a.bundle refs/pull/469/head ``` Raw bundle · Diff ### Provenance This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record: ``` github-import 1 aien-dev/aienux 469 7049c620e689024a818c5cd78fce624545447f93 ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"aienux","number":469,"url":"https://github.com/aien-dev/aienux/pull/469","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:30Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/.crumb b/.crumb index 6b915568..f536fffc 100644 --- a/.crumb +++ b/.crumb @@ -27,20 +27,20 @@ "purpose": "Directory crates. Purpose not yet described by a human." }, { - "digest": "99d177c93f58a07c5491ac84a08c71d3aa0b0512ce445dd839aa802a7490de89", - "last_commit": "832bcbd9", + "digest": "ca789f13ea75187b676799c37b525e192b9529c0058391bd04e175ac63189d75", + "last_commit": "0ff206e7", "name": "docs", "purpose": "Directory docs. Purpose not yet described by a human." }, { - "digest": "1b716d22758667b3d122dc64823eb251a8561f9cee50fa8dca357d0e384b548d", - "last_commit": "6dd64a0c", + "digest": "f271b24cfa01e1f5714b6466e64eaff7e9bacfd2a642d1af2eadd143db96ebf7", + "last_commit": "ec3043bc", "name": "native", "purpose": "Directory native. Purpose not yet described by a human." }, { - "digest": "3ff6ec04ad2ae8ef9bc36a536cdf659cdfe5ea0960c3a21eb61ce6e9e16adfa4", - "last_commit": "89e296db", + "digest": "dfb7d7427df2bc70e6ed6342169ba6db6223965edca01370f25b107484141de5", + "last_commit": "ec3043bc", "name": "scripts", "purpose": "Directory scripts. Purpose not yet described by a human." }, @@ -51,15 +51,15 @@ "purpose": "First-party host artifact preparation tools" } ], - "children_root": "sha256:9a51e4dbf367368f0a2ee86219d8cf4e1c8d5ca37506df08ecb5fad8d037380a", - "compiled_at": "2026-10-30T04:38:58Z", + "children_root": "sha256:4c7bcb7fc30fa5f62ed15e75841f9d6fd07fb908896c822891df7f10557f19f3", + "compiled_at": "2026-10-30T05:07:55Z", "compiler": "crumb-compile/1", - "digest": "sha256:ca9e40b904cf216ba3783d4df38fe90f47f7927287e6e2680b4cdb56f2c87cdf", + "digest": "sha256:b4d5ae902876aba5a3c85dd55eaa436abbb18e538b549e5e080a88a62458a5bc", "evidence_files": 236, "evidence_root": "sha256:55ef5621f09577ce1ada90d990955aec996d15e16a9b0f6953ecb90f3ca499df", "files": 3557, - "generated_at_commit": "6dd64a0c588ba28904dd7efc7ed1a1655459005e", - "source_tree": "sha256:b87f0bb336351753589a7ecd074d4b52d96dec472b33965a805ae1da7d9780d1" + "generated_at_commit": "ec3043bc977dc9577ef7765fb57f19956a148a77", + "source_tree": "sha256:af7ecf17aef1d464564a7272b370815374c5ea20ce167dbbefc576c8f1df6657" }, "owner_lane": "", "provenance": { diff --git a/docs/.crumb b/docs/.crumb index 135b8fbb..b36d6c4a 100644 --- a/docs/.crumb +++ b/docs/.crumb @@ -18,26 +18,26 @@ "children": [ { "digest": "477f9151be8ffe5662c59ab581ed6805379b4ed4da9ba10970d1864431f1cc3d", - "last_commit": "659ddd2", + "last_commit": "a088d77", "name": "adr", "purpose": "Directory docs/adr. Purpose not yet described by a human." }, { "digest": "5dc4f124f1c023aa4786f45336a671138fce9fa046478364cdc7454307d7b588", - "last_commit": "659ddd2", + "last_commit": "09e59a8", "name": "crumbs", "purpose": "Directory docs/crumbs. Purpose not yet described by a human." } ], "children_root": "sha256:efb4a0449db172a441d8663f55ab48d6d81405e011961fd54213541c119b6852", - "compiled_at": "2026-10-28T22:57:18Z", + "compiled_at": "2026-10-28T23:30:36Z", "compiler": "crumb-compile/1", - "digest": "sha256:99d177c93f58a07c5491ac84a08c71d3aa0b0512ce445dd839aa802a7490de89", + "digest": "sha256:ca789f13ea75187b676799c37b525e192b9529c0058391bd04e175ac63189d75", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 216, - "generated_at_commit": "21e52cee89b9368b59f52de06709f16347c0304a", - "source_tree": "sha256:030ed2f6d14cdd06580a0ea899e38c155db6fd6e67935f50cb6128af6d386b98" + "generated_at_commit": "7d555ade734bd56787d4bfd477caa0e79d0a1134", + "source_tree": "sha256:4bfa2cc15ce402f3dd1b5e9ed578cd8db4f27960d718d5f412128d78e72f79a4" }, "owner_lane": "", "provenance": { diff --git a/docs/campaigns/B7B-PHYSICAL-BOOT-PREP.md b/docs/campaigns/B7B-PHYSICAL-BOOT-PREP.md index 4a1667d0..ca97dc5f 100644 --- a/docs/campaigns/B7B-PHYSICAL-BOOT-PREP.md +++ b/docs/campaigns/B7B-PHYSICAL-BOOT-PREP.md @@ -1,8 +1,8 @@ # B7B-PHYSICAL-BOOT-PREP: the attended B7b hardware boot, on paper only -Status: PREPARATION DOCUMENT (2026-10-11). **None of this is executed without Drake's attended, explicitly approved -window.** Writing this page changed nothing on the machine: no reboot, no firmware staging, no boot-entry change, no -root command. Every PASS cited for the probe image is QEMU only, not physical. +Status: PREPARATION DOCUMENT (updated 2026-10-28). **Physical NOT_RUN. Nothing here authorizes staging or booting.** +Host/QEMU qualification and candidate-only builds do not qualify Spark hardware. The fixture-provisioned full +candidate is NOT boot-admissible; no approved Spark owner material is available. This lane performs no ESP or media writes. Owner issue: aien-dev/aienux#286 (native GB10, cut B7b). Authority: Drake's ruling of 2026-10-10 (aien-architecture#190, item 5) authorizes B7b *preparation*, not a boot; the boot needs "a first operator-confirmed, two-hour attended window @@ -12,10 +12,11 @@ Related, read first: `docs/native/PREFLIGHT-AND-RECOVERY.md`, `docs/NATIVE_BOOT_ ## 1. What B7b is, and what is already built -Goal in plain words: boot a special test build of the AIENOS kernel once, let it switch on the second memory-protection -chip ("SMMUv3 B", at 0x13000000) for one made-up device slot, read two read-only identity registers of that chip, switch -the slot off again, print one summary line, and return to Linux. No device is allowed to move data; the GPU is not -touched. +Goal: boot an explicitly admitted probe once, enable SMMUv3 B at the IORT-selected address (expected 0x13000000), +confine segment 15 requester 0x100 to one allocated page **plus that stream's accepted IORT RMR identity ranges**, +read IDR0/IDR1, release the stream back to abort, and collect SMMU events before the final report. The probe never +hands its page to the GPU and starts no GPU DMA. A full image also runs its ordinary device/security/Store/input +stages; "no GPU DMA" does not mean "no other device I/O". A core-only probe excludes those stages. Built and tested without hardware (PR #302, squash `863bef83`, issue #286 comment): @@ -24,8 +25,14 @@ Built and tested without hardware (PR #302, squash `863bef83`, issue #286 commen the link refuses a default image that carries the probe. - QEMU gate: `scripts/qemu_ck_b7b_probe_test.sh`. Default mode: the Spark-target image refuses fail-closed on QEMU (route none, `rc=-3 nostream`, nothing confined). `--positive`: TEST-ONLY segment-0 image confines one page, reads - IDR0/IDR1, unconfines. `--self-test`: 19 canned logs and 4 Makefile refusals. Local runs recorded in the PR: all PASS. + IDR0/IDR1, unconfines. `--events` uses a disposable QEMU NVMe negative-DMA oracle and all-SID decoded readout. + `--self-test` includes missing/wrong-SID/wrong-address event, overflow and pending negative controls plus flag refusals. - Expected Spark output: `docs/GB10_IORT_DECODE.md` section 10, labelled *expected, not observed*. +- New opt-in build: `make [full] CK_B7B_PROBE=1 CK_B7B_EVENT_READOUT=1`, separate + `target/native-kernel-b7b-events` output. `ck_b7b_event_readout` runs before the final report. It enumerates all + instance slots and consumes at most one queue capacity per live instance; no unbounded wait on a producer. + The host observer test covers all SIDs, full/wrapped queues, overflow acknowledgement, later-arriving events, + and raw-word retention; the host DROP_EVENT mutant must fail that same test. Built 2026-10-12 (native v1 package P02): the probe variant of the one-time staging script, `scripts/stage_one_time_boot_ck_b7b.sh` (`--dry-run` / `--apply`, same shape as `_full.sh`). It builds the probe @@ -33,7 +40,7 @@ hardware staging image twice and refuses on a digest mismatch, checks the image TEST marker, and stages it as `\EFI\AIENOS\aienos-ck-b7b.efi` with a `STAGED-CK-B7B.TXT` record. Its dry run was executed on the Spark on 2026-10-12 (read-only; it stopped on four preflight items, among them the recovery stick not being inserted), and two builds of the image at commit `51c05da` with the labelled TEST-FIXTURE owner files (a build -check only, never a boot) gave one digest. What remains for G7 is Drake reading the dry run. +check only, never a boot) gave one digest. This is historical preparation, not today's G7 or staging authority. ## 2. People and things required (all physical, all Drake's) @@ -41,10 +48,33 @@ check only, never a boot) gave one digest. What remains for G7 is Drake reading |---|---| | Drake present for the whole window | at the machine, display and keyboard attached; a fresh go-ahead for this boot, given in this window (a past approval does not carry over) | | Window | two hours, written down in advance with start time; nothing else uses the machine in it | -| Recovery stick | `AIENOSRECOV` plugged in, listed as `Boot0004`, verified (section 3) | -| Camera | one phone or camera on the screen for the whole boot; the screen is the only observation channel | +| Recovery stick | existing `AIENOSRECOV`, current firmware **Boot0002**, PARTUUID `f227357c-1e80-4fd0-a55e-2efbef1dd25c`; serial `5D0344B4`; read-only for this lane; parent alone owns any newly authorized backup/reuse/restore | +| Camera and witnesses | camera on screen for whole boot; primary native xHCI/USB keyboard plus independent RTL8127 UDP boot-report witness on iMac/MacBook (neither may be silently dropped) | | Witness | a second person (or Drake plus a time-stamped recording) who reads the screen aloud and keeps the clock | | Notes | paper or a laptop for times and the exact words on screen | +| Prerequisite 0: owner provisioning | completed Drake-provided `CK_OWNER_PUBKEYS` + `CK_MACHINE_ID` ceremony before full staging; currently NOT DONE; never generate a substitute or reuse another machine's key | +| Candidate medium | separate blank medium preferred; Drake subsequently approved parent-owned backup then reuse of the recovery stick, conditional on verified backup and an executable recovery restore path; this lane never writes it | + +The October 28 parent inspection found the existing recovery stick in the Spark, with shim/GRUB, recovery +kernel/initrd, `capture-attended.sh`, and `aienos-evidence/attended-recovery-machine1.txt`. The parent read that file: +2026-09-25T00:26:25Z, BootCurrent was this stick (then Boot0004), NVMe root/ESP mounted read-only, +`RECOVERY_BOOT_GATE: PASS`. This is historical physical recovery proof, not a recovery boot today. Recheck medium +identity before GO. Current Boot0002 and historical Boot0004 are the same PARTUUID; never rewrite it to match a number. + +Later October 28 authorization correction, relayed by the parent: Drake approved backing up this stick and then +reusing it. **The parent owns every `/dev/sda` action**, including backup, verification, writing and restoration; +this lane remains read-only. Before reuse/GO, retain a byte-exact backup with digest, partition metadata and the +on-stick recovery evidence, and prove a restoration route on another available machine if Spark fails to boot. +A backup stored only on an unbootable Spark is not a usable recovery route. While the stick contains a candidate, +Boot0002 does not magically remain a recovery environment: restore the verified recovery bytes before using it as +recovery. Recheck its restored identity/hash and historical evidence before another boot window. + +The full-image build parser (`native/kernel/tools/ck_owner_gen.c`, matching the existing native/m5 owner boundary) +accepts text lines `name hex`, blank lines and `#` comments. Public-key file: exactly +`owner_root_ed25519 <64 hex digits>`. Identity file: exactly `machine_id <64 hex digits>` and +`store_uuid <32 hex digits>`. Duplicate/unknown names, malformed lengths, all-equal placeholders and known TEST +values are refused. These are public identity inputs, not K_vol or private signing keys. Labelled +`native/kernel/tests/fixtures/owner/` inputs prove build mechanics only and MUST NOT be staged. ## 3. Recovery preflight: read-only checklist @@ -57,16 +87,16 @@ failure. | P1 | `git -C status --porcelain` | prints nothing (clean tree) | | P2 | `git -C rev-parse HEAD` | the commit the probe image is built from; write it down | | P3 | `quietlock check` | clear (no other session holds the machine quiet) | -| P4 | `efibootmgr` (no arguments) | lists `Boot0004` with `AIENOSRECOV`; `BootOrder` starts `0001`; no `BootNext`; `BootCurrent: 0001` | -| P5 | `lsblk -f` | the recovery stick is visible; the internal drive layout matches `docs/RECOVERY_MEDIA_MACHINE1.md` (root ext4 `d27bfd26-ff30-400e-9eca-9cdf73de9406`, ESP vfat `9DA2-3597`) | +| P4 | `efibootmgr` (no arguments) | `Boot0002 AIENOSRECOV` matches the recovery PARTUUID; `BootCurrent: 0001`; `BootOrder` and no `BootNext` match the captured current Linux baseline (do not assume an old BootOrder) | +| P5 | `lsblk -f` and parent-approved read-only identification | exact recovery identity above and internal root/ESP match; if parent reuses recovery medium, verified backup and independent-machine restore route are recorded before any write | | P6 | `bash scripts/verify_recovery_tools.sh` | `PASS` (static check of the recovery initrd; `NOT_RUN` is not a pass) | | P7 | `bash scripts/qemu_verify_recovery_media.sh` | the recovery environment boots in QEMU with zero hard disks | | P8 | `bash scripts/qemu_ck_rollback_test.sh` and `bash scripts/qemu_native_rollback_test.sh` | the rollback gates pass for this commit | -| P9 | `bash scripts/qemu_ck_b7b_probe_test.sh --self-test`, then with no flag, then `--positive` | `AIENOS_CK_B7B_PROBE_SELF_TEST: PASS`, `AIENOS_CK_B7B_PROBE: PASS`, `AIENOS_CK_B7B_PROBE_POSITIVE: PASS` | +| P9 | `bash scripts/qemu_ck_b7b_probe_test.sh --self-test`, no flag, `--positive`, then `--events` | all corresponding verdicts PASS, exact real negative SID/address decoded, final queue readout before report | | P10 | `bash scripts/ck_repro_build.sh full` (builds twice, compares); the probe staging image is built twice by the stage script itself (P12 shows the commands, `--apply` runs them and STOPs on a digest mismatch; `ck_repro_build.sh` does not build staging images, verified 2026-10-12 by reading it) | two equal digests for the default full image; the probe image digest is written down from the stage script output | | P11 | `bash scripts/native_boot_preflight.sh --image --expect-sha256 ` | last line `NATIVE_PREFLIGHT: READY`; the `ASK` lines are Drake's and are answered in person | | P12 | `AIENOS_OWNER_PUBKEYS= AIENOS_MACHINE_ID= bash scripts/stage_one_time_boot_ck_b7b.sh --dry-run` | prints every command, touches nothing, ends "Pre-flight clean"; Drake reads it | -| P13 | the recovery stick, tested in person: booted once in an earlier attended window per `docs/RECOVERY_MEDIA_MACHINE1.md`, evidence kept | the evidence file from that boot is on hand. UNVERIFIED whether a current one exists; no script checks this | +| P13 | reconcile the stick's `aienos-evidence/attended-recovery-machine1.txt` with its exact identity and an earlier attended physical recovery boot | Drake confirms physical recovery proof; mere file presence, QEMU boot, or firmware entry is insufficient | Secure Boot is recorded, never changed. As of 2026-10-01 it is OFF for development by owner decision (`docs/native/PREFLIGHT-AND-RECOVERY.md` item 3); `native_boot_preflight.sh` records the state and stops if it is ON. @@ -84,10 +114,14 @@ UNVERIFIED here and is part of Drake's go/no-go. on screen). - G5 `BootNext` unset, `BootOrder` unchanged (P4), Linux is the running system. - G6 Everyone can state the abort rule (section 7) from memory. -- G7 A reviewed probe variant of the staging script exists (`scripts/stage_one_time_boot_ck_b7b.sh`, since 2026-10-12) - and its dry run (P12) was read by Drake. **The script exists; the read-through has not happened; therefore today the - answer is still NO-GO.** +- G7 The media procedure `docs/campaigns/SPARK-BOOT-INPUT-20261028.md` is integrated and reviewed with Drake. + Either a separate identified medium is supplied, or the parent has completed the specifically authorized + recovery-backup/reuse prerequisite above. Only the parent acts on that medium. The legacy ESP staging script's + `--apply` still requires separate explicit ESP authorization and is not the current route. + Incomplete owner ceremony or composed keyboard/network witness image keeps this campaign NO-GO. - G8 Drake says "go" out loud in the window, and the witness writes the time. +- G9 The exact admitted candidate includes both native confined xHCI/USB keyboard and RTL8127 UDP report witness. + The standalone core-only SMMU artifact does not include either and cannot satisfy this combined physical campaign. **NO-GO (any one):** any preflight STOP line; a dirty tree; the stick missing; an unexpected `BootNext`; a digest mismatch; anyone unsure; less than the full window left; an open question about the SMMU B side effect (section 8) @@ -95,25 +129,29 @@ that Drake wants answered first. ## 5. Boot steps (only after GO; Drake or the witness reads each step aloud) -1. Start the camera and the notes. Write the commit and digest at the top. -2. In Linux, capture the "before" state (needs sudo; Drake runs it): - `sudo scripts/verify_native_rollback.sh --capture-pre evidence/pre_boot_capture.json`. - The staging script does this itself; do not capture twice. -3. Stage once: `sudo` is asked for by `scripts/stage_one_time_boot_ck_b7b.sh --apply` with the owner files set (needs sudo; it writes only the staging directory - `\EFI\AIENOS` on the ESP and sets `BootNext` once; it never reboots and never changes `BootOrder`). Read its - output aloud; it must end with `BootNext` set and `Boot0004 AIENOSRECOV` still listed. -4. Reboot by Drake's hand (`sudo reboot`). Start the clock. -5. Watch the screen only. Firmware consumes `BootNext` and loads the probe image. Expected lines, in order, as in - `docs/GB10_IORT_DECODE.md` section 10 (expected, not observed): `kernel: alive`; - `b7b_probe: start segment=15 rid=0x100 ...`; `b7b_probe: route instance=1 base=0x13000000 stream=0x100 ...`; - `smmu: instance 1 up base=0x13000000`; the reserved-range line; `b7b_probe: confined ...`; - `b7b_probe: instance=1 idr0=0x........ idr1=0x........ st_level=. sidsize=..`; `b7b_probe: unconfine rc=0 (ok)`; - `AIENOS_B7B_PROBE: CONFINED_AND_RELEASED`. -6. The image holds the console for 120 s (`CK_FB_HOLD_S=120`, set by the stage script; the probe returns to kmain and - the full image's normal final report, hold and reset follow, so the hold is the full image's own; UNVERIFIED on - the real console until this window) and then resets. Do not touch anything. The next start is Linux because `BootNext` is already consumed. -7. Back in Linux: `sudo scripts/verify_native_rollback.sh --capture-post evidence/post_boot_capture.json`, then - `--pre ... --post ... --verify` (ten invariants). Read the verdict aloud. +1. Start camera, witness receiver and notes; write exact source revision, candidate digest and medium identity. + Follow section 7's separately authorized incumbent stop procedure. Do not proceed while 18091 remains live or + without a verified restoration recipe. +2. Capture the before state with `sudo scripts/verify_native_rollback.sh --capture-pre evidence/pre_boot_capture.json` + only with the window's explicit authorization; preserve existing BootOrder/BootNext/Secure Boot and ESP. +3. Use the separately reviewed medium-identification/image-writing procedure in + `docs/campaigns/SPARK-BOOT-INPUT-20261028.md`. Parent alone may write the exact authorized candidate medium, + including recovery-stick reuse only after the verified backup/independent restore prerequisite. No internal ESP write. + Verify the exact candidate hash after packaging. Full TEST-FIXTURE image is never eligible. +4. Drake selects that candidate through the firmware's attended one-time boot menu and starts the clock. + Do not use ALLEN.EFI or Boot0000. No automatic reboot or persistent boot-order edit is part of this route. +5. Expected SMMU lines (expected, not observed): `kernel: alive`; `b7b_probe: start segment=15 rid=0x100 ...`; + IORT route instance/base/SID; every `b7b_rmr:` interval; one-page confinement; IDR0/IDR1; successful unconfine; + `AIENOS_B7B_PROBE: CONFINED_AND_RELEASED`. Photograph **all** SIDs in every `b7b_event:` line, then each live + queue's `events`, `overflow`, `pending`, and all `not-live`/`failed` slots between final begin/end. + GB10 and HDA0 records must be attributed by the actual IORT stream map, not guessed from neighboring IDs. +6. Confirm readout precedes `report_kind: final`; record native keyboard evidence and independent UDP witness. + A queue with overflow/pending or a missing witness is incomplete, never a physical PASS. The console hold + (`CK_FB_HOLD_S=120`) then reset is expected, not physically verified; no further event observation is promised + during the hold. If the firmware does not return to Linux, use section 7 recovery. +7. Back in Linux, capture post state and run `verify_native_rollback.sh --pre ... --post ... --verify` on the exact + saved pair. Restore and verify the incumbent 18091 answer service by section 7. Preserve the candidate/recovery + media and all evidence; no second attempt without fresh authority. ## 6. Observation points @@ -130,26 +168,71 @@ that Drake wants answered first. - **Abort rule.** If the screen shows a panic, shows nothing new for 60 seconds, or anyone says "stop": touch nothing until the 60 seconds are over, then hold the chassis power button until the machine is off, wait ten seconds, press - it again. `BootNext` was consumed before the image started, so the machine boots `BootOrder` (Linux, `0001`). -- **If Linux does not come up:** firmware boot-menu key (F11 or the firmware's own), pick `AIENOSRECOV` (`Boot0004`). - Mount root and ESP **read-only** and run the collector exactly as in `docs/RECOVERY_MEDIA_MACHINE1.md` ("Inspect - internal storage read-only", "Capture the recovery evidence"). + it again. The one-time menu choice must not change captured BootOrder; normal fallback is Linux (`0001`). +- **If Linux does not come up:** use the firmware one-time menu for `AIENOSRECOV` (current historical entry + **Boot0002**, verify recovery PARTUUID), but only if its recovery contents are present. If the parent reused it, + the parent first restores its verified recovery backup using the pre-arranged independent-machine route. + Then mount internal root/ESP **read-only** and run the collector in `docs/RECOVERY_MEDIA_MACHINE1.md`. - **Repair** (removing `\EFI\AIENOS`, touching `BootOrder`) needs a new, separate go-ahead from Drake at that moment. - **Never**: change Secure Boot, change firmware settings, run `--apply` a second time, retry a failed probe in the same window without a fresh go, or "fix" anything on the machine during the window. - Rehearsed so far only in QEMU (`scripts/qemu_ck_rollback_test.sh`, gate M0_ROLLBACK); not on the Spark. +### Resident model stop and exact restore (operator-only, separate approval) + +Stopping the service is NOT authorized by this document. Before opening a physical boot window the parent must +obtain Drake's explicit approval to stop/restore the live 18091 model and capture its *current* command, executable +hash and non-secret runtime settings. On October 28 the read-only snapshot was PID 16911, +`bin-19173f9e/aien-serve-http`, 8 slots, context 49152, stroke 1. PIDs are not stable; never signal that recorded PID +without identifying the current listener and executable again. Do not dump the entire process environment into +receipts: it may contain credentials. + +1. Save `curl -fsS http://127.0.0.1:18091/v1/models`, `ss -ltnp 'sport = :18091'`, + `readlink /proc//exe`, and `sha256sum /proc//exe` in the private window evidence. + Confirm with the coordinator that no other process owns the GPU window. Record any supervising unit and its + restart policy; if supervised, use that unit's approved stop/restore instead of fighting an automatic restart. +2. After the exact stop authorization and quietlock/spark-window approval: `kill -TERM `. + Wait for process exit; verify the listener is gone and no model GPU process remains using read-only telemetry. + If shutdown does not finish, STOP: no unapproved SIGKILL, reset, driver unload or VFIO operation. +3. Proceed with the approved one-time boot. If staging/preflight fails before reboot, restore immediately by the + same recipe; do not leave the incumbent stopped while investigating. +4. After Linux returns and rollback checks pass, the coordinator restores the captured incumbent. For the recorded + October 28 baseline, the exact non-default settings are: + + ```sh + Q36_BATCH_BIN=bin-19173f9e Q36_BATCH_SLOTS=8 Q36_MAX_CONTEXT=49152 \ + AIEN_Q36_STROKE=1 AIEN_SERVE_GPU_LOCK=/tmp/aien-serve-18091.lock \ + /home/drakestapleton/.local/state/aien-q36/start-35b-batch.sh + ``` + + Re-capture before the window: if the incumbent changed, use its newly recorded recipe, not this historical one. + The launcher's default binary/stroke differ, so invoking it without these settings is not an exact restore. +5. Verify the restored executable hash, listener, `/v1/models`, and one real `/v1/chat/completions` answer with the + captured model id. Record observed status/output without inventing expected wording. A model-list response alone + does not prove answer service restoration. Close the operator window only after restoration or an explicit + operator-directed recovery handoff. + +Undo: restore only the captured incumbent settings and approved staging backup. For authorized recovery-stick +reuse, the parent alone restores and verifies its byte-exact recovery backup; this lane never writes the stick. +Never delete CORE.EFI, boot ALLEN.EFI/Boot0000, or change BootOrder/Secure Boot. Removing a newly created boot +entry or staged file is a distinct write requiring Drake's approval; preserve before/after receipts. + ## 8. Known unknowns (carried from #302) -- UNKNOWN whether the GB10 or the HDA0 audio device attempts DMA while no OS drives them, after SMMUv3 B is left - enabled with every stream aborting until the next reset. An abort there is recorded as an event, not acted on. - Checked 2026-10-12 against the code; corrected 2026-10-28 at main `659ddd2d`: the unconfine path - (`ck_dma_unconfine`, `native/kernel/core/smmu_svc.c`) reads no events at all. Only `ck_dma_faults` drains the event - queues, and only the NVMe and virtio-net negative tests call it; the probe never does. So a later GB10 or HDA0 abort - would NOT appear on screen in this window, and a probe summary is not a fault or visibility measurement. It is not - answered by the Spark user guide either (DOCS SILENT); the window records only what the screen shows. Answering it - needs a later probe build that reads and prints the event queue before the final report (a P07 item), not a change - to this one. +- UNKNOWN whether GB10 or HDA0 attempts DMA while no OS drives it. `CK_B7B_EVENT_READOUT=1` prints every event + consumed by `ck_dma_faults` during stages and a final bounded drain of **every already-live** SMMU instance, + regardless of SID. It does not enable unused SMMUs just to read them. Each record includes instance/base, + SID, architectural type/name, word-2 address and all four raw words. Unknown types remain UNKNOWN with raw data. + Each final queue summary reports overflow and whether records remain pending; an inactive instance says + `not-live`, not "zero faults". Overflow/pending means incomplete observations. No-event output is not evidence + that a device tried DMA, that a GPU path is confined, or that cache visibility is correct. +- This readout consumes/acknowledges events and is probe-only. It runs before the final report, **not continuously + during the framebuffer hold**. Events arriving later can be missed. The architectural abort policy can suppress + event reporting for some traffic; absence of a record must never be promoted to absence of traffic. +- Every accepted RMR range is printed separately when installed. The permitted set is the explicit window UNION + those ranges while the stream translates; after release its STE aborts. An RMR address is not a valid + "out-of-window must fault" negative target. An address in word 2 is interpreted as an input address only for + address-bearing translation/access/permission classes; retain raw words for other classes. - UNVERIFIED that the Spark's real IORT routes segment 15 rid 0x100 to instance 1; this is the expectation from decoded tables (`GB10_IORT_DECODE.md` sections 3 and 9), and the first thing the window tests. - UNVERIFIED hold time and reset behavior of the probe image on the real console. @@ -164,7 +247,56 @@ with limits; a physical PASS is claimed only for what was seen. ## 10. Statement of non-execution -This page prepares a boot. It is not an authorization. No command in sections 3 or 5 has been run for this campaign -beyond the host-side QEMU gates already recorded in PR #302 and the read-only dry run of the staging script on -2026-10-12 (it printed its commands and stopped; nothing was built into the ESP, no boot entry was created, `BootNext` -stayed unset), and nothing in it will run on the Spark until Drake has opened an attended window and said "go" in it. +This page is preparation, not authorization. October 28 receipts under +`/home/drakestapleton/handoffs/spark-five-20261028/QualSmmu/` record host/QEMU runs and candidate-only builds. +The full fixture-provisioned artifact is NOT boot-admissible. Physical boot, actual GB10/HDA0 fault observation, +GPU traffic/visibility and combined USB/network input witnesses are NOT_RUN. No ESP, USB or boot-entry writes, +model stop, firmware operation or GPU effect is authorized or performed by this lane. + +## 11. First GPU-traffic confinement experiment (DESIGNED, not implemented or authorized) + +The no-DMA B7B probe is not this experiment. QEMU's NVMe DMA oracle proves SMMU event plumbing only, not GB10 +stream routing, GPU execution, GPU GMMU behavior, cache visibility, or fault recovery. + +Required native capability from path 2: a composed **native Aienux** GPU submission endpoint, bound to kernel-owned +typed DMA-window/MMIO/IRQ capabilities, that (a) maps a supplied IOVA into GPU VA, (b) issues a bounded GPU-initiated +store, (c) performs the target-correct engine/system visibility operation and writes a GPU-uncached completion, +and (d) proves global device quiescence before bus-master revoke/SMMU release. GPU fault/status collection must +distinguish a GPU GMMU rejection from an SMMU rejection. There is no such endpoint in `omega-gpu-driver` +`b1c8e6ea76da81dc47b57670304bf256b0ba9818`: `build.sh` emits Linux/VFIO `w0`/`fwprep`, not a native kernel +artifact; `gsp/dispatch.om` refuses hardware sequencer effects; `chan/dma.om` owns VFIO mappings, not native SMMU +authority. Path 2's draft [omega-gpu-driver#6](https://github.com/aien-dev/omega-gpu-driver/pull/6), +`95383da4789556c9ca09befb9c6ab788e4e25d79`, `GB20B.md` ("Composed launcher and native effect seam"), +explicitly leaves native submit/fence/completion/quiesce absent. Its GB20B SEC2/BOOT/RPC host implementation alone +does not supply this capability. A native adapter and composed submit artifact are missing prerequisites, not +permission to substitute a CPU store or Linux/VFIO. + +Proposed sequence, only after that native endpoint is implemented and independently exercised: + +1. With the exact chip profile, firmware provenance, cold/warm state, operator window and recovery admitted, + allocate one native DMA arena W containing all GPU-accessible queue descriptors, GPU page tables, command bytes, + payload and a GPU-uncached completion. Record the complete interval and every accepted IORT RMR exception. + Confine the IORT-routed GPU SID on its actual SMMU to W UNION RMR; all other streams stay abort. Do not claim + "one page" if the submitted command's own dependencies require more. No global/bypass mapping. +2. Allocate a CPU-visible canary page C outside W and outside **every** accepted RMR; prove interval disjointness + with checked interval operations and log actual addresses. Initialize input/output/completion/canary on CPU, + perform the native publication boundary, and drain all older events as a separately labelled baseline. +3. Positive: submit a GPU command storing a unique recorded value inside W. After the specified system visibility + boundary, observe the uncached completion and exact CPU-visible payload; collect all SMMU/GPU faults. Require + the expected bytes and no new target-SID fault. CPU writes and simulator stores cannot satisfy this condition. +4. Negative: map a GPU VA to the **ungranted IOVA C** in the GPU's own GMMU (GPU page tables stay inside W), then + request a GPU-initiated write there. If native GPU mapping authority refuses that mapping, record its refusal: + that is NOT an exercised SMMU fault. Otherwise require an SMMU F_TRANSLATION for the actual GPU SID and C, + intact CPU canary, and the documented device fault/recovery state. An unrelated SID/event is not acceptance. + Never require completion from an operation whose DMA was deliberately aborted; use bounded fault observation. +5. If fault containment/global idle is uncertain, quarantine all backing and STOP; do not free/reuse pages or + retry. After verified device quiescence, revoke bus mastering, install abort and invalidate, checking the return + code. On failed release retain the confinement slot/backing (base fix `832bcbd9`), never pretend release succeeded. +6. Recovery inside W is a distinct accepted submission after the documented target-specific reset/recovery path, + requiring fresh data, completion and event observations. Reset/recovery itself needs separate exact approval; + this document does not authorize one. Report transfer, visibility, confinement and recovery separately. + +Visibility authority: NVIDIA open 580.173.02 `nvos.h`, `NVOS32_ATTR2_GPU_CACHEABLE_YES`, says system-memory GPU +caching "will not be coherent with direct CPU mappings". Unified physical RAM does not remove the engine/cache +fence requirement. DOCS SILENT here on an admitted native GB20B engine fence/quiesce endpoint; path 2 must implement +and qualify it before step 3. Current physical GPU traffic, completion visibility and SMMU negative control: NOT_RUN. diff --git a/native/.crumb b/native/.crumb index 9894c75d..573dab91 100644 --- a/native/.crumb +++ b/native/.crumb @@ -79,8 +79,8 @@ "purpose": "Directory native/disk. Purpose not yet described by a human." }, { - "digest": "d309a454c2bf3d88668768219b1411a2a6ed19ef917dc0204f42f28dc49d8f0b", - "last_commit": "c01180eb", + "digest": "bb06d8754682e7e2387983efa0195ac12eaa40221a8524c4b56512e8c8c8d086", + "last_commit": "ec3043bc", "name": "kernel", "purpose": "Directory native/kernel. Purpose not yet described by a human." }, @@ -98,7 +98,7 @@ }, { "digest": "f3c7ee4f18f768fa9964c123e07f076c544c58c0966a8a5e9571b0397bf57b06", - "last_commit": "9d8cbeb4", + "last_commit": "", "name": "omega", "purpose": "Seeded Omega native modules" }, @@ -115,15 +115,15 @@ "purpose": "Directory native/store. Purpose not yet described by a human." } ], - "children_root": "sha256:a5430bc57246e68114cd4f646fb74922773408c792cfb900e17cebe21687ba12", - "compiled_at": "2026-10-30T04:38:58Z", + "children_root": "sha256:a95d5b4c3c2905b6547b18881f53d652d25cda8c204b1076f912820121d4cacd", + "compiled_at": "2026-10-30T05:07:55Z", "compiler": "crumb-compile/1", - "digest": "sha256:1b716d22758667b3d122dc64823eb251a8561f9cee50fa8dca357d0e384b548d", + "digest": "sha256:f271b24cfa01e1f5714b6466e64eaff7e9bacfd2a642d1af2eadd143db96ebf7", "evidence_files": 24, "evidence_root": "sha256:ecc7ccf2e924c221a5bac1d91e23b13d8f3c8d78c2a893a882ed7ca5e88d855d", "files": 657, - "generated_at_commit": "6dd64a0c588ba28904dd7efc7ed1a1655459005e", - "source_tree": "sha256:16d3440f3390586c8904b87076004f16f4fcb861d69db9409b1b4ecf4955b780" + "generated_at_commit": "ec3043bc977dc9577ef7765fb57f19956a148a77", + "source_tree": "sha256:d332f7ea64e09b3921ccae1a08ce404bd614438ce151a7b3ca410ceb81b3100c" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/.crumb b/native/kernel/.crumb index 02ae63e0..5b8cab61 100644 --- a/native/kernel/.crumb +++ b/native/kernel/.crumb @@ -57,14 +57,14 @@ "purpose": "Directory native/kernel/artifact. Purpose not yet described by a human." }, { - "digest": "260dd9252422aaa6f636c8665c2b403126dc7a48e8177968be612420fd278add", - "last_commit": "f45d00ad", + "digest": "e6a371afcab6664b74ed49199722a013c18d962fc48b5907eeb18e14b3c35ba1", + "last_commit": "7d555ade", "name": "core", "purpose": "Directory native/kernel/core. Purpose not yet described by a human." }, { "digest": "41794b17b28a7290757288202b665a2d71f09a041f05058a13e55a080710ae18", - "last_commit": "c01180eb", + "last_commit": "832bcbd9", "name": "dev", "purpose": "Directory native/kernel/dev. Purpose not yet described by a human." }, @@ -87,27 +87,27 @@ "purpose": "Directory native/kernel/svc. Purpose not yet described by a human." }, { - "digest": "a8880cfbeb9538ee6fa9784d115339e1af0df7bd58ca2c683e5138548b4104ee", - "last_commit": "89e296db", + "digest": "f0db5439404db6ec096059fd2e3e18a2c8c70e75f78251e499746cad2c457a99", + "last_commit": "7d555ade", "name": "tests", "purpose": "Directory native/kernel/tests. Purpose not yet described by a human." }, { "digest": "7863ced57b54d23a2e3c2aa02ab53468462616b44cf256f71a530a35f6ecb25d", - "last_commit": "89e296db", + "last_commit": "41119ceb", "name": "tools", "purpose": "Hosted (Linux-built) checkers for the native kernel, run by `make -C native/kernel test`; nothin" } ], - "children_root": "sha256:f37c78da6407322f067bbce568b2311e45e37fa5784a8548696c39db6803498b", - "compiled_at": "2026-10-29T21:21:48Z", + "children_root": "sha256:bb228f1b90360a64ddc23c4f19b6342913a9c4124b1e4e80d31773e4848f1477", + "compiled_at": "2026-10-30T02:45:39Z", "compiler": "crumb-compile/1", - "digest": "sha256:d309a454c2bf3d88668768219b1411a2a6ed19ef917dc0204f42f28dc49d8f0b", + "digest": "sha256:bb06d8754682e7e2387983efa0195ac12eaa40221a8524c4b56512e8c8c8d086", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 427, - "generated_at_commit": "eee83193edb719d4a6380e25506b1f7728dc93b2", - "source_tree": "sha256:72da07fb93143aa15a4224376f684748e8ada260c5a8a220b9c5579a87378236" + "generated_at_commit": "7112a008703b16ea79c1ccdbf1afca0c78aa51e2", + "source_tree": "sha256:40d078387cfd4316be975f4f87e9a0c0114143b5103b20b8510be4abcb3f25bb" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/Makefile b/native/kernel/Makefile index 24a0a408..fedb0f2d 100644 --- a/native/kernel/Makefile +++ b/native/kernel/Makefile @@ -391,6 +391,18 @@ SMP_TEST_FLAGS := -DCK_TEST_SMP_SKIP_CPU=1 else SMP_TEST_FLAGS := endif +CK_B7B_PROBE ?= +CK_B7B_EVENT_READOUT ?= +ifneq ($(strip $(CK_B7B_EVENT_READOUT)),) +ifneq ($(strip $(CK_B7B_EVENT_READOUT)),1) +$(error CK_B7B_EVENT_READOUT must be empty or 1) +endif +ifneq ($(strip $(CK_B7B_PROBE)),1) +$(error CK_B7B_EVENT_READOUT requires CK_B7B_PROBE=1) +endif +OUT ?= $(REPO)/target/native-kernel-b7b-events +SMP_TEST_FLAGS += -DCK_B7B_EVENT_READOUT=1 +endif # B7b preparation probe (aienos#286, core/smmu_svc.c): CK_B7B_PROBE=1 builds an # image that confines PCI segment 15 requester 0x100 (the Spark's GB10) once on # a one-page window, prints the route and SMMU_IDR0/IDR1, and unconfines. Own @@ -399,7 +411,6 @@ endif # (TEST-ONLY, needs CK_B7B_PROBE=1) probes segment 0 for the QEMU positive path # and is refused with CK_HARDWARE_STAGING. Default images are checked to carry # no probe (b7b_check). Gate: scripts/qemu_ck_b7b_probe_test.sh. -CK_B7B_PROBE ?= CK_B7B_PROBE_TEST_SEGMENT0 ?= ifneq ($(strip $(CK_B7B_PROBE_TEST_SEGMENT0)),) ifneq ($(strip $(CK_B7B_PROBE_TEST_SEGMENT0)),1) @@ -1231,6 +1242,11 @@ define b7b_check else \ if grep -aqF "TEST-ONLY B7b probe" $(1); then echo "image carries the TEST-ONLY segment-0 probe"; rm -f $(1); exit 1; fi; \ fi + @if [ "$(strip $(CK_B7B_EVENT_READOUT))" = 1 ]; then \ + grep -aqF "b7b_events: final begin all_sids=yes" $(1) || { echo "B7b image lacks event readout"; rm -f $(1); exit 1; }; \ + else \ + if grep -aqF "b7b_events:" $(1); then echo "image carries unrequested event readout"; rm -f $(1); exit 1; fi; \ + fi endef # crash_check(elf): a full image built without CK_TEST_STORE_CRASH must carry @@ -1466,7 +1482,8 @@ iort-mutants: $(OUT)/host/test_smmu # UNGRANTED_VALID: L1STDs valid before any grant; BAD_L1_PTR: misaligned L1 # table accepted; L2_NO_FILL: a new L2 page published without abort STEs). # Host only (smmu.c refuses them freestanding and with CK_HARDWARE_STAGING). -SMMU_L2_MUTANTS := CK_SMMU_MUTANT_SPAN_OVERFLOW CK_SMMU_MUTANT_UNGRANTED_VALID CK_SMMU_MUTANT_BAD_L1_PTR CK_SMMU_MUTANT_L2_NO_FILL +# Also kills DROP_EVENT: consuming the queue without visiting its records. +SMMU_L2_MUTANTS := CK_SMMU_MUTANT_SPAN_OVERFLOW CK_SMMU_MUTANT_UNGRANTED_VALID CK_SMMU_MUTANT_BAD_L1_PTR CK_SMMU_MUTANT_L2_NO_FILL CK_SMMU_MUTANT_DROP_EVENT smmu-l2-mutants: $(OUT)/host/test_smmu @mkdir -p $(OUT)/host-mut; fail=0; \ $(OUT)/host/test_smmu > $(OUT)/host-mut/smmu-l2-base.log 2>&1 || { echo "unmutated test_smmu fails"; fail=1; }; \ diff --git a/native/kernel/core/.crumb b/native/kernel/core/.crumb index 60fdca99..1ca17647 100644 --- a/native/kernel/core/.crumb +++ b/native/kernel/core/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-24T04:15:32Z", + "compiled_at": "2026-10-28T23:15:29Z", "compiler": "crumb-compile/1", - "digest": "sha256:260dd9252422aaa6f636c8665c2b403126dc7a48e8177968be612420fd278add", + "digest": "sha256:e6a371afcab6664b74ed49199722a013c18d962fc48b5907eeb18e14b3c35ba1", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 69, - "generated_at_commit": "621c9e6fe430ee689836bee3ee2689d7d32e0f7d", - "source_tree": "sha256:42c98f3543cbb0ed8bbb342c611c55afea087105bf873a9fb8ffb911a691ce7c" + "generated_at_commit": "832bcbd98fc59a6f7695aefa68223caa7e08df05", + "source_tree": "sha256:52f48edd6dbf5d3067f4db592b035ae0563de8518893343b3e6763083eb28317" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/core/ck_internal.h b/native/kernel/core/ck_internal.h index b2eaa735..1e8df249 100644 --- a/native/kernel/core/ck_internal.h +++ b/native/kernel/core/ck_internal.h @@ -143,6 +143,9 @@ void ck_smp_run(void); #ifdef CK_B7B_PROBE /* Cut B7b preparation probe (core/smmu_svc.c), probe build only. */ void ck_b7b_probe(void); +#ifdef CK_B7B_EVENT_READOUT +void ck_b7b_event_readout(void); +#endif #endif void ck_fpu_run(void); /* core/fpu.c: probe build only (CK_RUST_LIBS), else a no-op */ void ck_infer_run(void); /* core/infer.c: probe build only (CK_INFER_LIB), else a no-op */ diff --git a/native/kernel/core/kmain.c b/native/kernel/core/kmain.c index 6b7dbf2b..8b9b01eb 100644 --- a/native/kernel/core/kmain.c +++ b/native/kernel/core/kmain.c @@ -340,6 +340,9 @@ static __attribute__((noreturn)) void ck_el1_main(void *arg) ck_printf("stage lifecycle: %s rc=%d\n", lrc == 0 ? "ok" : "FAIL", lrc); } +#ifdef CK_B7B_EVENT_READOUT + ck_b7b_event_readout(); +#endif ck_set_stage("final"); ck_puts("\n"); ck_report_header("final"); diff --git a/native/kernel/core/smmu.c b/native/kernel/core/smmu.c index ace1b9aa..25b61348 100644 --- a/native/kernel/core/smmu.c +++ b/native/kernel/core/smmu.c @@ -20,7 +20,8 @@ /* TEST-only two-level stream table mutants (make smmu-l2-mutants): each * must make test_smmu FAIL. Host builds only; never part of an image. */ #if defined(CK_SMMU_MUTANT_SPAN_OVERFLOW) || defined(CK_SMMU_MUTANT_UNGRANTED_VALID) || \ - defined(CK_SMMU_MUTANT_BAD_L1_PTR) || defined(CK_SMMU_MUTANT_L2_NO_FILL) + defined(CK_SMMU_MUTANT_BAD_L1_PTR) || defined(CK_SMMU_MUTANT_L2_NO_FILL) || \ + defined(CK_SMMU_MUTANT_DROP_EVENT) #if !__STDC_HOSTED__ #error "CK_SMMU_MUTANT_* are host test mutants only" #endif @@ -469,3 +470,54 @@ int ck_smmu_read_events(const struct ck_smmu_regs *r, const struct ck_smmu_table *overflowed = ovf != (cons_raw & EVENTQ_OVERFLOW); return count; } + +const char *ck_smmu_event_name(uint8_t type) +{ + /* Arm IHI 0070 event IDs; unknown events keep their raw payload. */ + switch (type) { + case 0x02: return "C_BAD_STREAMID"; + case 0x03: return "F_STE_FETCH"; + case 0x04: return "C_BAD_STE"; + case 0x06: return "F_STREAM_DISABLED"; + case 0x08: return "C_BAD_SUBSTREAMID"; + case 0x09: return "F_CD_FETCH"; + case 0x0a: return "C_BAD_CD"; + case 0x10: return "F_TRANSLATION"; + case 0x11: return "F_ADDR_SIZE"; + case 0x12: return "F_ACCESS"; + case 0x13: return "F_PERMISSION"; + case 0x25: return "F_VMS_FETCH"; + default: return "UNKNOWN"; + } +} + +struct ck_smmu_observation ck_smmu_observe_events( + const struct ck_smmu_regs *r, const struct ck_smmu_tables *t, + void (*visit)(void *ctx, const struct ck_smmu_event *e), void *ctx) +{ + struct ck_smmu_observation result = {0, 0, 0}; +#ifdef CK_SMMU_MUTANT_DROP_EVENT + (void)visit; + (void)ctx; +#endif + while (result.events < t->evt_n) { + struct ck_smmu_event events[4]; + uint32_t remaining = t->evt_n - result.events; + int overflow = 0; + int n = ck_smmu_read_events(r, t, events, remaining < 4 ? (int)remaining : 4, + &overflow); + result.overflow |= overflow; + for (int i = 0; i < n; i++) { +#ifndef CK_SMMU_MUTANT_DROP_EVENT + visit(ctx, &events[i]); +#endif + } + result.events += (uint32_t)n; + if (n < 4) + break; + } + struct qc prod = q_decode(rd(r, CK_SMMU_EVENTQ_PROD), t->evt_n); + struct qc cons = q_decode(rd(r, CK_SMMU_EVENTQ_CONS), t->evt_n); + result.pending = prod.index != cons.index || prod.wrap != cons.wrap; + return result; +} diff --git a/native/kernel/core/smmu.h b/native/kernel/core/smmu.h index d285c699..f0637820 100644 --- a/native/kernel/core/smmu.h +++ b/native/kernel/core/smmu.h @@ -200,4 +200,16 @@ int ck_smmu_abort_ste(const struct ck_smmu_regs *r, const struct ck_smmu_tables * Returns the number of records written to out. */ int ck_smmu_read_events(const struct ck_smmu_regs *r, const struct ck_smmu_tables *t, struct ck_smmu_event *out, int n, int *overflowed); + +/* Probe observer: visit every SID, at most one queue capacity per call. + * A busy producer cannot keep the final report from running. pending marks an + * incomplete drain; overflow marks loss even if no records remain. */ +struct ck_smmu_observation { + uint32_t events; + int overflow, pending; +}; +struct ck_smmu_observation ck_smmu_observe_events( + const struct ck_smmu_regs *r, const struct ck_smmu_tables *t, + void (*visit)(void *ctx, const struct ck_smmu_event *e), void *ctx); +const char *ck_smmu_event_name(uint8_t type); #endif diff --git a/native/kernel/core/smmu_svc.c b/native/kernel/core/smmu_svc.c index 8f9b1ecc..0b0a1f38 100644 --- a/native/kernel/core/smmu_svc.c +++ b/native/kernel/core/smmu_svc.c @@ -260,6 +260,11 @@ static int map_reserved(struct ck_pt *pt, const struct ck_iort_route *rt, uint32 (unsigned long long)r->range[k].base, (unsigned long long)r->range[k].len); return -1; } +#ifdef CK_B7B_EVENT_READOUT + ck_printf("b7b_rmr: sid=0x%x base=0x%llx len=0x%llx flags=0x%x identity=yes\n", + sid, (unsigned long long)r->range[k].base, + (unsigned long long)r->range[k].len, r->flags); +#endif (*n)++; } } @@ -350,6 +355,36 @@ int ck_dma_unconfine(uint32_t stream_id) return 0; } +#ifdef CK_B7B_EVENT_READOUT +static void b7b_event(void *ctx, const struct ck_smmu_event *e) +{ + const struct inst *in = ctx; + ck_printf("b7b_event: instance=%u base=0x%llx sid=0x%x type=0x%02x name=%s addr=0x%llx " + "raw=%016llx,%016llx,%016llx,%016llx\n", + in->index, (unsigned long long)in->base, e->sid, e->type, + ck_smmu_event_name(e->type), (unsigned long long)e->addr, + (unsigned long long)e->raw[0], (unsigned long long)e->raw[1], + (unsigned long long)e->raw[2], (unsigned long long)e->raw[3]); +} + +void ck_b7b_event_readout(void) +{ + ck_puts("b7b_events: final begin all_sids=yes\n"); + for (uint32_t k = 0; k < CK_IORT_MAX_SMMUS; k++) { + struct inst *in = &g.inst[k]; + if (in->state != 1) { + ck_printf("b7b_events: instance=%u state=%s\n", k, + in->state == CK_SMMU_FAILED ? "failed" : "not-live"); + continue; + } + struct ck_smmu_observation o = ck_smmu_observe_events(&in->regs, &in->t, b7b_event, in); + ck_printf("b7b_events: instance=%u base=0x%llx events=%u overflow=%d pending=%d\n", + k, (unsigned long long)in->base, o.events, o.overflow, o.pending); + } + ck_puts("b7b_events: final end\n"); +} +#endif + int ck_dma_faults(uint32_t stream_id, struct ck_dma_fault *first) { int matched = 0, ovf = 0, any = 0; @@ -364,7 +399,16 @@ int ck_dma_faults(uint32_t stream_id, struct ck_dma_fault *first) int o = 0; n = ck_smmu_read_events(&in->regs, &in->t, ev, 4, &o); ovf |= o; +#ifdef CK_B7B_EVENT_READOUT + if (o) + ck_printf("b7b_events: instance=%u source=dma_faults overflow=1\n", k); +#endif for (int i = 0; i < n; i++) { +#ifdef CK_B7B_EVENT_READOUT + /* Report before filtering: other SIDs must not disappear when + * a device's negative test consumes the shared event queue. */ + b7b_event(in, &ev[i]); +#endif if (ev[i].sid != stream_id) continue; if (!matched && first) { diff --git a/native/kernel/tests/.crumb b/native/kernel/tests/.crumb index 862399f9..819c3c78 100644 --- a/native/kernel/tests/.crumb +++ b/native/kernel/tests/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-27T01:40:10Z", + "compiled_at": "2026-10-30T02:45:39Z", "compiler": "crumb-compile/1", - "digest": "sha256:a8880cfbeb9538ee6fa9784d115339e1af0df7bd58ca2c683e5138548b4104ee", + "digest": "sha256:f0db5439404db6ec096059fd2e3e18a2c8c70e75f78251e499746cad2c457a99", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 190, - "generated_at_commit": "42d0fc5e842480e817996f6b8a2de68d15521dee", - "source_tree": "sha256:06a335db8eccf60bdadbc13fda6bfd4cc5b660cbaee22d8e7d887447865a978a" + "generated_at_commit": "7112a008703b16ea79c1ccdbf1afca0c78aa51e2", + "source_tree": "sha256:706c09bf54137adb3906d64c5d12fc00a978904e74cc93d876388258e6e9a838" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/tests/test_smmu.c b/native/kernel/tests/test_smmu.c index c437f898..6ad04bcf 100644 --- a/native/kernel/tests/test_smmu.c +++ b/native/kernel/tests/test_smmu.c @@ -327,6 +327,53 @@ static void test_events(void) CHECK(ck_smmu_read_events(&R, &T, ev, 4, &ovf) == 1 && ovf == 0); } +struct observed_events { + struct ck_smmu_event events[16]; + unsigned count; + int inject; +}; + +static void observe_event(void *ctx, const struct ck_smmu_event *e) +{ + struct observed_events *seen = ctx; + CHECK(seen->count < 16); + if (seen->count < 16) + seen->events[seen->count++] = *e; + if (seen->inject && seen->count == 16) + M.evtq_prod = 17u | (1u << 31); +} + +static void test_event_observer(void) +{ + reset(); + CHECK(ck_smmu_enable(&R, &T, 100) == 0); + struct observed_events seen = {0}; + struct ck_smmu_observation o = ck_smmu_observe_events(&R, &T, observe_event, &seen); + CHECK(!o.events && !o.overflow && !o.pending && !seen.count); + for (unsigned i = 0; i < 16; i++) { + mem.evt[i * 4] = ((uint64_t)(0x100 + i) << 32) | (i ? 0x06 : 0x10); + mem.evt[i * 4 + 1] = 0x1234 + i; + mem.evt[i * 4 + 2] = 0x8000 + i * 0x1000; + mem.evt[i * 4 + 3] = 0xabcd + i; + } + M.evtq_prod = 16u | (1u << 31); /* full queue, reported loss */ + seen.inject = 1; /* producer keeps going: observer must remain bounded */ + o = ck_smmu_observe_events(&R, &T, observe_event, &seen); + CHECK(o.events == 16 && o.overflow && o.pending && seen.count == 16); + for (unsigned i = 0; i < seen.count; i++) { + CHECK(seen.events[i].sid == 0x100 + i); + CHECK(seen.events[i].raw[1] == 0x1234 + i && seen.events[i].raw[3] == 0xabcd + i); + CHECK(seen.events[i].addr == 0x8000 + i * 0x1000); + } + seen.count = 0; + seen.inject = 0; + o = ck_smmu_observe_events(&R, &T, observe_event, &seen); + CHECK(o.events == 1 && !o.overflow && !o.pending && seen.count == 1); + CHECK(strcmp(ck_smmu_event_name(0x10), "F_TRANSLATION") == 0); + CHECK(strcmp(ck_smmu_event_name(0x06), "F_STREAM_DISABLED") == 0); + CHECK(strcmp(ck_smmu_event_name(0xff), "UNKNOWN") == 0); +} + /* ---- IORT -------------------------------------------------------------- */ static void w16(uint8_t *p, uint16_t v) { memcpy(p, &v, 2); } static void w32(uint8_t *p, uint32_t v) { memcpy(p, &v, 4); } @@ -759,6 +806,7 @@ int main(void) test_install_abort(); test_queue_wrap(); test_events(); + test_event_observer(); test_iort(); test_iort_spark_shape(); test_iort_cap_overlap(); diff --git a/scripts/.crumb b/scripts/.crumb index 0c8460ff..c032e318 100644 --- a/scripts/.crumb +++ b/scripts/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-27T01:40:10Z", + "compiled_at": "2026-10-30T02:45:39Z", "compiler": "crumb-compile/1", - "digest": "sha256:3ff6ec04ad2ae8ef9bc36a536cdf659cdfe5ea0960c3a21eb61ce6e9e16adfa4", + "digest": "sha256:dfb7d7427df2bc70e6ed6342169ba6db6223965edca01370f25b107484141de5", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 124, - "generated_at_commit": "42d0fc5e842480e817996f6b8a2de68d15521dee", - "source_tree": "sha256:f123b7e91d998130fe06f9289e33cabc0bcb9d614316867890f7d8943b434385" + "generated_at_commit": "7112a008703b16ea79c1ccdbf1afca0c78aa51e2", + "source_tree": "sha256:02314ce1c1fb2e54ca973a87a985b007945b45f4b4a8974fef0145244b43f3f9" }, "owner_lane": "", "provenance": { diff --git a/scripts/native_boot_preflight.sh b/scripts/native_boot_preflight.sh index fcfdb74a..d7d6810f 100755 --- a/scripts/native_boot_preflight.sh +++ b/scripts/native_boot_preflight.sh @@ -39,7 +39,9 @@ set -uo pipefail repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" default_entry="0001" -recov_entry="0004" +# The recovery entry is identified by its partition GUID, never by its number: the same stick +# was Boot0004 on 2026-09-25 and is Boot0002 on 2026-10-28 (docs/campaigns/B7B-PHYSICAL-BOOT-PREP.md). +recov_partuuid="${AIENOS_RECOVERY_PARTUUID:-f227357c-1e80-4fd0-a55e-2efbef1dd25c}" recov_label="AIENOSRECOV" sb_default="/sys/firmware/efi/efivars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c" @@ -57,10 +59,10 @@ preflight() { order="$(sed -n 's/^BootOrder: //p' <<<"${boot}")" next="$(sed -n 's/^BootNext: //p' <<<"${boot}")" current="$(sed -n 's/^BootCurrent: //p' <<<"${boot}")" - recov="$(grep -E "^Boot${recov_entry}\*? " <<<"${boot}" || true)" + recov="$(grep -iE "^Boot[0-9A-F]{4}\*? .*GPT,${recov_partuuid}," <<<"${boot}" || true)" echo "INFO BootCurrent=${current:-?} BootOrder=${order:-?}" - [[ "${recov}" == *"${recov_label}"* ]] && ok "recovery stick: Boot${recov_entry} ${recov_label} listed" \ - || stop "recovery stick: Boot${recov_entry} ${recov_label} not listed (got '${recov:-none}'); plug it in, see docs/RECOVERY_MEDIA_MACHINE1.md" + [[ "${recov}" == *"${recov_label}"* && $(grep -c . <<<"${recov}") == 1 ]] && ok "recovery stick: ${recov%%\**} ${recov_label} PARTUUID ${recov_partuuid} listed" \ + || stop "recovery stick: exactly one ${recov_label} entry with PARTUUID ${recov_partuuid} not listed (got '${recov:-none}'); see docs/RECOVERY_MEDIA_MACHINE1.md" [[ "${order%%,*}" == "${default_entry}" ]] && ok "BootOrder starts with ${default_entry} (Linux, the permanent default)" \ || stop "BootOrder does not start with ${default_entry} (got '${order:-none}')" [[ -z "${next}" ]] && ok "BootNext is not set (no other one-time boot pending)" \ @@ -103,7 +105,7 @@ preflight() { if [[ "${1:-}" == --self-test ]]; then st=0; t="$(mktemp -d)"; trap 'rm -rf "${t}"' EXIT - good=$'BootCurrent: 0001\nTimeout: 5 seconds\nBootOrder: 0001,0003\nBoot0001* ubuntu\nBoot0003* UEFI PXE\nBoot0004* AIENOSRECOV' + good=$'BootCurrent: 0001\nTimeout: 5 seconds\nBootOrder: 0001,0003\nBoot0001* ubuntu\nBoot0003* UEFI PXE\nBoot0002* AIENOSRECOV\tHD(1,GPT,f227357c-1e80-4fd0-a55e-2efbef1dd25c,0x800,0x1df000)/File(\\EFI\\BOOT\\BOOTAA64.EFI)' printf '\0\0\0\0\0' >"${t}/sb_off"; printf '\0\0\0\0\1' >"${t}/sb_on" esp="/" # any mounted path stands in for the ESP in the self-test printf 'img' >"${t}/img"; dig="$(sha256sum "${t}/img" | cut -c1-64)" @@ -113,7 +115,9 @@ if [[ "${1:-}" == --self-test ]]; then } case_ "good state is READY" 0 "${good}" "${t}/sb_off" "${t}/noflag" "" "${t}/img" "${dig}" case_ "BootNext pending -> NOT_READY" 1 "${good}"$'\nBootNext: 0000' "${t}/sb_off" "${t}/noflag" "" "" "" - case_ "recovery stick absent -> NOT_READY" 1 "${good/Boot0004\* AIENOSRECOV/}" "${t}/sb_off" "${t}/noflag" "" "" "" + case_ "recovery stick absent -> NOT_READY" 1 "${good/Boot0002\* AIENOSRECOV/}" "${t}/sb_off" "${t}/noflag" "" "" "" + case_ "AIENOSRECOV label on another PARTUUID -> NOT_READY" 1 "${good/f227357c/0badc0de}" "${t}/sb_off" "${t}/noflag" "" "" "" + case_ "recovery entry renumbered (Boot0004) is still READY" 0 "${good/Boot0002/Boot0004}" "${t}/sb_off" "${t}/noflag" "" "${t}/img" "${dig}" case_ "BootOrder not Linux first -> NOT_READY" 1 "${good/BootOrder: 0001,0003/BootOrder: 0000,0001}" "${t}/sb_off" "${t}/noflag" "" "" "" case_ "booted from another entry -> NOT_READY" 1 "${good/BootCurrent: 0001/BootCurrent: 0004}" "${t}/sb_off" "${t}/noflag" "" "" "" case_ "Secure Boot on -> NOT_READY" 1 "${good}" "${t}/sb_on" "${t}/noflag" "" "" "" diff --git a/scripts/qemu_ck_b7b_probe_test.sh b/scripts/qemu_ck_b7b_probe_test.sh index 22fa0bc4..2b790d94 100755 --- a/scripts/qemu_ck_b7b_probe_test.sh +++ b/scripts/qemu_ck_b7b_probe_test.sh @@ -33,6 +33,10 @@ # SIDSIZE that covers stream 0x100, the unconfine returns 0 and # the summary is CONFINED_AND_RELEASED. # Last line AIENOS_CK_B7B_PROBE_POSITIVE: PASS|FAIL|NOT_RUN. +# --events TEST-ONLY full image plus disposable NVMe/GPT disk. The +# existing negative DMA test must produce a decoded event for +# its exact SID/address, and every live queue is drained before +# the final report. No physical GPU behavior is exercised. # --self-test canned serial logs for every failure mode below plus the # Makefile refusals of the probe flags; no QEMU, no compile. # Last line AIENOS_CK_B7B_PROBE_SELF_TEST: PASS|FAIL. @@ -48,8 +52,9 @@ mode=gate case "${1:-}" in "") ;; --positive) mode=positive ;; + --events) mode=events ;; --self-test) mode=self ;; - *) echo "usage: $0 [--positive|--self-test]" >&2; exit 2 ;; + *) echo "usage: $0 [--positive|--events|--self-test]" >&2; exit 2 ;; esac test_marker="TEST-ONLY B7b probe on PCI segment 0" @@ -106,6 +111,33 @@ common_tail() { if grep -qE '^report_kind: panic|^panic:|^exception:' "${f}"; then bad "panic or exception after the probe"; else ok "no panic or exception"; fi } +check_events() { + local f="$1" line sid addr begin end final + check_positive "${f}" + line="$(grep -E '^smmu_negative: refused dma outside window .*faults=[1-9][0-9]* type=0x10 .*page=intact .*recovery_read=ok' "${f}" || true)" + if [[ "${line}" =~ sid=(0x[0-9a-f]+)[[:space:]]addr=(0x[0-9a-f]+) ]]; then + sid="${BASH_REMATCH[1]}"; addr="${BASH_REMATCH[2]}" + grep -qE "^b7b_event: instance=0 base=0x9050000 sid=${sid} type=0x10 name=F_TRANSLATION addr=${addr} raw=[0-9a-f]{16},[0-9a-f]{16},[0-9a-f]{16},[0-9a-f]{16}$" "${f}" \ + && ok "real out-of-window NVMe DMA has matching decoded event" || bad "missing matching SID/address decoded event" + else + bad "no successful negative DMA oracle" + fi + begin="$(grep -n '^b7b_events: final begin all_sids=yes$' "${f}" | cut -d: -f1)" + end="$(grep -n '^b7b_events: final end$' "${f}" | cut -d: -f1)" + final="$(grep -n '^report_kind: final$' "${f}" | cut -d: -f1)" + if [[ "${begin}" =~ ^[0-9]+$ && "${end}" =~ ^[0-9]+$ && "${final}" =~ ^[0-9]+$ ]] \ + && (( begin < end && end < final )); then + ok "one final queue readout before final report" + else + bad "final readout missing, duplicated or out of order" + fi + grep -qE '^b7b_events: instance=0 base=0x9050000 events=[0-9]+ overflow=0 pending=0$' "${f}" \ + && ok "live queue drained without loss" || bad "no live queue completion" + if grep -qE '^b7b_events: .*overflow=1|^b7b_events: .*pending=1' "${f}"; then + bad "queue loss or incomplete readout" + fi +} + self_test() { local tmp st_fail=0 tmp="$(mktemp -d)" @@ -162,6 +194,21 @@ LOG grep -v 'idr0=' "${tmp}/positive" >"${tmp}/p4"; expect no-idr-line fail check_positive "${tmp}/p4" sed 's/len=0x1000/len=0x2000/' "${tmp}/positive" >"${tmp}/p5"; expect wrong-window fail check_positive "${tmp}/p5" sed 's/CONFINED_AND_RELEASED/FAIL/' "${tmp}/positive" >"${tmp}/p6"; expect positive-summary-fail fail check_positive "${tmp}/p6" + grep -v '^report_kind: final$' "${tmp}/positive" >"${tmp}/events" + cat >>"${tmp}/events" <<'LOG' +b7b_event: instance=0 base=0x9050000 sid=0x108 type=0x10 name=F_TRANSLATION addr=0x12345000 raw=0000010800000010,0000000000000000,0000000012345000,0000000000000000 +smmu_negative: refused dma outside window iova=0x12345000 faults=1 type=0x10 sid=0x108 addr=0x12345000 page=intact cmd_rc=-1 recovery_read=ok +b7b_events: final begin all_sids=yes +b7b_events: instance=0 base=0x9050000 events=0 overflow=0 pending=0 +b7b_events: final end +report_kind: final +LOG + expect events-good pass check_events "${tmp}/events" + grep -v '^b7b_event:' "${tmp}/events" >"${tmp}/e1"; expect events-no-readout fail check_events "${tmp}/e1" + sed '/^b7b_event:/s/sid=0x108/sid=0x109/' "${tmp}/events" >"${tmp}/e2"; expect events-wrong-sid fail check_events "${tmp}/e2" + sed '/^b7b_event:/s/addr=0x12345000/addr=0x12346000/' "${tmp}/events" >"${tmp}/e3"; expect events-wrong-address fail check_events "${tmp}/e3" + sed 's/overflow=0/overflow=1/' "${tmp}/events" >"${tmp}/e4"; expect events-overflow fail check_events "${tmp}/e4" + sed 's/pending=0/pending=1/' "${tmp}/events" >"${tmp}/e5"; expect events-pending fail check_events "${tmp}/e5" # Makefile refusals: parse-time $(error), nothing is compiled (make -n). refuse() { # NAME MESSAGE MAKE-ARGS... @@ -178,6 +225,8 @@ LOG refuse seg0-with-staging "CK_B7B_PROBE_TEST_SEGMENT0 (TEST-only QEMU positive path) cannot be combined with CK_HARDWARE_STAGING" \ CK_B7B_PROBE=1 CK_B7B_PROBE_TEST_SEGMENT0=1 CK_HARDWARE_STAGING=1 refuse probe-with-unsafe-dma "CK_B7B_PROBE cannot be combined with CK_QEMU_UNSAFE_DMA" CK_B7B_PROBE=1 CK_QEMU_UNSAFE_DMA=1 + refuse events-without-probe "CK_B7B_EVENT_READOUT requires CK_B7B_PROBE=1" CK_B7B_EVENT_READOUT=1 + refuse events-bad-value "CK_B7B_EVENT_READOUT must be empty or 1" CK_B7B_PROBE=1 CK_B7B_EVENT_READOUT=2 if grep -qE '^#if defined\(CK_B7B_PROBE_TEST_SEGMENT0\) && defined\(CK_HARDWARE_STAGING\)$' native/kernel/core/smmu_svc.c; then echo "PASS self-test core/smmu_svc.c also refuses the segment-0 probe in a hardware staging compile" else @@ -195,6 +244,7 @@ fi # --------------------------------------------------------------- QEMU boot verdict_name=AIENOS_CK_B7B_PROBE [[ "${mode}" == positive ]] && verdict_name=AIENOS_CK_B7B_PROBE_POSITIVE +[[ "${mode}" == events ]] && verdict_name=AIENOS_CK_B7B_EVENTS code_fd="${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}" vars_fd="${AAVMF_VARS:-/usr/share/AAVMF/AAVMF_VARS.fd}" @@ -204,7 +254,11 @@ command -v qemu-system-aarch64 >/dev/null || { echo "qemu-system-aarch64 not ins cross="" if [ "$(uname -m)" != "aarch64" ]; then cross="aarch64-linux-gnu-"; fi commit="$(git rev-parse HEAD 2>/dev/null || echo unknown)" -if [[ "${mode}" == positive ]]; then +if [[ "${mode}" == events ]]; then + out="${repo_root}/target/native-kernel-test-b7b-events" + make -s -C native/kernel full gpt-image CROSS="${cross}" OUT="${out}" AIENOS_COMMIT="${commit}" \ + CK_B7B_PROBE=1 CK_B7B_PROBE_TEST_SEGMENT0=1 CK_B7B_EVENT_READOUT=1 >/dev/null +elif [[ "${mode}" == positive ]]; then out="${repo_root}/target/native-kernel-test-b7b-seg0" make -s -C native/kernel CROSS="${cross}" OUT="${out}" AIENOS_COMMIT="${commit}" CK_B7B_PROBE=1 CK_B7B_PROBE_TEST_SEGMENT0=1 >/dev/null else @@ -227,7 +281,14 @@ cleanup() { trap cleanup EXIT mkdir -p "${work}/esp/EFI/BOOT" "${work}/esp/EFI/AIENOS" touch "${work}/esp/EFI/AIENOS/BOOTREPORT.TXT" -cp "${out}/BOOTAA64.EFI" "${work}/esp/EFI/BOOT/BOOTAA64.EFI" +extra_devices=() +image="${out}/BOOTAA64.EFI" +if [[ "${mode}" == events ]]; then + image="${out}/full/BOOTAA64.EFI" + "${out}/host/ck_gpt_image" create "${work}/nvme.img" 512 64 aienos-middle >/dev/null + extra_devices=(-drive "if=none,id=nvme,format=raw,file=${work}/nvme.img" -device nvme,drive=nvme,serial=b7b-events) +fi +cp "${image}" "${work}/esp/EFI/BOOT/BOOTAA64.EFI" cp "${vars_fd}" "${work}/vars.fd" log="${work}/serial.log" @@ -240,6 +301,7 @@ timeout "${AIENOS_QEMU_TIMEOUT:-180}" qemu-system-aarch64 \ -drive if=pflash,format=raw,file="${work}/vars.fd" \ -drive if=none,id=esp,format=raw,file=fat:rw:"${work}/esp" \ -device virtio-blk-pci,drive=esp \ + "${extra_devices[@]}" \ -device ramfb -display none -nic none \ -serial file:"${log}" -no-reboot qemu_status=$? @@ -252,7 +314,9 @@ tr -d '\r' <"${log}" >"${work}/serial.txt" echo "qemu exit ${qemu_status} after ${elapsed} s (commit ${commit:0:12}, ${mode})" failed=0 -if [[ "${mode}" == positive ]]; then +if [[ "${mode}" == events ]]; then + results="$(check_events "${work}/serial.txt")" || true +elif [[ "${mode}" == positive ]]; then results="$(check_positive "${work}/serial.txt")" || true else results="$(check_refused "${work}/serial.txt")" || true @@ -260,7 +324,7 @@ fi grep -q '^FAIL' <<<"${results}" && failed=1 printf '%s\n' "${results}" if [[ "${qemu_status}" == 0 ]]; then echo "PASS QEMU exit 0 (PSCI reset)"; else echo "FAIL QEMU exit ${qemu_status}"; failed=1; fi -grep -E '^b7b_probe: |^AIENOS_B7B_PROBE: |^smmu: ' "${work}/serial.txt" | sed 's/^/LOG /' +grep -E '^b7b_probe: |^AIENOS_B7B_PROBE: |^smmu: |^b7b_event|^b7b_rmr|^smmu_negative:' "${work}/serial.txt" | sed 's/^/LOG /' if [[ "${failed}" != 0 || -n "${AIENOS_QEMU_VERBOSE:-}" ]]; then echo "---- serial console ----" cat "${work}/serial.txt" diff --git a/scripts/stage_one_time_boot_ck_b7b.sh b/scripts/stage_one_time_boot_ck_b7b.sh index 2deb15bc..8b0b0944 100755 --- a/scripts/stage_one_time_boot_ck_b7b.sh +++ b/scripts/stage_one_time_boot_ck_b7b.sh @@ -63,12 +63,12 @@ # directory, docs/NATIVE_BOOT_ONE_TIME.md invariant 4) with a # STAGED-CK-B7B.TXT record; # 4. creates a boot entry WITHOUT adding it to BootOrder (BootOrder is -# restored if anything changed it), checks that Boot0004 AIENOSRECOV is +# restored if anything changed it), checks that Boot0002 AIENOSRECOV is # still there, and sets BootNext once. # # It never reboots. The firmware consumes BootNext on that boot, so the next # boot after it returns to the normal BootOrder (Linux). The boot itself is -# attended: Drake at the machine, AIENOSRECOV stick inserted (Boot0004), +# attended: Drake at the machine, AIENOSRECOV stick inserted (Boot0002), # camera on, witness present (B7B-PHYSICAL-BOOT-PREP.md sections 2 to 5). # # Carried unknowns (B7B-PHYSICAL-BOOT-PREP.md section 8), unchanged by this @@ -102,7 +102,7 @@ image="${out}/full-hardware-staging/BOOTAA64.EFI" image_b="${out_b}/full-hardware-staging/BOOTAA64.EFI" loader='\EFI\AIENOS\aienos-ck-b7b.efi' label="AIENOS C kernel B7b probe (one-time)" -recov_entry="0004" +recov_entry="0002" recov_label="AIENOSRECOV" hold_s=120 secure_boot_var="/sys/firmware/efi/efivars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c" @@ -192,7 +192,7 @@ cross="" [[ "$(uname -m)" == aarch64 ]] || cross="aarch64-linux-gnu-" for o in "${out}" "${out_b}"; do run make -s -C native/kernel CROSS="${cross}" OUT="${o}" AIENOS_COMMIT="${commit}" full \ - CK_B7B_PROBE=1 CK_HARDWARE_STAGING=1 \ + CK_B7B_PROBE=1 CK_B7B_EVENT_READOUT=1 CK_HARDWARE_STAGING=1 \ CK_OWNER_PUBKEYS="${owner_pubkeys:-}" \ CK_MACHINE_ID="${machine_id:-}" CK_FB_HOLD_S="${hold_s}" done @@ -202,6 +202,7 @@ if [[ "${mode}" == apply ]]; then [[ "${digest}" == "${digest_b}" ]] \ || { echo "STOP: the two probe builds differ (${digest} vs ${digest_b}); the image is not reproducible"; exit 1; } grep -aqF "b7b_probe: start segment=" "${image}" || { echo "STOP: the image carries no B7b probe"; exit 1; } + grep -aqF "b7b_events: final begin all_sids=yes" "${image}" || { echo "STOP: the image carries no SMMU event readout"; exit 1; } grep -aqF "screen: gop " "${image}" || { echo "STOP: the image has no screen console"; exit 1; } grep -aqF "xhci_acpi: " "${image}" || { echo "STOP: the image has no platform xHCI discovery"; exit 1; } grep -aqF "recovery_access: " "${image}" || { echo "STOP: the image has no recovery access hook"; exit 1; } @@ -211,7 +212,7 @@ if [[ "${mode}" == apply ]]; then echo "image sha256: ${digest} (build A and build B equal)" else echo "+ (compare the two digests: STOP if they differ)" - echo "+ (check the image: B7b probe for segment 15, screen console, xhci_acpi discovery and recovery_access present; no TEST-ONLY, TEST Store, TEST machine id or segment 0 marker)" + echo "+ (check the image: B7b probe for segment 15, all-SID SMMU event readout, screen console, xhci_acpi discovery and recovery_access present; no TEST-ONLY, TEST Store, TEST machine id or segment 0 marker)" digest="(computed after the build)" digest_b="(computed after the build)" fi @@ -224,7 +225,7 @@ record="${evidence_dir}/STAGED-CK-B7B.TXT" if [[ "${mode}" == apply ]]; then cat >"${record}" <