1# 2# Aarch64 system tests 3# 4 5AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64 6AARCH64_SYSTEM_SRC=$(AARCH64_SRC)/system 7 8VPATH+=$(AARCH64_SYSTEM_SRC) 9 10# These objects provide the basic boot code and helper functions for all tests 11CRT_OBJS=boot.o 12 13AARCH64_TEST_C_SRCS=$(wildcard $(AARCH64_SYSTEM_SRC)/*.c) 14AARCH64_TEST_S_SRCS=$(AARCH64_SYSTEM_SRC)/mte.S 15 16AARCH64_C_TESTS = $(patsubst $(AARCH64_SYSTEM_SRC)/%.c, %, $(AARCH64_TEST_C_SRCS)) 17AARCH64_S_TESTS = $(patsubst $(AARCH64_SYSTEM_SRC)/%.S, %, $(AARCH64_TEST_S_SRCS)) 18 19AARCH64_TESTS = $(AARCH64_C_TESTS) 20AARCH64_TESTS += $(AARCH64_S_TESTS) 21 22CRT_PATH=$(AARCH64_SYSTEM_SRC) 23LINK_SCRIPT=$(AARCH64_SYSTEM_SRC)/kernel.ld 24LDFLAGS=-Wl,-T$(LINK_SCRIPT) 25TESTS+=$(AARCH64_TESTS) $(MULTIARCH_TESTS) 26EXTRA_RUNS+=$(MULTIARCH_RUNS) 27CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC) 28LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc 29 30config-cc.mak: Makefile 31 $(quiet-@)( \ 32 $(call cc-option,-march=armv8.3-a, CROSS_CC_HAS_ARMV8_3); \ 33 $(call cc-option,-march=armv8.5-a+memtag, CROSS_CC_HAS_ARMV8_MTE)) 3> config-cc.mak 34-include config-cc.mak 35 36# building head blobs 37.PRECIOUS: $(CRT_OBJS) 38 39%.o: $(CRT_PATH)/%.S 40 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -x assembler-with-cpp -Wa,--noexecstack -c $< -o $@ 41 42# Build and link the tests 43%: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS) 44 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) 45 46memory: CFLAGS+=-DCHECK_UNALIGNED=1 47 48memory-sve: memory.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS) 49 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) 50 51memory-sve: CFLAGS+=-DCHECK_UNALIGNED=1 -march=armv8.1-a+sve -O3 52 53TESTS+=memory-sve 54 55# Running 56QEMU_BASE_MACHINE=-M virt -cpu max -display none 57QEMU_BASE_ARGS=-semihosting-config enable=on,target=native,chardev=output 58QEMU_OPTS+=$(QEMU_BASE_MACHINE) $(QEMU_BASE_ARGS) -kernel 59 60# console test is manual only 61QEMU_SEMIHOST=-serial none -chardev stdio,mux=on,id=stdio0 -semihosting-config enable=on,chardev=stdio0 -mon chardev=stdio0,mode=readline 62run-semiconsole: QEMU_OPTS=$(QEMU_BASE_MACHINE) $(QEMU_SEMIHOST) -kernel 63run-semiconsole: semiconsole 64 $(call skip-test, $<, "MANUAL ONLY") 65 $(if $(V),@printf " %-7s %s %s\n" "TO RUN" $(notdir $(QEMU)) "$(QEMU_OPTS) $<") 66run-plugin-semiconsole-with-%: semiconsole 67 $(call skip-test, $<, "MANUAL ONLY") 68 69# vtimer test needs EL2 70QEMU_EL2_MACHINE=-machine virt,virtualization=on,gic-version=2 -cpu cortex-a57 -smp 4 71run-vtimer: QEMU_OPTS=$(QEMU_EL2_MACHINE) $(QEMU_BASE_ARGS) -kernel 72 73# Simple Record/Replay Test 74.PHONY: memory-record 75run-memory-record: memory-record memory 76 $(call run-test, $<, \ 77 $(QEMU) -monitor none -display none \ 78 -chardev file$(COMMA)path=$<.out$(COMMA)id=output \ 79 -icount shift=5$(COMMA)rr=record$(COMMA)rrfile=record.bin \ 80 $(QEMU_OPTS) memory) 81 82.PHONY: memory-replay 83run-memory-replay: memory-replay run-memory-record 84 $(call run-test, $<, \ 85 $(QEMU) -monitor none -display none \ 86 -chardev file$(COMMA)path=$<.out$(COMMA)id=output \ 87 -icount shift=5$(COMMA)rr=replay$(COMMA)rrfile=record.bin \ 88 $(QEMU_OPTS) memory) 89 90EXTRA_RUNS+=run-memory-replay 91 92ifneq ($(CROSS_CC_HAS_ARMV8_3),) 93pauth-3: CFLAGS += $(CROSS_CC_HAS_ARMV8_3) 94else 95pauth-3: 96 $(call skip-test, "BUILD of $@", "missing compiler support") 97run-pauth-3: 98 $(call skip-test, "RUN of pauth-3", "not built") 99endif 100 101ifneq ($(CROSS_CC_HAS_ARMV8_MTE),) 102QEMU_MTE_ENABLED_MACHINE=-M virt,mte=on -cpu max -display none 103QEMU_OPTS_WITH_MTE_ON = $(QEMU_MTE_ENABLED_MACHINE) $(QEMU_BASE_ARGS) -kernel 104mte: CFLAGS+=-march=armv8.5-a+memtag 105mte: mte.S $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS) 106 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) 107 108run-mte: QEMU_OPTS=$(QEMU_OPTS_WITH_MTE_ON) 109run-mte: mte 110 111ifeq ($(GDB_SUPPORTS_MTE_IN_BAREMETAL),y) 112run-gdbstub-mte: QEMU_OPTS=$(QEMU_OPTS_WITH_MTE_ON) 113run-gdbstub-mte: mte 114 $(call run-test, $@, $(GDB_SCRIPT) \ 115 --output run-gdbstub-mte.out \ 116 --gdb $(GDB) \ 117 --qemu $(QEMU) --qargs "-chardev null$(COMMA)id=output $(QEMU_OPTS)" \ 118 --bin $< --test $(AARCH64_SRC)/gdbstub/test-mte.py -- --mode=system, \ 119 gdbstub MTE support) 120 121EXTRA_RUNS += run-gdbstub-mte 122else # !GDB_SUPPORTS_MTE_IN_BAREMETAL 123run-gdbstub-mte: 124 $(call skip-test "RUN of gdbstub-mte", "GDB does not support MTE in baremetal!") 125endif 126else # !CROSS_CC_HAS_ARMV8_MTE 127mte: 128 $(call skip-test, "BUILD of $@", "missing compiler support") 129run-mte: 130 $(call skip-test, "RUN of mte", "not build") 131endif 132