From ee019fa5db78dbc3428656996c82b07f6c3bcc8a Mon Sep 17 00:00:00 2001 From: Don Porter Date: Sat, 21 Jan 2017 15:06:37 -0500 Subject: [PATCH] Clearer error message on non-power-of-two enclave size. Issue #39 --- Pal/src/host/Linux-SGX/sgx_main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Pal/src/host/Linux-SGX/sgx_main.c b/Pal/src/host/Linux-SGX/sgx_main.c index e4123de5..9ecc1762 100644 --- a/Pal/src/host/Linux-SGX/sgx_main.c +++ b/Pal/src/host/Linux-SGX/sgx_main.c @@ -269,6 +269,14 @@ int initialize_enclave (struct pal_enclave * enclave) enclave->size = parse_int(cfgbuf); + /* DEP 1/21/17: SGX currently only supports power-of-two enclaves. + * Give users a better warning about this. */ + if (enclave->size & (enclave->size - 1)) { + SGX_DBG(DBG_E, "Enclave size not a power of two. SGX requires power-of-two enclaves.\n"); + ret = -EINVAL; + goto err; + } + /* Reading sgx.thread_num from manifest */ if (get_config(enclave->config, "sgx.thread_num", cfgbuf, CONFIG_MAX) > 0) enclave->thread_num = parse_int(cfgbuf);