aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / scripts / verify_all.sh
| 1 | #!/usr/bin/env bash |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # AIENOS End-to-End Build and Evidence Verification Harness |
| 18 | # Enforces sequential integration gates on the host DGX Spark environment. |
| 19 | # Last line: VERIFY_ALL: PASS only when every step ran; VERIFY_ALL: NOT_RUN if any step |
| 20 | # was skipped (scripts/lib_verify_summary.sh; test: bash scripts/lib_verify_summary.sh --self-test). |
| 21 | |
| 22 | set -euo pipefail |
| 23 | # |
| 24 | # AIENOS_STRICT=1 turns every SKIPPED step into a failure, so a green strict |
| 25 | # run proves every step really ran. AIENOS_LOG_DIR=<dir> makes the QEMU |
| 26 | # scripts copy their serial logs into <dir> (used by scripts/m3_receipt.sh). |
| 27 | # Without either variable the behaviour is unchanged. |
| 28 | |
| 29 | REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
| 30 | if [[ -n "${AIENOS_LOG_DIR:-}" ]]; then |
| 31 | mkdir -p "${AIENOS_LOG_DIR}" |
| 32 | AIENOS_LOG_DIR="$(cd "${AIENOS_LOG_DIR}" && pwd)" |
| 33 | export AIENOS_LOG_DIR |
| 34 | fi |
| 35 | cd "${REPO_ROOT}" |
| 36 | |
| 37 | # This harness and the QEMU scripts it calls read build output from target/ in this |
| 38 | # checkout (for example target/aarch64-unknown-uefi/release/aienos-boot.efi). A caller's |
| 39 | # CARGO_TARGET_DIR elsewhere (the Spark judge sets a shared one per repository) made the |
| 40 | # UEFI image check fail with "No such file or directory", and a shared directory can hand |
| 41 | # a test binary built from another checkout. Build into this checkout's own target/. |
| 42 | export CARGO_TARGET_DIR="${REPO_ROOT}/target" |
| 43 | # The Spark judge runs gates with PATH=/var/lib/aien-run/cargo/bin:/usr/local/bin:/usr/bin:/bin, without the sbin |
| 44 | # directories. Unprivileged tools from there are still needed (the recovery initrd build runs |
| 45 | # `modprobe --show-depends`), so append them; earlier PATH entries keep precedence. |
| 46 | export PATH="${PATH}:/usr/sbin:/sbin" |
| 47 | |
| 48 | # shellcheck source=scripts/lib_verify_summary.sh |
| 49 | source "${REPO_ROOT}/scripts/lib_verify_summary.sh" |
| 50 | |
| 51 | echo "============================================================" |
| 52 | echo "AIENOS Integration Verification Harness" |
| 53 | echo "Host: $(uname -n) | Arch: $(uname -m) | Kernel: $(uname -r)" |
| 54 | echo "Date: $(date -u +"%Y-%m-%dT%H:%M:%SZ")" |
| 55 | echo "Strict: ${AIENOS_STRICT:-0} | Serial log dir: ${AIENOS_LOG_DIR:-none}" |
| 56 | echo "============================================================" |
| 57 | |
| 58 | # Step 1: Gate 1 Verification (Config A Reference Bundle) |
| 59 | echo "" |
| 60 | echo "--- [Gate 1 Verification: Config A Freeze] ---" |
| 61 | if [[ ! -f "evidence/config_a_reference_bundle.json" ]]; then |
| 62 | echo "Running freeze_reality.sh..." |
| 63 | ./scripts/freeze_reality.sh |
| 64 | fi |
| 65 | ./scripts/verify_evidence.sh "evidence/config_a_reference_bundle.json" |
| 66 | echo "PASS Gate 1 Config A reference bundle verified" |
| 67 | |
| 68 | # Step 1b: Formatting |
| 69 | echo "" |
| 70 | echo "--- [Formatting: cargo fmt --check] ---" |
| 71 | cargo fmt --all --check |
| 72 | echo "PASS formatting: cargo fmt --all --check" |
| 73 | |
| 74 | # Step 2: Host component test suite |
| 75 | echo "" |
| 76 | echo "--- [Host Component Testing: Workspace Crates] ---" |
| 77 | cargo test --workspace -- --format=pretty |
| 78 | echo "PASS host tests: cargo test --workspace -- --format=pretty" |
| 79 | echo "PASS ABI conformance: frozen wire format golden bytes and roundtrips verified" |
| 80 | |
| 81 | # Step 3: Linting & Zero-Warning Enforcement |
| 82 | echo "" |
| 83 | echo "--- [Clippy Verification: -D warnings] ---" |
| 84 | cargo clippy --workspace --all-targets -- -D warnings |
| 85 | echo "PASS clippy: zero warnings with -D warnings" |
| 86 | |
| 87 | # Step 3b: target-only code (bare-metal kernel, UEFI images) is invisible to |
| 88 | # the host clippy run above, so lint each shipped target/feature set too. |
| 89 | echo "" |
| 90 | echo "--- [Clippy Verification: AArch64 targets, -D warnings] ---" |
| 91 | cargo clippy -p aienos-kernel --target aarch64-unknown-none --no-default-features -- -D warnings |
| 92 | cargo clippy -p aienos-kernel --target aarch64-unknown-none --no-default-features --features seed0b-test-anchor -- -D warnings |
| 93 | for features in firmware handoff seed0b-qualification usb-keyboard nvme-read nvme-write store-qual continuity-qual recovery-qual; do |
| 94 | cargo clippy -p aienos-boot --target aarch64-unknown-uefi --features "${features}" --bins -- -D warnings |
| 95 | done |
| 96 | echo "PASS clippy: aarch64-unknown-none kernel and aarch64-unknown-uefi images, zero warnings" |
| 97 | |
| 98 | # Step 3c: TEST-ONLY SEED-0B qualification code paths are feature-gated and |
| 99 | # so absent from the default runs above; test and lint them explicitly. |
| 100 | echo "" |
| 101 | echo "--- [SEED-0B qualification features: tests and clippy] ---" |
| 102 | cargo test -p aienos-artifact --features seed0b-test-anchor |
| 103 | cargo test -p aienos-artifact-tool --features seed0b-test-signing |
| 104 | cargo clippy -p aienos-artifact-tool --all-targets --features seed0b-test-signing -- -D warnings |
| 105 | if cargo build --release -p aienos-artifact-tool --features seed0b-test-signing >/dev/null 2>&1; then |
| 106 | echo "FAIL release build accepted the TEST-ONLY SEED-0B signing identity" >&2 |
| 107 | exit 1 |
| 108 | fi |
| 109 | echo "PASS SEED-0B qualification features tested and linted; release build refuses the test signing identity" |
| 110 | |
| 111 | # Step 4: Bare-metal library compilation check (not a boot test) |
| 112 | echo "" |
| 113 | echo "--- [Bare-Metal Target Compilation Check] ---" |
| 114 | cargo check -p aienos-kernel --target aarch64-unknown-none --no-default-features |
| 115 | cargo build -p aienos-kernel --target aarch64-unknown-none --no-default-features |
| 116 | echo "PASS AArch64 build: aienos-kernel for aarch64-unknown-none" |
| 117 | |
| 118 | # Step 5: Build an AArch64 UEFI diagnostic image and inspect its PE header. |
| 119 | # This verifies the firmware entry artifact format, not a hardware boot. |
| 120 | echo "" |
| 121 | echo "--- [AArch64 UEFI Image Builds] ---" |
| 122 | cargo build --release -p aienos-boot --target aarch64-unknown-uefi --features firmware --bin aienos-boot |
| 123 | cargo run --quiet --release -p aienos-evidence -- verify-efi "${CARGO_TARGET_DIR:-target}"/aarch64-unknown-uefi/release/aienos-boot.efi |
| 124 | cargo build --release -p aienos-boot --target aarch64-unknown-uefi --features handoff --bin aienos-handoff |
| 125 | cargo run --quiet --release -p aienos-evidence -- verify-efi "${CARGO_TARGET_DIR:-target}"/aarch64-unknown-uefi/release/aienos-handoff.efi |
| 126 | echo "PASS AArch64 build: aienos-boot.efi and aienos-handoff.efi PE headers verified" |
| 127 | |
| 128 | # Step 6: QEMU AArch64 UEFI Boot Verification (Emulator Boot Test) |
| 129 | echo "" |
| 130 | echo "--- [QEMU AArch64 UEFI Boot Verification] ---" |
| 131 | if command -v qemu-system-aarch64 >/dev/null && [[ -r "${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}" ]]; then |
| 132 | ./scripts/qemu_boot_test.sh |
| 133 | else |
| 134 | skipped "qemu-system-aarch64 or AAVMF firmware not present on host." |
| 135 | fi |
| 136 | |
| 137 | # Step 6a: P2-5 Binary Artifact loader. Signed candidates are staged, |
| 138 | # verified, admitted, run at EL0 from their exact authenticated bytes under |
| 139 | # W^X, and reclaimed; the ordinary build rejects every one (QEMU only). |
| 140 | echo "" |
| 141 | echo "--- [P2-5 Binary Artifact Loader in QEMU] ---" |
| 142 | if command -v qemu-system-aarch64 >/dev/null && [[ -r "${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}" ]]; then |
| 143 | ./scripts/qemu_artifact_test.sh |
| 144 | else |
| 145 | skipped "qemu-system-aarch64 or AAVMF firmware not present on host." |
| 146 | fi |
| 147 | |
| 148 | # Step 6b: SEED-0A USB keyboard candidate, proven in QEMU only (ADR 0012). |
| 149 | echo "" |
| 150 | echo "--- [SEED-0A USB Keyboard in QEMU (input.keyboard.usb)] ---" |
| 151 | if command -v qemu-system-aarch64 >/dev/null && [[ -r "${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}" ]]; then |
| 152 | # Never an unsafe DMA bypass build here: clear any inherited override. |
| 153 | unset AIENOS_UNSAFE_DMA_BYPASS AIENOS_BUILD_FEATURES |
| 154 | # Default mode: keyboard DMA only through a QEMU SMMUv3 stream. |
| 155 | AIENOS_QEMU_SMMU=1 ./scripts/qemu_keyboard_test.sh |
| 156 | else |
| 157 | skipped "qemu-system-aarch64 or AAVMF firmware not present on host." |
| 158 | fi |
| 159 | |
| 160 | # Step 6c: SMMUv3 DMA confinement of the xHCI keyboard, QEMU only. |
| 161 | echo "" |
| 162 | echo "--- [SMMUv3 DMA Confinement in QEMU] ---" |
| 163 | if command -v qemu-system-aarch64 >/dev/null && [[ -r "${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}" ]]; then |
| 164 | ./scripts/qemu_smmu_test.sh |
| 165 | # No SMMU and no bypass: the keyboard must stay unavailable, DMA off. |
| 166 | AIENOS_QEMU_SMMU=0 ./scripts/qemu_keyboard_test.sh |
| 167 | else |
| 168 | skipped "qemu-system-aarch64 or AAVMF firmware not present on host." |
| 169 | fi |
| 170 | |
| 171 | # Step 6d: M0 Native-Boot Rollback Verification (QEMU only). |
| 172 | echo "" |
| 173 | echo "--- [M0 Native-Boot Rollback Verification in QEMU] ---" |
| 174 | if command -v qemu-system-aarch64 >/dev/null && [[ -r "${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}" ]]; then |
| 175 | ./scripts/qemu_native_rollback_test.sh |
| 176 | else |
| 177 | skipped "qemu-system-aarch64 or AAVMF firmware not present on host." |
| 178 | fi |
| 179 | |
| 180 | # Step 6e: P3 native NVMe driver and System Store v1 over NVMe (QEMU only). |
| 181 | # Read and write/flush in both DMA modes (SMMU-confined, and fail-closed with |
| 182 | # no SMMU), 4K root-write atomicity, the 4K Store crash/reboot campaign and the |
| 183 | # 512-byte Store campaign, the M4 continuity campaign (ADR 0016) and the |
| 184 | # Recovery Core campaign (ADR 0006, TEST-ONLY operator key). Never an |
| 185 | # unsafe DMA bypass build here. |
| 186 | echo "" |
| 187 | echo "--- [P3 NVMe + System Store v1 in QEMU] ---" |
| 188 | if command -v qemu-system-aarch64 >/dev/null && [[ -r "${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}" ]]; then |
| 189 | unset AIENOS_UNSAFE_DMA_BYPASS AIENOS_BUILD_FEATURES |
| 190 | AIENOS_QEMU_SMMU=1 ./scripts/qemu_nvme_test.sh |
| 191 | AIENOS_QEMU_SMMU=0 ./scripts/qemu_nvme_test.sh |
| 192 | AIENOS_QEMU_SMMU=1 ./scripts/qemu_nvme_rw_test.sh |
| 193 | AIENOS_QEMU_SMMU=0 ./scripts/qemu_nvme_rw_test.sh |
| 194 | ./scripts/qemu_nvme_atomicity_test.sh |
| 195 | ./scripts/qemu_store_crash_test.sh |
| 196 | ./scripts/qemu_store_512b_crash_test.sh |
| 197 | ./scripts/qemu_continuity_test.sh |
| 198 | ./scripts/qemu_recovery_test.sh |
| 199 | else |
| 200 | skipped "qemu-system-aarch64 or AAVMF firmware not present on host." |
| 201 | fi |
| 202 | |
| 203 | echo "" |
| 204 | # Steps 1 to 6e (host checks and QEMU emulator runs) are done. The closing verdict is |
| 205 | # written once, at the very end, from what actually ran (final_verdict). |
| 206 | |
| 207 | # Step 7: TRUST-1 Gate 4 Security Suite (swTPM, Soak, Fault Injection) |
| 208 | echo "" |
| 209 | echo "--- [TRUST-1 Gate 4 Security Suite Verification] ---" |
| 210 | if command -v qemu-system-aarch64 >/dev/null && command -v swtpm >/dev/null && [[ -r "${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}" ]]; then |
| 211 | GATE4_SOAK_RUNS=3 ./scripts/qemu_security_suite.sh |
| 212 | else |
| 213 | skipped "qemu-system-aarch64, swtpm, or AAVMF firmware not present on host." |
| 214 | fi |
| 215 | |
| 216 | # Step 8: TRUST-1 Gate 1 Standalone Recovery Verification (Zero-Disk Boot) |
| 217 | echo "" |
| 218 | echo "--- [TRUST-1 Gate 1 Standalone Recovery Verification] ---" |
| 219 | if command -v qemu-system-aarch64 >/dev/null; then |
| 220 | ./scripts/qemu_verify_recovery_media.sh |
| 221 | else |
| 222 | skipped "qemu-system-aarch64 not present on host." |
| 223 | fi |
| 224 | |
| 225 | # Step 9: Recovery Media Tooling Manifest (issue #17; host-side, no real |
| 226 | # devices, no root -- extracts the built initrd and checks file presence). |
| 227 | echo "" |
| 228 | echo "--- [Recovery Media Tooling Manifest] ---" |
| 229 | if command -v gzip >/dev/null && command -v cpio >/dev/null; then |
| 230 | run_or_skip "recovery tool manifest" ./scripts/verify_recovery_tools.sh |
| 231 | else |
| 232 | skipped "gzip or cpio not present on host." |
| 233 | fi |
| 234 | |
| 235 | # Offline recovery media trust boundary (scratch files and throwaway keys). |
| 236 | # The host-only test does not qualify shim enrollment or physical media. |
| 237 | echo "" |
| 238 | echo "--- [Recovery Media Security Regression] ---" |
| 239 | if command -v mkfs.ext4 >/dev/null && command -v mkfs.vfat >/dev/null && |
| 240 | command -v grub-mkstandalone >/dev/null && command -v sbsign >/dev/null && |
| 241 | command -v sbverify >/dev/null && command -v openssl >/dev/null; then |
| 242 | run_or_skip "recovery media security" ./scripts/test_recovery_media_security.sh |
| 243 | else |
| 244 | skipped "mkfs, GRUB standalone builder, OpenSSL or sbsigntool not present on host." |
| 245 | fi |
| 246 | |
| 247 | # Step 10: TRUST-1 Gate 0/2 measurement tools (software TPM, no hardware). |
| 248 | echo "" |
| 249 | echo "--- [TRUST-1 Measurement Tools Self-Test] ---" |
| 250 | # FLAG(sovereignty): tpm2_pcrread gate (tpm2-tools, outside dep) on host; replace with in-house C tool check. |
| 251 | if command -v swtpm >/dev/null && command -v tpm2_pcrread >/dev/null && command -v xxd >/dev/null; then |
| 252 | ./scripts/test_trust1_measurement_tools.sh |
| 253 | else |
| 254 | skipped "swtpm, tpm2-tools, or xxd not present on host." |
| 255 | fi |
| 256 | |
| 257 | # Step 11: TRUST-1 Gate 4 Secure Boot enforcement in QEMU. Firmware with |
| 258 | # Secure Boot ON and the published Debian "snakeoil" TEST key in PK/KEK/db: |
| 259 | # signed loader boots, unsigned / one-byte-tampered / wrong-key are refused |
| 260 | # with Access Denied. No owner key, no hardware. |
| 261 | echo "" |
| 262 | echo "--- [TRUST-1 Gate 4 Secure Boot Signing in QEMU] ---" |
| 263 | if command -v qemu-system-aarch64 >/dev/null && command -v sbsign >/dev/null && command -v sbverify >/dev/null \ |
| 264 | && [[ -r /usr/share/AAVMF/AAVMF_CODE.snakeoil.fd && -r /usr/share/qemu-efi-aarch64/PkKek-1-snakeoil.key ]]; then |
| 265 | ./scripts/qemu_secureboot_signing_test.sh |
| 266 | else |
| 267 | skipped "qemu-system-aarch64, sbsigntool, or snakeoil AAVMF firmware not present on host." |
| 268 | fi |
| 269 | |
| 270 | # Step 12: TRUST-1 Gate 3 key ceremony tool self-test. THROWAWAY keys in a |
| 271 | # private temp folder only (deleted on exit); never an owner key. |
| 272 | echo "" |
| 273 | echo "--- [TRUST-1 Gate 3 Key Ceremony Tool Self-Test] ---" |
| 274 | if command -v openssl >/dev/null && openssl version | grep -q '^OpenSSL 3\.'; then |
| 275 | run_or_skip "TRUST-1 key ceremony self-test" bash -c 'exec ./scripts/test_trust1_key_ceremony.sh 2>/dev/null' |
| 276 | else |
| 277 | skipped "OpenSSL 3 not present on host." |
| 278 | fi |
| 279 | |
| 280 | # Step 13: evidence receipts with hardcoded invariant labels must be amended. |
| 281 | echo "" |
| 282 | echo "--- [Evidence Receipt Label Lint] ---" |
| 283 | run_or_skip "receipt label lint self-test" ./scripts/check_receipt_labels.sh --self-test |
| 284 | run_or_skip "receipt label lint" ./scripts/check_receipt_labels.sh |
| 285 | |
| 286 | final_verdict |