blob: 608fa835c764dacebd0e1020e8b991dbdd068755 [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
Aaron Lewisc90992b2019-10-21 16:30:28 -070028TEST_GEN_PROGS_x86_64 += x86_64/xss_msr_test
Paolo Bonzini2a31b9d2018-10-23 02:36:47 +020029TEST_GEN_PROGS_x86_64 += clear_dirty_log_test
Aaron Lewis61cfcd52019-05-21 17:13:58 +000030TEST_GEN_PROGS_x86_64 += dirty_log_test
Paolo Bonzinifd4198bf2019-07-15 12:50:46 +020031TEST_GEN_PROGS_x86_64 += kvm_create_max_vcpus
Andrew Jonesfff8dcd2018-09-18 19:54:32 +020032
Paolo Bonzini2a31b9d2018-10-23 02:36:47 +020033TEST_GEN_PROGS_aarch64 += clear_dirty_log_test
Aaron Lewis61cfcd52019-05-21 17:13:58 +000034TEST_GEN_PROGS_aarch64 += dirty_log_test
Thomas Huth49fe9a52019-05-23 18:43:09 +020035TEST_GEN_PROGS_aarch64 += kvm_create_max_vcpus
Paolo Bonzini783e9e52018-03-27 11:49:19 +020036
Thomas Huthbe6f55a2019-08-29 15:07:32 +020037TEST_GEN_PROGS_s390x = s390x/memop
Thomas Huthee1563f2019-05-23 18:43:07 +020038TEST_GEN_PROGS_s390x += s390x/sync_regs_test
Thomas Hutha049a372019-07-31 17:15:25 +020039TEST_GEN_PROGS_s390x += dirty_log_test
Thomas Huth49fe9a52019-05-23 18:43:09 +020040TEST_GEN_PROGS_s390x += kvm_create_max_vcpus
Paolo Bonzini783e9e52018-03-27 11:49:19 +020041
42TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M))
43LIBKVM += $(LIBKVM_$(UNAME_M))
44
45INSTALL_HDR_PATH = $(top_srcdir)/usr
46LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
Andrew Jonescc687652018-09-18 19:54:26 +020047LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include
Sean Christophersona5543d32019-12-20 20:44:56 -080048LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/x86/include
Thomas Huth319f6f92019-05-17 11:04:45 +020049CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
50 -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
Sean Christophersona5543d32019-12-20 20:44:56 -080051 -I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \
52 -I$(<D) -Iinclude/$(UNAME_M) -I..
Paolo Bonzinic2390f12019-04-11 15:51:19 +020053
54no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \
Shuah Khan6e069832019-10-02 17:14:30 -060055 $(CC) -Werror -no-pie -x c - -o "$$TMP", -no-pie)
Paolo Bonzinic2390f12019-04-11 15:51:19 +020056
Christian Borntraeger8343ba22019-05-24 12:27:01 +020057# On s390, build the testcases KVM-enabled
58pgste-option = $(call try-run, echo 'int main() { return 0; }' | \
59 $(CC) -Werror -Wl$(comma)--s390-pgste -x c - -o "$$TMP",-Wl$(comma)--s390-pgste)
60
61
62LDFLAGS += -pthread $(no-pie-option) $(pgste-option)
Paolo Bonzini783e9e52018-03-27 11:49:19 +020063
64# After inclusion, $(OUTPUT) is defined and
65# $(TEST_GEN_PROGS) starts with $(OUTPUT)/
66include ../lib.mk
67
68STATIC_LIBS := $(OUTPUT)/libkvm.a
69LIBKVM_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM))
Andrew Joneseea192b2018-09-18 19:54:27 +020070EXTRA_CLEAN += $(LIBKVM_OBJ) $(STATIC_LIBS) cscope.*
Paolo Bonzini783e9e52018-03-27 11:49:19 +020071
72x := $(shell mkdir -p $(sort $(dir $(LIBKVM_OBJ))))
73$(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c
74 $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
75
76$(OUTPUT)/libkvm.a: $(LIBKVM_OBJ)
77 $(AR) crs $@ $^
78
Anders Roxellb2d35fa2018-09-04 12:47:21 +020079all: $(STATIC_LIBS)
Paolo Bonzini783e9e52018-03-27 11:49:19 +020080$(TEST_GEN_PROGS): $(STATIC_LIBS)
Andrew Joneseea192b2018-09-18 19:54:27 +020081
82cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib ..
83cscope:
84 $(RM) cscope.*
85 (find $(include_paths) -name '*.h' \
86 -exec realpath --relative-base=$(PWD) {} \;; \
87 find . -name '*.c' \
88 -exec realpath --relative-base=$(PWD) {} \;) | sort -u > cscope.files
89 cscope -b