Makefile (3257B)
1LINUX ?= linux 2CORES ?= $(shell getconf _NPROCESSORS_ONLN) 3LOAD ?= $(CORES) 4JOBS ?= $(CORES) 5 6PWD := $(shell pwd) 7 8BINS = test/eviction test/kvm-eviction 9BINS += test/kvm-eviction-with_guest test/kvm-eviction-without_guest 10BINS += test/kvm-step test/kvm-step_guest 11BINS += test/kvm-targetstep test/kvm-targetstep_guest 12BINS += test/kvm-pagestep test/kvm-pagestep_guest 13BINS += test/qemu-pagestep 14BINS += test/qemu-targetstep test/qemu-targetstep_guest 15BINS += test/qemu-aes_guest test/qemu-aes 16#BINS += test/qemu-poc 17BINS += util/loglevel util/reset util/mainpfn 18 19CFLAGS = -I . -I linux/usr/include 20CFLAGS += -g -Wunused-variable -Wunknown-pragmas -Wunused-function 21 22HOST_CFLAGS = $(CFLAGS) -fsanitize=address 23GUEST_CFLAGS = $(CFLAGS) -static 24 25LDLIBS = -lpthread 26 27UTIL_HDRS = cachepc/uapi.h cachepc/const.h 28UTIL_SRCS = 29 30TEST_HDRS = cachepc/uapi.h cachepc/const.h test/util.h test/kvm.h 31TEST_SRCS = test/util.c test/kvm.c 32 33all: build $(BINS) 34 35clean: 36 $(MAKE) -C $(LINUX) clean M=arch/x86/kvm 37 $(MAKE) -C $(LINUX) clean M=crypto 38 rm -f cachepc/*.o 39 rm -f $(BINS) 40 41$(LINUX)/arch/x86/kvm/cachepc: 42 ln -sf $(PWD)/cachepc $@ 43 44linux: # build host kernel for depmod 45 git -C $(LINUX) add . 46 git -C $(LINUX) stash 47 git -C $(LINUX) checkout d9bd54fea4d2 48 rm -f $(LINUX)/arch/x86/kvm/cachepc 49 $(MAKE) -C $(LINUX) -j $(JOBS) -l $(LOAD) vmlinux headers 50 git -C $(LINUX) checkout master 51 git -C $(LINUX) stash pop || true 52 53build: $(LINUX)/arch/x86/kvm/cachepc 54 $(MAKE) -C $(LINUX) -j $(JOBS) -l $(LOAD) M=arch/x86/kvm modules 55 $(MAKE) -C $(LINUX) -j $(JOBS) -l $(LOAD) M=crypto modules 56 57load: 58 sudo rmmod kvm_amd || true 59 sudo rmmod kvm || true 60 sudo insmod $(LINUX)/arch/x86/kvm/kvm.ko 61 sudo insmod $(LINUX)/arch/x86/kvm/kvm-amd.ko 62 63prep: 64 sudo sh -c "echo 0 > /proc/sys/kernel/watchdog" 65 sudo sh -c "echo performance > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor" 66 sudo sh -c "echo 1500000 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq" 67 sudo sh -c "echo 1500000 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq" 68 sudo sh -c "echo 1500000 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq" 69 sudo bash -c "for f in /proc/irq/*/smp_affinity; do echo 1 > \$$f 2>/dev/null; done" 70 71util/%: util/%.c $(UTIL_SRCS) 72 $(CC) -o $@ $< $(HOST_CFLAGS) 73 74util/mainpfn: util/mainpfn.c $(UTIL_SRCS) 75 $(CC) -o $@ $< $(GUEST_CFLAGS) 76 77test/%.o: test/%.c $(TEST_HDRS) 78 $(CC) -c -o $@ $< $(HOST_CFLAGS) 79 80test/%.o: test/%.S $(TEST_HDRS) 81 $(CC) -c -o $@ $< $(HOST_CFLAGS) 82 83test/%: test/%.c $(TEST_SRCS) 84 $(CC) -o $@ $(filter %.c,$^) $(HOST_CFLAGS) $(LDLIBS) 85 86test/kvm-%_guest: test/kvm-%_guest.o test/kvm-guest.lds 87 $(LD) -Ttest/kvm-guest.lds -o $@ $< 88 89test/kvm-%: test/kvm-%.c $(TEST_SRCS) 90 $(CC) -o $@ $(filter %.c,$^) $(filter %.S,$^) $(HOST_CFLAGS) $(LDLIBS) 91 92test/kvm-eviction: test/kvm-eviction.c test/kvm-eviction.h $(TEST_SRCS) 93 $(CC) -o $@ $(filter %.c,$^) $(filter %.S,$^) $(HOST_CFLAGS) $(LDLIBS) 94 95test/qemu-%: test/qemu-%.c $(TEST_SRCS) 96 $(CC) -o $@ $(filter %.c,$^) $(filter %.S,$^) $(HOST_CFLAGS) $(LDLIBS) 97 98test/qemu-aes_guest: test/qemu-aes_guest.c test/libkcapi/.libs/libkcapi.a 99 $(CC) -o $@ $^ $(GUEST_CFLAGS) -I test/libkcapi/lib 100 101test/qemu-%_guest: test/qemu-%_guest.c 102 $(CC) -o $@ $^ $(GUEST_CFLAGS) 103 104.PHONY: all clean linux build load prep