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/blob/main/scripts/collect_boot_report.sh # 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 branch `main` Branches Tags History `aienux / scripts / collect_boot_report.sh` 104 lines ยท 5119 bytes Raw Blame History 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 # Collect and judge the evidence from an AIENOS first-boot attempt. Read-only. 18 # Run under `aien-proof hold --resource machine-1` so the full output becomes 19 # an audit event in the hardware-test ledger. 20 # 21 # Gate (M2 first native boot): Machine 1 left firmware, entered native AIENOS 22 # code with no Linux underneath, left independently recoverable evidence, and 23 # returned to the existing system without damaging it. 24 set -uo pipefail 25 26 esp="${AIENOS_ESP_DIR:-/boot/efi/EFI/AIENOS}" 27 staged_file="${esp}/STAGED.TXT" 28 report_file="${esp}/BOOTREPORT.TXT" 29 image="${esp}/aienos-handoff.efi" 30 report_var="${AIENOS_REPORT_VAR:-/sys/firmware/efi/efivars/AienosBootReportV1-`a1e05b0e`-7c3d-4f51-9b6a-`2d8e4c1f0a37`}" 31 32 field() { sed -n "s/^$1: //p" <<<"$2" | head -1; } 33 check() { # name, pass(0/1), detail 34 if [[ "$2" == 1 ]]; then echo "PASS $1: $3"; else echo "FAIL $1: $3"; failed=1; fi 35 } 36 failed=0 37 38 echo "== staging record (${staged_file})" 39 staged="$(cat "${staged_file}" 2>/dev/null)" 40 if [[ -z "${staged}" ]]; then 41 echo "missing: nothing was staged, or the file is unreadable" 42 echo "M2_GATE: UNPROVEN" 43 exit 1 44 fi 45 printf '%s\n' "${staged}" 46 commit="$(field aienos_commit "${staged}")" 47 48 echo "== staged image" 49 digest_now="$(sha256sum "${image}" 2>/dev/null | cut -d' ' -f1)" 50 echo "sha256: ${digest_now:-missing}" 51 52 echo "== pre-exit report (${report_file})" 53 pre="$(cat "${report_file}" 2>/dev/null)" 54 printf '%s\n' "${pre:-missing}" 55 56 echo "== native firmware-variable report" 57 native="" 58 if [[ -r "${report_var}" ]]; then 59 # efivarfs prefixes the value with 4 bytes of attributes. 60 # efivarfs files cannot seek, so stream the value instead of `tail` on the path. 61 native="$(cat "${report_var}" 2>/dev/null | tail -c +5)" 62 fi 63 printf '%s\n' "${native:-missing}" 64 65 echo "== current boot state" 66 boot_state="$(efibootmgr)" 67 printf '%s\n' "${boot_state}" | sed -n '1,4p' 68 echo "kernel: $(uname -r)" 69 echo "root: $(findmnt -no OPTIONS / | cut -d, -f1)" 70 71 echo "== verdict" 72 check "image_unchanged" "$([[ -n "${digest_now}" && "${digest_now}" == "$(field image_sha256 "${staged}")" ]] && echo 1 || echo 0)" \ 73 "staged ${commit:0:12}, image ${digest_now:0:16}" 74 # Either report proves the firmware ran this image; the variable is written only 75 # after ExitBootServices, so it alone also proves firmware exit. 76 check "left_firmware_into_aienos" "$([[ "$(field aienos_commit "${pre}")" == "${commit}" || "$(field aienos_commit "${native}")" == "${commit}" ]] && echo 1 || echo 0)" \ 77 "pre-exit file: $([[ -n "${pre}" ]] && echo present || echo missing), native report: $([[ -n "${native}" ]] && echo present || echo missing)" 78 check "native_code_after_firmware_exit" "$([[ -n "${native}" && "$(field aienos_commit "${native}")" == "${commit}" ]] && echo 1 || echo 0)" \ 79 "firmware variable written by AIENOS after ExitBootServices (kind $(field report_kind "${native}"))" 80 check "kernel_alive" "$(grep -qx "kernel: alive" <<<"${native}" && echo 1 || echo 0)" \ 81 "last stage $(field last_stage "${native}")" 82 check "boot_next_consumed" "$(grep -q "^BootNext:" <<<"${boot_state}" && echo 0 || echo 1)" \ 83 "no pending one-time boot" 84 # Firmware may append entries for removable media it finds (a USB stick). The 85 # gate is that the original entries keep their order and AIENOS never joined. 86 order_before="$(field boot_order_before "${staged}")" 87 order_now="$(field BootOrder "${boot_state}")" 88 kept="$(tr ',' '\n' <<<"${order_now}" | grep -Fx -f <(tr ',' '\n' <<<"${order_before}") | paste -sd,)" 89 added="$(tr ',' '\n' <<<"${order_now}" | grep -Fvx -f <(tr ',' '\n' <<<"${order_before}") | paste -sd,)" 90 aienos_in_order="$(tr ',' '\n' <<<"${order_now}" | grep -Fxc "$(field aienos_boot_entry "${staged}")")" 91 check "boot_order_preserved" "$([[ "${kept}" == "${order_before}" && "${aienos_in_order}" == 0 ]] && echo 1 || echo 0)" \ 92 "before ${order_before}, now ${order_now}${added:+ (added by firmware: ${added})}" 93 check "linux_entry_booted" "$([[ "$(field BootCurrent "${boot_state}")" == "$(field boot_current_before "${staged}")" ]] && echo 1 || echo 0)" \ 94 "BootCurrent $(field BootCurrent "${boot_state}")" 95 check "linux_kernel_unchanged" "$([[ "$(uname -r)" == "$(field linux_kernel_before "${staged}")" ]] && echo 1 || echo 0)" \ 96 "$(uname -r)" 97 check "root_filesystem_writable" "$([[ "$(findmnt -no OPTIONS / | cut -d, -f1)" == "rw" ]] && echo 1 || echo 0)" "/" 98 99 if [[ "${failed}" == 0 ]]; then 100 echo "M2_GATE: PASS" 101 else 102 echo "M2_GATE: FAIL" 103 exit 1 104 fi