Skip to content

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

C

krun-vm.sh: 6 vCPUs by default (room for the Mac's own work); README: the Mac agent

Heyang Zhou5246089efabe
diff --git a/README.md b/README.md
index 4709067..a6432c2 100644
--- a/README.md
+++ b/README.md
@@ -51,6 +51,8 @@ The host is an arm64 Linux VM with PAC on an Apple Silicon Mac (`scripts/krun-vm
6. `scripts/install-service.sh` (in the VM, once) runs it as a service: `xnulinux.service` starts it at boot, stops it
cleanly (the disk synced) when the VM shuts down and starts it again after a panic; settings in `/etc/xnulinux.conf`
(CPUs, memory, disk, GPU, xnu.ko parameters), each run's kernel log in `/var/log/xnulinux/`.
+ On the Mac, `scripts/install-krun-agent.sh` keeps the VM itself running (launchd: started again after the guest
+ reboots or powers off, and at login); `scripts/install-krun-agent.sh remove` shuts the guest down and removes it.
Debugging: the VM console is captured on the host (`scripts/serial-pty.py`), a monitor thread on another CPU prints XNU's
counters every 2 s, and XNU dumps its threads with their saved frames after 20000 idle rounds.
diff --git a/scripts/krun-vm.sh b/scripts/krun-vm.sh
index 421eeb4..4dba34b 100644
--- a/scripts/krun-vm.sh
+++ b/scripts/krun-vm.sh
@@ -10,7 +10,7 @@ set -euo pipefail
KRUN=${KRUN:-$HOME/.local/krunkit}
DISK=${DISK:-$HOME/.tart/vms/xnupoc/disk.img}
MAC=${MAC:-$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["macAddress"])' "$(dirname "$DISK")/config.json")}
-CPUS=${CPUS:-12}; MEM=${MEM:-24576}; SSH_PORT=${SSH_PORT:-2223}
+CPUS=${CPUS:-6}; MEM=${MEM:-24576}; SSH_PORT=${SSH_PORT:-2223}
S=${S:-$HOME/.local/state/xnupoc-krun}; mkdir -p "$S"
if pgrep -f "tart run xnupoc" >/dev/null; then echo "tart is running xnupoc: stop it first" >&2; exit 1; fi
rm -f "$S"/gv.sock "$S"/gvapi.sock