KVM Virtualization for ARMv8 Architectures
How to setup a KVM development environment for 64-bit ARM SoCs
This is a guide for KVM Virtualization on the ARMv8 architecture and illustrates how to set up a KVM development environment on ARM64 processors. It showcases how to run a guest virtual machine on top of an ARM64 host. This guide uses ARM Foundation Model to simulate ARMv8 environment.
The ARMv8 architecture introduces 64-bit support to the ARM architecture, including backward compatibility for the 32-bit software. In addition to enhancing the performance of ARM processors, the ARMv8 architecture provides low power consumption as well.
Tools are available to build software for the ARMv8 architecture: there are in fact cross-compilers for generating ARM64 binaries (some distributions such as Ubuntu include them in their own repositories) or already compiled GNU/Linux based basic filesystem images are available to boot a full system. As an alternative we can build our custom filesystem using bootstrap tools and these tools are also available in the Ubuntu repositories.
The main purpose of this guide is to demonstrate how to run a guest operating system inside an ARM64 host, powered by the Linux kernel, which can take advantage of the KVM module to virtualize guest systems. This scenario is quite common: we will have a system, called Host, which will provide the virtualization capabilities, its kernel has to be custom compiled to include all the required modules. The Guest instead, is the system virtualized by the Host and does not require any particular module in the kernel. To make things simpler, both Host and Guest will share the same architecture (ARM64) and will use the same kernel together with the same userspace.
Later in this guide we will refer to ARM64, ARMv8 or aarch64 as the same architecture.
In the following sections we will go through all of these topics, providing detailed descriptions to reach a fully functional environment, capable of virtualization and ready to be deployed on the upcoming development boards. Within this guide, we test these systems using the ARM Foundation Models, which are a very convenient way to simulate ARMv8 environment.
The steps given in this guide are based on Ubuntu 13.04 (codename Raring) system, however all the tools used herewith are also available for other Linux distributions, such as Debian and Fedora. Here is the list of required components:
64-bit ARM Cross Compiler The cross compiler used to compile toward the ARMv8 64bit architecture.
ARMv8 Foundation Model The freely available Foundation Model used to emulate an ARMv8 platform.
The following components will constitute the system that we'll simulate. Each system (Host and Guest) requires a Linux kernel including a bootloader (or bootwrapper) and a userspace image (also referred as file system).
Host and Guest 64-bit Userspace Images Userspace images for the systems we are going to run.
ARM64 Host and Guest Kernels 64-bit ARM kernels with KVM capability, which is mandatory for the Host system.
Bootwrapper Bootloader to start the host kernel.
Getting the 64-bit ARM Cross Compiler
We will use the cross compiler available in the repository of Ubuntu 13.04:
$ sudo apt-get install gcc-aarch64-linux-gnu
And test if the compiler has been correctly added to the PATH:
$ which aarch64-linux-gnu-gcc < You should get the compiler path here >
Since the previous versions of Ubuntu do not provide this package, it's necessary to add a Ubuntu Raring repository in order to install the cross compiler. This tip is still valid for any Debian derivative. Edit your /etc/apt/source.list file and append the following line:
deb http://en.archive.ubuntu.com/ubuntu/ raring universe
Then proceed with these commands to install the package:$ sudo apt-get update && sudo apt-get install gcc-aarch64-linux-gnu
Once the compiler is installed, it is highly recommended to remove the appended repository and to update again the apt index to avoid potential problems during the next upgrade of the system.
Alternatively, you can always download manually from the Ubuntu repository both the package and its dependences. At the time of writing the required packages are gcc-4.7-aarch64-linux-gnu-base, cpp-4.7-aarch64-linux-gnu, binutils-aarch64-linux-gnu, libgcc-4.7-dev-arm64-cross, libc6, libcloog-ppl1, libgmp10, libmpc2, libmpfr4, libppl-c4 and zlib1g.
ARMv8 Foundation Model
The Foundation Models provide the ARM developers with all the needed tools to run ARMv8 systems before the availability of any development board. These models are based on ARM Fast Models, and are freely available from ARM site, after registration. Once logged in, the software download URL is located at page.
Supposing that FM000-KT-00035-r0p8-52rel06.tgz is the name of the downloaded model, then we can extract it by:
$ tar -xf FM000-KT-00035-r0p8-52rel06.tgz
The Foundation Model executable "Foundation_v8" is inside the folder Foundation_v8pkg/models/Linux64_GCC-4.1/. We can add it to the PATH variable with:
$ export PATH=$PWD/Foundation_v8pkg/models/Linux64_GCC-4.1/Foundation_v8/:$PATH
Host and Guest 64-bit Userspace Images
There are various user space images you can download from the linaro repository. In this guide we are going to use the OpenEmbedded (Minimal) image (linaro-image-minimal-genericarmv8-20130526-319.rootfs.tar.gz). You can refer to this web page to try other alternatives.
Userspace NFS Image for the Host
We will use NFS to mount the userspace image for our Host. This will allow us to access the mounted filesystem from the real host machine even when the ARM Host is running.
In order to export a directory through NFS we have to install the NFS service, which is available in almost all Linux distributions. For instance, in Ubuntu, we can install the NFS service with the following command:
$ sudo apt-get install nfs-kernel-server nfs-common
An NFS root directory (/srv/nfsroot for example) has to be exported in the /etc/exports file:
This configuration exports the folder /srv/nfsroot for all the machine in the subnet 192.168.1.0/24. At this point the NFS service has been configured, so we should re-start the server process:
$ sudo service nfs-kernel-server stop $ sudo service nfs-kernel-server start
For further information about NFS refer to the official NFS-HOWTO.
Now we are ready to create the folder /srv/nfsroot which will serve the ARM Host image, then we will copy the Host filesystem into it:
$ sudo mkdir -p /srv/nfsroot/ $ sudo tar -xf linaro-image-minimal-genericarmv8-20130526-319.rootfs.tar.gz \ -C /srv/nfsroot/
To make it available through NFS, we add into /etc/exports file the following configuration:
Then we restart the NFS server:
sudo service nfs-kernel-server restart
Login or register to access full information