The existing arm64 kernels for the RPi and IMX.8 are unsuitable for use in hardware-accelerated VMs because they rely on specific CPU features (such as 64K page sizes and physical timers) which are not available on all hypervisors (such as Apple’s Hypervisor.framework). Additionally, they do not support QEMU-emulated hardware such as the ECAM-based PCIe bus nor VirtIO drivers.
Thankfully, there is a community kernel which provides all the modifications available to run fully hardware-accelerated VMs via KVM (Linux) or Hypervisor.framework (macOS) through QEMU.
Kernel Build and Installation Image
Clone and build the kernel:
cd /sys/src/9/ git/clone git://shithub.us/kws/qemu cd qemu mk
Then, on a host machine, download the MNT Reform image which is suitable as a base system (available in the Downloads section).
Create a plan9.ini which describes the QEMU configuration (this is required because the kernel does not parse device trees for memory and CPU topology), e.g. for 4 CPUs and 4GB of RAM:
console=0 *ncpu=4 *maxmem=0x140000000
Create an installation disk:
qemu-img create -f qcow2 9front.qcow2 64G
Perform an install e.g. for macOS Hypervisor.framework:
qemu-system-aarch64 -M virt-2.12,accel=hvf,gic-version=3 \ -cpu host -smp 4 -m 4G \ -device loader,file=9qemu,addr=0x40200000,force-raw=on,cpu-num=0 \ -device loader,file=plan9.ini,addr=0x40100000,force-raw=on \ -drive file=9front.reform.img,format=raw,if=none,id=reform \ -drive file=9front.qcow2,if=none,id=disk \ -device virtio-blk-pci-non-transitional,drive=reform \ -device virtio-blk-pci-non-transitional,drive=disk \ -serial stdio
virt-2.12is required because newer virt versions place ECAM is high memory which is a headache
gic-version=3is required as the kernel assumes GICv3 but QEMU defaults to GICv2
-device loaderlines place the kernel and configuration in specific regions of memory so we can avoid the use of a bootloader altogether which results in instantaneous boot times
- VirtIO devices require the
non-transistionalflag, otherwise they use the old version of the emulated device which has a broken configuration layout