From ceaa02230ee359339556a09b14d18736ac90eb12 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Fri, 2 Jun 2023 09:05:50 +0200 Subject: [PATCH] qemu: set default cpu model for x86_64 explicitly With the update to sel4 and the gcc 12, assembly instructions are generated and used, like POPCNT. The instruction is available on our native hardware, but not emulated by the default cpu model necessarily, which leads to undefined opcode exceptions (Qemu 4.2.1 && seL4). Additionally, the features of the default Qemu cpu model may vary between Qemu releases and makes it harder to correlate effects. --- repos/base/board/pc/qemu_args | 1 + tool/builddir/build.conf/run_x86 | 3 --- tool/run/power_on/qemu | 7 +++++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/repos/base/board/pc/qemu_args b/repos/base/board/pc/qemu_args index 7232ed8d4b..7c03fe4ad9 100644 --- a/repos/base/board/pc/qemu_args +++ b/repos/base/board/pc/qemu_args @@ -1,2 +1,3 @@ -machine q35 +-cpu Nehalem-v2 -net nic,model=e1000,netdev=net0 -netdev user,id=net0 diff --git a/tool/builddir/build.conf/run_x86 b/tool/builddir/build.conf/run_x86 index d07a7205ca..580de8ab81 100644 --- a/tool/builddir/build.conf/run_x86 +++ b/tool/builddir/build.conf/run_x86 @@ -24,9 +24,6 @@ QEMU_OPT += -no-kvm # use time-tested graphics backend QEMU_OPT += -display sdl -# use machine model that supports nested virtualization -QEMU_OPT(nova) += -cpu core2duo - # add kernel-specific Qemu arguments QEMU_OPT += $(QEMU_OPT(${KERNEL})) diff --git a/tool/run/power_on/qemu b/tool/run/power_on/qemu index a2b835354b..687de98385 100644 --- a/tool/run/power_on/qemu +++ b/tool/run/power_on/qemu @@ -150,6 +150,13 @@ proc run_power_on { } { if {[regexp -- {-netdev\s+user,id=(\w+)} $qemu_args dummy netdev]} { regsub -all "\\-netdev\\s+user,id=$netdev\\S*" $board_qemu_args "" board_qemu_args } + ## + # If -cpu is specified by qemu_args, remove -cpu from board_qemu_args to + # support overwriting it, e.g. used for virtualization scenarios + # + if {[regexp -- {-cpu\s+} $qemu_args dummy]} { + regsub -all {\-cpu\s+\S*} $board_qemu_args "" board_qemu_args } + # append custom board-specific qemu_args append qemu_args " $board_qemu_args"