Skip to content

Commit

Permalink
Restructured Enclave Build Process (introducing vault.sh) (#96)
Browse files Browse the repository at this point in the history
* Changed Makefile to use overlay

* Changed travis files to pass test

* Bump riscv-pk and linux-keystone-driver

* add makeself package

* hifive.mk: rebuild when the overlay directory has been changed

* build test app using vault.sh

* initialize runtime

* Removed wrong travis command and add KEYSTONE_SDK_DIR

Rebuilding with OPTIONS_FLAGS="" will not remove all options.
The tests will fail without freemem plugin

* Wrong KEYSTONE_SDK_DIR set for travis

* bump sdk

* Separate sdk build from Makefile

* Moved SDK and test build to setup scripts

* Change setup script and bump runtime

* bump sdk and pk to match with documentation

* bump sdk and update travis script to ignore decompress msg

* Revert "bump sdk and update travis script to ignore decompress msg"

This reverts commit 4cf1153.

* bump sdk

* bump sdk again

* bump sdk to master
  • Loading branch information
dayeol committed Jul 11, 2019
1 parent 500bc77 commit cee6885
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 21 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ git:
depth: 1

env:
- RISCV=$TRAVIS_BUILD_DIR/riscv PATH=$PATH:$RISCV/bin
- RISCV=$TRAVIS_BUILD_DIR/riscv PATH=$PATH:$RISCV/bin KEYSTONE_SDK_DIR=$TRAVIS_BUILD_DIR/sdk

addons:
apt:
Expand Down Expand Up @@ -52,6 +52,7 @@ addons:
- libglib2.0-dev
- libpixman-1-dev
- libssl-dev
- makeself

branches:
only:
Expand Down Expand Up @@ -79,10 +80,6 @@ jobs:
- source ./source.sh
- travis_wait 120 make -j2
- travis_wait 10 ./scripts/travis.sh
- cd sdk; make clean; OPTIONS_FLAGS="" make
- cd ..
- make
- travis_wait 10 ./scripts/travis.sh
- cd riscv-qemu; git clean -fxd > /dev/null;git reset --hard > /dev/null;rm -rf .git;mv ../riscv-qemu-git .git;cd ..
- cd riscv-linux;git clean -fxd > /dev/null;git reset --hard > /dev/null;rm -rf .git;mv ../riscv-linux-git .git;cd ..
after_failure:
Expand Down
8 changes: 1 addition & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
BOOTROM_DIR=bootrom
SDK_DIR=sdk
QEMU_DIR=riscv-qemu

BOOTROM=$(BOOTROM_DIR)/bootrom.elf
Expand All @@ -13,17 +12,12 @@ all: hifive
qemu:
./scripts/run-qemu.sh


.PHONY: hifive
hifive: sdk $(QEMU) $(BOOTROM)
hifive: $(QEMU) $(BOOTROM)
$(MAKE) -f hifive.mk
$(MAKE) -C hifive-work/buildroot_initramfs
$(MAKE) -f hifive.mk

.PHONY: sdk
sdk:
$(MAKE) -C $(SDK_DIR)

$(QEMU):
./scripts/apply-patch.sh
cd $(QEMU_DIR); ./configure --target-list=riscv64-softmmu,riscv32-softmmu;
Expand Down
6 changes: 6 additions & 0 deletions fast-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,10 @@ else
fi

git config --global submodule.riscv-gnu-toolchain.update none
git submodule sync --recursive
git submodule update --init --recursive

# build tests in SDK
make -C sdk
./sdk/scripts/init.sh --runtime eyrie --force
./sdk/examples/tests/vault.sh
2 changes: 1 addition & 1 deletion hifive-conf/buildroot_initramfs_config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ BR2_RISCV_64=y
BR2_RISCV_g=y
BR2_RISCV_ABI_LP64D=y
BR2_JLEVEL=2
BR2_ROOTFS_POST_BUILD_SCRIPT="board/keystone/br_copy_bins.sh"
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_PATH="$(RISCV)"
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="$(ARCH)-unknown-linux-gnu"
Expand Down Expand Up @@ -42,3 +41,4 @@ BR2_PACKAGE_PCIUTILS=y
BR2_PACKAGE_DROPBEAR=y
BR2_PACKAGE_SCREEN=y
BR2_PACKAGE_HTOP=y
BR2_ROOTFS_OVERLAY="../buildroot_overlay"
13 changes: 10 additions & 3 deletions hifive.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ buildroot_initramfs_sysroot := $(wrkdir)/buildroot_initramfs_sysroot
buildroot_rootfs_wrkdir := $(wrkdir)/buildroot_rootfs
buildroot_rootfs_ext := $(buildroot_rootfs_wrkdir)/images/rootfs.ext4
buildroot_rootfs_config := $(confdir)/buildroot_rootfs_config
buildroot_rootfs_overlay_dir := $(srcdir)/buildroot_overlay

linux_srcdir := $(srcdir)/riscv-linux
linux_wrkdir := $(wrkdir)/hifive-linux
Expand Down Expand Up @@ -65,7 +66,8 @@ all: $(hex) $(vmlinux) $(linux_module)
@echo " ... you will need gdisk and e2fsprogs installed"
@echo

$(buildroot_initramfs_wrkdir)/.config: $(buildroot_srcdir)

$(buildroot_initramfs_wrkdir)/.config: $(buildroot_srcdir) $(buildroot_rootfs_overlay_dir)/.dirstamp
rm -rf $(dir $@)
mkdir -p $(dir $@)
cp $(buildroot_initramfs_config) $@
Expand All @@ -80,7 +82,7 @@ buildroot_initramfs-menuconfig: $(buildroot_initramfs_wrkdir)/.config $(buildroo
$(MAKE) -C $(dir $<) O=$(buildroot_initramfs_wrkdir) savedefconfig
cp $(dir $<)/defconfig $(confdir)/buildroot_initramfs_config

$(buildroot_rootfs_wrkdir)/.config: $(buildroot_srcdir)
$(buildroot_rootfs_wrkdir)/.config: $(buildroot_srcdir) $(buildroot_rootfs_overlay_dir)/.dirstamp
rm -rf $(dir $@)
mkdir -p $(dir $@)
cp $(buildroot_rootfs_config) $@
Expand Down Expand Up @@ -126,6 +128,10 @@ $(vmlinux): $(linux_srcdir) $(linux_wrkdir)/.config $(buildroot_initramfs_sysroo
ARCH=riscv \
vmlinux

$(buildroot_rootfs_overlay_dir)/.dirstamp:
mkdir -p $(buildroot_rootfs_overlay_dir)
touch $@

$(linux_module): $(vmlinux)
rm -rf $(linux_module_wrkdir)
mkdir -p $(linux_module_wrkdir)
Expand All @@ -135,7 +141,8 @@ $(linux_module): $(vmlinux)
ARCH=riscv \
M=$(linux_module_wrkdir) \
modules
cp $(linux_module) $(buildroot_initramfs_wrkdir)/target/root/
mkdir -p $(buildroot_rootfs_overlay_dir)/root
cp $(linux_module) $(buildroot_rootfs_overlay_dir)/root

$(vmlinux_stripped): $(vmlinux)
$(target)-strip -o $@ $<
Expand Down
2 changes: 1 addition & 1 deletion linux-keystone-driver
2 changes: 1 addition & 1 deletion scripts/test-qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ expect "yes/no" {
log_file -noappend output.log

expect "# " { send "insmod keystone-driver.ko\r" }
expect "# " { send "./test\r" }
expect "# " { send "cd tests; ./tests.ke\r" }
expect "# " { send "poweroff\r" }
expect eof
2 changes: 1 addition & 1 deletion sdk
Submodule sdk updated 64 files
+0 −3 .gitmodules
+0 −27 Makefile
+29 −0 examples/hello-native/eapp/Makefile
+25 −0 examples/hello-native/eapp/eapp_native.c
+25 −0 examples/hello-native/host/Makefile
+81 −0 examples/hello-native/host/host_native.cpp
+78 −0 examples/hello-native/vault.sh
+4 −0 examples/hello/eapp/Makefile
+7 −0 examples/hello/eapp/hello.c
+9 −0 examples/hello/host/Makefile
+24 −0 examples/hello/host/host.cpp
+78 −0 examples/hello/vault.sh
+0 −0 examples/tests/.gitignore
+1 −1 examples/tests/Makefile
+0 −0 examples/tests/app.lds
+1 −1 examples/tests/app.mk
+2 −2 examples/tests/attestation/Makefile
+0 −0 examples/tests/attestation/attestation.c
+0 −0 examples/tests/attestation/edge_wrapper.c
+0 −0 examples/tests/attestation/edge_wrapper.h
+0 −0 examples/tests/edge_wrapper.cpp
+0 −0 examples/tests/edge_wrapper.h
+0 −0 examples/tests/fib-bench/Makefile
+0 −0 examples/tests/fib-bench/fib-bench.c
+0 −0 examples/tests/fibonacci/Makefile
+0 −0 examples/tests/fibonacci/fibonacci.c
+0 −0 examples/tests/long-nop/Makefile
+0 −0 examples/tests/long-nop/add_long.s
+0 −0 examples/tests/long-nop/func_base.s
+0 −0 examples/tests/long-nop/func_long.s
+0 −0 examples/tests/long-nop/generate_func.sh
+4,107 −0 examples/tests/long-nop/long-nop.s
+0 −0 examples/tests/long-nop/nop.s
+0 −0 examples/tests/loop/Makefile
+0 −0 examples/tests/loop/loop.s
+0 −0 examples/tests/malloc/Makefile
+0 −0 examples/tests/malloc/malloc.c
+0 −0 examples/tests/stack/Makefile
+0 −0 examples/tests/stack/stack.s
+0 −1 examples/tests/test-runner.cpp
+2 −2 examples/tests/untrusted/Makefile
+0 −0 examples/tests/untrusted/edge_wrapper.c
+0 −0 examples/tests/untrusted/edge_wrapper.h
+0 −0 examples/tests/untrusted/untrusted.c
+85 −0 examples/tests/vault.sh
+1 −1 lib/edge/Makefile
+1 −0 rts/eyrie.version
+0 −1 runtime
+0 −5 samples/Makefile
+0 −3 samples/tiny-AES-c/.gitignore
+0 −25 samples/tiny-AES-c/Makefile
+0 −23 samples/tiny-AES-c/aes.cpp
+0 −24 samples/tiny-AES-c/app.lds
+0 −65 samples/tiny-AES-c/app/Makefile
+0 −80 samples/tiny-AES-c/app/README.md
+0 −570 samples/tiny-AES-c/app/aes.c
+0 −90 samples/tiny-AES-c/app/aes.h
+0 −12 samples/tiny-AES-c/app/aes.hpp
+0 −13 samples/tiny-AES-c/app/library.json
+0 −320 samples/tiny-AES-c/app/test.c
+0 −24 samples/tiny-AES-c/app/unlicense.txt
+425 −0 scripts/common
+102 −0 scripts/init.sh
+35 −0 scripts/vault-sample.sh
6 changes: 6 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

git submodule sync --recursive
git submodule update --init --recursive

mkdir riscv
Expand All @@ -9,3 +10,8 @@ cd riscv-gnu-toolchain
./configure --prefix=$RISCV
make && make linux
cd ..

# build tests in SDK
make -C sdk
./sdk/scripts/init.sh --runtime eyrie --force
./sdk/examples/tests/vault.sh
4 changes: 3 additions & 1 deletion tests/test-qemu.expected.log
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

# insmod keystone-driver.ko
# ./test
# cd tests; ./tests.ke
Verifying archive integrity... All good.
Uncompressing Keystone vault archive
testing stack
testing fibonacci
testing long-nop
Expand Down

0 comments on commit cee6885

Please sign in to comment.