xref: /kvm-unit-tests/arm/run (revision 9fcec1db99ec896b0bad74fe66a50810379c5261)
1#!/usr/bin/env bash
2
3if [ -z "$KUT_STANDALONE" ]; then
4	if [ ! -f config.mak ]; then
5		echo "run ./configure && make first. See ./configure -h"
6		exit 2
7	fi
8	source config.mak
9	source scripts/arch-run.bash
10	source scripts/vmm.bash
11fi
12
13vmm_check_supported
14
15qemu_cpu="$TARGET_CPU"
16
17if [ "$QEMU" ] && [ -z "$ACCEL" ] &&
18   [ "$HOST" = "aarch64" ] && [ "$ARCH" = "arm" ] &&
19   [ "$(basename $QEMU)" = "qemu-system-arm" ]; then
20	ACCEL="tcg"
21fi
22
23set_qemu_accelerator || exit $?
24if [ "$ACCEL" = "kvm" ]; then
25	QEMU_ARCH=$HOST
26fi
27
28qemu=$(search_qemu_binary) ||
29	exit $?
30
31if ! $qemu -machine '?' | grep -q 'ARM Virtual Machine'; then
32	echo "$qemu doesn't support mach-virt ('-machine virt'). Exiting."
33	exit 2
34fi
35
36M='-machine virt'
37
38if [ "$ACCEL" = "kvm" ]; then
39	if $qemu $M,\? | grep -q gic-version; then
40		M+=',gic-version=host'
41	fi
42fi
43
44if [ -z "$qemu_cpu" ]; then
45	if ( [ "$ACCEL" = "kvm" ] || [ "$ACCEL" = "hvf" ] ) &&
46	   ( [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ] ); then
47		qemu_cpu="host"
48		if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; then
49			qemu_cpu+=",aarch64=off"
50		fi
51	else
52		qemu_cpu="$DEFAULT_QEMU_CPU"
53	fi
54fi
55
56if [ "$ARCH" = "arm" ]; then
57	M+=",highmem=off"
58fi
59
60if ! $qemu $M -device '?' | grep -q virtconsole; then
61	echo "$qemu doesn't support virtio-console for chr-testdev. Exiting."
62	exit 2
63fi
64
65if ! $qemu $M -chardev '?' | grep -q testdev; then
66	echo "$qemu doesn't support chr-testdev. Exiting."
67	exit 2
68fi
69
70if [ "$UEFI_SHELL_RUN" != "y" ] && [ "$EFI_USE_ACPI" != "y" ]; then
71	chr_testdev='-device virtio-serial-device'
72	chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd'
73fi
74
75pci_testdev=
76if $qemu $M -device '?' | grep -q pci-testdev; then
77	pci_testdev="-device pci-testdev"
78fi
79
80A="-accel $ACCEL$ACCEL_PROPS"
81command="$qemu -nodefaults $M $A -cpu $qemu_cpu $chr_testdev $pci_testdev"
82command+=" -display none -serial stdio"
83command="$(migration_cmd) $(timeout_cmd) $command"
84
85if [ "$UEFI_SHELL_RUN" = "y" ]; then
86	ENVIRON_DEFAULT=n run_qemu_status $command "$@"
87elif [ "$EFI_USE_ACPI" = "y" ]; then
88	run_qemu_status $command -kernel "$@"
89else
90	run_qemu $command -kernel "$@"
91fi
92