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 |
Paolo Bonzini | 2a31b9d | 2018-10-23 02:36:47 +0200 | [diff] [blame] | 28 | TEST_GEN_PROGS_x86_64 += clear_dirty_log_test |
Aaron Lewis | 61cfcd5 | 2019-05-21 17:13:58 +0000 | [diff] [blame] | 29 | TEST_GEN_PROGS_x86_64 += dirty_log_test |
Paolo Bonzini | fd4198bf | 2019-07-15 12:50:46 +0200 | [diff] [blame] | 30 | TEST_GEN_PROGS_x86_64 += kvm_create_max_vcpus |
Andrew Jones | fff8dcd | 2018-09-18 19:54:32 +0200 | [diff] [blame] | 31 | |
Paolo Bonzini | 2a31b9d | 2018-10-23 02:36:47 +0200 | [diff] [blame] | 32 | TEST_GEN_PROGS_aarch64 += clear_dirty_log_test |
Aaron Lewis | 61cfcd5 | 2019-05-21 17:13:58 +0000 | [diff] [blame] | 33 | TEST_GEN_PROGS_aarch64 += dirty_log_test |
Thomas Huth | 49fe9a5 | 2019-05-23 18:43:09 +0200 | [diff] [blame] | 34 | TEST_GEN_PROGS_aarch64 += kvm_create_max_vcpus |
Paolo Bonzini | 783e9e5 | 2018-03-27 11:49:19 +0200 | [diff] [blame] | 35 | |
Thomas Huth | be6f55a | 2019-08-29 15:07:32 +0200 | [diff] [blame] | 36 | TEST_GEN_PROGS_s390x = s390x/memop |
Thomas Huth | ee1563f | 2019-05-23 18:43:07 +0200 | [diff] [blame] | 37 | TEST_GEN_PROGS_s390x += s390x/sync_regs_test |
Thomas Huth | a049a37 | 2019-07-31 17:15:25 +0200 | [diff] [blame] | 38 | TEST_GEN_PROGS_s390x += dirty_log_test |
Thomas Huth | 49fe9a5 | 2019-05-23 18:43:09 +0200 | [diff] [blame] | 39 | TEST_GEN_PROGS_s390x += kvm_create_max_vcpus |
Paolo Bonzini | 783e9e5 | 2018-03-27 11:49:19 +0200 | [diff] [blame] | 40 | |
| 41 | TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M)) |
| 42 | LIBKVM += $(LIBKVM_$(UNAME_M)) |
| 43 | |
| 44 | INSTALL_HDR_PATH = $(top_srcdir)/usr |
| 45 | LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/ |
Andrew Jones | cc68765 | 2018-09-18 19:54:26 +0200 | [diff] [blame] | 46 | LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include |
Thomas Huth | 319f6f9 | 2019-05-17 11:04:45 +0200 | [diff] [blame] | 47 | CFLAGS += -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 Bonzini | c2390f1 | 2019-04-11 15:51:19 +0200 | [diff] [blame] | 50 | |
| 51 | no-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 Borntraeger | 8343ba2 | 2019-05-24 12:27:01 +0200 | [diff] [blame] | 54 | # On s390, build the testcases KVM-enabled |
| 55 | pgste-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 | |
| 59 | LDFLAGS += -pthread $(no-pie-option) $(pgste-option) |
Paolo Bonzini | 783e9e5 | 2018-03-27 11:49:19 +0200 | [diff] [blame] | 60 | |
| 61 | # After inclusion, $(OUTPUT) is defined and |
| 62 | # $(TEST_GEN_PROGS) starts with $(OUTPUT)/ |
| 63 | include ../lib.mk |
| 64 | |
| 65 | STATIC_LIBS := $(OUTPUT)/libkvm.a |
| 66 | LIBKVM_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM)) |
Andrew Jones | eea192b | 2018-09-18 19:54:27 +0200 | [diff] [blame] | 67 | EXTRA_CLEAN += $(LIBKVM_OBJ) $(STATIC_LIBS) cscope.* |
Paolo Bonzini | 783e9e5 | 2018-03-27 11:49:19 +0200 | [diff] [blame] | 68 | |
| 69 | x := $(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 Roxell | b2d35fa | 2018-09-04 12:47:21 +0200 | [diff] [blame] | 76 | all: $(STATIC_LIBS) |
Paolo Bonzini | 783e9e5 | 2018-03-27 11:49:19 +0200 | [diff] [blame] | 77 | $(TEST_GEN_PROGS): $(STATIC_LIBS) |
Andrew Jones | eea192b | 2018-09-18 19:54:27 +0200 | [diff] [blame] | 78 | |
| 79 | cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib .. |
| 80 | cscope: |
| 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 |