Skip to content

Commit

Permalink
boot-qemu.sh: Support using KVM on arm64 hardware (#23)
Browse files Browse the repository at this point in the history
* boot-qemu.sh: Support using KVM on arm64 hardware

Tested on a Raspberry Pi 4.

Signed-off-by: Nathan Chancellor <[email protected]>

* 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 <[email protected]>
  • Loading branch information
nathanchance authored Aug 13, 2020
1 parent 2a68826 commit 3b21a5b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions boot-qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
;;
Expand Down Expand Up @@ -201,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) ;;
Expand Down

0 comments on commit 3b21a5b

Please sign in to comment.