XNU as a loadable kernel module inside Linux (macOS personality for arm64 Linux)
C
Merge main into dgx-spark
秋 奈月c0549e0adb35
diff --cc LICENSEindex afec7f0,e7c2774..090eb57--- a/LICENSE+++ b/LICENSE@@@ -1,12 -1,13 +1,13 @@@xnulinux is made of parts under different licenses, kept apart along the line between the Linux kernel and XNU.Each source file names its license in an SPDX-License-Identifier line; the full texts are in LICENSES/:- GPL-2.0-only fki-ko/, linux/, scripts/, tools/, tests/, docs/, gpu/xnu-drm/xnudrmd.c, gpu/venus/+ GPL-2.0-only fki-ko/, linux/, scripts/, tools/, tests/, docs/, gpu/xnu-drm/ (xnudrmd, test/), gpu/venus/GPL-2.0-or-later gpu/xnu-cpu-metal/- APSL-2.0 xnu-ko/, xnu-patches/, kexts/+ APSL-2.0 xnu-ko/, xnu-patches/, kexts/ (kexts/free/compat/ too)BSD-2-Clause-Patent kexts/XnuDisplay/, kexts/XnuEthernet/, kexts/XnuInput/ (from macOS-DroidVM),gpu/xnu-cpu-metal/src/xnu-cpu-metal-bundle/XnuCpuMetalShim.h (from UniXNU/AdrenoMetal)- MIT gpu/xnu-drm/darwin/, gpu/xnu-drm/xnudrm_proto.h; the patches to Mesa and virglrenderer+ MPL-2.0 kexts/free/patches/corecrypto-arm64e-sptr.patch (a patch to corecrypto, under its license)+ MIT gpu/xnu-drm/darwin/, gpu/xnu-drm/test/, gpu/xnu-drm/xnudrm_proto.h; the patches to Mesa and virglrenderer(under their upstream's license, as are the patches to metal2vulkan: GPL-2.0-or-later)docs/images/ holds screenshots of macOS running on xnulinux; the macOS interface and wallpaper in them are Apple's.diff --cc scripts/xnulinux-boot.shindex f9595cf,f1edb34..da9a39f--- a/scripts/xnulinux-boot.sh+++ b/scripts/xnulinux-boot.sh@@@ -33,13 -33,14 +33,14 @@@ if [ "${1:-}" = stop ]; then # end thefiWAIT=0; [ "${1:-}" = --wait ] && WAIT=1[ -f /etc/xnulinux.conf ] && . /etc/xnulinux.conf- [ -f /var/tmp/mac.conf ] && . /var/tmp/mac.conf+ MAC_CONF=${MAC_CONF:-/var/tmp/mac.conf} # the disk's UUIDs: mk-macvm-disk.sh's, or mk-puredarwin-disk.sh's output+ [ -f "$MAC_CONF" ] && . "$MAC_CONF"DISK=${DISK:-/var/tmp/mac.img}; RAM_MB=${RAM_MB:-7900}; GPU=${GPU:-auto}; CPUS=${CPUS:-1}CONSOLE_IN=${CONSOLE_IN:-/var/tmp/console-in}; INPUT_IN=${INPUT_IN:-/var/tmp/xnu-input}; FB_DUMP=${FB_DUMP:-/var/tmp/xnu-fb.raw}- KEYSTORE=${KEYSTORE:-/var/tmp/xnu-keystore.bin}; TRUSTCACHE=${TRUSTCACHE:-xnu/trustcache-mac.bin}; IMAGE=${IMAGE:-xnu/kc.bin}+ KEYSTORE=${KEYSTORE:-/var/tmp/xnu-keystore.bin}; TRUSTCACHE=${TRUSTCACHE-xnu/trustcache-mac.bin}; IMAGE=${IMAGE:-xnu/kc.bin}BOOTARGS=${BOOTARGS:-amfi_get_out_of_my_way=1 lp-sip0=2050}: "${ROOT_UUID:?no ROOT_UUID (/var/tmp/mac.conf from mk-macvm-disk.sh)}" "${BOOT_UUID:?no BOOT_UUID}"-lsmod | grep -q '^xnu ' && { echo "xnu.ko is loaded: a hosted system is running (sudo rmmod xnu first)" >&2; exit 1; }+[ -d /sys/module/xnu ] && { echo "xnu.ko is loaded: a hosted system is running (sudo rmmod xnu first)" >&2; exit 1; }K=/lib/modules/$(uname -r)/buildbuild() { # a module; its compiler errors on failure@@@ -128,11 -110,11 +129,11 @@@ for try in 1 2 3 4 5 6 7 8 9; dsync; echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null; echo 1 | sudo tee /proc/sys/vm/compact_memory >/dev/nullsudo dmesg -Csudo setsid nohup insmod xnu-ko/xnu.ko mode=3 cpus="$CPUS" ram_mb="$RAM_MB" image="$IMAGE" \- trustcache="$TRUSTCACHE" disk="$DISK" root_uuid="$ROOT_UUID" boot_uuid="$BOOT_UUID" preboot_uuid="$BOOT_UUID" \+ ${TRUSTCACHE:+trustcache="$TRUSTCACHE"} disk="$DISK" root_uuid="$ROOT_UUID" boot_uuid="$BOOT_UUID" preboot_uuid="$BOOT_UUID" \- console_in="$CONSOLE_IN" input_in="$INPUT_IN" fb_dump="$FB_DUMP" keystore="$KEYSTORE" bootargs="\"$BOOTARGS\"" ${XNU_ARGS:-} \+ console_in="$CONSOLE_IN" input_in="$INPUT_IN" fb_dump="$FB_DUMP" keystore="$KEYSTORE" bootargs="\"$BOOTARGS\"" "${NAMES[@]}" ${XNU_ARGS:-} \> /var/tmp/xnu-insmod.log 2>&1 < /dev/null &sleep 5- if sudo dmesg | grep -aqE "fki: carve-out .* (overlaps|is not all RAM)"; then # a configuration error: no retry+ if sudo dmesg | grep -aE "fki: carve-out .* (overlaps|is not all RAM)" >/dev/null; then # a configuration error: no retrysudo dmesg | grep -aE "fki: carve-out .* (overlaps|is not all RAM)" >&2sudo systemctl stop xnudrmd 2>/dev/null || trueexit 1