Running a AArch64 guest on a AAarch64 host using QEMU

NOTE: this entire page is now misleadingly out of date:

  • you want to use upstream QEMU, not John Rigby's WIP repo
  • use an upstream kernel, not Marc's repo
  • the QEMU command lines are out of date
  • the QEMU configure script options include --enable-tcg-interpreter, which is now actively a bad idea, and --static, which is questionable.

Building QEMU

You will need to create a raring chroot with aarch64 toolchain and other pkgs installed to build.

See https://wiki.linaro.org/Platform/DevPlatform/CrossCompile/arm64bootstrap for how to do that.

Clone the work in progress repo.

git clone git://git.linaro.org/people/jcrigby/qemu-aarch64.git --branch kvm-aarch64-wip

Create a build directory and then use the chroot created above to build in it.

cd qemu-aarch64
mkdir build-aarch64-aarch64
schroot -c raring-amd64-sbuild
cd build-aarch64-aarch64
../configure --cross-prefix=aarch64-linux-gnu- --target-list=aarch64-softmmu --enable-tcg-interpreter --enable-kvm --enable-fdt --audio-drv-list="" --static
make

Host kernel and filesystem

I used Marc Zyngier's repo git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git

For a filesystem I downloaded an image from snapshots.linaro.org: vexpress64-openembedded_minimal-armv8_20130513-328.img

Guest kernel and filesystem

I used buildroot to create a minimal root filesystem.

git clone git://git.busybox.net/buildroot
cd buildroot
make arm_foundationv8_defconfig
make menuconfig

Navigate to "Filesystem images" and turn on "cpio the root filesystem"

make
# let it build....
cp output/images/rootfs.cpio /tmp

Then for the kernel I used the same source as for the host and added an embedded init ramfs:

CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE="/tmp/rootfs.cpio"              

Running It All

Run host using foundation model

sudo ./Foundation_v8pkg/Foundation_v8 --image ~/work/kernel/maz/boot-wrapper-aarch64/linux-system-foundation.axf --block-device ./newdownloads/vexpress64-openembedded_minimal-armv8_20130513-328.img --network=bridged

An xterm will pop up in which you need to configure networking.

ifconfig eth0 10.10.10.10

Back on the host configure the other end of the bridge and test it out.

sudo ifconfig ARM0 10.10.10.11
ping 10.10.10.10

Copy guest kernel and qemu to host.

scp ~/work/kernel/maz/build-guest/arch/arm64/boot/Image root@10.10.10.10:/boot/Image-guest
scp ~/work/qemu-aarch64/build-aarch64-aarch64/aarch64-softmmu/qemu-system-aarch64 root@10.10.10.10:/usr/bin

Run qemu-system-aarch64.

qemu-system-aarch64 -M machvirt -kernel /boot/Image-guest -append 'earlyprintk=smh rdinit=/bin/sh init=/bin/sh console=ttyAMA0,38400 keep_bootcon' -enable-kvm -nographic

Limitations

  • mach-virt only supports 64 bits on aarch64
  • only one processor is supported in guest, psci support needs to be added to qemu to allow more

Platform/DevPlatform/AArch64QEMU (last modified 2014-05-09 11:15:06)