@@ -13,7 +13,6 @@ legacy_pmem_size="2" #in GiB
13
13
pmem_size=" 16384" # in MiB
14
14
pmem_label_size=2 # in MiB
15
15
pmem_final_size=" $(( pmem_size + pmem_label_size)) "
16
- : " ${qemu:= qemu-system-x86_64} "
17
16
: " ${gdb:= gdb} "
18
17
: " ${ndctl:= $(readlink -e ~/ git/ ndctl)} "
19
18
selftests_home=root/built-selftests
@@ -89,6 +88,47 @@ fail()
89
88
exit 1
90
89
}
91
90
91
+ set_qemu_machine ()
92
+ {
93
+ # In the future we could override this with some new --qmachine option
94
+ # ARG_OPTIONAL_SINGLE([qmachine] ...
95
+ case " ${host_arch} " in
96
+ x86_64)
97
+ qemu_machine=q35
98
+ ;;
99
+ aarch64)
100
+ qemu_machine=virt
101
+ ;;
102
+ * ) fail ' Unknown host architecture %s' " ${host_arch} " ;;
103
+ esac
104
+ }
105
+
106
+ # If this grows too big, switch to sourcing separate ${qemu_machine}.sh files
107
+ set_guest_params ()
108
+ {
109
+ case " ${qemu_machine} " in
110
+ q35)
111
+ guest_arch_toolchain=x86_64
112
+ guest_arch_linux=x86_64
113
+ ;;
114
+ virt)
115
+ guest_arch_toolchain=aarch64
116
+ guest_arch_linux=arm64
117
+ ;;
118
+ * )
119
+ fail " Unknown QEMU machine=%s" " $qemu_machine " ;;
120
+ esac
121
+ machine_args=(" ${qemu_machine} " )
122
+ test -n " $qemu " || qemu=qemu-system-" $guest_arch_linux "
123
+ }
124
+
125
+ arch_init ()
126
+ {
127
+ host_arch=$( uname -m)
128
+ set_qemu_machine
129
+ set_guest_params
130
+ }
131
+
92
132
script_dir=" $( cd " $( dirname " $( readlink -e " ${BASH_SOURCE[0]} " ) " ) " && pwd) "
93
133
parser_generator=" ${script_dir} /parser_generator.m4"
94
134
parser_lib=" ${script_dir} /run_qemu_parser.sh"
@@ -329,6 +369,9 @@ process_options_logic()
329
369
if [[ $_arg_debug == " on" ]]; then
330
370
set -x
331
371
fi
372
+
373
+ arch_init
374
+
332
375
if [[ $_arg_cxl_test_run == " on" ]]; then
333
376
_arg_cxl_debug=" on"
334
377
_arg_cxl_test=" on"
@@ -452,7 +495,7 @@ make_install_kernel()
452
495
exit 1
453
496
}
454
497
455
- cat arch/x86_64 /boot/bzImage > " $inst_path " /vmlinuz-" $kver "
498
+ cat arch/" ${guest_arch_linux} " /boot/* Image > " $inst_path " /vmlinuz-" $kver "
456
499
cp System.map " $inst_path " /System.map-" $kver "
457
500
ln -fs vmlinuz-" $kver " " $inst_path " /vmlinuz
458
501
ln -fs System.map-" $kver " " $inst_path " /System.map
@@ -934,7 +977,9 @@ __update_existing_rootfs()
934
977
local _trace_sh=' -x'
935
978
fi
936
979
# shellcheck disable=SC2086
937
- sudo -E bash $_trace_sh -e -c " $( declare -f make_install_kernel) ; kver=$kver make_install_kernel $inst_path "
980
+ sudo -E bash $_trace_sh -e -c " $( declare -f make_install_kernel) ;
981
+ kver=$kver guest_arch_linux=$guest_arch_linux
982
+ make_install_kernel $inst_path "
938
983
939
984
if [[ $_arg_cxl_test == " off" ]]; then
940
985
sudo rm -f " $inst_prefix " /usr/lib/modules/" $kver " /extra/cxl_* .ko
@@ -1524,7 +1569,7 @@ prepare_qcmd()
1524
1569
if [[ $_arg_kvm = " off" ]]; then
1525
1570
accel=" tcg" # the default
1526
1571
fi
1527
- machine_args=( " q35 " " accel=$accel " )
1572
+ machine_args+=( " accel=$accel " )
1528
1573
if [[ " $num_pmems " -gt 0 ]]; then
1529
1574
machine_args+=(" nvdimm=on" )
1530
1575
fi
0 commit comments