xref: /kvm-unit-tests/s390x/Makefile (revision 1f08a91a41402b0e032ecce8ed1b5952cbfca0ea)
1tests = $(TEST_DIR)/selftest.elf
2tests += $(TEST_DIR)/selftest-migration.elf
3tests += $(TEST_DIR)/memory-verify.elf
4tests += $(TEST_DIR)/intercept.elf
5tests += $(TEST_DIR)/emulator.elf
6tests += $(TEST_DIR)/sieve.elf
7tests += $(TEST_DIR)/sthyi.elf
8tests += $(TEST_DIR)/tprot.elf
9tests += $(TEST_DIR)/skey.elf
10tests += $(TEST_DIR)/diag10.elf
11tests += $(TEST_DIR)/diag308.elf
12tests += $(TEST_DIR)/pfmf.elf
13tests += $(TEST_DIR)/cmm.elf
14tests += $(TEST_DIR)/vector.elf
15tests += $(TEST_DIR)/gs.elf
16tests += $(TEST_DIR)/iep.elf
17tests += $(TEST_DIR)/cpumodel.elf
18tests += $(TEST_DIR)/diag288.elf
19tests += $(TEST_DIR)/stsi.elf
20tests += $(TEST_DIR)/skrf.elf
21tests += $(TEST_DIR)/smp.elf
22tests += $(TEST_DIR)/sclp.elf
23tests += $(TEST_DIR)/sck.elf
24tests += $(TEST_DIR)/css.elf
25tests += $(TEST_DIR)/uv-guest.elf
26tests += $(TEST_DIR)/sie.elf
27tests += $(TEST_DIR)/mvpg.elf
28tests += $(TEST_DIR)/uv-host.elf
29tests += $(TEST_DIR)/edat.elf
30tests += $(TEST_DIR)/mvpg-sie.elf
31tests += $(TEST_DIR)/spec_ex-sie.elf
32tests += $(TEST_DIR)/spec_ex.elf
33tests += $(TEST_DIR)/firq.elf
34tests += $(TEST_DIR)/epsw.elf
35tests += $(TEST_DIR)/adtl-status.elf
36tests += $(TEST_DIR)/migration.elf
37tests += $(TEST_DIR)/pv-attest.elf
38tests += $(TEST_DIR)/migration-cmm.elf
39tests += $(TEST_DIR)/migration-skey.elf
40tests += $(TEST_DIR)/panic-loop-extint.elf
41tests += $(TEST_DIR)/panic-loop-pgm.elf
42tests += $(TEST_DIR)/migration-sck.elf
43tests += $(TEST_DIR)/exittime.elf
44tests += $(TEST_DIR)/ex.elf
45tests += $(TEST_DIR)/topology.elf
46tests += $(TEST_DIR)/sie-dat.elf
47tests += $(TEST_DIR)/diag258.elf
48tests += $(TEST_DIR)/stfle-sie.elf
49
50pv-tests += $(TEST_DIR)/pv-diags.elf
51pv-tests += $(TEST_DIR)/pv-icptcode.elf
52pv-tests += $(TEST_DIR)/pv-ipl.elf
53
54# Add PV host tests if we're able to generate them
55# The host key document and a tool to generate SE headers are the prerequisite
56ifneq ($(HOST_KEY_DOCUMENT),)
57ifneq ($(GEN_SE_HEADER),)
58tests += $(pv-tests)
59endif
60endif
61
62# Add binary flat images for use in non-KVM hypervisors
63tests_binary = $(patsubst %.elf,%.bin,$(tests))
64ifneq ($(HOST_KEY_DOCUMENT),)
65tests_pv_binary = $(patsubst %.bin,%.pv.bin,$(tests_binary))
66else
67tests_pv_binary =
68GEN_SE_HEADER =
69endif
70snippets-obj = $(patsubst %.gbin,%.gobj,$(snippets))
71
72all: directories test_cases test_cases_binary test_cases_pv
73
74test_cases: $(tests)
75test_cases_binary: $(tests_binary)
76test_cases_pv: $(tests_pv_binary)
77
78SNIPPET_INCLUDE :=
79INCLUDE_PATHS = $(SNIPPET_INCLUDE) $(SRCDIR)/lib $(SRCDIR)/lib/s390x $(SRCDIR)/s390x
80# Include generated header files (e.g. in case of out-of-source builds)
81INCLUDE_PATHS += lib
82CPPFLAGS = $(addprefix -I,$(INCLUDE_PATHS))
83
84CFLAGS += -std=gnu99
85CFLAGS += -ffreestanding
86CFLAGS += $(CPPFLAGS)
87CFLAGS += -O2
88CFLAGS += -march=zEC12
89CFLAGS += -mbackchain
90CFLAGS += -fno-delete-null-pointer-checks
91LDFLAGS += -Wl,--build-id=none
92
93# We want to keep intermediate files
94.PRECIOUS: %.o %.lds
95
96asm-offsets = lib/$(ARCH)/asm-offsets.h
97include $(SRCDIR)/scripts/asm-offsets.mak
98
99cflatobjs += lib/auxinfo.o
100cflatobjs += lib/util.o
101cflatobjs += lib/alloc.o
102cflatobjs += lib/alloc_phys.o
103cflatobjs += lib/alloc_page.o
104cflatobjs += lib/vmalloc.o
105cflatobjs += lib/alloc_phys.o
106cflatobjs += lib/getchar.o
107cflatobjs += lib/migrate.o
108cflatobjs += lib/s390x/io.o
109cflatobjs += lib/s390x/stack.o
110cflatobjs += lib/s390x/sclp.o
111cflatobjs += lib/s390x/sclp-console.o
112cflatobjs += lib/s390x/interrupt.o
113cflatobjs += lib/s390x/mmu.o
114cflatobjs += lib/s390x/smp.o
115cflatobjs += lib/s390x/hardware.o
116cflatobjs += lib/s390x/css_dump.o
117cflatobjs += lib/s390x/css_lib.o
118cflatobjs += lib/s390x/malloc_io.o
119cflatobjs += lib/s390x/uv.o
120cflatobjs += lib/s390x/sie.o
121cflatobjs += lib/s390x/sie-icpt.o
122cflatobjs += lib/s390x/fault.o
123
124OBJDIRS += lib/s390x
125
126asmlib = $(TEST_DIR)/cstart64.o $(TEST_DIR)/cpu.o $(TEST_DIR)/cpu-sie.o
127
128FLATLIBS = $(libcflat)
129
130# Snippets
131SNIPPET_DIR = $(TEST_DIR)/snippets
132SNIPPET_SRC_DIR = $(SRCDIR)/s390x/snippets
133snippet_asmlib = $(SNIPPET_DIR)/c/cstart.o
134snippet_lib = $(snippet_asmlib) lib/auxinfo.o
135include $(SNIPPET_SRC_DIR)/Makefile
136
137# perquisites (=guests) for the snippet hosts.
138# $(TEST_DIR)/<snippet-host>.elf: snippets = $(SNIPPET_DIR)/<c/asm>/<snippet>.gbin
139$(TEST_DIR)/mvpg-sie.elf: snippets = $(SNIPPET_DIR)/c/mvpg-snippet.gbin
140$(TEST_DIR)/sie-dat.elf: snippets = $(SNIPPET_DIR)/c/sie-dat.gbin
141$(TEST_DIR)/spec_ex-sie.elf: snippets = $(SNIPPET_DIR)/c/spec_ex.gbin
142$(TEST_DIR)/stfle-sie.elf: snippets = $(SNIPPET_DIR)/c/stfle.gbin
143
144$(TEST_DIR)/pv-diags.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-diag-yield.gbin
145$(TEST_DIR)/pv-diags.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-diag-288.gbin
146$(TEST_DIR)/pv-diags.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-diag-500.gbin
147$(TEST_DIR)/pv-icptcode.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-icpt-112.gbin
148$(TEST_DIR)/pv-icptcode.elf: pv-snippets += $(SNIPPET_DIR)/asm/icpt-loop.gbin
149$(TEST_DIR)/pv-icptcode.elf: pv-snippets += $(SNIPPET_DIR)/asm/loop.gbin
150$(TEST_DIR)/pv-icptcode.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-icpt-vir-timing.gbin
151$(TEST_DIR)/pv-ipl.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-diag-308.gbin
152
153# Add PV tests and snippets if GEN_SE_HEADER is set
154ifneq ($(GEN_SE_HEADER),)
155snippets += $(pv-snippets)
156tests += $(pv-tests)
157snippet-hdr-obj = $(patsubst %.gbin,%.hdr.obj,$(pv-snippets))
158else
159snippet-hdr-obj =
160endif
161
162# Generate loader script
163lds-autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d -MT $@
164%.lds: %.lds.S $(asm-offsets)
165	$(CPP) $(lds-autodepend-flags) $(CPPFLAGS) -P -C -o $@ $<
166
167%.aux.o: $(SRCDIR)/lib/auxinfo.c
168	$(CC) $(CFLAGS) -c -o $@ $< -DPROGNAME=\"$(@:.aux.o=.elf)\"
169
170.SECONDEXPANSION:
171%.elf: $(FLATLIBS) $(asmlib) $(TEST_DIR)/flat.lds $$(snippets-obj) $$(snippet-hdr-obj) %.o %.aux.o
172	@$(CC) $(LDFLAGS) -o $@ -T $(TEST_DIR)/flat.lds \
173		$(filter %.o, $^) $(FLATLIBS) $(snippets-obj) $(snippet-hdr-obj) || \
174		{ echo "Failure probably caused by missing definition of gen-se-header executable"; exit 1; }
175	@chmod a-x $@
176
177# Secure Execution Customer Communication Key file
178# 32 bytes of key material, uses existing one if available
179comm-key = $(TEST_DIR)/comm.key
180$(comm-key):
181	dd if=/dev/urandom of=$@ bs=32 count=1 status=none
182
183%.bin: %.elf
184	$(OBJCOPY) -O binary  $< $@
185
186define test_genprotimg_opt
187$(shell $(GENPROTIMG) --help | grep -q -- "$1" && echo yes || echo no)
188endef
189
190GENPROTIMG_DEFAULT_ARGS := --no-verify
191ifneq ($(HOST_KEY_DOCUMENT),)
192# The genprotimg arguments for the cck changed over time so we need to
193# figure out which argument to use in order to set the cck
194ifeq ($(call test_genprotimg_opt,--comm-key),yes)
195	GENPROTIMG_COMM_OPTION := --comm-key
196else
197	GENPROTIMG_COMM_OPTION := --x-comm-key
198endif
199# Newer version of the genprotimg command checks if the given image/kernel is a
200# s390x Linux kernel and it does not overwrite the output file by default.
201# Disable the component check, since a KUT test is being prepared, and always
202# overwrite the output.
203ifeq ($(call test_genprotimg_opt,--overwrite),yes)
204	GENPROTIMG_DEFAULT_ARGS += --overwrite --no-component-check
205endif
206endif
207
208ifeq ($(CONFIG_DUMP),yes)
209	# allow dumping + PCKMO
210	GENPROTIMG_PCF := 0x200000e0
211else
212	# allow PCKMO
213	GENPROTIMG_PCF := 0x000000e0
214endif
215
216$(patsubst %.parmfile,%.pv.bin,$(wildcard s390x/*.parmfile)): %.pv.bin: %.parmfile
217%.pv.bin: %.bin $(HOST_KEY_DOCUMENT) $(comm-key)
218	$(eval parmfile_args = $(if $(filter %.parmfile,$^),--parmfile $(filter %.parmfile,$^),))
219	$(GENPROTIMG) $(GENPROTIMG_DEFAULT_ARGS) --host-key-document $(HOST_KEY_DOCUMENT) $(GENPROTIMG_COMM_OPTION) $(comm-key) --x-pcf $(GENPROTIMG_PCF) $(parmfile_args) --image $(filter %.bin,$^) -o $@
220
221$(snippet_asmlib): $$(patsubst %.o,%.S,$$@) $(asm-offsets)
222	$(CC) $(CFLAGS) -c -nostdlib -o $@ $<
223
224
225arch_clean: asm_offsets_clean snippet_clean
226	$(RM) $(TEST_DIR)/*.{o,elf,bin,lds} $(TEST_DIR)/.*.d lib/s390x/.*.d $(comm-key)
227
228generated-files = $(asm-offsets)
229$(tests:.elf=.o) $(asmlib) $(cflatobjs): $(generated-files)
230