diff options
| author | salmonik <salmonik@tuta.io> | 2026-08-02 15:21:34 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-08-02 15:21:34 +0200 |
| commit | c7d92071e1dd11c45999457b16554b4abaa73b28 (patch) | |
| tree | aff7c7f19adcffe1dd91e1c2514af02c77fd524e /scripts | |
| parent | v0.5.5: fix real-hardware boot crash — shadow back in heap as first allocation (diff) | |
| download | rs-dos-c7d92071e1dd11c45999457b16554b4abaa73b28.tar.gz rs-dos-c7d92071e1dd11c45999457b16554b4abaa73b28.zip | |
v0.5.5: crash reports go to a dedicated CRASHLOG USB stick
The fault handler now writes crash.log to the volume labeled CRASHLOG
(label-selected via fat::crash_vol), falling back to slot 0. On real
hardware the boot USB may be unwritable, so a second stick labeled
CRASHLOG survives the write; the shell auto-prints the previous crash
report from it at next boot (read_crash_log resolves /disk/<uid>/crash.log
through the FAT path, since Disk nodes hold no cached children).
- fat.rs: volume_label() + crash_vol() (no allocation)
- fs.rs: write_crash_log targets crash_vol(); read_crash_log prefers the
CRASHLOG disk node; drop now-unused first_disk()
- mkdisk.sh: --label option
- test-fault.sh: boots with a dedicated CRASHLOG stick (mkfs -F 32 -n
CRASHLOG), verifies crash.log lands there and NOT on the ESP
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/mkdisk.sh | 10 | ||||
| -rwxr-xr-x | scripts/test-fault.sh | 28 |
2 files changed, 31 insertions, 7 deletions
diff --git a/scripts/mkdisk.sh b/scripts/mkdisk.sh index 6bdd50c..2c62f76 100755 --- a/scripts/mkdisk.sh +++ b/scripts/mkdisk.sh | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | # ./scripts/mkdisk.sh --size 128M # different size (default 64M) | 9 | # ./scripts/mkdisk.sh --size 128M # different size (default 64M) |
| 10 | # ./scripts/mkdisk.sh /path/img # custom image path | 10 | # ./scripts/mkdisk.sh /path/img # custom image path |
| 11 | # ./scripts/mkdisk.sh --no-seed # skip the seed/ directory | 11 | # ./scripts/mkdisk.sh --no-seed # skip the seed/ directory |
| 12 | # ./scripts/mkdisk.sh --label CRASHLOG # volume label (default RSDOS) | ||
| 12 | # | 13 | # |
| 13 | # The image is created with `mkfs.fat -C`, which is the option that | 14 | # The image is created with `mkfs.fat -C`, which is the option that |
| 14 | # actually creates the file — plain `mkfs.fat` only writes into an | 15 | # actually creates the file — plain `mkfs.fat` only writes into an |
| @@ -23,6 +24,7 @@ IMG="/tmp/disk.img" | |||
| 23 | SIZE="64M" | 24 | SIZE="64M" |
| 24 | FRESH=0 | 25 | FRESH=0 |
| 25 | SEED_DIR="$PROJECT_DIR/seed" | 26 | SEED_DIR="$PROJECT_DIR/seed" |
| 27 | LABEL="RSDOS" | ||
| 26 | 28 | ||
| 27 | while [ $# -gt 0 ]; do | 29 | while [ $# -gt 0 ]; do |
| 28 | case "$1" in | 30 | case "$1" in |
| @@ -32,6 +34,10 @@ while [ $# -gt 0 ]; do | |||
| 32 | SIZE="$1" | 34 | SIZE="$1" |
| 33 | ;; | 35 | ;; |
| 34 | --no-seed) SEED_DIR="" ;; | 36 | --no-seed) SEED_DIR="" ;; |
| 37 | --label) | ||
| 38 | shift | ||
| 39 | LABEL="$1" | ||
| 40 | ;; | ||
| 35 | --help | -h) | 41 | --help | -h) |
| 36 | head -20 "$0" | grep "^#" | sed 's/^# \?//' | 42 | head -20 "$0" | grep "^#" | sed 's/^# \?//' |
| 37 | exit 0 | 43 | exit 0 |
| @@ -65,9 +71,9 @@ if [ -z "$SIZE_BLOCKS" ] || [ "$SIZE_BLOCKS" -le 0 ] 2>/dev/null; then | |||
| 65 | exit 1 | 71 | exit 1 |
| 66 | fi | 72 | fi |
| 67 | 73 | ||
| 68 | echo "mkdisk: creating $IMG ($SIZE FAT32, label RSDOS)" | 74 | echo "mkdisk: creating $IMG ($SIZE FAT32, label $LABEL)" |
| 69 | rm -f "$IMG" | 75 | rm -f "$IMG" |
| 70 | mkfs.fat -C -F 32 -n RSDOS "$IMG" "$SIZE_BLOCKS" | 76 | mkfs.fat -C -F 32 -n "$LABEL" "$IMG" "$SIZE_BLOCKS" |
| 71 | 77 | ||
| 72 | if [ -n "$SEED_DIR" ] && [ -d "$SEED_DIR" ]; then | 78 | if [ -n "$SEED_DIR" ] && [ -d "$SEED_DIR" ]; then |
| 73 | if ! command -v mcopy >/dev/null 2>&1; then | 79 | if ! command -v mcopy >/dev/null 2>&1; then |
diff --git a/scripts/test-fault.sh b/scripts/test-fault.sh index 49ba791..59f741f 100755 --- a/scripts/test-fault.sh +++ b/scripts/test-fault.sh | |||
| @@ -52,12 +52,18 @@ echo "==> 2/5 deploy to ESP" | |||
| 52 | mkdir -p "$ESP_DIR/EFI/BOOT" | 52 | mkdir -p "$ESP_DIR/EFI/BOOT" |
| 53 | cp target/x86_64-unknown-uefi/debug/rsdos.efi "$ESP_DIR/EFI/BOOT/BOOTX64.EFI" | 53 | cp target/x86_64-unknown-uefi/debug/rsdos.efi "$ESP_DIR/EFI/BOOT/BOOTX64.EFI" |
| 54 | 54 | ||
| 55 | echo "==> 3/5 boot QEMU (headless)" | 55 | echo "==> 3/6 boot QEMU (headless, + dedicated CRASHLOG stick)" |
| 56 | kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true | 56 | kill "$(cat "$QPID" 2>/dev/null)" 2>/dev/null || true |
| 57 | sleep 1 | 57 | sleep 1 |
| 58 | rm -f "$SOCK" "$LOG" | 58 | rm -f "$SOCK" "$LOG" |
| 59 | # A second FAT32 stick labeled CRASHLOG: crash reports must land here | ||
| 60 | # (label-selected by the kernel), not on the boot device. | ||
| 61 | CRASH_IMG=/tmp/rsdos-crash.img | ||
| 62 | "$SCRIPT_DIR/mkdisk.sh" --fresh --label CRASHLOG --no-seed "$CRASH_IMG" >/dev/null | ||
| 59 | "$QEMU" -bios "$OVMF" \ | 63 | "$QEMU" -bios "$OVMF" \ |
| 60 | -drive file=fat:rw:"$ESP_DIR",format=raw \ | 64 | -drive file=fat:rw:"$ESP_DIR",format=raw \ |
| 65 | -drive file="$CRASH_IMG",format=raw,if=none,id=crash \ | ||
| 66 | -device ide-hd,drive=crash,bus=ide.2 \ | ||
| 61 | -serial file:"$LOG" \ | 67 | -serial file:"$LOG" \ |
| 62 | -monitor unix:"$SOCK",server,nowait \ | 68 | -monitor unix:"$SOCK",server,nowait \ |
| 63 | -m 256M -machine q35 -cpu qemu64 -no-reboot -display none \ | 69 | -m 256M -machine q35 -cpu qemu64 -no-reboot -display none \ |
| @@ -66,11 +72,12 @@ echo $! >"$QPID" | |||
| 66 | 72 | ||
| 67 | wait_log "$LOG" "boot: entering shell" 90 || fail "kernel never reached the shell" | 73 | wait_log "$LOG" "boot: entering shell" 90 || fail "kernel never reached the shell" |
| 68 | 74 | ||
| 69 | echo "==> 4/5 boot diagnostics present" | 75 | echo "==> 4/6 boot diagnostics present" |
| 70 | grep -aq "gop: fb base=" "$LOG" || fail "fb geometry diagnostic missing" | 76 | grep -aq "gop: fb base=" "$LOG" || fail "fb geometry diagnostic missing" |
| 71 | grep -aq "gop: mode .* selected" "$LOG" || fail "mode-selection diagnostic missing" | 77 | grep -aq "gop: mode .* selected" "$LOG" || fail "mode-selection diagnostic missing" |
| 78 | grep -aq "CRASHLOG" "$LOG" || fail "CRASHLOG stick not mounted" | ||
| 72 | 79 | ||
| 73 | echo "==> 5/5 inject a page fault (fault command)" | 80 | echo "==> 5/6 inject a page fault (fault command)" |
| 74 | python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \ | 81 | python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \ |
| 75 | "clear" \ | 82 | "clear" \ |
| 76 | "fault" | 83 | "fault" |
| @@ -83,8 +90,19 @@ grep -aq "cr2=0x400000000000" "$LOG" || fail "CR2 not reported (faulting address | |||
| 83 | grep -aq "task=0 \"shell\"" "$LOG" || fail "faulting task not identified" | 90 | grep -aq "task=0 \"shell\"" "$LOG" || fail "faulting task not identified" |
| 84 | grep -aq "!!! halting" "$LOG" || fail "no halt message" | 91 | grep -aq "!!! halting" "$LOG" || fail "no halt message" |
| 85 | 92 | ||
| 93 | echo "==> 6/6 crash.log persisted on the CRASHLOG stick" | ||
| 94 | grep -aq "crashlog: vol .* (CRASHLOG)" "$LOG" || fail "crashlog did not target the CRASHLOG stick" | ||
| 95 | grep -aq "crashlog: wrote" "$LOG" || fail "crashlog write did not complete" | ||
| 96 | mdir -i "$CRASH_IMG" "::" 2>/dev/null | grep -aqi "crash" \ | ||
| 97 | || fail "crash.log missing on the CRASHLOG stick" | ||
| 98 | # The boot ESP must NOT receive the crash log. | ||
| 99 | if [ -f "$ESP_DIR/crash.log" ]; then | ||
| 100 | fail "crash.log landed on the boot ESP instead of the CRASHLOG stick" | ||
| 101 | fi | ||
| 102 | |||
| 86 | # The screen dump itself is exercised in-kernel (dump_lines); the serial | 103 | # The screen dump itself is exercised in-kernel (dump_lines); the serial |
| 87 | # path sharing the same format line is verified above. | 104 | # path sharing the same format line is verified above. |
| 88 | echo "" | 105 | echo "" |
| 89 | echo "PASS — fault dump works (vec, err, rip, cr2, task → screen + serial)" | 106 | echo "PASS — fault dump + crash.log on the CRASHLOG stick" |
| 90 | echo " every CPU exception now halts with a diagnosable dump, not a freeze" | 107 | echo " every CPU exception halts with a diagnosable dump; the report" |
| 108 | echo " survives reboot on the dedicated CRASHLOG volume" | ||
