]> rtime.felk.cvut.cz Git - hercules2020/jailhouse-build.git/blob - build/Makefile
Update memgaurd test and add test for throttling correctness
[hercules2020/jailhouse-build.git] / build / Makefile
1 all: buildroot/images/rootfs.cpio.uboot kernel-4.4/vmlinux
2
3 NPROC:=$(shell nproc)
4
5 # TX2 U-Boot does not support FIT images
6 image.fit: buildroot/images/rootfs.cpio.uboot kernel-4.4/vmlinux
7         mkimage -f auto -d kernel-4.4/arch/arm64/boot/Image -i buildroot/images/rootfs.cpio.uboot -b kernel-4.4/arch/arm64/boot/dts/tegra186-quill-p3310-1000-c03-00-base.dtb image.fit
8
9 buildroot/images/rootfs.cpio.uboot: ./buildroot/.config
10 buildroot/images/rootfs.cpio.uboot: rootfs-overlay/lib/firmware/jailhouse.bin
11 buildroot/images/rootfs.cpio.uboot: modules_install
12 buildroot/images/rootfs.cpio.uboot: $(shell find rootfs-overlay)
13 buildroot/images/rootfs.cpio.uboot: rootfs-overlay/bin/prem-test
14         $(MAKE) -j1 -C buildroot ROOTFS_CPIO_COMPRESS_CMD="gzip --fast -c"
15
16 rootfs-overlay/bin/prem-test: ../test/prem-test
17         install -D $< $@
18
19 rootfs-overlay/lib/firmware/jailhouse.bin: ../jailhouse/hypervisor/jailhouse.bin
20 rootfs-overlay/lib/firmware/jailhouse.bin: $(wildcard ../jailhouse/configs/arm64/*.cell)
21         $(MAKE) jailhouse-install
22
23 jailhouse: ../jailhouse/hypervisor/jailhouse.bin
24
25 DESTDIR=$(CURDIR)/rootfs-overlay
26
27 jailhouse-install: FORCE
28         $(MAKE) -C ../jailhouse -j$(NPROC) install KDIR=$(CURDIR)/kernel-4.4 ARCH=arm64 DESTDIR=$(abspath $(DESTDIR)) prefix=/usr
29         mkdir -p $(DESTDIR)/jailhouse/configs/ $(DESTDIR)/jailhouse/demos/
30 #       cp ../jailhouse/inmates/demos/arm64/my-demo.bin rootfs-overlay/jailhouse/demos/
31         cp ../jailhouse/configs/arm64/jetson-tx2.cell $(DESTDIR)/jailhouse/configs/
32         cp ../jailhouse/configs/arm64/jetson-tx2-demo.cell $(DESTDIR)/jailhouse/demos/
33
34 # Add something like this to ~/.ssh/config for
35 # jailhouse-install-remote to work out of the box:
36 #
37 #    Host tx2
38 #      Hostname 192.168.1.54
39 INSTALL_HOST ?= root@tx2
40
41 jailhouse-install-remote: DESTDIR=jailhouse-install
42 jailhouse-install-remote: jailhouse-install
43         rsync -rlptD jailhouse-install/ $(INSTALL_HOST):/
44         rsync -rlptD rootfs-overlay/lib/modules/ $(INSTALL_HOST):/lib/modules
45
46 ../jailhouse/hypervisor/jailhouse.bin: ../jailhouse/include/jailhouse/config.h
47 ../jailhouse/hypervisor/jailhouse.bin: kernel-4.4/vmlinux
48 ../jailhouse/hypervisor/jailhouse.bin: $(addprefix ../jailhouse/,$(shell cd ../jailhouse && git ls-files))
49         $(MAKE) -C ../jailhouse -j$(NPROC) KDIR=$(CURDIR)/kernel-4.4 ARCH=arm64 prefix=/usr
50
51 ../jailhouse/include/jailhouse/config.h: Makefile
52         rm -f $@.tmp
53         echo '#define CONFIG_TRACE_ERROR             1' >> $@.tmp
54         echo '#define CONFIG_ARM_GIC_V2              1' >> $@.tmp
55         echo '#define CONFIG_MACH_JETSON_TX2         1' >> $@.tmp
56         mv --update $@.tmp $@
57
58 kernel-4.4/vmlinux:
59         $(MAKE) -C $(@D) -j$(NPROC)
60
61 kernel-4.4/vmlinux/tools/perf/perf: kernel-4.4/vmlinux
62         $(MAKE) -C kernel-4.4 tools/perf
63
64 perf-install: kernel-4.4/tools/perf/perf
65         cp $^ $(DESTDIR)/bin
66
67 linux_install: kernel-4.4/vmlinux
68         install -m644 -D kernel-4.4/arch/arm64/boot/Image $(DESTDIR)/boot/Image-prem
69
70 modules_install: kernel-4.4/vmlinux
71         $(MAKE) -C kernel-4.4 -j$(NPROC)  modules_install INSTALL_MOD_PATH=$(DESTDIR)
72
73 .PHONY: FORCE
74
75 ../test/prem-test ../test/memguard-test: FORCE
76         $(MAKE) -C ../test
77
78 clean:
79         rm -rf buildroot/images/rootfs.cpio.uboot kernel-4.4/vmlinux buildroot/target `find buildroot/ -name .stamp_target_installed` jailhouse-install
80
81 deploy: ../test/prem-test ../test/memguard-test
82 #deploy: ../jailhouse/hypervisor/jailhouse.bin
83         scp ../test/prem-test ../test/memguard-test tx2:/bin
84 #       scp ../jailhouse/hypervisor/jailhouse.bin tx2:/lib/firmware
85         ssh tx2 'sh /etc/init.d/S20jailhouse.sh stop && sh /etc/init.d/S20jailhouse.sh start'
86
87 deb: DESTDIR=$(CURDIR)/_install.deb
88 deb: jailhouse-install linux_install modules_install DEBIAN_DIR
89         $(file >$(DESTDIR)/DEBIAN/control,$(deb_control))
90         $(file >$(DESTDIR)/DEBIAN/postinst,$(deb_postinst))
91         $(file >$(DESTDIR)/DEBIAN/prerm,$(deb_prerm))
92         chmod +x $(DESTDIR)/DEBIAN/postinst $(DESTDIR)/DEBIAN/prerm
93         rm -f _install.deb/lib/modules/*/source _install.deb/lib/modules/*/build
94         install -D ./rootfs-overlay/etc/init.d/S20jailhouse.sh $(DESTDIR)/etc/init.d/jailhouse
95         install -m644 -D ./rootfs-overlay/etc/systemd/system/jailhouse.service $(DESTDIR)/lib/systemd/system/jailhouse.service
96         #install -d $(DESTDIR)/lib/systemd/system/multi-user.target.wants/
97         #ln -sf ../jailhouse.service $(DESTDIR)/lib/systemd/system/multi-user.target.wants/jailhouse.service
98 # Note: --root-owner-group requires dpkg version 1.19.0+
99         dpkg-deb --root-owner-group --build $(DESTDIR) .
100
101 DEBIAN_DIR:
102         install -d $(DESTDIR)/DEBIAN
103
104
105 define deb_control
106 Package: jailhouse
107 Essential: no
108 Priority: optional
109 Section: admin
110 Maintainer: Michal Sojka <michal.sojka@cvut.cz>
111 Architecture: arm64
112 Version: $(shell git describe --always --dirty)
113 Description: Jailhouse hypervisor and the Linux kernel for the HERCULES project.
114 endef
115
116 define deb_postinst
117 #!/bin/sh
118 set -e
119 if ! grep -q Image-prem /boot/extlinux/extlinux.conf; then
120 cat >>/boot/extlinux/extlinux.conf <<'EOF'
121 LABEL prem
122       MENU LABEL prem kernel and jailhouse
123       LINUX /boot/Image-prem
124       APPEND $${cbootargs} root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 mem=7808M vmalloc=512M jailhouse
125 EOF
126 fi
127 endef
128
129 define deb_prerm
130 #!/bin/sh
131 set -e
132 if grep -q Image-prem /boot/extlinux/extlinux.conf; then
133         . # TODO
134 fi
135 endef