qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

tests/tcg: cleanup Makefile inclusions

Rename Makefile.probe to Makefile.prereqs and make it actually
define rules for the tests.

Rename Makefile to Makefile.target, since it is not a toplevel
makefile.

Rename Makefile.include to Makefile.qemu and disentangle it
from the QEMU Makefile.target, so that it is invoked recursively
by tests/Makefile.include. Tests are now placed in
tests/tcg/$(TARGET).

Drop the usage of TARGET_BASE_ARCH, which is ignored by everything except
x86_64 and aarch64. Fix x86 tests by using -cpu max and, while
at it, standardize on QEMU_OPTS for aarch64 tests too.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20190807143523.15917-3-pbonzini@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

authored by

Paolo Bonzini and committed by
Alex Bennée
fc76c56d 6a9e0ef3

+168 -140
-3
Makefile.target
··· 39 39 PROGS=$(QEMU_PROG) $(QEMU_PROGW) 40 40 STPFILES= 41 41 42 - # Makefile Tests 43 - include $(SRC_PATH)/tests/tcg/Makefile.include 44 - 45 42 config-target.h: config-target.h-timestamp 46 43 config-target.h-timestamp: config-target.mak 47 44
+14 -9
tests/Makefile.include
··· 1062 1062 ifeq ($(HAVE_USER_DOCKER),y) 1063 1063 # Probe for the Docker Builds needed for each build 1064 1064 $(foreach PROBE_TARGET,$(TARGET_DIRS), \ 1065 - $(eval -include $(SRC_PATH)/tests/tcg/Makefile.probe) \ 1066 - $(if $(DOCKER_PREREQ), \ 1067 - $(eval build-tcg-tests-$(PROBE_TARGET): $(DOCKER_PREREQ)))) 1065 + $(eval -include $(SRC_PATH)/tests/tcg/Makefile.prereqs)) 1068 1066 endif 1069 1067 1070 1068 build-tcg-tests-%: 1071 - $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" \ 1072 - SKIP_DOCKER_BUILD=1 TARGET_DIR="$*/" guest-tests, \ 1069 + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \ 1070 + -f $(SRC_PATH)/tests/tcg/Makefile.qemu \ 1071 + SRC_PATH=$(SRC_PATH) \ 1072 + V="$(V)" TARGET_DIR="$*/" guest-tests, \ 1073 1073 "BUILD", "TCG tests for $*") 1074 1074 1075 - run-tcg-tests-%: % build-tcg-tests-% 1076 - $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" \ 1077 - SKIP_DOCKER_BUILD=1 TARGET_DIR="$*/" run-guest-tests, \ 1075 + run-tcg-tests-%: build-tcg-tests-% %/all 1076 + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \ 1077 + -f $(SRC_PATH)/tests/tcg/Makefile.qemu \ 1078 + SRC_PATH=$(SRC_PATH) SPEED="$(SPEED)" \ 1079 + V="$(V)" TARGET_DIR="$*/" run-guest-tests, \ 1078 1080 "RUN", "TCG tests for $*") 1079 1081 1080 1082 clean-tcg-tests-%: 1081 - $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" clean-guest-tests,) 1083 + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \ 1084 + -f $(SRC_PATH)/tests/tcg/Makefile.qemu \ 1085 + SRC_PATH=$(SRC_PATH) TARGET_DIR="$*/" clean-guest-tests, \ 1086 + "RUN", "TCG tests for $*") 1082 1087 1083 1088 .PHONY: build-tcg 1084 1089 build-tcg: $(BUILD_TCG_TARGET_RULES)
+4 -9
tests/tcg/Makefile tests/tcg/Makefile.target
··· 29 29 # We also expect to be in the tests build dir for the FOO-(linux-user|softmmu). 30 30 # 31 31 32 + all: 32 33 -include ../../config-host.mak 33 - -include ../config-target.mak 34 + -include ../../../$(TARGET_DIR)/config-target.mak 34 35 35 36 # for including , in command strings 36 37 COMMA := , ··· 64 65 65 66 # The QEMU for this TARGET 66 67 ifdef CONFIG_USER_ONLY 67 - QEMU=../qemu-$(TARGET_NAME) 68 + QEMU=../../../$(TARGET_DIR)/qemu-$(TARGET_NAME) 68 69 else 69 - QEMU=../qemu-system-$(TARGET_NAME) 70 + QEMU=../../../$(TARGET_DIR)/qemu-system-$(TARGET_NAME) 70 71 endif 71 72 QEMU_OPTS= 72 73 ··· 82 83 # The order we include is important. We include multiarch, base arch 83 84 # and finally arch if it's not the same as base arch. 84 85 -include $(SRC_PATH)/tests/tcg/multiarch/Makefile.target 85 - -include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.target 86 - ifneq ($(TARGET_BASE_ARCH),$(TARGET_NAME)) 87 86 -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.target 88 - endif 89 87 90 88 # Add the common build options 91 89 CFLAGS+=-Wall -O0 -g -fno-strict-aliasing ··· 101 99 # are expected to provide their own build recipes. 102 100 -include $(SRC_PATH)/tests/tcg/minilib/Makefile.target 103 101 -include $(SRC_PATH)/tests/tcg/multiarch/system/Makefile.softmmu-target 104 - -include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.softmmu-target 105 - ifneq ($(TARGET_BASE_ARCH),$(TARGET_NAME)) 106 102 -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.softmmu-target 107 - endif 108 103 109 104 endif 110 105
-88
tests/tcg/Makefile.include
··· 1 - # -*- Mode: makefile -*- 2 - # 3 - # TCG tests (per-target rules) 4 - # 5 - # This Makefile fragment is included from the per-target 6 - # Makefile.target so will be invoked for each linux-user program we 7 - # build. We have two options for compiling, either using a configured 8 - # guest compiler or calling one of our docker images to do it for us. 9 - # 10 - 11 - # The per ARCH makefile, if it exists, holds extra information about 12 - # useful docker images or alternative compiler flags. 13 - 14 - -include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include 15 - -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include 16 - 17 - GUEST_BUILD= 18 - TCG_MAKE=$(SRC_PATH)/tests/tcg/Makefile 19 - # Support installed Cross Compilers 20 - 21 - ifdef CROSS_CC_GUEST 22 - 23 - .PHONY: cross-build-guest-tests 24 - cross-build-guest-tests: 25 - $(call quiet-command, \ 26 - (mkdir -p tests && cd tests && \ 27 - $(MAKE) -f $(TCG_MAKE) CC=$(CROSS_CC_GUEST) \ 28 - BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \ 29 - EXTRA_CFLAGS=$(CROSS_CC_GUEST_CFLAGS)), \ 30 - "BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)") 31 - 32 - GUEST_BUILD=cross-build-guest-tests 33 - 34 - endif 35 - 36 - # Support building with Docker 37 - 38 - ifeq ($(HAVE_USER_DOCKER)$(GUEST_BUILD),y) 39 - ifneq ($(DOCKER_IMAGE),) 40 - 41 - # We also need the Docker make rules to depend on 42 - include $(SRC_PATH)/tests/docker/Makefile.include 43 - 44 - DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc \ 45 - --cc $(DOCKER_CROSS_COMPILER) \ 46 - -i qemu:$(DOCKER_IMAGE) \ 47 - -s $(SRC_PATH) -- " 48 - DOCKER_PREREQ=docker-image-$(DOCKER_IMAGE) 49 - 50 - .PHONY: docker-build-guest-tests 51 - docker-build-guest-tests: $(DOCKER_PREREQ) 52 - $(call quiet-command, \ 53 - (mkdir -p tests && cd tests && \ 54 - $(MAKE) -f $(TCG_MAKE) CC=$(DOCKER_COMPILE_CMD) \ 55 - BUILD_STATIC=y \ 56 - EXTRA_CFLAGS=$(DOCKER_CROSS_COMPILER_CFLAGS)), \ 57 - "BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)") 58 - 59 - GUEST_BUILD=docker-build-guest-tests 60 - 61 - endif 62 - endif 63 - 64 - # Final targets 65 - .PHONY: guest-tests 66 - 67 - ifneq ($(GUEST_BUILD),) 68 - guest-tests: $(GUEST_BUILD) 69 - 70 - run-guest-tests: guest-tests qemu-$(subst y,system-,$(CONFIG_SOFTMMU))$(TARGET_NAME) 71 - $(call quiet-command, \ 72 - (cd tests && $(MAKE) -f $(TCG_MAKE) SPEED=$(SPEED) run), \ 73 - "RUN", "tests for $(TARGET_NAME)") 74 - 75 - else 76 - guest-tests: 77 - $(call quiet-command, /bin/true, "BUILD", \ 78 - "$(TARGET_NAME) guest-tests SKIPPED") 79 - 80 - run-guest-tests: 81 - $(call quiet-command, /bin/true, "RUN", \ 82 - "tests for $(TARGET_NAME) SKIPPED") 83 - endif 84 - 85 - # It doesn't matter if these don't exits 86 - .PHONY: clean-guest-tests 87 - clean-guest-tests: 88 - rm -rf tests || echo "no $(TARGET_NAME) tests to remove"
+2 -3
tests/tcg/Makefile.probe tests/tcg/Makefile.prereqs
··· 8 8 # each target. 9 9 10 10 # First we need the target makefile which tells us the target architecture 11 + CROSS_CC_GUEST:= 11 12 -include $(BUILD_DIR)/$(PROBE_TARGET)/config-target.mak 12 13 13 14 # Then we load up the target architecture makefiles which tell us 14 15 # about the compilers 15 - CROSS_CC_GUEST:= 16 16 DOCKER_IMAGE:= 17 - DOCKER_PREREQ:= 18 17 19 18 -include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include 20 19 -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include 21 20 22 21 ifndef CROSS_CC_GUEST 23 22 ifneq ($(DOCKER_IMAGE),) 24 - DOCKER_PREREQ:=docker-image-$(DOCKER_IMAGE) 23 + build-tcg-tests-$(PROBE_TARGET): docker-image-$(DOCKER_IMAGE) 25 24 endif 26 25 endif 27 26
+96
tests/tcg/Makefile.qemu
··· 1 + # -*- Mode: makefile -*- 2 + # 3 + # TCG tests (per-target rules) 4 + # 5 + # This Makefile fragment is included from the build-tcg target, once 6 + # for each target we build. We have two options for compiling, either 7 + # using a configured guest compiler or calling one of our docker images 8 + # to do it for us. 9 + # 10 + 11 + # The per ARCH makefile, if it exists, holds extra information about 12 + # useful docker images or alternative compiler flags. 13 + 14 + include $(TARGET_DIR)config-target.mak 15 + include $(SRC_PATH)/rules.mak 16 + include $(wildcard \ 17 + $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include \ 18 + $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include) 19 + 20 + GUEST_BUILD= 21 + TCG_MAKE=../Makefile.target 22 + # Support installed Cross Compilers 23 + 24 + ifdef CROSS_CC_GUEST 25 + 26 + .PHONY: cross-build-guest-tests 27 + cross-build-guest-tests: 28 + $(call quiet-command, \ 29 + (mkdir -p tests/tcg/$(TARGET_DIR) && cd tests/tcg/$(TARGET_DIR) && \ 30 + $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" CC="$(CROSS_CC_GUEST)" \ 31 + SRC_PATH="$(SRC_PATH)" BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \ 32 + EXTRA_CFLAGS=$(CROSS_CC_GUEST_CFLAGS)), \ 33 + "BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)") 34 + 35 + GUEST_BUILD=cross-build-guest-tests 36 + 37 + endif 38 + 39 + # Support building with Docker 40 + 41 + ifeq ($(HAVE_USER_DOCKER)$(GUEST_BUILD),y) 42 + ifneq ($(DOCKER_IMAGE),) 43 + 44 + # We also need the Docker make rules to depend on 45 + SKIP_DOCKER_BUILD=1 46 + include $(SRC_PATH)/tests/docker/Makefile.include 47 + 48 + DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc \ 49 + --cc $(DOCKER_CROSS_COMPILER) \ 50 + -i qemu:$(DOCKER_IMAGE) \ 51 + -s $(SRC_PATH) -- " 52 + 53 + .PHONY: docker-build-guest-tests 54 + docker-build-guest-tests: docker-image-$(DOCKER_IMAGE) 55 + $(call quiet-command, \ 56 + (mkdir -p tests/tcg/$(TARGET_DIR) && cd tests/tcg/$(TARGET_DIR) && \ 57 + $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" CC=$(DOCKER_COMPILE_CMD) \ 58 + SRC_PATH="$(SRC_PATH)" BUILD_STATIC=y \ 59 + EXTRA_CFLAGS=$(DOCKER_CROSS_COMPILER_CFLAGS)), \ 60 + "BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)") 61 + 62 + GUEST_BUILD=docker-build-guest-tests 63 + 64 + endif 65 + endif 66 + 67 + # Final targets 68 + all: 69 + @echo "Do not invoke this Makefile directly"; exit 1 70 + 71 + .PHONY: guest-tests 72 + 73 + ifneq ($(GUEST_BUILD),) 74 + guest-tests: $(GUEST_BUILD) 75 + 76 + run-guest-tests: guest-tests 77 + $(call quiet-command, \ 78 + (cd tests/tcg/$(TARGET_DIR) && \ 79 + $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" \ 80 + SRC_PATH="$(SRC_PATH)" SPEED=$(SPEED) run), \ 81 + "RUN", "tests for $(TARGET_NAME)") 82 + 83 + else 84 + guest-tests: 85 + $(call quiet-command, /bin/true, "BUILD", \ 86 + "$(TARGET_DIR) guest-tests SKIPPED") 87 + 88 + run-guest-tests: 89 + $(call quiet-command, /bin/true, "RUN", \ 90 + "tests for $(TARGET_DIR) SKIPPED") 91 + endif 92 + 93 + # It doesn't matter if these don't exits 94 + .PHONY: clean-guest-tests 95 + clean-guest-tests: 96 + rm -rf tests/tcg/$(TARGET_DIR)
+7 -5
tests/tcg/aarch64/Makefile.target
··· 2 2 # 3 3 # AArch64 specific tweaks 4 4 5 + ARM_SRC=$(SRC_PATH)/tests/tcg/arm 6 + VPATH += $(ARM_SRC) 7 + 5 8 AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64 6 9 VPATH += $(AARCH64_SRC) 7 10 8 - # we don't build any of the ARM tests 9 - AARCH64_TESTS=$(filter-out $(ARM_TESTS), $(TESTS)) 10 - AARCH64_TESTS+=fcvt 11 + # we don't build any other ARM test 12 + AARCH64_TESTS=fcvt 11 13 12 14 fcvt: LDFLAGS+=-lm 13 15 ··· 16 18 $(call diff-out,$<,$(AARCH64_SRC)/fcvt.ref) 17 19 18 20 AARCH64_TESTS += pauth-1 pauth-2 19 - run-pauth-%: QEMU += -cpu max 21 + run-pauth-%: QEMU_OPTS += -cpu max 20 22 21 - TESTS:=$(AARCH64_TESTS) 23 + TESTS += $(AARCH64_TESTS)
-4
tests/tcg/arm/Makefile.softmmu-target
··· 3 3 # ARM SoftMMU tests - included from tests/tcg/Makefile 4 4 # 5 5 6 - ifeq ($(TARGET_ABI_DIR),arm) 7 - 8 6 ARM_SRC=$(SRC_PATH)/tests/tcg/arm 9 7 10 8 # Set search path for all sources ··· 25 23 test-armv6m-undef: EXTRA_CFLAGS+=-mcpu=cortex-m0 26 24 27 25 run-test-armv6m-undef: QEMU_OPTS+=-semihosting -M microbit -kernel 28 - 29 - endif
-8
tests/tcg/i386/Makefile.softmmu-target
··· 12 12 # These objects provide the basic boot code and helper functions for all tests 13 13 CRT_OBJS=boot.o 14 14 15 - ifeq ($(TARGET_X86_64), y) 16 - CRT_PATH=$(X64_SYSTEM_SRC) 17 - CFLAGS=-march=x86-64 18 - LINK_SCRIPT=$(X64_SYSTEM_SRC)/kernel.ld 19 - LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_x86_64 20 - else 21 15 CRT_PATH=$(I386_SYSTEM_SRC) 22 - CFLAGS+=-m32 23 16 LINK_SCRIPT=$(I386_SYSTEM_SRC)/kernel.ld 24 17 LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_i386 25 - endif 26 18 CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC) 27 19 LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc 28 20
+5 -8
tests/tcg/i386/Makefile.target
··· 6 6 VPATH += $(I386_SRC) 7 7 8 8 I386_SRCS=$(notdir $(wildcard $(I386_SRC)/*.c)) 9 - I386_TESTS=$(I386_SRCS:.c=) 10 - I386_ONLY_TESTS=$(filter-out test-i386-ssse3, $(I386_TESTS)) 9 + ALL_X86_TESTS=$(I386_SRCS:.c=) 10 + I386_TESTS:=$(filter-out test-i386-ssse3, $(ALL_X86_TESTS)) 11 + X86_64_TESTS:=$(filter test-i386-ssse3, $(ALL_X86_TESTS)) 11 12 # Update TESTS 12 - TESTS+=$(I386_ONLY_TESTS) 13 - 14 - ifneq ($(TARGET_NAME),x86_64) 15 - CFLAGS+=-m32 16 - endif 13 + TESTS=$(MULTIARCH_TESTS) $(I386_TESTS) 17 14 18 15 # 19 16 # hello-i386 is a barebones app ··· 26 23 # 27 24 28 25 test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S test-i386.h test-i386-shift.h test-i386-muldiv.h 29 - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ 26 + $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_CFLAGS) -o $@ \ 30 27 $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm 31 28 32 29 ifeq ($(SPEED), slow)
+36
tests/tcg/x86_64/Makefile.softmmu-target
··· 1 + # 2 + # x86 system tests 3 + # 4 + # This currently builds only for i386. The common C code is built 5 + # with standard compiler flags however so we can support both by 6 + # adding additional boot files for x86_64. 7 + # 8 + 9 + I386_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/i386/system 10 + X64_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/x86_64/system 11 + 12 + # These objects provide the basic boot code and helper functions for all tests 13 + CRT_OBJS=boot.o 14 + 15 + CRT_PATH=$(X64_SYSTEM_SRC) 16 + LINK_SCRIPT=$(X64_SYSTEM_SRC)/kernel.ld 17 + LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_x86_64 18 + CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC) 19 + LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc 20 + 21 + TESTS+=$(MULTIARCH_TESTS) 22 + 23 + # building head blobs 24 + .PRECIOUS: $(CRT_OBJS) 25 + 26 + %.o: $(CRT_PATH)/%.S 27 + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@ 28 + 29 + # Build and link the tests 30 + %: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS) 31 + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) 32 + 33 + memory: CFLAGS+=-DCHECK_UNALIGNED=1 34 + 35 + # Running 36 + QEMU_OPTS+=-device isa-debugcon,chardev=output -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel
+4 -3
tests/tcg/x86_64/Makefile.target
··· 6 6 # $(SRC)/tests/tcg/i386/ 7 7 # 8 8 9 - X86_64_TESTS=$(filter-out $(I386_ONLY_TESTS), $(TESTS)) 10 - X86_64_TESTS+=test-x86_64 11 - TESTS:=$(X86_64_TESTS) 9 + include $(SRC_PATH)/tests/tcg/i386/Makefile.target 10 + 11 + TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64 12 + QEMU_OPTS += -cpu max 12 13 13 14 test-x86_64: LDFLAGS+=-lm -lc 14 15 test-x86_64: test-i386.c test-i386.h test-i386-shift.h test-i386-muldiv.h