diff --git a/LibOS/.packed/glibc.sha384 b/LibOS/.packed/glibc.sha384 index 8ee79c13..7a7941e7 100644 --- a/LibOS/.packed/glibc.sha384 +++ b/LibOS/.packed/glibc.sha384 @@ -1 +1 @@ -glibc-build/crt1.o glibc-build/crti.o glibc-build/crtn.o glibc-build/ld-linux-x86-64.so.2 glibc-build/libc.so.6 glibc-build/libdl.so.2 glibc-build/liblibos.so.1 glibc-build/libm.so.6 glibc-build/libpthread.so.0 glibc-build/libutil.so.1 \ No newline at end of file +glibc-build/crt1.o glibc-build/crti.o glibc-build/crtn.o glibc-build/ld-linux-x86-64.so.2 glibc-build/libc.so.6 glibc-build/libdl.so.2 glibc-build/liblibos.so.1 glibc-build/libm.so.6 glibc-build/libnss_dns.so.2 glibc-build/libpthread.so.0 glibc-build/libresolv.so.2 glibc-build/libutil.so.1 \ No newline at end of file diff --git a/LibOS/.packed/glibc.tar.gz b/LibOS/.packed/glibc.tar.gz index e4e61751..bbf4e440 100644 Binary files a/LibOS/.packed/glibc.tar.gz and b/LibOS/.packed/glibc.tar.gz differ diff --git a/LibOS/shim/src/.packed/shim.sha384 b/LibOS/shim/src/.packed/shim.sha384 index 74621a35..f7f5f6bb 100644 --- a/LibOS/shim/src/.packed/shim.sha384 +++ b/LibOS/shim/src/.packed/shim.sha384 @@ -1 +1 @@ -bookkeep/shim_handle.o bookkeep/shim_signal.o bookkeep/shim_thread.o bookkeep/shim_vma.o elf/shim_rtld.o fs/chroot/fs.o fs/dev/fs.o fs/pipe/fs.o fs/proc/fs.o fs/proc/info.o fs/proc/ipc-thread.o fs/proc/thread.o fs/shim_dcache.o fs/shim_fs_hash.o fs/shim_fs.o fs/shim_namei.o fs/socket/fs.o fs/str/fs.o ipc/shim_ipc_child.o ipc/shim_ipc_helper.o ipc/shim_ipc.o ipc/shim_ipc_pid.o ipc/shim_ipc_sysv.o libsysdb.a libsysdb_debug.so libsysdb.so shim_async.o shim_checkpoint.o shim_debug.o shim_init.o shim_malloc.o shim_parser.o shim_random.o shim_syscalls.o shim_table.o start.o syscallas.o sys/shim_access.o sys/shim_alarm.o sys/shim_benchmark.o sys/shim_brk.o sys/shim_clone.o sys/shim_dup.o sys/shim_epoll.o sys/shim_exec.o sys/shim_exit.o sys/shim_fcntl.o sys/shim_fork.o sys/shim_fs.o sys/shim_futex.o sys/shim_getcwd.o sys/shim_getpid.o sys/shim_getrlimit.o sys/shim_ioctl.o sys/shim_migrate.o sys/shim_mmap.o sys/shim_msgget.o sys/shim_open.o sys/shim_pipe.o sys/shim_poll.o sys/shim_sandbox.o sys/shim_sched.o sys/shim_semget.o sys/shim_sigaction.o sys/shim_sleep.o sys/shim_socket.o sys/shim_stat.o sys/shim_time.o sys/shim_uname.o sys/shim_vfork.o sys/shim_wait.o sys/shim_wrappers.o utils/md5.o utils/printf.o utils/strobjs.o 9bbabfb9b051d17da7c0a24460c1e5962c8455579e4a2c677929332c8f5418b1302df7010af7f613d8910ba7b288b7ac \ No newline at end of file +bookkeep/shim_handle.o bookkeep/shim_signal.o bookkeep/shim_thread.o bookkeep/shim_vma.o elf/shim_rtld.o fs/chroot/fs.o fs/dev/fs.o fs/pipe/fs.o fs/proc/fs.o fs/proc/info.o fs/proc/ipc-thread.o fs/proc/thread.o fs/shim_dcache.o fs/shim_fs_hash.o fs/shim_fs.o fs/shim_namei.o fs/socket/fs.o fs/str/fs.o ipc/shim_ipc_child.o ipc/shim_ipc_helper.o ipc/shim_ipc.o ipc/shim_ipc_pid.o ipc/shim_ipc_sysv.o shim_async.o shim_checkpoint.o shim_debug.o shim_init.o shim_malloc.o shim_parser.o shim_random.o shim_syscalls.o shim_table.o start.o syscallas.o sys/shim_access.o sys/shim_alarm.o sys/shim_benchmark.o sys/shim_brk.o sys/shim_clone.o sys/shim_dup.o sys/shim_epoll.o sys/shim_exec.o sys/shim_exit.o sys/shim_fcntl.o sys/shim_fork.o sys/shim_fs.o sys/shim_futex.o sys/shim_getcwd.o sys/shim_getpid.o sys/shim_getrlimit.o sys/shim_ioctl.o sys/shim_migrate.o sys/shim_mmap.o sys/shim_msgget.o sys/shim_open.o sys/shim_pipe.o sys/shim_poll.o sys/shim_sandbox.o sys/shim_sched.o sys/shim_semget.o sys/shim_sigaction.o sys/shim_sleep.o sys/shim_socket.o sys/shim_stat.o sys/shim_time.o sys/shim_uname.o sys/shim_vfork.o sys/shim_wait.o sys/shim_wrappers.o utils/md5.o utils/printf.o utils/strobjs.o 92ddf4b5992c4b2cea2c857001d95a0da8fdb708b1f39be3ba0a384ff07567605e46957e20c6e40e1a9af5aa6e4cc531 \ No newline at end of file diff --git a/LibOS/shim/src/.packed/shim.tar.gz b/LibOS/shim/src/.packed/shim.tar.gz index e2f8b524..cd699672 100644 Binary files a/LibOS/shim/src/.packed/shim.tar.gz and b/LibOS/shim/src/.packed/shim.tar.gz differ diff --git a/LibOS/shim/test/apps/openjdk/Makefile b/LibOS/shim/test/apps/openjdk/Makefile index ee2e9865..0518c9ed 100644 --- a/LibOS/shim/test/apps/openjdk/Makefile +++ b/LibOS/shim/test/apps/openjdk/Makefile @@ -11,8 +11,14 @@ clean-extra = clean-classes JAVA_HOST_HOME = $(shell readlink -f /usr/bin/java | xargs dirname | xargs dirname) +compact_rule = sys.stack.size = 1M\nsys.brk.size = 16M\nglibc.heap_size = 4M\nsgx.enclave_size = 4G\nsgx.thread_num = 16\nsgx.heap_min = 0x80000000 +large_rule = sys.stack.size = 4M\nsys.brk.size = 64M\nglibc.heap_size = 16M\nsgx.enclave_size = 8G\nsgx.thread_num = 32\nsgx.heap_min = 0x40000000 + ABSPATH_IN_MANIFEST = yes -extra_rules = -e 's:\$$(JAVA_HOME):$(JAVA_HOST_HOME):g' +extra_rules = \ + -e 's:\$$(DEBUGTYPE):$(if $(DEBUG),inline,none):g' \ + -e 's:\$$(JAVA_HOME):$(JAVA_HOST_HOME):g' \ + -e 's:\$$(RESOURCE_RULE):$(if $(COMPACT),$(compact_rule),$(large_rule)):g' level = ../../ include ../../Makefile diff --git a/LibOS/shim/test/apps/openjdk/java.manifest.template b/LibOS/shim/test/apps/openjdk/java.manifest.template index ea2bfe55..ae9a0d57 100644 --- a/LibOS/shim/test/apps/openjdk/java.manifest.template +++ b/LibOS/shim/test/apps/openjdk/java.manifest.template @@ -5,7 +5,7 @@ loader.exec = file:$(JAVA_HOME)/bin/java loader.execname = java loader.env.LD_LIBRARY_PATH = $(JAVA_HOME)/lib/amd64:$(JAVA_HOME)/lib/amd64/jli:/graphene:/lib/x86_64-linux-gnu:/usr/lib:/usr/lib/x86_64-linux-gnu loader.env.PATH = /jre/bin:/bin:/usr/bin -loader.debug_type = none +loader.debug_type = $(DEBUGTYPE) fs.mount.lib1.type = chroot fs.mount.lib1.path = /graphene @@ -27,13 +27,7 @@ fs.mount.tmp.type = chroot fs.mount.tmp.path = /tmp fs.mount.tmp.uri = file:/tmp -sys.stack.size = 1M -sys.brk.size = 16M -glibc.heap_size = 4M - -sgx.enclave_size = 8G -sgx.thread_num = 40 -sgx.heap_min = 0x80000000 +$(RESOURCE_RULE) sgx.trusted_files.ld = file:$(LIBCDIR)/ld-linux-x86-64.so.2 sgx.trusted_files.libc = file:$(LIBCDIR)/libc.so.6 diff --git a/LibOS/shim/test/apps/openjdk/run-java b/LibOS/shim/test/apps/openjdk/run-compact-java similarity index 100% rename from LibOS/shim/test/apps/openjdk/run-java rename to LibOS/shim/test/apps/openjdk/run-compact-java diff --git a/Pal/regression/.packed/test.sha384 b/Pal/regression/.packed/test.sha384 index 3eda8fd0..93950155 100644 --- a/Pal/regression/.packed/test.sha384 +++ b/Pal/regression/.packed/test.sha384 @@ -1 +1 @@ -Bootstrap Bootstrap2 Bootstrap3 Directory Exception File Ipc Memory Misc Pipe Preload1.so Preload2.so Process Process2 Process3 SendHandle Socket Symbols Thread da9eddeb36c6f24f4fbebb7f94c198b81fe757849556080cda2c40cbbeadf4cd86e72533983cda9fc0af34f65ce75d16 \ No newline at end of file +Bootstrap ..Bootstrap Bootstrap2 Bootstrap3 Directory Exception File Ipc Memory Misc Pipe Preload1.so Preload2.so Process Process2 Process3 Semaphore SendHandle Socket Symbols Thread 5851656aa1965a98de2be10613e5bddfb52659eb2fad51a0d1cac35b7b38110765dea769c5bc5b90d3933661794744c0 \ No newline at end of file diff --git a/Pal/regression/.packed/test.tar.gz b/Pal/regression/.packed/test.tar.gz index af13eae3..56ce9d64 100644 Binary files a/Pal/regression/.packed/test.tar.gz and b/Pal/regression/.packed/test.tar.gz differ diff --git a/Pal/src/host/Linux-SGX/db_memory.c b/Pal/src/host/Linux-SGX/db_memory.c index faedaf82..83d85b9d 100644 --- a/Pal/src/host/Linux-SGX/db_memory.c +++ b/Pal/src/host/Linux-SGX/db_memory.c @@ -86,7 +86,7 @@ int _DkVirtualMemoryAlloc (void ** paddr, uint64_t size, int alloc_type, int pro if (!mem) return addr ? -PAL_ERROR_DENIED : -PAL_ERROR_NOMEM; - memset(mem, 0, size); + //memset(mem, 0, size); if (alloc_type & PAL_ALLOC_INTERNAL) { SGX_DBG(DBG_M, "pal allocates %p-%p for internal use\n", mem, mem + size); diff --git a/Pal/src/host/Linux-SGX/enclave_pages.c b/Pal/src/host/Linux-SGX/enclave_pages.c index b7e43e1e..3d85f342 100644 --- a/Pal/src/host/Linux-SGX/enclave_pages.c +++ b/Pal/src/host/Linux-SGX/enclave_pages.c @@ -105,7 +105,9 @@ void * get_reserved_pages(void * addr, uint64_t size) void * avail_top = heap_base + heap_size; list_for_each_entry(vma, &heap_vma_list, list) { - if (avail_top - vma->top > size) { + if (vma->top < heap_base) + break; + if (avail_top >= vma->top + size) { addr = avail_top - size; goto allocated; } @@ -113,15 +115,15 @@ void * get_reserved_pages(void * addr, uint64_t size) avail_top = prev->bottom; } - if (avail_top - heap_base > size) { + if (avail_top >= heap_base + size) { addr = avail_top - size; goto allocated; } _DkInternalUnlock(&heap_vma_lock); - asm volatile("int $3"); SGX_DBG(DBG_E, "*** Not enough space on the heap (requested = %llu) ***\n", size); + asm volatile("int $3"); return NULL; allocated: diff --git a/Pal/src/host/Linux-SGX/sgx_thread.c b/Pal/src/host/Linux-SGX/sgx_thread.c index 258764d2..e17ae99b 100644 --- a/Pal/src/host/Linux-SGX/sgx_thread.c +++ b/Pal/src/host/Linux-SGX/sgx_thread.c @@ -85,7 +85,7 @@ int clone_thread (void) int interrupt_thread (void * tcs) { - int index = current_tcs - enclave_tcs; + int index = (sgx_arch_tcs_t *) tcs - enclave_tcs; struct thread_map * map = &enclave_thread_map[index]; if (index >= enclave_thread_num) return -PAL_ERROR_INVAL; diff --git a/Runtime/Makefile b/Runtime/Makefile index da90d60e..1cf4deee 100644 --- a/Runtime/Makefile +++ b/Runtime/Makefile @@ -2,3 +2,4 @@ clean: rm -f libc.so.6 ld-linux-x86-64.so.2 libpthread.so.0 libm.so.6 libdl.so.2 libutil.so.1 crt1.o crti.o crtn.o liblibos.so.1 libnss_dns.so.2 libresolv.so.2 pal_gdb* pal-* pal_sec* all: +pack: diff --git a/Runtime/pal_loader b/Runtime/pal_loader index 80ca2ba1..4d359040 100755 --- a/Runtime/pal_loader +++ b/Runtime/pal_loader @@ -1,8 +1,10 @@ #!/bin/bash if [ "$1" == "SGX" ]; then - export SGX=1 - shift + if [ "$SGX" != "0" ]; then + export SGX=1 + fi + shift fi RUNTIME_DIR=$(/usr/bin/dirname $(readlink -f ${BASH_SOURCE[0]}))