summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: e7b04df6cf9891e0dcd78f500c937a4e0ec8442a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
LINUX ?= linux
CORES ?= $(shell ls /dev/cpu | wc -l)
LOAD ?= $(CORES)
JOBS ?= $(CORES)

PWD := $(shell pwd)

BINS = test/eviction test/kvm-eviction # test/kvm-execstep
# BINS += test/qemu-eviction_guest test/qemu-eviction_host
# BINS += test/qemu-aes_guest test/qemu-aes_host
BINS += util/svme util/debug util/reset

CFLAGS = -I . -I linux/usr/include -I test
CFLAGS += -g -Wunused-variable -Wunknown-pragmas
CFLAGS += -fsanitize=address

CACHEPC_UAPI = cachepc/uapi.h cachepc/const.h

all: build $(BINS)

clean:
	$(MAKE) -C $(LINUX) clean M=arch/x86/kvm 
	$(MAKE) -C $(LINUX) clean M=crypto 
	rm $(BINS)

$(LINUX)/arch/x86/kvm/cachepc:
	ln -sf $(PWD)/cachepc $@

host:
	# build host kernel and Module.symvers for depmod
	cp extra/.config linux/.config
	git -C $(LINUX) add .
	git -C $(LINUX) stash
	git -C $(LINUX) checkout 0aaa1e5
	rm -f $(LINUX)/arch/x86/kvm/cachepc
	$(MAKE) -C $(LINUX) -j $(JOBS) -l $(LOAD) bindeb-pkg
	git -C $(LINUX) checkout master
	git -C $(LINUX) stash pop

build: $(LINUX)/arch/x86/kvm/cachepc
	$(MAKE) -C $(LINUX) -j $(JOBS) -l $(LOAD) M=arch/x86/kvm modules
	#$(MAKE) -C $(LINUX) -j $(JOBS) -l $(LOAD) M=crypto modules

load:
	sudo rmmod kvm_amd || true
	sudo rmmod kvm || true
	sudo insmod $(LINUX)/arch/x86/kvm/kvm.ko
	sudo insmod $(LINUX)/arch/x86/kvm/kvm-amd.ko

freq:
	sudo cpupower frequency-set -f 3.7GHz
	sudo cpupower frequency-set -u 3.7GHz
	sudo cpupower frequency-set -d 3.7GHz

update:
	git -C $(LINUX) diff 0aaa1e599bee256b3b15643bbb95e80ce7aa9be5 -G. > patch.diff

util/%: util/%.c $(CACHEPC_UAPI)

test/%: test/%.c $(CACHEPC_UAPI)

test/kvm-eviction: test/kvm-eviction.c test/kvm-eviction_guest.S \
		test/kvm-eviction.h $(CACHEPC_UAPI)
	$(CC) -o $@ test/kvm-eviction.c test/kvm-eviction_guest.S $(CFLAGS)

.PHONY: all clean host build load freq update