From 1531f44314c8da08d58e0aa270bac352234b348a Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Thu, 16 Jul 2020 19:14:23 -0700 Subject: [PATCH 1/2] boot-qemu.sh: Support using KVM on arm64 hardware Tested on a Raspberry Pi 4. Signed-off-by: Nathan Chancellor --- boot-qemu.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/boot-qemu.sh b/boot-qemu.sh index 3bbb367..aa2c279 100755 --- a/boot-qemu.sh +++ b/boot-qemu.sh @@ -139,8 +139,13 @@ function setup_qemu_args() { arm64) KIMAGE=Image.gz APPEND_STRING+="console=ttyAMA0 " + if [[ "$(uname -m)" = "aarch64" && -e /dev/kvm ]]; then + ARM64_CPU=host + ARM64_KVM_FLAGS=(-enable-kvm) + fi QEMU_ARCH_ARGS=( - -cpu max + "${ARM64_KVM_FLAGS[@]}" + -cpu "${ARM64_CPU:-max}" -machine virt) QEMU=(qemu-system-aarch64) ;; From e16b124c3d94c9d1181deaa64391d01a55403ac3 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Fri, 17 Jul 2020 19:43:22 -0700 Subject: [PATCH 2/2] boot-qemu.sh: Simplify x86 KVM check This brings us more in line with the AArch64 one that was just added. Signed-off-by: Nathan Chancellor --- boot-qemu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boot-qemu.sh b/boot-qemu.sh index aa2c279..bd55f1b 100755 --- a/boot-qemu.sh +++ b/boot-qemu.sh @@ -206,8 +206,8 @@ function setup_qemu_args() { x86 | x86_64) KIMAGE=bzImage APPEND_STRING+="console=ttyS0 " - # Use KVM if the processor supports it (first part) and the KVM module is loaded (second part) - [[ $(grep -c -E 'vmx|svm' /proc/cpuinfo) -gt 0 && $(lsmod 2>/dev/null | grep -c kvm) -gt 0 ]] && + # Use KVM if the processor supports it and the KVM module is loaded (i.e. /dev/kvm exists) + [[ $(grep -c -E 'vmx|svm' /proc/cpuinfo) -gt 0 && -e /dev/kvm ]] && QEMU_ARCH_ARGS=("${QEMU_ARCH_ARGS[@]}" -cpu host -d "unimp,guest_errors" -enable-kvm -smp "$(nproc)") case ${ARCH} in x86) QEMU=(qemu-system-i386) ;;