forked from weirdindiankid/cacheflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
76 lines (61 loc) · 2.08 KB
/
Makefile
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
67
68
69
70
71
72
73
74
75
76
obj-m += dumpcache.o
.PHONY: run
run: load
cd experiments; make run
# CFLAGS_dumpcache.o := -D_FORTIFY_SOURCE=0
UNAME_R := $(shell uname -r)
FIXED_ADDRESS_FILES = \
xxx_rmap_walk_locked_func_addr.h.out \
rmap_walk_locked_func_addr.h.out \
xxx_kallsyms_lookup_name_func_addr.h.out \
kallsyms_lookup_name_func_addr.h.out \
$(NULL)
#
# NOTE: modules_install won't work when doing out of (Linux source) tree build,
# eg, when running on the raspberry pi4 ARM hardware directly.
#
.PHONY: build
build: dumpcache.ko
dumpcache.ko: dumpcache.c cache_operations.c params_kernel.h Makefile $(FIXED_ADDRESS_FILES)
make -C /lib/modules/$(UNAME_R)/build M=$(PWD) modules
# make -C /lib/modules/$(UNAME_R)/build M=$(PWD) modules_install
xxx_rmap_walk_locked_func_addr.h.out: /boot/System.map-$(UNAME_R) Makefile
sudo grep -w rmap_walk_locked $< | sed -e 's/^/0x/' -e 's/ .*/ULL/' > $@
rmap_walk_locked_func_addr.h.out: /proc/kallsyms Makefile
grep -w rmap_walk_locked $< | sed -e 's/^/0x/' -e 's/ .*/ULL/' > $@
xxx_kallsyms_lookup_name_func_addr.h.out: /boot/System.map-$(UNAME_R) Makefile
sudo grep -w kallsyms_lookup_name $< | sed -e 's/^/0x/' -e 's/ .*/ULL/' > $@
kallsyms_lookup_name_func_addr.h.out: /proc/kallsyms Makefile
grep -w kallsyms_lookup_name $< | sed -e 's/^/0x/' -e 's/ .*/ULL/' > $@
.PHONY: fish
fish: $(FIXED_ADDRESS_FILES)
.PHONY: clean
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
.PHONY: load
load: dumpcache.ko
-sudo rmmod dumpcache
sudo insmod $<
sudo dmesg | tail -10
.PHONY: disassemble
disassemble: cache_jig.c experiments/data/cachedump0000.csv
gcc -g -c cache_jig.c
echo x/4096i vals | gdb cache_jig.o
%.x: %.c
gcc -Wall -O0 -g -o $@ $<
CPPLINT_ARGS = \
--filter=-runtime/int,-readability/casting,-runtime/printf \
$(NULL)
CPPLINT = $(HOME)/rrhbuild/cpplint/cpplint.py
XLINT_VICTIMS = \
$(NULL)
LINT_VICTIMS = \
dumpcache.c \
params_kernel.h \
cache_operations.c \
experiments/e11_flood.c \
experiments/snapshot.c \
$(NULL)
.PHONY: lint
lint: $(CPPLINT) $(LINT_VICTIMS)
python3 $(CPPLINT) $(CPPLINT_ARGS) $(LINT_VICTIMS)