Skip to content

XNU as a loadable kernel module inside Linux (macOS personality for arm64 Linux)

C

Merge main into dgx-spark

Heyang Zhou76e43e94d8cf
diff --cc scripts/xnulinux-boot.sh
index 01b33cf,e9848e7..bc7c141
--- a/scripts/xnulinux-boot.sh
+++ b/scripts/xnulinux-boot.sh
@@@ -110,14 -102,9 +110,15 @@@ if [ "$GPU" != off ] && [ -e /dev/dri/r
sudo systemctl stop xnudrmd 2>/dev/null || true
fi
fi
+# Chip name for System Information (override: SOC_NAME=)
+XCPU0=$(cat /sys/module/fki/parameters/cpu_list 2>/dev/null | tr -d '\n' | cut -d, -f1); XCPU0=${XCPU0:-0}
+SOC_NAME=${SOC_NAME:-$(lscpu -e=CPU,MODELNAME 2>/dev/null | awk -v c="$XCPU0" '$1 == c { $1 = ""; sub(/^ +/, ""); print }' || true)}
+NAMES=()
+[ -n "${SOC_NAME:-}" ] && NAMES+=("soc_name=\"$SOC_NAME\"")
+[ -n "${GPU_MODEL:-}" ] && NAMES+=("gpu_model=\"$GPU_MODEL\"")
# mode=3: the kernel collection; the run lasts until the hosted system halts.
# insmod returns when the run ends: it runs detached, its output in /var/tmp/xnu-insmod.log.
+ START=$(date +%s) # the run's log (--wait) starts here, so a failure while xnu.ko loads is in it
for try in 1 2 3 4 5 6 7 8 9; do
sync; echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null; echo 1 | sudo tee /proc/sys/vm/compact_memory >/dev/null
sudo dmesg -C