For arm64, newer architecture features are supported only on newer CPUs. Instead of expecting the user to know which CPU model supports which feature when using the TCG accelerator for qemu, let's make it easier and add support for the --processor 'max' value. The --processor value is passed to the compiler's -mcpu argument and to qemu's -cpu argument. 'max' is a special value that only qemu understands - it means that all CPU features that qemu implements are supported by the guest CPU, and passing it to the compiler causes a build error. So omit the -mcpu argument when $PROCESSOR=max. This affects only the TCG accelerator; when using KVM or HVF, kvm-unit-tests sets the cpu model to 'host'. Note that using --processor=max with a 32 bit compiler will cause a build error: the CPU model that the compiler defaults to when the -mcpu argument is missing lacks support for some of the instructions that kvm-unit-tests uses. The solution in the case is to specify a CPU model for the compiler using --cflags: ./configure --arch=arm --processor=max --cflags=-mcpu=<cpu> This patch doesn't introduce a regression for arm when --processor=max is used, it's only the error that changes: from an unknown processor type to using instructions that are not available on the processor. Signed-off-by: Alexandru Elisei <alexandru.elisei@xxxxxxx> --- arm/Makefile.common | 2 ++ configure | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/arm/Makefile.common b/arm/Makefile.common index a5d97bcf477a..b757250dc9ae 100644 --- a/arm/Makefile.common +++ b/arm/Makefile.common @@ -25,7 +25,9 @@ AUXFLAGS ?= 0x0 # stack.o relies on frame pointers. KEEP_FRAME_POINTER := y +ifneq ($(PROCESSOR),max) CFLAGS += -mcpu=$(PROCESSOR) +endif CFLAGS += -std=gnu99 CFLAGS += -ffreestanding CFLAGS += -O2 diff --git a/configure b/configure index 138840c3f76d..46964d36a7d8 100755 --- a/configure +++ b/configure @@ -67,7 +67,10 @@ usage() { Options include: --arch=ARCH architecture to compile for ($arch). ARCH can be one of: arm, arm64/aarch64, i386, ppc64, riscv32, riscv64, s390x, x86_64 - --processor=PROCESSOR processor to compile for ($default_processor) + --processor=PROCESSOR processor to compile for ($default_processor). For arm and arm64, the + value 'max' is special and it will be passed directly to + qemu, bypassing the compiler. In this case, --cflags can be + used to compile for a specific 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 -- 2.47.1