PeterMaydell/KVM/HowTo/KVMHostSetup - Linaro Wiki


: 4

Previous: Set up the Fast Model.

This page deals with setting up the KVM host system: a kernel and filesystem which will run under the Fast Model.

Install a cross compiler

In trusty the packages you need should all be in the (universe) archive. Install these:

gcc-4.6-arm-linux-gnueabi binutils-arm-linux-gnueabi libc6-armel-cross linux-libc-dev-armel-cross gcc-arm-linux-gnueabi libc6-dev-armel-cross cpp-arm-linux-gnueabi

Set up a guest filesystem

You'll need at least the qemu-user-static package installed for this.

$ cd /srv
$ sudo mkdir arm-trusty-root
$ sudo qemu-debootstrap --arch=armhf --include=libfdt1 trusty ./arm-trusty-root/

When it's done, you'll need to tweak some files in the chroot:

  • add 'ttyAMA0' to etc/securetty
  • copy etc/init/tty1.conf to etc/init/ttyAMA0.conf and edit it to change 'tty1' to 'ttyAMA0' everywhere
  • sudo chroot /srv/arm-trusty-root and run passwd to set root's password

  • create an etc/apt/sources.list:
deb trusty main restricted universe
deb-src trusty main restricted universe

Note that since this is a qemu-debootstrap-created directory tree you can run "sudo chroot /srv/arm-trusty-root" to chroot into it using qemu's linux-user emulation. This is particularly useful for installing random extra packages. (If you try to do anything too exciting in the chroot you may run into issues with QEMU. Sorry...)

Export the guest filesystem via NFS

You need to make sure that the guest filesystem is exported via NFS to the IP address of the host x86 system (not but its public IP address). Install nfs-kernel-server if you don't have it already, and add a line like this to /etc/exports:


(using the correct IP address, of course). Then run /etc/init.d/nfs-kernel-server reload.

If your machine changes IP address you'll need to fix /etc/exports and reload.

Get and build the kernel

We're using Marc Zyngier's kernel tree here. WARNING: this tree is temporary and unstable and rebases -- deal with it accordingly.

$ git clone git:// linux-kvm-arm
$ cd linux-kvm-arm && git checkout kvm-arm-3.5-rc3

Get the config-for-model.3.5rc3 and save it as .config.

$ make oldconfig ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-

(it is probably OK to just hit return if it prompts for anything, but use your judgement). MAKE SURE TO ENABLE 10/100 Ethernet :)

$ make -j4 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
$ make -j4 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules
$ sudo make modules_install ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=/srv/arm-trusty-root

(in fact the suggested config disables modules but the above commands will cope even if you enabled them.)

This will build the zImage into arch/arm/boot/zImage -- you may wish to copy it somewhere else and/or rename it to avoid confusion with the KVM guest kernel.

Get the boot wrapper

$ cd ..
$ git clone git://
$ cd boot-wrapper

Previous versions of the boot-wrapper required you to bake a particular kernel uImage and command line arguments into it, so you would need to rebuild it every time you changed the kernel. That is no longer required, so these instructions document how to build a single linux-system-semi.axf which you can then use for any kernel (zImage or uImage) and command line. You can build this with:

$ make CROSS_COMPILE=arm-linux-gnueabi- linux-system-semi.axf

Get a Device Tree

Recent ARM kernels require a device tree, which describes the devices in the system. You will need the device tree compiler, if you haven't already got it installed:

$ sudo apt-get install device-tree-compiler

Then you will need a device tree: these are kept in source form, and compiled into a "device tree blob" for the kernel to use:

$ cd ..
$ git clone git://
$ dtc -O dtb arm-dts/fast_models/rtsm_ve-cortex_a15x2.dts > boot-wrapper/fastmodel-a15x2.dtb

Run the model

$ ~/ARM/FastModelsPortfolio_7.0/examples/RTSM_VE/Build_Cortex-A15x2/Linux64-Release-GCC-4.1/isim_system linux-system-semi.axf -C motherboard.smsc_91c111.enabled=1 -C motherboard.hostbridge.userNetworking=1 -C cluster.cpu0.semihosting-cmd_line="--kernel /path/to/zImage --dtb fastmodel-a15x2.dtb -- console=ttyAMA0 mem=512M earlyprintk root=/dev/nfs nfsroot=,tcp rw ip=dhcp nfsrootdebug"

Substitute in the correct path to the kernel zImage (you can also use a uImage) and the NFS server's IP address. (We aren't using an initrd in this howto, but if you are then you can add '--initrd /path/to/initrd' after the '--kernel /path/to/zImage' argument.)

Note that this uses the "user networking" feature of Fast Models 7.0. Paths may differ slightly if you built a 32 bit model. If this fails to mount its root fs then you may have misconfigured your host /etc/exports.

You should confirm that you can boot the kernel under the model and get to a login prompt. Note that there will be a long (few minutes) pause between the kernel saying it is going to run init and the login prompt appearing. This is because the guest filesystem we have set up is not configured to print init's progress messages to the serial terminal.

Next: Build QEMU.