06dd94e843
Extend MTE gdbstub tests to also run in system mode (share tests between user mode and system mode). The tests will only run if a version of GDB that supports MTE on baremetal is available in the test environment and if available compiler supports the 'memtag' flag (-march=armv8.5-a+memtag). For the tests running in system mode, a page that supports MTE ops. is necessary. Therefore, an MTE-enabled page is made available (mapped) in the third 2 MB chunk of the second 1 GB space in the flat mapping set in boot.S. A new binary, mte.S, is also introduced for the tests. It links against boot.S and is executed by QEMU in system mode. Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org> Message-Id: <20240906143316.657436-6-gustavo.romero@linaro.org> [AJB: fix stray _] Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20240910173900.4154726-11-alex.bennee@linaro.org>
132 lines
4.3 KiB
Makefile
132 lines
4.3 KiB
Makefile
#
|
|
# Aarch64 system tests
|
|
#
|
|
|
|
AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64
|
|
AARCH64_SYSTEM_SRC=$(AARCH64_SRC)/system
|
|
|
|
VPATH+=$(AARCH64_SYSTEM_SRC)
|
|
|
|
# These objects provide the basic boot code and helper functions for all tests
|
|
CRT_OBJS=boot.o
|
|
|
|
AARCH64_TEST_C_SRCS=$(wildcard $(AARCH64_SYSTEM_SRC)/*.c)
|
|
AARCH64_TEST_S_SRCS=$(AARCH64_SYSTEM_SRC)/mte.S
|
|
|
|
AARCH64_C_TESTS = $(patsubst $(AARCH64_SYSTEM_SRC)/%.c, %, $(AARCH64_TEST_C_SRCS))
|
|
AARCH64_S_TESTS = $(patsubst $(AARCH64_SYSTEM_SRC)/%.S, %, $(AARCH64_TEST_S_SRCS))
|
|
|
|
AARCH64_TESTS = $(AARCH64_C_TESTS)
|
|
AARCH64_TESTS += $(AARCH64_S_TESTS)
|
|
|
|
CRT_PATH=$(AARCH64_SYSTEM_SRC)
|
|
LINK_SCRIPT=$(AARCH64_SYSTEM_SRC)/kernel.ld
|
|
LDFLAGS=-Wl,-T$(LINK_SCRIPT)
|
|
TESTS+=$(AARCH64_TESTS) $(MULTIARCH_TESTS)
|
|
EXTRA_RUNS+=$(MULTIARCH_RUNS)
|
|
CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC)
|
|
LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
|
|
|
|
config-cc.mak: Makefile
|
|
$(quiet-@)( \
|
|
$(call cc-option,-march=armv8.3-a, CROSS_CC_HAS_ARMV8_3); \
|
|
$(call cc-option,-march=armv8.5-a+memtag, CROSS_CC_HAS_ARMV8_MTE)) 3> config-cc.mak
|
|
-include config-cc.mak
|
|
|
|
# building head blobs
|
|
.PRECIOUS: $(CRT_OBJS)
|
|
|
|
%.o: $(CRT_PATH)/%.S
|
|
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -x assembler-with-cpp -Wa,--noexecstack -c $< -o $@
|
|
|
|
# Build and link the tests
|
|
%: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
|
|
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
|
|
|
|
memory: CFLAGS+=-DCHECK_UNALIGNED=1
|
|
|
|
memory-sve: memory.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
|
|
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
|
|
|
|
memory-sve: CFLAGS+=-DCHECK_UNALIGNED=1 -march=armv8.1-a+sve -O3
|
|
|
|
TESTS+=memory-sve
|
|
|
|
# Running
|
|
QEMU_BASE_MACHINE=-M virt -cpu max -display none
|
|
QEMU_BASE_ARGS=-semihosting-config enable=on,target=native,chardev=output
|
|
QEMU_OPTS+=$(QEMU_BASE_MACHINE) $(QEMU_BASE_ARGS) -kernel
|
|
|
|
# console test is manual only
|
|
QEMU_SEMIHOST=-serial none -chardev stdio,mux=on,id=stdio0 -semihosting-config enable=on,chardev=stdio0 -mon chardev=stdio0,mode=readline
|
|
run-semiconsole: QEMU_OPTS=$(QEMU_BASE_MACHINE) $(QEMU_SEMIHOST) -kernel
|
|
run-semiconsole: semiconsole
|
|
$(call skip-test, $<, "MANUAL ONLY")
|
|
$(if $(V),@printf " %-7s %s %s\n" "TO RUN" $(notdir $(QEMU)) "$(QEMU_OPTS) $<")
|
|
run-plugin-semiconsole-with-%: semiconsole
|
|
$(call skip-test, $<, "MANUAL ONLY")
|
|
|
|
# vtimer test needs EL2
|
|
QEMU_EL2_MACHINE=-machine virt,virtualization=on,gic-version=2 -cpu cortex-a57 -smp 4
|
|
run-vtimer: QEMU_OPTS=$(QEMU_EL2_MACHINE) $(QEMU_BASE_ARGS) -kernel
|
|
|
|
# Simple Record/Replay Test
|
|
.PHONY: memory-record
|
|
run-memory-record: memory-record memory
|
|
$(call run-test, $<, \
|
|
$(QEMU) -monitor none -display none \
|
|
-chardev file$(COMMA)path=$<.out$(COMMA)id=output \
|
|
-icount shift=5$(COMMA)rr=record$(COMMA)rrfile=record.bin \
|
|
$(QEMU_OPTS) memory)
|
|
|
|
.PHONY: memory-replay
|
|
run-memory-replay: memory-replay run-memory-record
|
|
$(call run-test, $<, \
|
|
$(QEMU) -monitor none -display none \
|
|
-chardev file$(COMMA)path=$<.out$(COMMA)id=output \
|
|
-icount shift=5$(COMMA)rr=replay$(COMMA)rrfile=record.bin \
|
|
$(QEMU_OPTS) memory)
|
|
|
|
EXTRA_RUNS+=run-memory-replay
|
|
|
|
ifneq ($(CROSS_CC_HAS_ARMV8_3),)
|
|
pauth-3: CFLAGS += $(CROSS_CC_HAS_ARMV8_3)
|
|
else
|
|
pauth-3:
|
|
$(call skip-test, "BUILD of $@", "missing compiler support")
|
|
run-pauth-3:
|
|
$(call skip-test, "RUN of pauth-3", "not built")
|
|
endif
|
|
|
|
ifneq ($(CROSS_CC_HAS_ARMV8_MTE),)
|
|
QEMU_MTE_ENABLED_MACHINE=-M virt,mte=on -cpu max -display none
|
|
QEMU_OPTS_WITH_MTE_ON = $(QEMU_MTE_ENABLED_MACHINE) $(QEMU_BASE_ARGS) -kernel
|
|
mte: CFLAGS+=-march=armv8.5-a+memtag
|
|
mte: mte.S $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
|
|
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
|
|
|
|
run-mte: QEMU_OPTS=$(QEMU_OPTS_WITH_MTE_ON)
|
|
run-mte: mte
|
|
|
|
ifeq ($(GDB_SUPPORTS_MTE_IN_BAREMETAL),y)
|
|
run-gdbstub-mte: QEMU_OPTS=$(QEMU_OPTS_WITH_MTE_ON)
|
|
run-gdbstub-mte: mte
|
|
$(call run-test, $@, $(GDB_SCRIPT) \
|
|
--output run-gdbstub-mte.out \
|
|
--gdb $(GDB) \
|
|
--qemu $(QEMU) --qargs "-chardev null$(COMMA)id=output $(QEMU_OPTS)" \
|
|
--bin $< --test $(AARCH64_SRC)/gdbstub/test-mte.py -- --mode=system, \
|
|
gdbstub MTE support)
|
|
|
|
EXTRA_RUNS += run-gdbstub-mte
|
|
else # !GDB_SUPPORTS_MTE_IN_BAREMETAL
|
|
run-gdbstub-mte:
|
|
$(call skip-test "RUN of gdbstub-mte", "GDB does not support MTE in baremetal!")
|
|
endif
|
|
else # !CROSS_CC_HAS_ARMV8_MTE
|
|
mte:
|
|
$(call skip-test, "BUILD of $@", "missing compiler support")
|
|
run-mte:
|
|
$(call skip-test, "RUN of mte", "not build")
|
|
endif
|