public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH v3 0/5] arm64: Change the default QEMU CPU type to "max"
@ 2025-03-25 16:00 Jean-Philippe Brucker
  2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 1/5] configure: arm64: Don't display 'aarch64' as the default architecture Jean-Philippe Brucker
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Jean-Philippe Brucker @ 2025-03-25 16:00 UTC (permalink / raw)
  To: andrew.jones, alexandru.elisei
  Cc: eric.auger, kvmarm, kvm, kvm-riscv, vladimir.murzin,
	Jean-Philippe Brucker

This is v3 of the series that cleans up the configure flags and sets the
default CPU type to "max" on arm64, in order to test the latest Arm
features.

Since v2 [1] I moved the CPU selection to ./configure, and improved the
help text. Unfortunately I couldn't keep most of the Review tags since
there were small changes all over.

[1] https://lore.kernel.org/all/20250314154904.3946484-2-jean-philippe@linaro.org/

Alexandru Elisei (3):
  configure: arm64: Don't display 'aarch64' as the default architecture
  configure: arm/arm64: Display the correct default processor
  arm64: Implement the ./configure --processor option

Jean-Philippe Brucker (2):
  configure: Add --qemu-cpu option
  arm64: Use -cpu max as the default for TCG

 scripts/mkstandalone.sh |  3 ++-
 arm/run                 | 15 ++++++-----
 riscv/run               |  8 +++---
 configure               | 55 +++++++++++++++++++++++++++++++++++------
 arm/Makefile.arm        |  1 -
 arm/Makefile.common     |  1 +
 6 files changed, 63 insertions(+), 20 deletions(-)

-- 
2.49.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [kvm-unit-tests PATCH v3 1/5] configure: arm64: Don't display 'aarch64' as the default architecture
  2025-03-25 16:00 [kvm-unit-tests PATCH v3 0/5] arm64: Change the default QEMU CPU type to "max" Jean-Philippe Brucker
@ 2025-03-25 16:00 ` Jean-Philippe Brucker
  2025-03-27 17:11   ` Alexandru Elisei
  2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 2/5] configure: arm/arm64: Display the correct default processor Jean-Philippe Brucker
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Jean-Philippe Brucker @ 2025-03-25 16:00 UTC (permalink / raw)
  To: andrew.jones, alexandru.elisei
  Cc: eric.auger, kvmarm, kvm, kvm-riscv, vladimir.murzin,
	Jean-Philippe Brucker

From: Alexandru Elisei <alexandru.elisei@arm.com>

--arch=aarch64, intentional or not, has been supported since the initial
arm64 support, commit 39ac3f8494be ("arm64: initial drop"). However,
"aarch64" does not show up in the list of supported architectures, but
it's displayed as the default architecture if doing ./configure --help
on an arm64 machine.

Keep everything consistent and make sure that the default value for
$arch is "arm64", but still allow --arch=aarch64, in case they are users
that use this configuration for kvm-unit-tests.

The help text for --arch changes from:

   --arch=ARCH            architecture to compile for (aarch64). ARCH can be one of:
                           arm, arm64, i386, ppc64, riscv32, riscv64, s390x, x86_64

to:

    --arch=ARCH            architecture to compile for (arm64). ARCH can be one of:
                           arm, arm64, i386, ppc64, riscv32, riscv64, s390x, x86_64

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
 configure | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure b/configure
index 52904d3a..010c68ff 100755
--- a/configure
+++ b/configure
@@ -43,6 +43,7 @@ else
 fi
 
 usage() {
+    [ "$arch" = "aarch64" ] && arch="arm64"
     cat <<-EOF
 	Usage: $0 [options]
 
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [kvm-unit-tests PATCH v3 2/5] configure: arm/arm64: Display the correct default processor
  2025-03-25 16:00 [kvm-unit-tests PATCH v3 0/5] arm64: Change the default QEMU CPU type to "max" Jean-Philippe Brucker
  2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 1/5] configure: arm64: Don't display 'aarch64' as the default architecture Jean-Philippe Brucker
@ 2025-03-25 16:00 ` Jean-Philippe Brucker
  2025-03-27 17:11   ` Alexandru Elisei
  2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 3/5] arm64: Implement the ./configure --processor option Jean-Philippe Brucker
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Jean-Philippe Brucker @ 2025-03-25 16:00 UTC (permalink / raw)
  To: andrew.jones, alexandru.elisei
  Cc: eric.auger, kvmarm, kvm, kvm-riscv, vladimir.murzin,
	Jean-Philippe Brucker

From: Alexandru Elisei <alexandru.elisei@arm.com>

The help text for the --processor option displays the architecture name as
the default processor type. But the default for arm is cortex-a15, and for
arm64 is cortex-a57. Teach configure to display the correct default
processor type for these two architectures.

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
 configure | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index 010c68ff..b4875ef3 100755
--- a/configure
+++ b/configure
@@ -5,6 +5,24 @@ if [ -z "${BASH_VERSINFO[0]}" ] || [ "${BASH_VERSINFO[0]}" -lt 4 ] ; then
     exit 1
 fi
 
+# Return the default CPU type to compile for
+function get_default_processor()
+{
+    local arch="$1"
+
+    case "$arch" in
+    "arm")
+        echo "cortex-a15"
+        ;;
+    "arm64")
+        echo "cortex-a57"
+        ;;
+    *)
+        echo "$arch"
+        ;;
+    esac
+}
+
 srcdir=$(cd "$(dirname "$0")"; pwd)
 prefix=/usr/local
 cc=gcc
@@ -44,13 +62,14 @@ fi
 
 usage() {
     [ "$arch" = "aarch64" ] && arch="arm64"
+    [ -z "$processor" ] && processor=$(get_default_processor $arch)
     cat <<-EOF
 	Usage: $0 [options]
 
 	Options include:
 	    --arch=ARCH            architecture to compile for ($arch). ARCH can be one of:
 	                           arm, arm64, i386, ppc64, riscv32, riscv64, s390x, x86_64
-	    --processor=PROCESSOR  processor to compile for ($arch)
+	    --processor=PROCESSOR  processor to compile for ($processor)
 	    --target=TARGET        target platform that the tests will be running on (qemu or
 	                           kvmtool, default is qemu) (arm/arm64 only)
 	    --cross-prefix=PREFIX  cross compiler prefix
@@ -326,13 +345,8 @@ if [ "$earlycon" ]; then
     fi
 fi
 
-[ -z "$processor" ] && processor="$arch"
-
-if [ "$processor" = "arm64" ]; then
-    processor="cortex-a57"
-elif [ "$processor" = "arm" ]; then
-    processor="cortex-a15"
-fi
+# $arch will have changed when cross-compiling.
+[ -z "$processor" ] && processor=$(get_default_processor $arch)
 
 if [ "$arch" = "i386" ] || [ "$arch" = "x86_64" ]; then
     testdir=x86
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [kvm-unit-tests PATCH v3 3/5] arm64: Implement the ./configure --processor option
  2025-03-25 16:00 [kvm-unit-tests PATCH v3 0/5] arm64: Change the default QEMU CPU type to "max" Jean-Philippe Brucker
  2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 1/5] configure: arm64: Don't display 'aarch64' as the default architecture Jean-Philippe Brucker
  2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 2/5] configure: arm/arm64: Display the correct default processor Jean-Philippe Brucker
@ 2025-03-25 16:00 ` Jean-Philippe Brucker
  2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 4/5] configure: Add --qemu-cpu option Jean-Philippe Brucker
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Jean-Philippe Brucker @ 2025-03-25 16:00 UTC (permalink / raw)
  To: andrew.jones, alexandru.elisei
  Cc: eric.auger, kvmarm, kvm, kvm-riscv, vladimir.murzin,
	Jean-Philippe Brucker

From: Alexandru Elisei <alexandru.elisei@arm.com>

The help text for the ./configure --processor option says:

    --processor=PROCESSOR  processor to compile for (cortex-a57)

but, unlike arm, the build system does not pass a -mcpu argument to the
compiler. Fix it, and bring arm64 at parity with arm.

Note that this introduces a regression, which is also present on arm: if
the --processor argument is something that the compiler doesn't understand,
but qemu does (like 'max'), then compilation fails. This will be fixed in a
following patch; another fix is to specify a CPU model that gcc implements
by using --cflags=-mcpu=<cpu>.

Reviewed-by: Andrew Jones <andrew.jones@linux.dev>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
 arm/Makefile.arm    | 1 -
 arm/Makefile.common | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/arm/Makefile.arm b/arm/Makefile.arm
index 7fd39f3a..d6250b7f 100644
--- a/arm/Makefile.arm
+++ b/arm/Makefile.arm
@@ -12,7 +12,6 @@ $(error Cannot build arm32 tests as EFI apps)
 endif
 
 CFLAGS += $(machine)
-CFLAGS += -mcpu=$(PROCESSOR)
 CFLAGS += -mno-unaligned-access
 
 ifeq ($(TARGET),qemu)
diff --git a/arm/Makefile.common b/arm/Makefile.common
index f828dbe0..a5d97bcf 100644
--- a/arm/Makefile.common
+++ b/arm/Makefile.common
@@ -25,6 +25,7 @@ AUXFLAGS ?= 0x0
 # stack.o relies on frame pointers.
 KEEP_FRAME_POINTER := y
 
+CFLAGS += -mcpu=$(PROCESSOR)
 CFLAGS += -std=gnu99
 CFLAGS += -ffreestanding
 CFLAGS += -O2
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [kvm-unit-tests PATCH v3 4/5] configure: Add --qemu-cpu option
  2025-03-25 16:00 [kvm-unit-tests PATCH v3 0/5] arm64: Change the default QEMU CPU type to "max" Jean-Philippe Brucker
                   ` (2 preceding siblings ...)
  2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 3/5] arm64: Implement the ./configure --processor option Jean-Philippe Brucker
@ 2025-03-25 16:00 ` Jean-Philippe Brucker
  2025-03-27  8:25   ` Andrew Jones
  2025-03-27 17:14   ` Alexandru Elisei
  2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 5/5] arm64: Use -cpu max as the default for TCG Jean-Philippe Brucker
  2025-03-26 18:51 ` [kvm-unit-tests PATCH v3 0/5] arm64: Change the default QEMU CPU type to "max" Andrew Jones
  5 siblings, 2 replies; 13+ messages in thread
From: Jean-Philippe Brucker @ 2025-03-25 16:00 UTC (permalink / raw)
  To: andrew.jones, alexandru.elisei
  Cc: eric.auger, kvmarm, kvm, kvm-riscv, vladimir.murzin,
	Jean-Philippe Brucker

Add the --qemu-cpu option to let users set the CPU type to run on.
At the moment --processor allows to set both GCC -mcpu flag and QEMU
-cpu. On Arm we'd like to pass `-cpu max` to QEMU in order to enable all
the TCG features by default, and it could also be nice to let users
modify the CPU capabilities by setting extra -cpu options.  Since GCC
-mcpu doesn't accept "max" or "host", separate the compiler and QEMU
arguments.

`--processor` is now exclusively for compiler options, as indicated by
its documentation ("processor to compile for"). So use $QEMU_CPU on
RISC-V as well.

Suggested-by: Andrew Jones <andrew.jones@linux.dev>
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
 scripts/mkstandalone.sh |  3 ++-
 arm/run                 | 15 +++++++++------
 riscv/run               |  8 ++++----
 configure               | 24 ++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 11 deletions(-)

diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
index 2318a85f..9b4f983d 100755
--- a/scripts/mkstandalone.sh
+++ b/scripts/mkstandalone.sh
@@ -42,7 +42,8 @@ generate_test ()
 
 	config_export ARCH
 	config_export ARCH_NAME
-	config_export PROCESSOR
+	config_export QEMU_CPU
+	config_export DEFAULT_QEMU_CPU
 
 	echo "echo BUILD_HEAD=$(cat build-head)"
 
diff --git a/arm/run b/arm/run
index efdd44ce..4675398f 100755
--- a/arm/run
+++ b/arm/run
@@ -8,7 +8,7 @@ if [ -z "$KUT_STANDALONE" ]; then
 	source config.mak
 	source scripts/arch-run.bash
 fi
-processor="$PROCESSOR"
+qemu_cpu="$QEMU_CPU"
 
 if [ "$QEMU" ] && [ -z "$ACCEL" ] &&
    [ "$HOST" = "aarch64" ] && [ "$ARCH" = "arm" ] &&
@@ -37,12 +37,15 @@ if [ "$ACCEL" = "kvm" ]; then
 	fi
 fi
 
-if [ "$ACCEL" = "kvm" ] || [ "$ACCEL" = "hvf" ]; then
-	if [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ]; then
-		processor="host"
+if [ -z "$qemu_cpu" ]; then
+	if ( [ "$ACCEL" = "kvm" ] || [ "$ACCEL" = "hvf" ] ) &&
+	   ( [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ] ); then
+		qemu_cpu="host"
 		if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; then
-			processor+=",aarch64=off"
+			qemu_cpu+=",aarch64=off"
 		fi
+	else
+		qemu_cpu="$DEFAULT_QEMU_CPU"
 	fi
 fi
 
@@ -71,7 +74,7 @@ if $qemu $M -device '?' | grep -q pci-testdev; then
 fi
 
 A="-accel $ACCEL$ACCEL_PROPS"
-command="$qemu -nodefaults $M $A -cpu $processor $chr_testdev $pci_testdev"
+command="$qemu -nodefaults $M $A -cpu $qemu_cpu $chr_testdev $pci_testdev"
 command+=" -display none -serial stdio"
 command="$(migration_cmd) $(timeout_cmd) $command"
 
diff --git a/riscv/run b/riscv/run
index e2f5a922..02fcf0c0 100755
--- a/riscv/run
+++ b/riscv/run
@@ -11,12 +11,12 @@ fi
 
 # Allow user overrides of some config.mak variables
 mach=$MACHINE_OVERRIDE
-processor=$PROCESSOR_OVERRIDE
+qemu_cpu=$QEMU_CPU_OVERRIDE
 firmware=$FIRMWARE_OVERRIDE
 
-[ "$PROCESSOR" = "$ARCH" ] && PROCESSOR="max"
+[ -z "$QEMU_CPU" ] && QEMU_CPU="max"
 : "${mach:=virt}"
-: "${processor:=$PROCESSOR}"
+: "${qemu_cpu:=$QEMU_CPU}"
 : "${firmware:=$FIRMWARE}"
 [ "$firmware" ] && firmware="-bios $firmware"
 
@@ -32,7 +32,7 @@ fi
 mach="-machine $mach"
 
 command="$qemu -nodefaults -nographic -serial mon:stdio"
-command+=" $mach $acc $firmware -cpu $processor "
+command+=" $mach $acc $firmware -cpu $qemu_cpu "
 command="$(migration_cmd) $(timeout_cmd) $command"
 
 if [ "$UEFI_SHELL_RUN" = "y" ]; then
diff --git a/configure b/configure
index b4875ef3..b79145a5 100755
--- a/configure
+++ b/configure
@@ -23,6 +23,21 @@ function get_default_processor()
     esac
 }
 
+# Return the default CPU type to run on
+function get_default_qemu_cpu()
+{
+    local arch="$1"
+
+    case "$arch" in
+    "arm")
+        echo "cortex-a15"
+        ;;
+    "arm64")
+        echo "cortex-a57"
+        ;;
+    esac
+}
+
 srcdir=$(cd "$(dirname "$0")"; pwd)
 prefix=/usr/local
 cc=gcc
@@ -52,6 +67,7 @@ earlycon=
 console=
 efi=
 efi_direct=
+qemu_cpu=
 
 # Enable -Werror by default for git repositories only (i.e. developer builds)
 if [ -e "$srcdir"/.git ]; then
@@ -70,6 +86,9 @@ usage() {
 	    --arch=ARCH            architecture to compile for ($arch). ARCH can be one of:
 	                           arm, arm64, i386, ppc64, riscv32, riscv64, s390x, x86_64
 	    --processor=PROCESSOR  processor to compile for ($processor)
+	    --qemu-cpu=CPU         the CPU model to run on. If left unset, the run script
+	                           selects the best value based on the host system and the
+	                           test configuration.
 	    --target=TARGET        target platform that the tests will be running on (qemu or
 	                           kvmtool, default is qemu) (arm/arm64 only)
 	    --cross-prefix=PREFIX  cross compiler prefix
@@ -146,6 +165,9 @@ while [[ $optno -le $argc ]]; do
         --processor)
 	    processor="$arg"
 	    ;;
+	--qemu-cpu)
+	    qemu_cpu="$arg"
+	    ;;
 	--target)
 	    target="$arg"
 	    ;;
@@ -471,6 +493,8 @@ ARCH=$arch
 ARCH_NAME=$arch_name
 ARCH_LIBDIR=$arch_libdir
 PROCESSOR=$processor
+QEMU_CPU=$qemu_cpu
+DEFAULT_QEMU_CPU=$(get_default_qemu_cpu $arch)
 CC=$cc
 CFLAGS=$cflags
 LD=$cross_prefix$ld
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [kvm-unit-tests PATCH v3 5/5] arm64: Use -cpu max as the default for TCG
  2025-03-25 16:00 [kvm-unit-tests PATCH v3 0/5] arm64: Change the default QEMU CPU type to "max" Jean-Philippe Brucker
                   ` (3 preceding siblings ...)
  2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 4/5] configure: Add --qemu-cpu option Jean-Philippe Brucker
@ 2025-03-25 16:00 ` Jean-Philippe Brucker
  2025-03-26 18:51 ` [kvm-unit-tests PATCH v3 0/5] arm64: Change the default QEMU CPU type to "max" Andrew Jones
  5 siblings, 0 replies; 13+ messages in thread
From: Jean-Philippe Brucker @ 2025-03-25 16:00 UTC (permalink / raw)
  To: andrew.jones, alexandru.elisei
  Cc: eric.auger, kvmarm, kvm, kvm-riscv, vladimir.murzin,
	Jean-Philippe Brucker

In order to test all the latest features, default to "max" as the QEMU
CPU type on arm64. Leave the default 32-bit CPU as cortex-a15, because
that allows running the 32-bit tests with both qemu-system-arm, and with
qemu-system-aarch64 whose default "max" CPU doesn't boot in 32-bit mode.

Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index b79145a5..b86ccc0c 100755
--- a/configure
+++ b/configure
@@ -33,7 +33,7 @@ function get_default_qemu_cpu()
         echo "cortex-a15"
         ;;
     "arm64")
-        echo "cortex-a57"
+        echo "max"
         ;;
     esac
 }
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [kvm-unit-tests PATCH v3 0/5] arm64: Change the default QEMU CPU type to "max"
  2025-03-25 16:00 [kvm-unit-tests PATCH v3 0/5] arm64: Change the default QEMU CPU type to "max" Jean-Philippe Brucker
                   ` (4 preceding siblings ...)
  2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 5/5] arm64: Use -cpu max as the default for TCG Jean-Philippe Brucker
@ 2025-03-26 18:51 ` Andrew Jones
  2025-03-27 17:17   ` Alexandru Elisei
  5 siblings, 1 reply; 13+ messages in thread
From: Andrew Jones @ 2025-03-26 18:51 UTC (permalink / raw)
  To: Jean-Philippe Brucker
  Cc: alexandru.elisei, eric.auger, kvmarm, kvm, kvm-riscv,
	vladimir.murzin

On Tue, Mar 25, 2025 at 04:00:28PM +0000, Jean-Philippe Brucker wrote:
> This is v3 of the series that cleans up the configure flags and sets the
> default CPU type to "max" on arm64, in order to test the latest Arm
> features.
> 
> Since v2 [1] I moved the CPU selection to ./configure, and improved the
> help text. Unfortunately I couldn't keep most of the Review tags since
> there were small changes all over.
> 
> [1] https://lore.kernel.org/all/20250314154904.3946484-2-jean-philippe@linaro.org/
> 
> Alexandru Elisei (3):
>   configure: arm64: Don't display 'aarch64' as the default architecture
>   configure: arm/arm64: Display the correct default processor
>   arm64: Implement the ./configure --processor option
> 
> Jean-Philippe Brucker (2):
>   configure: Add --qemu-cpu option
>   arm64: Use -cpu max as the default for TCG
> 
>  scripts/mkstandalone.sh |  3 ++-
>  arm/run                 | 15 ++++++-----
>  riscv/run               |  8 +++---
>  configure               | 55 +++++++++++++++++++++++++++++++++++------
>  arm/Makefile.arm        |  1 -
>  arm/Makefile.common     |  1 +
>  6 files changed, 63 insertions(+), 20 deletions(-)
> 
> -- 
> 2.49.0

Thanks Jean-Philippe. I'll let Alex and Eric give it another look, but
LGTM.

drew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [kvm-unit-tests PATCH v3 4/5] configure: Add --qemu-cpu option
  2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 4/5] configure: Add --qemu-cpu option Jean-Philippe Brucker
@ 2025-03-27  8:25   ` Andrew Jones
  2025-03-27 17:14   ` Alexandru Elisei
  1 sibling, 0 replies; 13+ messages in thread
From: Andrew Jones @ 2025-03-27  8:25 UTC (permalink / raw)
  To: Jean-Philippe Brucker
  Cc: alexandru.elisei, eric.auger, kvmarm, kvm, kvm-riscv,
	vladimir.murzin

On Tue, Mar 25, 2025 at 04:00:32PM +0000, Jean-Philippe Brucker wrote:
> Add the --qemu-cpu option to let users set the CPU type to run on.
> At the moment --processor allows to set both GCC -mcpu flag and QEMU
> -cpu. On Arm we'd like to pass `-cpu max` to QEMU in order to enable all
> the TCG features by default, and it could also be nice to let users
> modify the CPU capabilities by setting extra -cpu options.  Since GCC
> -mcpu doesn't accept "max" or "host", separate the compiler and QEMU
> arguments.
> 
> `--processor` is now exclusively for compiler options, as indicated by
> its documentation ("processor to compile for"). So use $QEMU_CPU on
> RISC-V as well.
> 
> Suggested-by: Andrew Jones <andrew.jones@linux.dev>
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
> ---
>  scripts/mkstandalone.sh |  3 ++-
>  arm/run                 | 15 +++++++++------
>  riscv/run               |  8 ++++----
>  configure               | 24 ++++++++++++++++++++++++
>  4 files changed, 39 insertions(+), 11 deletions(-)
> 
> diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
> index 2318a85f..9b4f983d 100755
> --- a/scripts/mkstandalone.sh
> +++ b/scripts/mkstandalone.sh
> @@ -42,7 +42,8 @@ generate_test ()
>  
>  	config_export ARCH
>  	config_export ARCH_NAME
> -	config_export PROCESSOR
> +	config_export QEMU_CPU
> +	config_export DEFAULT_QEMU_CPU
>  
>  	echo "echo BUILD_HEAD=$(cat build-head)"
>  
> diff --git a/arm/run b/arm/run
> index efdd44ce..4675398f 100755
> --- a/arm/run
> +++ b/arm/run
> @@ -8,7 +8,7 @@ if [ -z "$KUT_STANDALONE" ]; then
>  	source config.mak
>  	source scripts/arch-run.bash
>  fi
> -processor="$PROCESSOR"
> +qemu_cpu="$QEMU_CPU"
>  
>  if [ "$QEMU" ] && [ -z "$ACCEL" ] &&
>     [ "$HOST" = "aarch64" ] && [ "$ARCH" = "arm" ] &&
> @@ -37,12 +37,15 @@ if [ "$ACCEL" = "kvm" ]; then
>  	fi
>  fi
>  
> -if [ "$ACCEL" = "kvm" ] || [ "$ACCEL" = "hvf" ]; then
> -	if [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ]; then
> -		processor="host"
> +if [ -z "$qemu_cpu" ]; then
> +	if ( [ "$ACCEL" = "kvm" ] || [ "$ACCEL" = "hvf" ] ) &&
> +	   ( [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ] ); then
> +		qemu_cpu="host"
>  		if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; then
> -			processor+=",aarch64=off"
> +			qemu_cpu+=",aarch64=off"
>  		fi
> +	else
> +		qemu_cpu="$DEFAULT_QEMU_CPU"
>  	fi
>  fi
>  
> @@ -71,7 +74,7 @@ if $qemu $M -device '?' | grep -q pci-testdev; then
>  fi
>  
>  A="-accel $ACCEL$ACCEL_PROPS"
> -command="$qemu -nodefaults $M $A -cpu $processor $chr_testdev $pci_testdev"
> +command="$qemu -nodefaults $M $A -cpu $qemu_cpu $chr_testdev $pci_testdev"
>  command+=" -display none -serial stdio"
>  command="$(migration_cmd) $(timeout_cmd) $command"
>  
> diff --git a/riscv/run b/riscv/run
> index e2f5a922..02fcf0c0 100755
> --- a/riscv/run
> +++ b/riscv/run
> @@ -11,12 +11,12 @@ fi
>  
>  # Allow user overrides of some config.mak variables
>  mach=$MACHINE_OVERRIDE
> -processor=$PROCESSOR_OVERRIDE
> +qemu_cpu=$QEMU_CPU_OVERRIDE
>  firmware=$FIRMWARE_OVERRIDE
>  
> -[ "$PROCESSOR" = "$ARCH" ] && PROCESSOR="max"
> +[ -z "$QEMU_CPU" ] && QEMU_CPU="max"
>  : "${mach:=virt}"
> -: "${processor:=$PROCESSOR}"
> +: "${qemu_cpu:=$QEMU_CPU}"
>  : "${firmware:=$FIRMWARE}"
>  [ "$firmware" ] && firmware="-bios $firmware"
>  
> @@ -32,7 +32,7 @@ fi
>  mach="-machine $mach"
>  
>  command="$qemu -nodefaults -nographic -serial mon:stdio"
> -command+=" $mach $acc $firmware -cpu $processor "
> +command+=" $mach $acc $firmware -cpu $qemu_cpu "
>  command="$(migration_cmd) $(timeout_cmd) $command"
>  
>  if [ "$UEFI_SHELL_RUN" = "y" ]; then
> diff --git a/configure b/configure
> index b4875ef3..b79145a5 100755
> --- a/configure
> +++ b/configure
> @@ -23,6 +23,21 @@ function get_default_processor()
>      esac
>  }
>  
> +# Return the default CPU type to run on
> +function get_default_qemu_cpu()
> +{
> +    local arch="$1"
> +
> +    case "$arch" in
> +    "arm")
> +        echo "cortex-a15"
> +        ;;
> +    "arm64")
> +        echo "cortex-a57"
> +        ;;
> +    esac
> +}
> +
>  srcdir=$(cd "$(dirname "$0")"; pwd)
>  prefix=/usr/local
>  cc=gcc
> @@ -52,6 +67,7 @@ earlycon=
>  console=
>  efi=
>  efi_direct=
> +qemu_cpu=
>  
>  # Enable -Werror by default for git repositories only (i.e. developer builds)
>  if [ -e "$srcdir"/.git ]; then
> @@ -70,6 +86,9 @@ usage() {
>  	    --arch=ARCH            architecture to compile for ($arch). ARCH can be one of:
>  	                           arm, arm64, i386, ppc64, riscv32, riscv64, s390x, x86_64
>  	    --processor=PROCESSOR  processor to compile for ($processor)
> +	    --qemu-cpu=CPU         the CPU model to run on. If left unset, the run script
> +	                           selects the best value based on the host system and the
> +	                           test configuration.

I'm starting to think we should name this '--target-cpu'. We already have
'--target' which allows us to change the target to kvmtool and we may
support other emulators/vmms someday. riscv kvmtool is already gaining
support for different cpu types[1] and other vmms we add may have that
support as well. There's no reason to add a separate configure command
line option for each.

So let's rename QEMU_CPU to TARGET_CPU, but keep DEFAULT_QEMU_CPU as it
is, since that's qemu specific. run scripts will need to check TARGET
is "qemu" to decide if it should use DEFAULT_QEMU_CPU when TARGET_CPU
isn't set. Since TARGET is currently arm-only we can drop the riscv
changes from this patch. I can do them with a follow-on series.

[1] https://lore.kernel.org/all/20250326065644.73765-1-apatel@ventanamicro.com/

Thanks,
drew

>  	    --target=TARGET        target platform that the tests will be running on (qemu or
>  	                           kvmtool, default is qemu) (arm/arm64 only)
>  	    --cross-prefix=PREFIX  cross compiler prefix
> @@ -146,6 +165,9 @@ while [[ $optno -le $argc ]]; do
>          --processor)
>  	    processor="$arg"
>  	    ;;
> +	--qemu-cpu)
> +	    qemu_cpu="$arg"
> +	    ;;
>  	--target)
>  	    target="$arg"
>  	    ;;
> @@ -471,6 +493,8 @@ ARCH=$arch
>  ARCH_NAME=$arch_name
>  ARCH_LIBDIR=$arch_libdir
>  PROCESSOR=$processor
> +QEMU_CPU=$qemu_cpu
> +DEFAULT_QEMU_CPU=$(get_default_qemu_cpu $arch)
>  CC=$cc
>  CFLAGS=$cflags
>  LD=$cross_prefix$ld
> -- 
> 2.49.0
> 
> 
> -- 
> kvm-riscv mailing list
> kvm-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kvm-riscv

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [kvm-unit-tests PATCH v3 1/5] configure: arm64: Don't display 'aarch64' as the default architecture
  2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 1/5] configure: arm64: Don't display 'aarch64' as the default architecture Jean-Philippe Brucker
@ 2025-03-27 17:11   ` Alexandru Elisei
  0 siblings, 0 replies; 13+ messages in thread
From: Alexandru Elisei @ 2025-03-27 17:11 UTC (permalink / raw)
  To: Jean-Philippe Brucker
  Cc: andrew.jones, eric.auger, kvmarm, kvm, kvm-riscv, vladimir.murzin

Hi Jean-Philippe

On Tue, Mar 25, 2025 at 04:00:29PM +0000, Jean-Philippe Brucker wrote:
> From: Alexandru Elisei <alexandru.elisei@arm.com>
> 
> --arch=aarch64, intentional or not, has been supported since the initial
> arm64 support, commit 39ac3f8494be ("arm64: initial drop"). However,
> "aarch64" does not show up in the list of supported architectures, but
> it's displayed as the default architecture if doing ./configure --help
> on an arm64 machine.
> 
> Keep everything consistent and make sure that the default value for
> $arch is "arm64", but still allow --arch=aarch64, in case they are users
> that use this configuration for kvm-unit-tests.

You can drop this paragraph, since the change to the default value for $arch was
dropped.

With this change:

Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>

Thanks,
Alex

> 
> The help text for --arch changes from:
> 
>    --arch=ARCH            architecture to compile for (aarch64). ARCH can be one of:
>                            arm, arm64, i386, ppc64, riscv32, riscv64, s390x, x86_64
> 
> to:
> 
>     --arch=ARCH            architecture to compile for (arm64). ARCH can be one of:
>                            arm, arm64, i386, ppc64, riscv32, riscv64, s390x, x86_64
> 
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
> ---
>  configure | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/configure b/configure
> index 52904d3a..010c68ff 100755
> --- a/configure
> +++ b/configure
> @@ -43,6 +43,7 @@ else
>  fi
>  
>  usage() {
> +    [ "$arch" = "aarch64" ] && arch="arm64"
>      cat <<-EOF
>  	Usage: $0 [options]
>  
> -- 
> 2.49.0
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [kvm-unit-tests PATCH v3 2/5] configure: arm/arm64: Display the correct default processor
  2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 2/5] configure: arm/arm64: Display the correct default processor Jean-Philippe Brucker
@ 2025-03-27 17:11   ` Alexandru Elisei
  0 siblings, 0 replies; 13+ messages in thread
From: Alexandru Elisei @ 2025-03-27 17:11 UTC (permalink / raw)
  To: Jean-Philippe Brucker
  Cc: andrew.jones, eric.auger, kvmarm, kvm, kvm-riscv, vladimir.murzin

Hi Jean-Philippe,

On Tue, Mar 25, 2025 at 04:00:30PM +0000, Jean-Philippe Brucker wrote:
> From: Alexandru Elisei <alexandru.elisei@arm.com>
> 
> The help text for the --processor option displays the architecture name as
> the default processor type. But the default for arm is cortex-a15, and for
> arm64 is cortex-a57. Teach configure to display the correct default
> processor type for these two architectures.

Looks good to me:

Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>

Thanks,
Alex

> 
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
> ---
>  configure | 30 ++++++++++++++++++++++--------
>  1 file changed, 22 insertions(+), 8 deletions(-)
> 
> diff --git a/configure b/configure
> index 010c68ff..b4875ef3 100755
> --- a/configure
> +++ b/configure
> @@ -5,6 +5,24 @@ if [ -z "${BASH_VERSINFO[0]}" ] || [ "${BASH_VERSINFO[0]}" -lt 4 ] ; then
>      exit 1
>  fi
>  
> +# Return the default CPU type to compile for
> +function get_default_processor()
> +{
> +    local arch="$1"
> +
> +    case "$arch" in
> +    "arm")
> +        echo "cortex-a15"
> +        ;;
> +    "arm64")
> +        echo "cortex-a57"
> +        ;;
> +    *)
> +        echo "$arch"
> +        ;;
> +    esac
> +}
> +
>  srcdir=$(cd "$(dirname "$0")"; pwd)
>  prefix=/usr/local
>  cc=gcc
> @@ -44,13 +62,14 @@ fi
>  
>  usage() {
>      [ "$arch" = "aarch64" ] && arch="arm64"
> +    [ -z "$processor" ] && processor=$(get_default_processor $arch)
>      cat <<-EOF
>  	Usage: $0 [options]
>  
>  	Options include:
>  	    --arch=ARCH            architecture to compile for ($arch). ARCH can be one of:
>  	                           arm, arm64, i386, ppc64, riscv32, riscv64, s390x, x86_64
> -	    --processor=PROCESSOR  processor to compile for ($arch)
> +	    --processor=PROCESSOR  processor to compile for ($processor)
>  	    --target=TARGET        target platform that the tests will be running on (qemu or
>  	                           kvmtool, default is qemu) (arm/arm64 only)
>  	    --cross-prefix=PREFIX  cross compiler prefix
> @@ -326,13 +345,8 @@ if [ "$earlycon" ]; then
>      fi
>  fi
>  
> -[ -z "$processor" ] && processor="$arch"
> -
> -if [ "$processor" = "arm64" ]; then
> -    processor="cortex-a57"
> -elif [ "$processor" = "arm" ]; then
> -    processor="cortex-a15"
> -fi
> +# $arch will have changed when cross-compiling.
> +[ -z "$processor" ] && processor=$(get_default_processor $arch)
>  
>  if [ "$arch" = "i386" ] || [ "$arch" = "x86_64" ]; then
>      testdir=x86
> -- 
> 2.49.0
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [kvm-unit-tests PATCH v3 4/5] configure: Add --qemu-cpu option
  2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 4/5] configure: Add --qemu-cpu option Jean-Philippe Brucker
  2025-03-27  8:25   ` Andrew Jones
@ 2025-03-27 17:14   ` Alexandru Elisei
  2025-03-31 13:54     ` Andrew Jones
  1 sibling, 1 reply; 13+ messages in thread
From: Alexandru Elisei @ 2025-03-27 17:14 UTC (permalink / raw)
  To: Jean-Philippe Brucker
  Cc: andrew.jones, eric.auger, kvmarm, kvm, kvm-riscv, vladimir.murzin

Hi Jean-Philippe,

On Tue, Mar 25, 2025 at 04:00:32PM +0000, Jean-Philippe Brucker wrote:
> Add the --qemu-cpu option to let users set the CPU type to run on.
> At the moment --processor allows to set both GCC -mcpu flag and QEMU
> -cpu. On Arm we'd like to pass `-cpu max` to QEMU in order to enable all
> the TCG features by default, and it could also be nice to let users
> modify the CPU capabilities by setting extra -cpu options.  Since GCC
> -mcpu doesn't accept "max" or "host", separate the compiler and QEMU
> arguments.
> 
> `--processor` is now exclusively for compiler options, as indicated by
> its documentation ("processor to compile for"). So use $QEMU_CPU on
> RISC-V as well.
> 
> Suggested-by: Andrew Jones <andrew.jones@linux.dev>
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
> ---
>  scripts/mkstandalone.sh |  3 ++-
>  arm/run                 | 15 +++++++++------
>  riscv/run               |  8 ++++----
>  configure               | 24 ++++++++++++++++++++++++
>  4 files changed, 39 insertions(+), 11 deletions(-)
> 
> diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
> index 2318a85f..9b4f983d 100755
> --- a/scripts/mkstandalone.sh
> +++ b/scripts/mkstandalone.sh
> @@ -42,7 +42,8 @@ generate_test ()
>  
>  	config_export ARCH
>  	config_export ARCH_NAME
> -	config_export PROCESSOR
> +	config_export QEMU_CPU
> +	config_export DEFAULT_QEMU_CPU
>  
>  	echo "echo BUILD_HEAD=$(cat build-head)"
>  
> diff --git a/arm/run b/arm/run
> index efdd44ce..4675398f 100755
> --- a/arm/run
> +++ b/arm/run
> @@ -8,7 +8,7 @@ if [ -z "$KUT_STANDALONE" ]; then
>  	source config.mak
>  	source scripts/arch-run.bash
>  fi
> -processor="$PROCESSOR"
> +qemu_cpu="$QEMU_CPU"
>  
>  if [ "$QEMU" ] && [ -z "$ACCEL" ] &&
>     [ "$HOST" = "aarch64" ] && [ "$ARCH" = "arm" ] &&
> @@ -37,12 +37,15 @@ if [ "$ACCEL" = "kvm" ]; then
>  	fi
>  fi
>  
> -if [ "$ACCEL" = "kvm" ] || [ "$ACCEL" = "hvf" ]; then
> -	if [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ]; then
> -		processor="host"
> +if [ -z "$qemu_cpu" ]; then
> +	if ( [ "$ACCEL" = "kvm" ] || [ "$ACCEL" = "hvf" ] ) &&
> +	   ( [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ] ); then
> +		qemu_cpu="host"
>  		if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; then
> -			processor+=",aarch64=off"
> +			qemu_cpu+=",aarch64=off"
>  		fi
> +	else
> +		qemu_cpu="$DEFAULT_QEMU_CPU"
>  	fi
>  fi
>  
> @@ -71,7 +74,7 @@ if $qemu $M -device '?' | grep -q pci-testdev; then
>  fi
>  
>  A="-accel $ACCEL$ACCEL_PROPS"
> -command="$qemu -nodefaults $M $A -cpu $processor $chr_testdev $pci_testdev"
> +command="$qemu -nodefaults $M $A -cpu $qemu_cpu $chr_testdev $pci_testdev"
>  command+=" -display none -serial stdio"
>  command="$(migration_cmd) $(timeout_cmd) $command"
>  
> diff --git a/riscv/run b/riscv/run
> index e2f5a922..02fcf0c0 100755
> --- a/riscv/run
> +++ b/riscv/run
> @@ -11,12 +11,12 @@ fi
>  
>  # Allow user overrides of some config.mak variables
>  mach=$MACHINE_OVERRIDE
> -processor=$PROCESSOR_OVERRIDE
> +qemu_cpu=$QEMU_CPU_OVERRIDE
>  firmware=$FIRMWARE_OVERRIDE
>  
> -[ "$PROCESSOR" = "$ARCH" ] && PROCESSOR="max"
> +[ -z "$QEMU_CPU" ] && QEMU_CPU="max"

If you make DEFAULT_QEMU_CPU=max for riscv, you can use it instead of "max",
just like arm/arm64 does. Not sure if it's worth another respin.

Otherwise the patch looks good to me.

Thanks,
Alex

>  : "${mach:=virt}"
> -: "${processor:=$PROCESSOR}"
> +: "${qemu_cpu:=$QEMU_CPU}"
>  : "${firmware:=$FIRMWARE}"
>  [ "$firmware" ] && firmware="-bios $firmware"
>  
> @@ -32,7 +32,7 @@ fi
>  mach="-machine $mach"
>  
>  command="$qemu -nodefaults -nographic -serial mon:stdio"
> -command+=" $mach $acc $firmware -cpu $processor "
> +command+=" $mach $acc $firmware -cpu $qemu_cpu "
>  command="$(migration_cmd) $(timeout_cmd) $command"
>  
>  if [ "$UEFI_SHELL_RUN" = "y" ]; then
> diff --git a/configure b/configure
> index b4875ef3..b79145a5 100755
> --- a/configure
> +++ b/configure
> @@ -23,6 +23,21 @@ function get_default_processor()
>      esac
>  }
>  
> +# Return the default CPU type to run on
> +function get_default_qemu_cpu()
> +{
> +    local arch="$1"
> +
> +    case "$arch" in
> +    "arm")
> +        echo "cortex-a15"
> +        ;;
> +    "arm64")
> +        echo "cortex-a57"
> +        ;;
> +    esac
> +}
> +
>  srcdir=$(cd "$(dirname "$0")"; pwd)
>  prefix=/usr/local
>  cc=gcc
> @@ -52,6 +67,7 @@ earlycon=
>  console=
>  efi=
>  efi_direct=
> +qemu_cpu=
>  
>  # Enable -Werror by default for git repositories only (i.e. developer builds)
>  if [ -e "$srcdir"/.git ]; then
> @@ -70,6 +86,9 @@ usage() {
>  	    --arch=ARCH            architecture to compile for ($arch). ARCH can be one of:
>  	                           arm, arm64, i386, ppc64, riscv32, riscv64, s390x, x86_64
>  	    --processor=PROCESSOR  processor to compile for ($processor)
> +	    --qemu-cpu=CPU         the CPU model to run on. If left unset, the run script
> +	                           selects the best value based on the host system and the
> +	                           test configuration.
>  	    --target=TARGET        target platform that the tests will be running on (qemu or
>  	                           kvmtool, default is qemu) (arm/arm64 only)
>  	    --cross-prefix=PREFIX  cross compiler prefix
> @@ -146,6 +165,9 @@ while [[ $optno -le $argc ]]; do
>          --processor)
>  	    processor="$arg"
>  	    ;;
> +	--qemu-cpu)
> +	    qemu_cpu="$arg"
> +	    ;;
>  	--target)
>  	    target="$arg"
>  	    ;;
> @@ -471,6 +493,8 @@ ARCH=$arch
>  ARCH_NAME=$arch_name
>  ARCH_LIBDIR=$arch_libdir
>  PROCESSOR=$processor
> +QEMU_CPU=$qemu_cpu
> +DEFAULT_QEMU_CPU=$(get_default_qemu_cpu $arch)
>  CC=$cc
>  CFLAGS=$cflags
>  LD=$cross_prefix$ld
> -- 
> 2.49.0
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [kvm-unit-tests PATCH v3 0/5] arm64: Change the default QEMU CPU type to "max"
  2025-03-26 18:51 ` [kvm-unit-tests PATCH v3 0/5] arm64: Change the default QEMU CPU type to "max" Andrew Jones
@ 2025-03-27 17:17   ` Alexandru Elisei
  0 siblings, 0 replies; 13+ messages in thread
From: Alexandru Elisei @ 2025-03-27 17:17 UTC (permalink / raw)
  To: Andrew Jones
  Cc: Jean-Philippe Brucker, eric.auger, kvmarm, kvm, kvm-riscv,
	vladimir.murzin

Hi Drew,

On Wed, Mar 26, 2025 at 07:51:35PM +0100, Andrew Jones wrote:
> On Tue, Mar 25, 2025 at 04:00:28PM +0000, Jean-Philippe Brucker wrote:
> > This is v3 of the series that cleans up the configure flags and sets the
> > default CPU type to "max" on arm64, in order to test the latest Arm
> > features.
> > 
> > Since v2 [1] I moved the CPU selection to ./configure, and improved the
> > help text. Unfortunately I couldn't keep most of the Review tags since
> > there were small changes all over.
> > 
> > [1] https://lore.kernel.org/all/20250314154904.3946484-2-jean-philippe@linaro.org/
> > 
> > Alexandru Elisei (3):
> >   configure: arm64: Don't display 'aarch64' as the default architecture
> >   configure: arm/arm64: Display the correct default processor
> >   arm64: Implement the ./configure --processor option
> > 
> > Jean-Philippe Brucker (2):
> >   configure: Add --qemu-cpu option
> >   arm64: Use -cpu max as the default for TCG
> > 
> >  scripts/mkstandalone.sh |  3 ++-
> >  arm/run                 | 15 ++++++-----
> >  riscv/run               |  8 +++---
> >  configure               | 55 +++++++++++++++++++++++++++++++++++------
> >  arm/Makefile.arm        |  1 -
> >  arm/Makefile.common     |  1 +
> >  6 files changed, 63 insertions(+), 20 deletions(-)
> > 
> > -- 
> > 2.49.0
> 
> Thanks Jean-Philippe. I'll let Alex and Eric give it another look, but
> LGTM.

Looks good to me too, just two nitpicks, not sure if it's worth respining just
for them, or if you want to make the changes when you apply the patches (or just
ignore them, that's fine too!).

Thanks,
Alex

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [kvm-unit-tests PATCH v3 4/5] configure: Add --qemu-cpu option
  2025-03-27 17:14   ` Alexandru Elisei
@ 2025-03-31 13:54     ` Andrew Jones
  0 siblings, 0 replies; 13+ messages in thread
From: Andrew Jones @ 2025-03-31 13:54 UTC (permalink / raw)
  To: Alexandru Elisei
  Cc: Jean-Philippe Brucker, eric.auger, kvmarm, kvm, kvm-riscv,
	vladimir.murzin

On Thu, Mar 27, 2025 at 05:14:39PM +0000, Alexandru Elisei wrote:
> Hi Jean-Philippe,
> 
> On Tue, Mar 25, 2025 at 04:00:32PM +0000, Jean-Philippe Brucker wrote:
> > Add the --qemu-cpu option to let users set the CPU type to run on.
> > At the moment --processor allows to set both GCC -mcpu flag and QEMU
> > -cpu. On Arm we'd like to pass `-cpu max` to QEMU in order to enable all
> > the TCG features by default, and it could also be nice to let users
> > modify the CPU capabilities by setting extra -cpu options.  Since GCC
> > -mcpu doesn't accept "max" or "host", separate the compiler and QEMU
> > arguments.
> > 
> > `--processor` is now exclusively for compiler options, as indicated by
> > its documentation ("processor to compile for"). So use $QEMU_CPU on
> > RISC-V as well.
> > 
> > Suggested-by: Andrew Jones <andrew.jones@linux.dev>
> > Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
> > ---
> >  scripts/mkstandalone.sh |  3 ++-
> >  arm/run                 | 15 +++++++++------
> >  riscv/run               |  8 ++++----
> >  configure               | 24 ++++++++++++++++++++++++
> >  4 files changed, 39 insertions(+), 11 deletions(-)
> > 
> > diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
> > index 2318a85f..9b4f983d 100755
> > --- a/scripts/mkstandalone.sh
> > +++ b/scripts/mkstandalone.sh
> > @@ -42,7 +42,8 @@ generate_test ()
> >  
> >  	config_export ARCH
> >  	config_export ARCH_NAME
> > -	config_export PROCESSOR
> > +	config_export QEMU_CPU
> > +	config_export DEFAULT_QEMU_CPU
> >  
> >  	echo "echo BUILD_HEAD=$(cat build-head)"
> >  
> > diff --git a/arm/run b/arm/run
> > index efdd44ce..4675398f 100755
> > --- a/arm/run
> > +++ b/arm/run
> > @@ -8,7 +8,7 @@ if [ -z "$KUT_STANDALONE" ]; then
> >  	source config.mak
> >  	source scripts/arch-run.bash
> >  fi
> > -processor="$PROCESSOR"
> > +qemu_cpu="$QEMU_CPU"
> >  
> >  if [ "$QEMU" ] && [ -z "$ACCEL" ] &&
> >     [ "$HOST" = "aarch64" ] && [ "$ARCH" = "arm" ] &&
> > @@ -37,12 +37,15 @@ if [ "$ACCEL" = "kvm" ]; then
> >  	fi
> >  fi
> >  
> > -if [ "$ACCEL" = "kvm" ] || [ "$ACCEL" = "hvf" ]; then
> > -	if [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ]; then
> > -		processor="host"
> > +if [ -z "$qemu_cpu" ]; then
> > +	if ( [ "$ACCEL" = "kvm" ] || [ "$ACCEL" = "hvf" ] ) &&
> > +	   ( [ "$HOST" = "aarch64" ] || [ "$HOST" = "arm" ] ); then
> > +		qemu_cpu="host"
> >  		if [ "$ARCH" = "arm" ] && [ "$HOST" = "aarch64" ]; then
> > -			processor+=",aarch64=off"
> > +			qemu_cpu+=",aarch64=off"
> >  		fi
> > +	else
> > +		qemu_cpu="$DEFAULT_QEMU_CPU"
> >  	fi
> >  fi
> >  
> > @@ -71,7 +74,7 @@ if $qemu $M -device '?' | grep -q pci-testdev; then
> >  fi
> >  
> >  A="-accel $ACCEL$ACCEL_PROPS"
> > -command="$qemu -nodefaults $M $A -cpu $processor $chr_testdev $pci_testdev"
> > +command="$qemu -nodefaults $M $A -cpu $qemu_cpu $chr_testdev $pci_testdev"
> >  command+=" -display none -serial stdio"
> >  command="$(migration_cmd) $(timeout_cmd) $command"
> >  
> > diff --git a/riscv/run b/riscv/run
> > index e2f5a922..02fcf0c0 100755
> > --- a/riscv/run
> > +++ b/riscv/run
> > @@ -11,12 +11,12 @@ fi
> >  
> >  # Allow user overrides of some config.mak variables
> >  mach=$MACHINE_OVERRIDE
> > -processor=$PROCESSOR_OVERRIDE
> > +qemu_cpu=$QEMU_CPU_OVERRIDE
> >  firmware=$FIRMWARE_OVERRIDE
> >  
> > -[ "$PROCESSOR" = "$ARCH" ] && PROCESSOR="max"
> > +[ -z "$QEMU_CPU" ] && QEMU_CPU="max"
> 
> If you make DEFAULT_QEMU_CPU=max for riscv, you can use it instead of "max",
> just like arm/arm64 does. Not sure if it's worth another respin.

Yup, we'll also need

diff --git a/configure b/configure
index b86ccc0c338b..541b9577a718 100755
--- a/configure
+++ b/configure
@@ -32,7 +32,7 @@ function get_default_qemu_cpu()
     "arm")
         echo "cortex-a15"
         ;;
-    "arm64")
+    "arm64" | "riscv32" | "riscv64")
         echo "max"
         ;;
     esac

Thanks,
drew

> 
> Otherwise the patch looks good to me.
> 
> Thanks,
> Alex
> 
> >  : "${mach:=virt}"
> > -: "${processor:=$PROCESSOR}"
> > +: "${qemu_cpu:=$QEMU_CPU}"
> >  : "${firmware:=$FIRMWARE}"
> >  [ "$firmware" ] && firmware="-bios $firmware"
> >  
> > @@ -32,7 +32,7 @@ fi
> >  mach="-machine $mach"
> >  
> >  command="$qemu -nodefaults -nographic -serial mon:stdio"
> > -command+=" $mach $acc $firmware -cpu $processor "
> > +command+=" $mach $acc $firmware -cpu $qemu_cpu "
> >  command="$(migration_cmd) $(timeout_cmd) $command"
> >  
> >  if [ "$UEFI_SHELL_RUN" = "y" ]; then
> > diff --git a/configure b/configure
> > index b4875ef3..b79145a5 100755
> > --- a/configure
> > +++ b/configure
> > @@ -23,6 +23,21 @@ function get_default_processor()
> >      esac
> >  }
> >  
> > +# Return the default CPU type to run on
> > +function get_default_qemu_cpu()
> > +{
> > +    local arch="$1"
> > +
> > +    case "$arch" in
> > +    "arm")
> > +        echo "cortex-a15"
> > +        ;;
> > +    "arm64")
> > +        echo "cortex-a57"
> > +        ;;
> > +    esac
> > +}
> > +
> >  srcdir=$(cd "$(dirname "$0")"; pwd)
> >  prefix=/usr/local
> >  cc=gcc
> > @@ -52,6 +67,7 @@ earlycon=
> >  console=
> >  efi=
> >  efi_direct=
> > +qemu_cpu=
> >  
> >  # Enable -Werror by default for git repositories only (i.e. developer builds)
> >  if [ -e "$srcdir"/.git ]; then
> > @@ -70,6 +86,9 @@ usage() {
> >  	    --arch=ARCH            architecture to compile for ($arch). ARCH can be one of:
> >  	                           arm, arm64, i386, ppc64, riscv32, riscv64, s390x, x86_64
> >  	    --processor=PROCESSOR  processor to compile for ($processor)
> > +	    --qemu-cpu=CPU         the CPU model to run on. If left unset, the run script
> > +	                           selects the best value based on the host system and the
> > +	                           test configuration.
> >  	    --target=TARGET        target platform that the tests will be running on (qemu or
> >  	                           kvmtool, default is qemu) (arm/arm64 only)
> >  	    --cross-prefix=PREFIX  cross compiler prefix
> > @@ -146,6 +165,9 @@ while [[ $optno -le $argc ]]; do
> >          --processor)
> >  	    processor="$arg"
> >  	    ;;
> > +	--qemu-cpu)
> > +	    qemu_cpu="$arg"
> > +	    ;;
> >  	--target)
> >  	    target="$arg"
> >  	    ;;
> > @@ -471,6 +493,8 @@ ARCH=$arch
> >  ARCH_NAME=$arch_name
> >  ARCH_LIBDIR=$arch_libdir
> >  PROCESSOR=$processor
> > +QEMU_CPU=$qemu_cpu
> > +DEFAULT_QEMU_CPU=$(get_default_qemu_cpu $arch)
> >  CC=$cc
> >  CFLAGS=$cflags
> >  LD=$cross_prefix$ld
> > -- 
> > 2.49.0
> > 
> 
> -- 
> kvm-riscv mailing list
> kvm-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kvm-riscv

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-03-31 13:54 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-25 16:00 [kvm-unit-tests PATCH v3 0/5] arm64: Change the default QEMU CPU type to "max" Jean-Philippe Brucker
2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 1/5] configure: arm64: Don't display 'aarch64' as the default architecture Jean-Philippe Brucker
2025-03-27 17:11   ` Alexandru Elisei
2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 2/5] configure: arm/arm64: Display the correct default processor Jean-Philippe Brucker
2025-03-27 17:11   ` Alexandru Elisei
2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 3/5] arm64: Implement the ./configure --processor option Jean-Philippe Brucker
2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 4/5] configure: Add --qemu-cpu option Jean-Philippe Brucker
2025-03-27  8:25   ` Andrew Jones
2025-03-27 17:14   ` Alexandru Elisei
2025-03-31 13:54     ` Andrew Jones
2025-03-25 16:00 ` [kvm-unit-tests PATCH v3 5/5] arm64: Use -cpu max as the default for TCG Jean-Philippe Brucker
2025-03-26 18:51 ` [kvm-unit-tests PATCH v3 0/5] arm64: Change the default QEMU CPU type to "max" Andrew Jones
2025-03-27 17:17   ` Alexandru Elisei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox