From fe7a603bf39b30bb99c43b481b632267f137e459 Mon Sep 17 00:00:00 2001 From: Dmitrii Kuvaiskii Date: Tue, 15 Oct 2019 18:12:24 -0700 Subject: [PATCH] [Pal/Linux-SGX] Increase MAX_DBG_THREADS constant from 64 to 1024 An internal Graphene structure for GDB metadata limits the number of enclave threads to MAX_DBG_THREADS. Previously, it was set to 64, which was enough for typical platforms. However, powerful servers have hundreds of logical cores. Graphene-SGX failed with error on such servers. This commit increases the limit to 1024. --- Pal/src/host/Linux-SGX/debugger/sgx_gdb.h | 2 +- Pal/src/host/Linux-SGX/sgx_main.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Pal/src/host/Linux-SGX/debugger/sgx_gdb.h b/Pal/src/host/Linux-SGX/debugger/sgx_gdb.h index dee781cf..b42e1aed 100644 --- a/Pal/src/host/Linux-SGX/debugger/sgx_gdb.h +++ b/Pal/src/host/Linux-SGX/debugger/sgx_gdb.h @@ -1,4 +1,4 @@ -#define MAX_DBG_THREADS 64 +#define MAX_DBG_THREADS 1024 /* This address is shared between our GDB and Graphene-SGX and must * reside in non-enclave memory. Graphene-SGX puts an enclave_dbginfo diff --git a/Pal/src/host/Linux-SGX/sgx_main.c b/Pal/src/host/Linux-SGX/sgx_main.c index dddf7c93..5700e76e 100644 --- a/Pal/src/host/Linux-SGX/sgx_main.c +++ b/Pal/src/host/Linux-SGX/sgx_main.c @@ -234,9 +234,11 @@ int initialize_enclave (struct pal_enclave * enclave) sgx_arch_enclave_css_t enclave_sigstruct; sgx_arch_secs_t enclave_secs; unsigned long enclave_entry_addr; - void* tcs_addrs[MAX_DBG_THREADS]; unsigned long heap_min = DEFAULT_HEAP_MIN; + /* this array may overflow the stack, so we allocate it in BSS */ + static void* tcs_addrs[MAX_DBG_THREADS]; + enclave_image = INLINE_SYSCALL(open, 3, ENCLAVE_FILENAME, O_RDONLY, 0); if (IS_ERR(enclave_image)) { SGX_DBG(DBG_E, "Cannot find %s\n", ENCLAVE_FILENAME);