-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from aegis2501/master
Gramine single-stepping example
- Loading branch information
Showing
11 changed files
with
426 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 0 additions & 61 deletions
61
sdk/gramine/0002-Example-usage-of-libsgxstep-functionality-on-Gramine.patch
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
diff --git a/CI-Examples/helloworld/helloworld.manifest.template b/CI-Examples/helloworld/helloworld.manifest.template | ||
index 64c908e1..205860da 100644 | ||
--- a/CI-Examples/helloworld/helloworld.manifest.template | ||
+++ b/CI-Examples/helloworld/helloworld.manifest.template | ||
@@ -6,6 +6,9 @@ loader.log_level = "{{ log_level }}" | ||
|
||
loader.env.LD_LIBRARY_PATH = "/lib" | ||
|
||
+loader.insecure__use_cmdline_argv = true | ||
+loader.insecure__disable_aslr = true | ||
+ | ||
fs.mounts = [ | ||
{ path = "/lib", uri = "file:{{ gramine.runtimedir() }}" }, | ||
{ path = "/helloworld", uri = "file:helloworld" }, | ||
@@ -13,6 +16,8 @@ fs.mounts = [ | ||
|
||
sgx.debug = true | ||
sgx.nonpie_binary = true | ||
+sgx.preheat_enclave = true | ||
+sgx.thread_num = 4 | ||
|
||
sgx.trusted_files = [ | ||
"file:{{ gramine.libos }}", | ||
diff --git a/pal/src/host/linux-sgx/host_ecalls.c b/pal/src/host/linux-sgx/host_ecalls.c | ||
index 9387266b..e83acc63 100644 | ||
--- a/pal/src/host/linux-sgx/host_ecalls.c | ||
+++ b/pal/src/host/linux-sgx/host_ecalls.c | ||
@@ -5,6 +5,14 @@ | ||
#include "host_internal.h" | ||
#include "pal_ecall_types.h" | ||
#include "pal_rpc_queue.h" | ||
+#include "sdk/gramine/aep.h" | ||
+ | ||
+#define SGX_STEP_ENABLE 1 | ||
+ | ||
+#define THREAD_END 4 | ||
+ | ||
+static int thread_ctr = 0; | ||
+static spinlock_t g_step_lock = INIT_SPINLOCK_UNLOCKED; | ||
|
||
int ecall_enclave_start(char* libpal_uri, char* args, size_t args_size, char* env, | ||
size_t env_size, int parent_stream_fd, sgx_target_info_t* qe_targetinfo, | ||
@@ -32,13 +40,37 @@ int ecall_enclave_start(char* libpal_uri, char* args, size_t args_size, char* en | ||
ms.ms_topo_info = topo_info; | ||
ms.ms_dns_host_conf = dns_conf; | ||
ms.rpc_queue = g_rpc_queue; | ||
+ | ||
+#if SGX_STEP_ENABLE | ||
+ /* NOTE: set sgx.preheat_enclave = true in manifest to prefault pages (occurs in pal_main.c) */ | ||
+ /* Configure and check attacker untrusted runtime environment. */ | ||
+ attacker_config_runtime(); | ||
+#endif | ||
+ | ||
return sgx_ecall(ECALL_ENCLAVE_START, &ms); | ||
} | ||
|
||
int ecall_thread_start(void) { | ||
+ | ||
+#if SGX_STEP_ENABLE | ||
+ thread_ctr++; | ||
+ if(thread_ctr == 4) { | ||
+ spinlock_lock(&g_step_lock); | ||
+ configure_mapping(); | ||
+ spinlock_unlock(&g_step_lock); | ||
+ } | ||
+#endif | ||
+ | ||
return sgx_ecall(ECALL_THREAD_START, NULL); | ||
} | ||
|
||
int ecall_thread_reset(void) { | ||
+ | ||
+#if SGX_STEP_ENABLE | ||
+ if(thread_ctr == THREAD_END){ | ||
+ restore_timer(); | ||
+ } | ||
+#endif | ||
+ | ||
return sgx_ecall(ECALL_THREAD_RESET, NULL); | ||
} |
Oops, something went wrong.