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/evidence/own-gpu-driver/rung2/window1-post.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 / evidence / own-gpu-driver / rung2 / window1-post.sh` 39 lines ยท 3227 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # L332 rung 2 window 1, part 2 (after the reboot from part 1). First removes the temporary blacklist. Then our module takes 3 # the GPU with both switches on, and aien_gsp_boot hands NVIDIA's signed GSP firmware to the chip through SEC2 (one 4 # attempt: the module refuses a second doorbell) and waits for GSP-RM's INIT_DONE. The module is NOT unloaded afterwards 5 # (GSP may still use its memory); a normal reboot gives the GPU back to NVIDIA's driver, and part 3 checks that. 6 # Usage: window1-post.sh [--no-reboot] 7 set -u 8 export PATH=$PATH:/usr/sbin:/sbin # modinfo, lsmod and friends live in sbin; a normal user shell may not list it 9 here=$(cd "$(dirname "$0")" && pwd); repo=$(cd "$here/../../.." && pwd) 10 log=$here/$(readlink "$here/window1-current.log") 11 ts() { echo "$(date -u +%FT%T.%NZ) $*" | tee -a "$log"; } 12 # The /run hold-back file stays for the whole window boot (tmpfs: gone at the restore reboot), so nothing can load 13 # NVIDIA's driver beside ours. 14 grep -q 'aien.gpuwindow=1' /proc/cmdline || { ts "WINDOW1 ABORT: this is not the one-shot window boot (no aien.gpuwindow=1); nothing done"; exit 1; } 15 ts "post start; window boot; hold-back file present: $([ -e /run/modprobe.d/zz-aien-gpu-window.conf ] && echo yes || echo NO); lease: $(systemctl is-active aien-gpu-window-lease.service)" 16 ts "boot: $(uptime -s) (uptime $(cut -d' ' -f1 /proc/uptime) s)" 17 ts "lsmod nvidia: [$(lsmod | grep -cE '^nvidia')] driver in use on the GPU: $(lspci -k -s 000f:01:00.0 | grep -c 'in use')" 18 [ "$(lsmod | grep -cE '^nvidia')" = 0 ] || { ts "WINDOW1 ABORT: an NVIDIA module is loaded; two drivers on one GPU must never happen"; exit 1; } 19 PKG=$(cat "$here/window1-package.path"); SHIM=$repo/native/linux/aien-gpu 20 # arena: everything the builder places, plus 8 MiB for the logs, queues and page tables (the tool refuses if short) 21 bytes=$(cat "$PKG"/rm_elf.bin "$PKG"/rm_sig.bin "$PKG"/bootloader.bin "$PKG"/fmc.bin | wc -c) 22 arena_mib=$(( bytes / `1048576` + 8 + 1 )) 23 sudo sysctl -q -w kernel.panic=10 kernel.panic_on_oops=1; ts "panic auto-reboot 10 s set (runtime only)" 24 ts "insmod aien_gpu allow_bind=1 allow_boot=1 arena_mib=$arena_mib heap_mib=512" 25 sudo insmod "$SHIM/aien_gpu.ko" allow_bind=1 allow_boot=1 arena_mib="$arena_mib" heap_mib=512 || { ts "WINDOW1 FAIL: insmod"; sudo dmesg | grep -i aien-gpu | tee -a "$log"; exit 1; } 26 sudo dmesg | grep -i aien-gpu | tee -a "$log" 27 out=$here/window1-$(date -u +%Y%m%dT%H%M%SZ)-run; app=$(cat "$PKG/app_version.txt") 28 ts "aien_gsp_boot --pkg $PKG --app-version $app --out $out" 29 t0=$(date +%s%N) 30 sudo "$SHIM/build/aien_gsp_boot" --pkg "$PKG" --app-version "$app" --out "$out" --polls 50000 --pause-us 100 --wait-ms 30000 2>&1 | tee -a "$log" 31 brc=${PIPESTATUS[0]}; t1=$(date +%s%N) 32 sudo chown -R "$(id -un)" "$out" 33 ts "aien_gsp_boot exit $brc wall ms $(( (t1 - t0) / `1000000` ))" 34 cat "$out/result.txt" >> "$log" 2>/dev/null 35 sudo dmesg | tail -40 > "$out/dmesg-tail.txt" 36 ts "WINDOW1 $( [ "$brc" = 0 ] && echo 'PASS (GSP-RM INIT_DONE on our driver)' || echo "STOPPED (see $out/result.txt)" )" 37 [ "${1:-}" = --no-reboot ] && exit 0 38 ts "normal reboot: gives the GPU back to NVIDIA's driver (aien_gpu is not unloaded; GSP may still use its memory)" 39 sync; sudo systemctl reboot