在基于 x86 的主机上模拟 macOS arm64e 的指南。
Use the following guide to download and configure all of the necessary tools and files for emulating the macOS arm64e kernel. The guide begins in this project's root directory, ie. the same directory as this README file.
Get, patch, and build xar:
git clone https://github.com/mackyle/xar.git
cd xar/xar
sed -i 's/OpenSSL_add_all_ciphers/OPENSSL_init_crypto/g' configure.ac
cat > ext2.patch sfr.zip
7z e -so 5.hfs "Shared Support/com_apple_MobileAsset_MacSoftwareUpdate/6c799f422b6d995ccc7f3fb669fe3246fd9f61aa.zip" > mac.zip
rm 5.hfs
7z e sfr.zip AssetData/usr/standalone/update/ramdisk/arm64eSURamDisk.dmg
7z e sfr.zip AssetData/boot/Firmware/all_flash/DeviceTree.j273aap.im4p
7z e sfr.zip AssetData/boot/kernelcache.release.j273Decode the kernel binaries:
…Build dtetool and patch the device tree file:
cd dtetool
./build.sh
./dtetool ../DeviceTree.j273aap.im4p.out -d dtediff_20C69 -o ../DeviceTree.j273aap.im4p.out.patched
cd ..This step can only be done on a macOS system. Copy the ramdisk onto a macOS system and expand it:
hdiutil resize -size 1.5G -imagekey diskimage-class=CRawDiskImage arm64eSURamDisk.dmg.outCopy the expanded ramdisk back onto the Linux system and extract the user binaries:
7z e mac.zip AssetData/Restore/022-10310-098.dmg
rm mac.zip
7z e 022-10310-098.dmg "3 - Apple_APFS"
rm 022-10310-098.dmgMount the filesystem and ramdisk to two new directories:
mkdir apfs ramdisk
apfs-fuse -o allow_other "3 - Apple_APFS" apfs
sudo mount -t hfsplus -o force,rw arm64eSURamDisk.dmg.out ramdiskTransfer the user binaries to ramdisk:
sudo cp -rn apfs/root/bin/* ramdisk/bin/
sudo cp -rn apfs/root/sbin/* ramdisk/sbin/
sudo cp -rn apfs/root/usr/bin/* ramdisk/usr/bin/
sudo cp -rn apfs/root/usr/sbin/* ramdisk/usr/sbin/Remove all existing launchd profiles and create a profile for bash:
sudo rm -rf ramdisk/System/Library/LaunchDaemons/*
cat > com.apple.bash.plist
Label
com.apple.bash
Umask
0
RunAtLoad
ProgramArguments
/bin/bash
StandardInPath
/dev/console
StandardOutPath
/dev/console
StandardErrorPath
/dev/console
POSIXSpawnType
Interactive
EnablePressuredExit
UserName
root
EOF
sudo cp com.apple.bash.plist ramdisk/System/Library/LaunchDaemons/Unmount the disk images:
sudo umount apfs ramdiskDownload, extract, and patch the QEMU 5.1.0 source:
wget https://download.qemu.org/qemu-5.1.0.tar.xz
tar xf qemu-5.1.0.tar.xz
mv qemu-5.1.0 xnu-qemu-arm64-5.1.0
git apply xnu-qemu-arm64-5.1.0.diffConfigure and build the source:
cd xnu-qemu-arm64-5.1.0
./configure --target-list=aarch64-softmmu --disable-capstone --disable-pie --disable-slirp
make -j6
cd ..Modify the -j6 option according to the number of cores on your CPU times 1.5.
Start the emulator with the following script:
./xnu-qemu-arm64-5.1.0/aarch64-softmmu/qemu-system-aarch64 \
-M macos11-j273-a12z,\
kernel-filename=kernelcache.release.j273.out,\
dtb-filename=DeviceTree.j273aap.im4p.out.patched,\
ramdisk-filename=arm64eSURamDisk.dmg.out,\
kern-cmd-args="kextlog=0xfff cpus=1 rd=md0 serial=2 -noprogress",\
xnu-ramfb=off \
-cpu max \
-m 6G \
-serial mon:stdio \
-nographic \暂无开放 Issues,或尚未同步最近议题。