mirror of
https://github.com/torvalds/linux.git
synced 2026-04-20 07:43:57 -04:00
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>
33 lines
896 B
Makefile
33 lines
896 B
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
# Copyright (C) 2020 ARM Limited
|
|
|
|
# preserve CC value from top level Makefile
|
|
ifeq ($(CC),cc)
|
|
CC := $(CROSS_COMPILE)gcc
|
|
endif
|
|
|
|
CFLAGS += -std=gnu99 -I. -pthread
|
|
LDFLAGS += -pthread
|
|
SRCS := $(filter-out mte_common_util.c,$(wildcard *.c))
|
|
PROGS := $(patsubst %.c,%,$(SRCS))
|
|
|
|
#check if the compiler works well
|
|
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)
|
|
|
|
ifeq ($(mte_cc_support),1)
|
|
# Generated binaries to be installed by top KSFT script
|
|
TEST_GEN_PROGS := $(PROGS)
|
|
|
|
# Get Kernel headers installed and use them.
|
|
else
|
|
$(warning compiler "$(CC)" does not support the ARMv8.5 MTE extension.)
|
|
$(warning test program "mte" will not be created.)
|
|
endif
|
|
|
|
# Include KSFT lib.mk.
|
|
include ../../lib.mk
|
|
|
|
ifeq ($(mte_cc_support),1)
|
|
$(TEST_GEN_PROGS): mte_common_util.c mte_helper.S
|
|
endif
|