Xen ARM with Virtualization Extensions/qemu-system-aarch64: Difference between revisions

From Xen
Jump to navigationJump to search
(Created page with "= QEMU AArch64 Emulator = QEMU is an Open Source GPLv2 software emulator. It can emulate a large range of machines of different architectures, including Cortex A57s based pla...")
 
No edit summary
Line 26: Line 26:
$ losetup /dev/loop0 /path/to/xenial-server-cloudimg-arm64-uefi1.img
$ losetup /dev/loop0 /path/to/xenial-server-cloudimg-arm64-uefi1.img
$ kpartx -a /dev/loop0
$ kpartx -a /dev/loop0
$ mount /dev/loop0p15 /mnt
$ mount /dev/mapper/loop0p15 /mnt


Follow [[Xen_ARM_with_Virtualization_Extensions#Building_Xen_on_ARM]] to build Xen on ARM. Then, copy the Xen on ARM efi binary to the image:
Follow [[Xen_ARM_with_Virtualization_Extensions#Building_Xen_on_ARM]] to build Xen on ARM. Then, copy the Xen on ARM efi binary to the image:
Line 53: Line 53:
-machine dumpdtb=/mnt/virt-gicv3.dtb.dtb
-machine dumpdtb=/mnt/virt-gicv3.dtb.dtb


We have written everything we need. Let's umount /mnt and proceed to download the UEFI firmware binary from Linaro: [http://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/latest/QEMU-AARCH64/RELEASE_CLANG35/QEMU_EFI.fd].
We have written everything we need to the disk image. Let's umount /mnt and proceed to download the UEFI firmware binary from Linaro: [http://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/latest/QEMU-AARCH64/RELEASE_CLANG35/QEMU_EFI.fd].





Revision as of 00:09, 24 October 2017

QEMU AArch64 Emulator

QEMU is an Open Source GPLv2 software emulator. It can emulate a large range of machines of different architectures, including Cortex A57s based platforms.

The following steps help you setup QEMU to emulate an ARM64 machine and run Xen inside it.

Build QEMU

QEMU v2.10 requires a few fixes to be able to run Xen on ARM in a nested fashion. QEMU v2.11 will likely work out of the box. For now, the simplest thing to do is to apply the appended patch. The following steps apply the patch and build QEMU:

$ git clone git://git.qemu.org/qemu.git

If you are running QEMU <= v2.10, save this patch to a text file, then:

$ patch -p1 < /path/to/Qemu-aarch64.patch

Finally build QEMU:

$ ./configure --target-list=aarch64-softmmu
$ make

Install Xen

QEMU works well with UEFI firmware for the emulated machine. To get the system working, download an Aarch64 UEFI ready distro image, like xenial-server-cloudimg-arm64-uefi1.img, then:

 $ losetup /dev/loop0 /path/to/xenial-server-cloudimg-arm64-uefi1.img
 $ kpartx -a /dev/loop0
 $ mount /dev/mapper/loop0p15 /mnt

Follow Xen_ARM_with_Virtualization_Extensions#Building_Xen_on_ARM to build Xen on ARM. Then, copy the Xen on ARM efi binary to the image:

 $ cp /path/to/xen.git/xen/xen.efi /mnt

Let's write a config file for it:

 $ vi /mnt/boot/xen.cfg

Let's use the following config:

 options=console=dtuart noreboot dom0_mem=512M
 kernel=kernel root=/dev/vda1 init=/bin/sh rw console=hvc0
 dtb=virt-gicv3.dtb

Build a Linux kernel image for Dom0 and copy the binary to /mnt/kernel.

Now we need the device tree binary. QEMU can generate one for you with the following command:

 $ /local/path/qemu.git/aarch64-softmmu/qemu-system-aarch64 \
   -machine virt,gic_version=3 \
   -machine virtualization=true \
   -cpu cortex-a57 -machine type=virt \
   -smp 4 -m 4096 -display none \
   -machine dumpdtb=/mnt/virt-gicv3.dtb.dtb

We have written everything we need to the disk image. Let's umount /mnt and proceed to download the UEFI firmware binary from Linaro: [1].


Run QEMU

The following command create a new emulated AArch64 machine with 4 Cortex A57s, 4G of RAM. The command below uses user networking in QEMU, other network configuration (bridging) are possible. Please change MAC_ADDRESS for the emulated machine and path to the guest image.

 $ /path/to/qemu.git/aarch64-softmmu/qemu-system-aarch64 \
   -machine virt,gic_version=3 \
   -machine virtualization=true \
   -cpu cortex-a57 -machine type=virt \
   -smp 4 -m 4096 -display none \
   -serial mon:stdio \
   -bios /path/to/QEMU_EFI.bin \
   -netdev user,id=hostnet0,hostfwd=tcp::2222-:22 -device virtio-net-device,netdev=hostnet0,mac=MAC_ADDRESS \
   -drive if=none,file=/path/to/xenial-server-cloudimg-arm64-uefi1.img,id=hd0 -device virtio-blk-device,drive=hd0