Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Dave Young | f0f57b2 | 2012-03-28 14:42:56 -0700 | [diff] [blame] | 2 | # Makefile for vm selftests |
Masami Hiramatsu | 7549b33 | 2019-10-23 13:57:49 +0900 | [diff] [blame] | 3 | uname_M := $(shell uname -m 2>/dev/null || echo not) |
Sandipan Das | 24c3f06 | 2020-01-30 12:31:18 +0530 | [diff] [blame] | 4 | MACHINE ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/') |
Dave Young | f0f57b2 | 2012-03-28 14:42:56 -0700 | [diff] [blame] | 5 | |
Thierry Reding | d0a8711 | 2015-09-22 14:58:52 -0700 | [diff] [blame] | 6 | CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS) |
bamvor.zhangjian@huawei.com | 7d758af | 2016-11-29 19:55:49 +0800 | [diff] [blame] | 7 | LDLIBS = -lrt |
bamvor.zhangjian@huawei.com | 88baa78 | 2016-11-29 19:55:47 +0800 | [diff] [blame] | 8 | TEST_GEN_FILES = compaction_test |
Aneesh Kumar K.V | 235266b | 2018-01-31 16:16:59 -0800 | [diff] [blame] | 9 | TEST_GEN_FILES += gup_benchmark |
Ralph Campbell | fee9f6d | 2020-04-22 12:50:27 -0700 | [diff] [blame] | 10 | TEST_GEN_FILES += hmm-tests |
bamvor.zhangjian@huawei.com | 88baa78 | 2016-11-29 19:55:47 +0800 | [diff] [blame] | 11 | TEST_GEN_FILES += hugepage-mmap |
| 12 | TEST_GEN_FILES += hugepage-shm |
| 13 | TEST_GEN_FILES += map_hugetlb |
Michael Ellerman | 91cbacc | 2018-10-26 15:10:48 -0700 | [diff] [blame] | 14 | TEST_GEN_FILES += map_fixed_noreplace |
Dmitry Safonov | 1caed86 | 2018-08-21 21:53:47 -0700 | [diff] [blame] | 15 | TEST_GEN_FILES += map_populate |
Aneesh Kumar K.V | 235266b | 2018-01-31 16:16:59 -0800 | [diff] [blame] | 16 | TEST_GEN_FILES += mlock-random-test |
bamvor.zhangjian@huawei.com | 88baa78 | 2016-11-29 19:55:47 +0800 | [diff] [blame] | 17 | TEST_GEN_FILES += mlock2-tests |
Brian Geffon | 0c28759 | 2020-04-01 21:09:20 -0700 | [diff] [blame] | 18 | TEST_GEN_FILES += mremap_dontunmap |
bamvor.zhangjian@huawei.com | 88baa78 | 2016-11-29 19:55:47 +0800 | [diff] [blame] | 19 | TEST_GEN_FILES += on-fault-limit |
| 20 | TEST_GEN_FILES += thuge-gen |
| 21 | TEST_GEN_FILES += transhuge-stress |
| 22 | TEST_GEN_FILES += userfaultfd |
Kirill A. Shutemov | e0c13f9 | 2020-06-03 16:00:06 -0700 | [diff] [blame] | 23 | TEST_GEN_FILES += khugepaged |
Masami Hiramatsu | 7549b33 | 2019-10-23 13:57:49 +0900 | [diff] [blame] | 24 | |
Sandipan Das | f21fda8 | 2020-06-04 16:52:54 -0700 | [diff] [blame^] | 25 | ifeq ($(ARCH),x86_64) |
| 26 | CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_32bit_program.c -m32) |
| 27 | CAN_BUILD_X86_64 := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_64bit_program.c) |
| 28 | CAN_BUILD_WITH_NOPIE := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_program.c -no-pie) |
| 29 | |
| 30 | TARGETS := protection_keys |
| 31 | BINARIES_32 := $(TARGETS:%=%_32) |
| 32 | BINARIES_64 := $(TARGETS:%=%_64) |
| 33 | |
| 34 | ifeq ($(CAN_BUILD_WITH_NOPIE),1) |
| 35 | CFLAGS += -no-pie |
| 36 | endif |
| 37 | |
| 38 | ifeq ($(CAN_BUILD_I386),1) |
| 39 | TEST_GEN_FILES += $(BINARIES_32) |
| 40 | endif |
| 41 | |
| 42 | ifeq ($(CAN_BUILD_X86_64),1) |
| 43 | TEST_GEN_FILES += $(BINARIES_64) |
| 44 | endif |
| 45 | else |
| 46 | TEST_GEN_FILES += protection_keys |
| 47 | endif |
| 48 | |
Sandipan Das | 963e3e9 | 2020-01-30 12:31:19 +0530 | [diff] [blame] | 49 | ifneq (,$(filter $(MACHINE),arm64 ia64 mips64 parisc64 ppc64 ppc64le riscv64 s390x sh64 sparc64 x86_64)) |
Aneesh Kumar K.V | 235266b | 2018-01-31 16:16:59 -0800 | [diff] [blame] | 50 | TEST_GEN_FILES += va_128TBswitch |
Anshuman Khandual | 4e5ce33 | 2017-05-08 16:00:19 -0700 | [diff] [blame] | 51 | TEST_GEN_FILES += virtual_address_range |
Mina Almasry | 29750f7 | 2020-04-01 21:11:38 -0700 | [diff] [blame] | 52 | TEST_GEN_FILES += write_to_hugetlbfs |
Masami Hiramatsu | 7549b33 | 2019-10-23 13:57:49 +0900 | [diff] [blame] | 53 | endif |
Dave Young | f0f57b2 | 2012-03-28 14:42:56 -0700 | [diff] [blame] | 54 | |
Michael Ellerman | 5e29a91 | 2015-03-11 15:05:59 +1100 | [diff] [blame] | 55 | TEST_PROGS := run_vmtests |
| 56 | |
Naresh Kamboju | bc2cce3 | 2019-05-28 13:18:09 +0100 | [diff] [blame] | 57 | TEST_FILES := test_vmalloc.sh |
| 58 | |
Shuah Khan | 211929f | 2018-12-12 20:25:14 -0700 | [diff] [blame] | 59 | KSFT_KHDR_INSTALL := 1 |
Michael Ellerman | 5e29a91 | 2015-03-11 15:05:59 +1100 | [diff] [blame] | 60 | include ../lib.mk |
Dave Young | f0f57b2 | 2012-03-28 14:42:56 -0700 | [diff] [blame] | 61 | |
Ralph Campbell | fee9f6d | 2020-04-22 12:50:27 -0700 | [diff] [blame] | 62 | $(OUTPUT)/hmm-tests: LDLIBS += -lhugetlbfs -lpthread |
| 63 | |
Sandipan Das | f21fda8 | 2020-06-04 16:52:54 -0700 | [diff] [blame^] | 64 | ifeq ($(ARCH),x86_64) |
| 65 | BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32)) |
| 66 | BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64)) |
| 67 | |
| 68 | define gen-target-rule-32 |
| 69 | $(1) $(1)_32: $(OUTPUT)/$(1)_32 |
| 70 | .PHONY: $(1) $(1)_32 |
| 71 | endef |
| 72 | |
| 73 | define gen-target-rule-64 |
| 74 | $(1) $(1)_64: $(OUTPUT)/$(1)_64 |
| 75 | .PHONY: $(1) $(1)_64 |
| 76 | endef |
| 77 | |
| 78 | ifeq ($(CAN_BUILD_I386),1) |
| 79 | $(BINARIES_32): CFLAGS += -m32 |
| 80 | $(BINARIES_32): LDLIBS += -lrt -ldl -lm |
| 81 | $(BINARIES_32): %_32: %.c |
| 82 | $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(notdir $^) $(LDLIBS) -o $@ |
| 83 | $(foreach t,$(TARGETS),$(eval $(call gen-target-rule-32,$(t)))) |
| 84 | endif |
| 85 | |
| 86 | ifeq ($(CAN_BUILD_X86_64),1) |
| 87 | $(BINARIES_64): CFLAGS += -m64 |
| 88 | $(BINARIES_64): LDLIBS += -lrt -ldl |
| 89 | $(BINARIES_64): %_64: %.c |
| 90 | $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(notdir $^) $(LDLIBS) -o $@ |
| 91 | $(foreach t,$(TARGETS),$(eval $(call gen-target-rule-64,$(t)))) |
| 92 | endif |
| 93 | |
| 94 | # x86_64 users should be encouraged to install 32-bit libraries |
| 95 | ifeq ($(CAN_BUILD_I386)$(CAN_BUILD_X86_64),01) |
| 96 | all: warn_32bit_failure |
| 97 | |
| 98 | warn_32bit_failure: |
| 99 | @echo "Warning: you seem to have a broken 32-bit build" 2>&1; \ |
| 100 | echo "environment. This will reduce test coverage of 64-bit" 2>&1; \ |
| 101 | echo "kernels. If you are using a Debian-like distribution," 2>&1; \ |
| 102 | echo "try:"; 2>&1; \ |
| 103 | echo ""; \ |
| 104 | echo " apt-get install gcc-multilib libc6-i386 libc6-dev-i386"; \ |
| 105 | echo ""; \ |
| 106 | echo "If you are using a Fedora-like distribution, try:"; \ |
| 107 | echo ""; \ |
| 108 | echo " yum install glibc-devel.*i686"; \ |
| 109 | exit 0; |
| 110 | endif |
| 111 | endif |
| 112 | |
Mike Rapoport | b6ad197 | 2017-05-03 14:54:54 -0700 | [diff] [blame] | 113 | $(OUTPUT)/userfaultfd: LDLIBS += -lpthread |
Linus Torvalds | c4f3f22 | 2017-02-25 15:32:53 -0800 | [diff] [blame] | 114 | |
bamvor.zhangjian@huawei.com | a8ba798 | 2016-11-29 19:55:52 +0800 | [diff] [blame] | 115 | $(OUTPUT)/mlock-random-test: LDLIBS += -lcap |