Thomas Gleixner | ec8f24b | 2019-05-19 13:07:45 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0-only |
Paolo Bonzini | c2390f1 | 2019-04-11 15:51:19 +0200 | [diff] [blame] | 2 | include ../../../../scripts/Kbuild.include |
| 3 | |
Paolo Bonzini | 783e9e5 | 2018-03-27 11:49:19 +0200 | [diff] [blame] | 4 | all: |
| 5 | |
Andrew Jones | cc68765 | 2018-09-18 19:54:26 +0200 | [diff] [blame] | 6 | top_srcdir = ../../../.. |
Shuah Khan | 211929f | 2018-12-12 20:25:14 -0700 | [diff] [blame] | 7 | KSFT_KHDR_INSTALL := 1 |
Paolo Bonzini | 783e9e5 | 2018-03-27 11:49:19 +0200 | [diff] [blame] | 8 | UNAME_M := $(shell uname -m) |
| 9 | |
Thomas Huth | 2040f41 | 2019-07-31 17:15:23 +0200 | [diff] [blame] | 10 | LIBKVM = lib/assert.c lib/elf.c lib/io.c lib/kvm_util.c lib/sparsebit.c |
| 11 | LIBKVM_x86_64 = lib/x86_64/processor.c lib/x86_64/vmx.c lib/x86_64/ucall.c |
| 12 | LIBKVM_aarch64 = lib/aarch64/processor.c lib/aarch64/ucall.c |
Thomas Huth | f90f57b | 2019-07-31 17:15:24 +0200 | [diff] [blame] | 13 | LIBKVM_s390x = lib/s390x/processor.c lib/s390x/ucall.c |
Paolo Bonzini | 783e9e5 | 2018-03-27 11:49:19 +0200 | [diff] [blame] | 14 | |
Aaron Lewis | 61cfcd5 | 2019-05-21 17:13:58 +0000 | [diff] [blame] | 15 | TEST_GEN_PROGS_x86_64 = x86_64/cr4_cpuid_sync_test |
Vitaly Kuznetsov | 18178ff | 2018-10-16 18:50:11 +0200 | [diff] [blame] | 16 | TEST_GEN_PROGS_x86_64 += x86_64/evmcs_test |
Vitaly Kuznetsov | 7edcb73 | 2018-12-10 18:21:59 +0100 | [diff] [blame] | 17 | TEST_GEN_PROGS_x86_64 += x86_64/hyperv_cpuid |
Aaron Lewis | 9dba988 | 2019-05-31 14:14:52 +0000 | [diff] [blame] | 18 | TEST_GEN_PROGS_x86_64 += x86_64/mmio_warning_test |
Aaron Lewis | 61cfcd5 | 2019-05-21 17:13:58 +0000 | [diff] [blame] | 19 | TEST_GEN_PROGS_x86_64 += x86_64/platform_info_test |
| 20 | TEST_GEN_PROGS_x86_64 += x86_64/set_sregs_test |
| 21 | TEST_GEN_PROGS_x86_64 += x86_64/smm_test |
| 22 | TEST_GEN_PROGS_x86_64 += x86_64/state_test |
| 23 | TEST_GEN_PROGS_x86_64 += x86_64/sync_regs_test |
| 24 | TEST_GEN_PROGS_x86_64 += x86_64/vmx_close_while_nested_test |
Paolo Bonzini | 0944442 | 2019-09-26 15:01:15 +0200 | [diff] [blame] | 25 | TEST_GEN_PROGS_x86_64 += x86_64/vmx_dirty_log_test |
Aaron Lewis | da1e307 | 2019-05-02 11:31:41 -0700 | [diff] [blame] | 26 | TEST_GEN_PROGS_x86_64 += x86_64/vmx_set_nested_state_test |
Aaron Lewis | 61cfcd5 | 2019-05-21 17:13:58 +0000 | [diff] [blame] | 27 | TEST_GEN_PROGS_x86_64 += x86_64/vmx_tsc_adjust_test |
Aaron Lewis | c90992b | 2019-10-21 16:30:28 -0700 | [diff] [blame] | 28 | TEST_GEN_PROGS_x86_64 += x86_64/xss_msr_test |
Paolo Bonzini | 2a31b9d | 2018-10-23 02:36:47 +0200 | [diff] [blame] | 29 | TEST_GEN_PROGS_x86_64 += clear_dirty_log_test |
Aaron Lewis | 61cfcd5 | 2019-05-21 17:13:58 +0000 | [diff] [blame] | 30 | TEST_GEN_PROGS_x86_64 += dirty_log_test |
Paolo Bonzini | fd4198bf | 2019-07-15 12:50:46 +0200 | [diff] [blame] | 31 | TEST_GEN_PROGS_x86_64 += kvm_create_max_vcpus |
Andrew Jones | fff8dcd | 2018-09-18 19:54:32 +0200 | [diff] [blame] | 32 | |
Paolo Bonzini | 2a31b9d | 2018-10-23 02:36:47 +0200 | [diff] [blame] | 33 | TEST_GEN_PROGS_aarch64 += clear_dirty_log_test |
Aaron Lewis | 61cfcd5 | 2019-05-21 17:13:58 +0000 | [diff] [blame] | 34 | TEST_GEN_PROGS_aarch64 += dirty_log_test |
Thomas Huth | 49fe9a5 | 2019-05-23 18:43:09 +0200 | [diff] [blame] | 35 | TEST_GEN_PROGS_aarch64 += kvm_create_max_vcpus |
Paolo Bonzini | 783e9e5 | 2018-03-27 11:49:19 +0200 | [diff] [blame] | 36 | |
Thomas Huth | be6f55a | 2019-08-29 15:07:32 +0200 | [diff] [blame] | 37 | TEST_GEN_PROGS_s390x = s390x/memop |
Thomas Huth | ee1563f | 2019-05-23 18:43:07 +0200 | [diff] [blame] | 38 | TEST_GEN_PROGS_s390x += s390x/sync_regs_test |
Thomas Huth | a049a37 | 2019-07-31 17:15:25 +0200 | [diff] [blame] | 39 | TEST_GEN_PROGS_s390x += dirty_log_test |
Thomas Huth | 49fe9a5 | 2019-05-23 18:43:09 +0200 | [diff] [blame] | 40 | TEST_GEN_PROGS_s390x += kvm_create_max_vcpus |
Paolo Bonzini | 783e9e5 | 2018-03-27 11:49:19 +0200 | [diff] [blame] | 41 | |
| 42 | TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M)) |
| 43 | LIBKVM += $(LIBKVM_$(UNAME_M)) |
| 44 | |
| 45 | INSTALL_HDR_PATH = $(top_srcdir)/usr |
| 46 | LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/ |
Andrew Jones | cc68765 | 2018-09-18 19:54:26 +0200 | [diff] [blame] | 47 | LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include |
Sean Christopherson | a5543d3 | 2019-12-20 20:44:56 -0800 | [diff] [blame^] | 48 | LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/x86/include |
Thomas Huth | 319f6f9 | 2019-05-17 11:04:45 +0200 | [diff] [blame] | 49 | CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \ |
| 50 | -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \ |
Sean Christopherson | a5543d3 | 2019-12-20 20:44:56 -0800 | [diff] [blame^] | 51 | -I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \ |
| 52 | -I$(<D) -Iinclude/$(UNAME_M) -I.. |
Paolo Bonzini | c2390f1 | 2019-04-11 15:51:19 +0200 | [diff] [blame] | 53 | |
| 54 | no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ |
Shuah Khan | 6e06983 | 2019-10-02 17:14:30 -0600 | [diff] [blame] | 55 | $(CC) -Werror -no-pie -x c - -o "$$TMP", -no-pie) |
Paolo Bonzini | c2390f1 | 2019-04-11 15:51:19 +0200 | [diff] [blame] | 56 | |
Christian Borntraeger | 8343ba2 | 2019-05-24 12:27:01 +0200 | [diff] [blame] | 57 | # On s390, build the testcases KVM-enabled |
| 58 | pgste-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 | |
| 62 | LDFLAGS += -pthread $(no-pie-option) $(pgste-option) |
Paolo Bonzini | 783e9e5 | 2018-03-27 11:49:19 +0200 | [diff] [blame] | 63 | |
| 64 | # After inclusion, $(OUTPUT) is defined and |
| 65 | # $(TEST_GEN_PROGS) starts with $(OUTPUT)/ |
| 66 | include ../lib.mk |
| 67 | |
| 68 | STATIC_LIBS := $(OUTPUT)/libkvm.a |
| 69 | LIBKVM_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM)) |
Andrew Jones | eea192b | 2018-09-18 19:54:27 +0200 | [diff] [blame] | 70 | EXTRA_CLEAN += $(LIBKVM_OBJ) $(STATIC_LIBS) cscope.* |
Paolo Bonzini | 783e9e5 | 2018-03-27 11:49:19 +0200 | [diff] [blame] | 71 | |
| 72 | x := $(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 Roxell | b2d35fa | 2018-09-04 12:47:21 +0200 | [diff] [blame] | 79 | all: $(STATIC_LIBS) |
Paolo Bonzini | 783e9e5 | 2018-03-27 11:49:19 +0200 | [diff] [blame] | 80 | $(TEST_GEN_PROGS): $(STATIC_LIBS) |
Andrew Jones | eea192b | 2018-09-18 19:54:27 +0200 | [diff] [blame] | 81 | |
| 82 | cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib .. |
| 83 | cscope: |
| 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 |