blob: fd84b7a78dcff2090f41caffa5b471e988dd7474 [file] [log] [blame]
Thomas Gleixnerec8f24b2019-05-19 13:07:45 +01001# SPDX-License-Identifier: GPL-2.0-only
Paolo Bonzinic2390f12019-04-11 15:51:19 +02002include ../../../../scripts/Kbuild.include
3
Paolo Bonzini783e9e52018-03-27 11:49:19 +02004all:
5
Andrew Jonescc687652018-09-18 19:54:26 +02006top_srcdir = ../../../..
Shuah Khan211929f2018-12-12 20:25:14 -07007KSFT_KHDR_INSTALL := 1
Paolo Bonzini783e9e52018-03-27 11:49:19 +02008UNAME_M := $(shell uname -m)
9
Thomas Huth2040f412019-07-31 17:15:23 +020010LIBKVM = lib/assert.c lib/elf.c lib/io.c lib/kvm_util.c lib/sparsebit.c
11LIBKVM_x86_64 = lib/x86_64/processor.c lib/x86_64/vmx.c lib/x86_64/ucall.c
12LIBKVM_aarch64 = lib/aarch64/processor.c lib/aarch64/ucall.c
Thomas Huthf90f57b2019-07-31 17:15:24 +020013LIBKVM_s390x = lib/s390x/processor.c lib/s390x/ucall.c
Paolo Bonzini783e9e52018-03-27 11:49:19 +020014
Aaron Lewis61cfcd52019-05-21 17:13:58 +000015TEST_GEN_PROGS_x86_64 = x86_64/cr4_cpuid_sync_test
Vitaly Kuznetsov18178ff2018-10-16 18:50:11 +020016TEST_GEN_PROGS_x86_64 += x86_64/evmcs_test
Vitaly Kuznetsov7edcb732018-12-10 18:21:59 +010017TEST_GEN_PROGS_x86_64 += x86_64/hyperv_cpuid
Aaron Lewis9dba9882019-05-31 14:14:52 +000018TEST_GEN_PROGS_x86_64 += x86_64/mmio_warning_test
Aaron Lewis61cfcd52019-05-21 17:13:58 +000019TEST_GEN_PROGS_x86_64 += x86_64/platform_info_test
20TEST_GEN_PROGS_x86_64 += x86_64/set_sregs_test
21TEST_GEN_PROGS_x86_64 += x86_64/smm_test
22TEST_GEN_PROGS_x86_64 += x86_64/state_test
23TEST_GEN_PROGS_x86_64 += x86_64/sync_regs_test
24TEST_GEN_PROGS_x86_64 += x86_64/vmx_close_while_nested_test
Paolo Bonzini09444422019-09-26 15:01:15 +020025TEST_GEN_PROGS_x86_64 += x86_64/vmx_dirty_log_test
Aaron Lewisda1e3072019-05-02 11:31:41 -070026TEST_GEN_PROGS_x86_64 += x86_64/vmx_set_nested_state_test
Aaron Lewis61cfcd52019-05-21 17:13:58 +000027TEST_GEN_PROGS_x86_64 += x86_64/vmx_tsc_adjust_test
Paolo Bonzini2a31b9d2018-10-23 02:36:47 +020028TEST_GEN_PROGS_x86_64 += clear_dirty_log_test
Aaron Lewis61cfcd52019-05-21 17:13:58 +000029TEST_GEN_PROGS_x86_64 += dirty_log_test
Paolo Bonzinifd4198bf2019-07-15 12:50:46 +020030TEST_GEN_PROGS_x86_64 += kvm_create_max_vcpus
Andrew Jonesfff8dcd2018-09-18 19:54:32 +020031
Paolo Bonzini2a31b9d2018-10-23 02:36:47 +020032TEST_GEN_PROGS_aarch64 += clear_dirty_log_test
Aaron Lewis61cfcd52019-05-21 17:13:58 +000033TEST_GEN_PROGS_aarch64 += dirty_log_test
Thomas Huth49fe9a52019-05-23 18:43:09 +020034TEST_GEN_PROGS_aarch64 += kvm_create_max_vcpus
Paolo Bonzini783e9e52018-03-27 11:49:19 +020035
Thomas Huthbe6f55a2019-08-29 15:07:32 +020036TEST_GEN_PROGS_s390x = s390x/memop
Thomas Huthee1563f2019-05-23 18:43:07 +020037TEST_GEN_PROGS_s390x += s390x/sync_regs_test
Thomas Hutha049a372019-07-31 17:15:25 +020038TEST_GEN_PROGS_s390x += dirty_log_test
Thomas Huth49fe9a52019-05-23 18:43:09 +020039TEST_GEN_PROGS_s390x += kvm_create_max_vcpus
Paolo Bonzini783e9e52018-03-27 11:49:19 +020040
41TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M))
42LIBKVM += $(LIBKVM_$(UNAME_M))
43
44INSTALL_HDR_PATH = $(top_srcdir)/usr
45LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
Andrew Jonescc687652018-09-18 19:54:26 +020046LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include
Thomas Huth319f6f92019-05-17 11:04:45 +020047CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
48 -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
49 -I$(LINUX_HDR_PATH) -Iinclude -I$(<D) -Iinclude/$(UNAME_M) -I..
Paolo Bonzinic2390f12019-04-11 15:51:19 +020050
51no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \
52 $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie)
53
Christian Borntraeger8343ba22019-05-24 12:27:01 +020054# On s390, build the testcases KVM-enabled
55pgste-option = $(call try-run, echo 'int main() { return 0; }' | \
56 $(CC) -Werror -Wl$(comma)--s390-pgste -x c - -o "$$TMP",-Wl$(comma)--s390-pgste)
57
58
59LDFLAGS += -pthread $(no-pie-option) $(pgste-option)
Paolo Bonzini783e9e52018-03-27 11:49:19 +020060
61# After inclusion, $(OUTPUT) is defined and
62# $(TEST_GEN_PROGS) starts with $(OUTPUT)/
63include ../lib.mk
64
65STATIC_LIBS := $(OUTPUT)/libkvm.a
66LIBKVM_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM))
Andrew Joneseea192b2018-09-18 19:54:27 +020067EXTRA_CLEAN += $(LIBKVM_OBJ) $(STATIC_LIBS) cscope.*
Paolo Bonzini783e9e52018-03-27 11:49:19 +020068
69x := $(shell mkdir -p $(sort $(dir $(LIBKVM_OBJ))))
70$(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c
71 $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
72
73$(OUTPUT)/libkvm.a: $(LIBKVM_OBJ)
74 $(AR) crs $@ $^
75
Anders Roxellb2d35fa2018-09-04 12:47:21 +020076all: $(STATIC_LIBS)
Paolo Bonzini783e9e52018-03-27 11:49:19 +020077$(TEST_GEN_PROGS): $(STATIC_LIBS)
Andrew Joneseea192b2018-09-18 19:54:27 +020078
79cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib ..
80cscope:
81 $(RM) cscope.*
82 (find $(include_paths) -name '*.h' \
83 -exec realpath --relative-base=$(PWD) {} \;; \
84 find . -name '*.c' \
85 -exec realpath --relative-base=$(PWD) {} \;) | sort -u > cscope.files
86 cscope -b