cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

Makefile (5359B)


      1# SPDX-License-Identifier: GPL-2.0
      2# Makefile for vm selftests
      3
      4LOCAL_HDRS += $(selfdir)/vm/local_config.h $(top_srcdir)/mm/gup_test.h
      5
      6include local_config.mk
      7
      8uname_M := $(shell uname -m 2>/dev/null || echo not)
      9MACHINE ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/ppc64/')
     10
     11# Without this, failed build products remain, with up-to-date timestamps,
     12# thus tricking Make (and you!) into believing that All Is Well, in subsequent
     13# make invocations:
     14.DELETE_ON_ERROR:
     15
     16# Avoid accidental wrong builds, due to built-in rules working just a little
     17# bit too well--but not quite as well as required for our situation here.
     18#
     19# In other words, "make userfaultfd" is supposed to fail to build at all,
     20# because this Makefile only supports either "make" (all), or "make /full/path".
     21# However,  the built-in rules, if not suppressed, will pick up CFLAGS and the
     22# initial LDLIBS (but not the target-specific LDLIBS, because those are only
     23# set for the full path target!). This causes it to get pretty far into building
     24# things despite using incorrect values such as an *occasionally* incomplete
     25# LDLIBS.
     26MAKEFLAGS += --no-builtin-rules
     27
     28CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
     29LDLIBS = -lrt -lpthread
     30TEST_GEN_FILES = compaction_test
     31TEST_GEN_FILES += gup_test
     32TEST_GEN_FILES += hmm-tests
     33TEST_GEN_FILES += hugetlb-madvise
     34TEST_GEN_FILES += hugepage-mmap
     35TEST_GEN_FILES += hugepage-mremap
     36TEST_GEN_FILES += hugepage-shm
     37TEST_GEN_FILES += hugepage-vmemmap
     38TEST_GEN_FILES += khugepaged
     39TEST_GEN_PROGS = madv_populate
     40TEST_GEN_FILES += map_fixed_noreplace
     41TEST_GEN_FILES += map_hugetlb
     42TEST_GEN_FILES += map_populate
     43TEST_GEN_FILES += memfd_secret
     44TEST_GEN_FILES += migration
     45TEST_GEN_FILES += mlock-random-test
     46TEST_GEN_FILES += mlock2-tests
     47TEST_GEN_FILES += mrelease_test
     48TEST_GEN_FILES += mremap_dontunmap
     49TEST_GEN_FILES += mremap_test
     50TEST_GEN_FILES += on-fault-limit
     51TEST_GEN_FILES += thuge-gen
     52TEST_GEN_FILES += transhuge-stress
     53TEST_GEN_FILES += userfaultfd
     54TEST_GEN_PROGS += soft-dirty
     55TEST_GEN_PROGS += split_huge_page_test
     56TEST_GEN_FILES += ksm_tests
     57
     58ifeq ($(MACHINE),x86_64)
     59CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_32bit_program.c -m32)
     60CAN_BUILD_X86_64 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_64bit_program.c)
     61CAN_BUILD_WITH_NOPIE := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_program.c -no-pie)
     62
     63VMTARGETS := protection_keys
     64BINARIES_32 := $(VMTARGETS:%=%_32)
     65BINARIES_64 := $(VMTARGETS:%=%_64)
     66
     67ifeq ($(CAN_BUILD_WITH_NOPIE),1)
     68CFLAGS += -no-pie
     69endif
     70
     71ifeq ($(CAN_BUILD_I386),1)
     72TEST_GEN_FILES += $(BINARIES_32)
     73endif
     74
     75ifeq ($(CAN_BUILD_X86_64),1)
     76TEST_GEN_FILES += $(BINARIES_64)
     77endif
     78else
     79
     80ifneq (,$(findstring $(MACHINE),ppc64))
     81TEST_GEN_FILES += protection_keys
     82endif
     83
     84endif
     85
     86ifneq (,$(filter $(MACHINE),arm64 ia64 mips64 parisc64 ppc64 riscv64 s390x sh64 sparc64 x86_64))
     87TEST_GEN_FILES += va_128TBswitch
     88TEST_GEN_FILES += virtual_address_range
     89TEST_GEN_FILES += write_to_hugetlbfs
     90endif
     91
     92TEST_PROGS := run_vmtests.sh
     93
     94TEST_FILES := test_vmalloc.sh
     95TEST_FILES += test_hmm.sh
     96
     97KSFT_KHDR_INSTALL := 1
     98include ../lib.mk
     99
    100$(OUTPUT)/madv_populate: vm_util.c
    101$(OUTPUT)/soft-dirty: vm_util.c
    102$(OUTPUT)/split_huge_page_test: vm_util.c
    103
    104ifeq ($(MACHINE),x86_64)
    105BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32))
    106BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64))
    107
    108define gen-target-rule-32
    109$(1) $(1)_32: $(OUTPUT)/$(1)_32
    110.PHONY: $(1) $(1)_32
    111endef
    112
    113define gen-target-rule-64
    114$(1) $(1)_64: $(OUTPUT)/$(1)_64
    115.PHONY: $(1) $(1)_64
    116endef
    117
    118ifeq ($(CAN_BUILD_I386),1)
    119$(BINARIES_32): CFLAGS += -m32 -mxsave
    120$(BINARIES_32): LDLIBS += -lrt -ldl -lm
    121$(BINARIES_32): $(OUTPUT)/%_32: %.c
    122	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(notdir $^) $(LDLIBS) -o $@
    123$(foreach t,$(VMTARGETS),$(eval $(call gen-target-rule-32,$(t))))
    124endif
    125
    126ifeq ($(CAN_BUILD_X86_64),1)
    127$(BINARIES_64): CFLAGS += -m64 -mxsave
    128$(BINARIES_64): LDLIBS += -lrt -ldl
    129$(BINARIES_64): $(OUTPUT)/%_64: %.c
    130	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(notdir $^) $(LDLIBS) -o $@
    131$(foreach t,$(VMTARGETS),$(eval $(call gen-target-rule-64,$(t))))
    132endif
    133
    134# x86_64 users should be encouraged to install 32-bit libraries
    135ifeq ($(CAN_BUILD_I386)$(CAN_BUILD_X86_64),01)
    136all: warn_32bit_failure
    137
    138warn_32bit_failure:
    139	@echo "Warning: you seem to have a broken 32-bit build" 2>&1;		\
    140	echo  "environment. This will reduce test coverage of 64-bit" 2>&1;	\
    141	echo  "kernels. If you are using a Debian-like distribution," 2>&1;	\
    142	echo  "try:"; 2>&1;							\
    143	echo  "";								\
    144	echo  "  apt-get install gcc-multilib libc6-i386 libc6-dev-i386";	\
    145	echo  "";								\
    146	echo  "If you are using a Fedora-like distribution, try:";		\
    147	echo  "";								\
    148	echo  "  yum install glibc-devel.*i686";				\
    149	exit 0;
    150endif
    151endif
    152
    153$(OUTPUT)/mlock-random-test $(OUTPUT)/memfd_secret: LDLIBS += -lcap
    154
    155# HMM_EXTRA_LIBS may get set in local_config.mk, or it may be left empty.
    156$(OUTPUT)/hmm-tests: LDLIBS += $(HMM_EXTRA_LIBS)
    157
    158$(OUTPUT)/ksm_tests: LDLIBS += -lnuma
    159
    160$(OUTPUT)/migration: LDLIBS += -lnuma
    161
    162local_config.mk local_config.h: check_config.sh
    163	/bin/sh ./check_config.sh $(CC)
    164
    165EXTRA_CLEAN += local_config.mk local_config.h
    166
    167ifeq ($(HMM_EXTRA_LIBS),)
    168all: warn_missing_hugelibs
    169
    170warn_missing_hugelibs:
    171	@echo ; \
    172	echo "Warning: missing libhugetlbfs support. Some HMM tests will be skipped." ; \
    173	echo
    174endif