XNU as a loadable kernel module inside Linux (macOS personality for arm64 Linux)
C
Hosted console: read XNU's output through journald; keep it off the VM console
Heyang Zhou139cba132cfb
diff --git a/scripts/vm-dmesg-shell.sh b/scripts/vm-dmesg-shell.shindex bc02587..20f9693 100755--- a/scripts/vm-dmesg-shell.sh+++ b/scripts/vm-dmesg-shell.sh@@ -1,10 +1,12 @@#!/bin/bash# On tokyo: talk to the hosted macOS shell through the VM. XNU's output is read from the kernel ring buffer (dmesg,# log_buf_len=128M) instead of the serial console: a flood of console lines through a 115200-baud console stalled-# printk with interrupts off on XNU's CPU (RCU stall). Usage: vm-dmesg-shell.sh mark | send 'cmd' [secs] | since MARK+# printk with interrupts off on XNU's CPU (RCU stall). The ring buffer is read through journald (`journalctl -k`): after a+# few minutes of XNU's output `dmesg` (util-linux, /dev/kmsg) stopped showing new records while journald kept them.+# Usage: vm-dmesg-shell.sh mark | send 'cmd' [secs] | since MARKcd "$(dirname "$0")/.."case "$1" in- mark) bash scripts/vm.sh 'sudo dmesg | tail -1 | sed "s/^\[ *\([0-9.]*\)\].*/\1/"';;+ mark) bash scripts/vm.sh 'sudo journalctl -k -n1 -q -o short-monotonic | sed "s/^\[ *\([0-9.]*\)\].*/\1/"';;send) printf '%s\n' "$2" | timeout 30 bash scripts/vm.sh 'cat >> /var/tmp/console-in'; sleep "${3:-10}";;- since) bash scripts/vm.sh 'sudo dmesg' | awk -v m="$2" 'substr($0,2,12)+0 > m+0';;+ since) bash scripts/vm.sh 'sudo journalctl -k -b -q -o short-monotonic --no-pager' | awk -v m="$2" 'substr($0,2,12)+0 > m+0';;esacdiff --git a/scripts/xnulinux-boot.sh b/scripts/xnulinux-boot.shindex d77adbf..968809c 100755--- a/scripts/xnulinux-boot.sh+++ b/scripts/xnulinux-boot.sh@@ -24,7 +24,9 @@ build() { # a module; its compiler errors on failure}build fki-kobuild xnu-ko "KBUILD_EXTRA_SYMBOLS=$PWD/fki-ko/Module.symvers"-sudo dmesg -n "${CONLEVEL:-8}"+# XNU prints a lot (console lines, kprintf): to the ring buffer only (journalctl -k, scripts/vm-dmesg-shell.sh), not the+# VM console, where a CPU printing waits for the console with interrupts off+sudo dmesg -n "${CONLEVEL:-1}"# fki has the hosted kernel's DRAM from its load at boot (scripts/vm-install-fki-service.sh): reload it only when it changed,# with the same carve-outCARVE="carve_base=$(cat /sys/module/fki/parameters/carve_base 2>/dev/null || echo 0x400000000) carve_mb=$(cat /sys/module/fki/parameters/carve_mb 2>/dev/null || echo 8156)"