XNU as a loadable kernel module inside Linux (macOS personality for arm64 Linux)
C
xnulinux-boot.sh: a panic in a long run's log is still a panic
CommaBot1899f625a8e1
diff --git a/scripts/xnulinux-boot.sh b/scripts/xnulinux-boot.shindex 18dae65..3d9b653 100755--- a/scripts/xnulinux-boot.sh+++ b/scripts/xnulinux-boot.sh@@ -219,7 +219,8 @@ collect() { # the run's kernel log, kept; the status says how it endedls -1t "$LOGDIR"/run-*.log | tail -n +21 | xargs -r sudo rm -f # the last 20 runs# how it ended is in xnu.ko's own lines, not in what the hosted console printed (the log has those too: a console that# showed the words "XNU panic" turned a clean shutdown into a panic, and systemd started the system again)- said() { grep -av "fki: darwin console: " "$LOG" | grep -aq "$1"; }+ # (grep -c, not -q: under pipefail the first grep, cut off by an early -q, fails with SIGPIPE on a long log)+ said() { grep -av "fki: darwin console: " "$LOG" | grep -ac "$1" >/dev/null; }if said "XNU panic"; then echo "the hosted system panicked: $LOG" >&2; return 2; fi# shut down from inside (shutdown -h, the Apple menu): a halt is a clean end; a restart ends with 4 for systemd to start it again# (checked before the stop: the other CPUs log "run stopped by the host" as they leave after it)diff --git a/tests/scripts/xnulinux-boot.test.sh b/tests/scripts/xnulinux-boot.test.shindex 3a979a6..0fb478d 100755--- a/tests/scripts/xnulinux-boot.test.sh+++ b/tests/scripts/xnulinux-boot.test.sh@@ -84,6 +84,8 @@ while :; docase $how inhalt) klog "fki: xnu: the hosted system halted: run ended";;panic) klog "fki: xnu: XNU panic:"; klog "fki: panic(cpu 0 caller 0xfffffe0000000000): stand-in";;+ longpanic) klog "fki: xnu: XNU panic:" # and a long log after it+ seq 1 50000 | sed 's/^/[0.000000] host kernel: fki: xnu: monitor line /' >> "$T/klog";;esacexit 0 # the module stays loaded after a run that ended by itselffi@@ -138,6 +140,8 @@ host 'panic 1'; boot --wait; s=$?check '--wait, an XNU panic: status 2, "panicked"' [ $s = 2 -a "$(grep -c '^the hosted system panicked: ' "$T/out")" != 0 ]check "... the run's log is kept, with the panic" grep -q 'fki: xnu: XNU panic:' "$(log)"check '... xnu.ko is unloaded and the interrupts are back (a run that ended by itself)' [ ! -d "$R/sys/module/xnu" -a "$(cat "$R/proc/irq/default_smp_affinity")" = f ]+host 'longpanic 1'; boot --wait; s=$?+check '--wait, an XNU panic with a long log after it: status 2, "panicked"' [ $s = 2 -a "$(grep -c '^the hosted system panicked: ' "$T/out")" != 0 ]host 'halt 2'; /bin/bash "$P/scripts/xnulinux-boot.sh" --wait > "$T/out" 2>&1 & w=$!wait_for 10 grep -q '^booting' "$T/out"klog "fki: darwin console: # grep -c 'XNU panic' /var/log/notes"; klog "fki: darwin console: XNU panic: 3 lines"