blob: fbd72bf45fbea31f73c08130f38daf366b3cbe92 [file] [log] [blame]
# AArch64 KVM Unit Test Driver
This directory contains the driver script for the AArch64 unit tests. These
scripts run the kvm-unit-tests inside an AArch64 emulator (qemu-system-aarch64).
This to enable testing KVM with virtual machines that are running natively on
the underlying system, as opposed to emulated VMs. We need this to be able to
test Protected KVM, which would be running VMs on the same architecture as the
host/hypervisor (i.e., AAarch64).
## Requirements:
- A Linux kernel image cross-compiled for AArch64. See ANDROID-KVM_DIR/linux
An example on how to build one, in the linux source:
cd ANDROID-KVM_DIR/linux
make ARCH=arm64 CROSS_COMPILE="aarch64-linux-gnu-" -j`nproc` defconfig
make ARCH=arm64 CROSS_COMPILE="aarch64-linux-gnu-" -j`nproc`
The image will be built at:
ANDROID-KVM_DIR/linux/arch/arm64/boot/Image
- KVM unit tests built as standalone. See ANDROID-KVM_DIR/kvm-unit-tests
To build these standalone tests, in the kvm-unit-tests source directory:
cd ANDROID-KVM_DIR/kvm-unit-tests
./configure --arch=arm64 --cross-prefix="aarch64-linux-gnu-"
make -j`nproc` standalone
The standalone tests will be built at:
ANDROID-KVM_DIR/kvm-unit-tests/tests
- A root file system image to boot. An image will be uploaded to
ANDROID-KVM_DIR/prebuilts. In the meantime, you can generate such an image
using Buildroot. See ANDROID-KVM_DIR/buildroot.
cd ANDROID-KVM_DIR/buildroot
make qemu_aarch64_virt_kvmunittests_defconfig
make clean all
The generated image will be at:
ANDROID-KVM_DIR/buildroot/output/images/rootfs.ext4
- QEMU with aarch64-softmmu, v5.0.0 or later
Buildroot creates one in the buildprocess. It's available at
ANDROID-KVM_DIR/buildroot/output/host/bin/qemu-system-aarch64
## Running the tests
Assuming you are using the binaries, tests, and images from above, you can run
the tests as follows:
./run_tests.sh -j `nproc` -t ANDROID-KVM_DIR/kvm-unit-tests/tests -l ANDROID-KVM_DIR/linux/arch/arm64/boot/Image -r ANDROID-KVM_DIR/buildroot/output/images/rootfs.ext4 -e ANDROID-KVM_DIR/buildroot/output/host/bin/qemu-system-aarch64