Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kselftest/arm64: Don't enable v8.5 for MTE selftest builds

Currently we set -march=armv8.5+memtag when building the MTE selftests,
allowing the compiler to emit v8.5 and MTE instructions for anything it
generates. This means that we may get code that will generate SIGILLs when
run on older systems rather than skipping on non-MTE systems as should be
the case. Most toolchains don't select any incompatible instructions but
I have seen some reports which suggest that some may be appearing which do
so. This is also potentially problematic in that if the compiler chooses to
emit any MTE instructions for the C code it may interfere with the MTE
usage we are trying to test.

Since the only reason we are specifying this option is to allow us to
assemble MTE instructions in mte_helper.S we can avoid these issues by
moving to using a .arch directive there and adding the -march explicitly to
the toolchain support check instead of the generic CFLAGS.

Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20220928154517.173108-1-broonie@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

Mark Brown and committed by
Catalin Marinas
55c8a987 33060a64

+3 -4
+1 -4
tools/testing/selftests/arm64/mte/Makefile
··· 11 11 SRCS := $(filter-out mte_common_util.c,$(wildcard *.c)) 12 12 PROGS := $(patsubst %.c,%,$(SRCS)) 13 13 14 - #Add mte compiler option 15 - CFLAGS += -march=armv8.5-a+memtag 16 - 17 14 #check if the compiler works well 18 - mte_cc_support := $(shell if ($(CC) $(CFLAGS) -E -x c /dev/null -o /dev/null 2>&1) then echo "1"; fi) 15 + mte_cc_support := $(shell if ($(CC) $(CFLAGS) -march=armv8.5-a+memtag -E -x c /dev/null -o /dev/null 2>&1) then echo "1"; fi) 19 16 20 17 ifeq ($(mte_cc_support),1) 21 18 # Generated binaries to be installed by top KSFT script
+2
tools/testing/selftests/arm64/mte/mte_helper.S
··· 3 3 4 4 #include "mte_def.h" 5 5 6 + .arch armv8.5-a+memtag 7 + 6 8 #define ENTRY(name) \ 7 9 .globl name ;\ 8 10 .p2align 2;\