From 0a810b9b585c0f0d756c8024191a2260d0f63fdf Mon Sep 17 00:00:00 2001 From: "Hui, Chunyang" Date: Tue, 1 Dec 2020 12:11:12 +0000 Subject: [PATCH] Add return error code for ecall --- src/pal/src/ocalls/spawn.c | 4 ++-- src/pal/src/pal_api.c | 6 +++--- src/pal/src/pal_enclave.c | 2 +- src/pal/src/pal_interrupt_thread.c | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/pal/src/ocalls/spawn.c b/src/pal/src/ocalls/spawn.c index c23bd870..a8d2c623 100644 --- a/src/pal/src/ocalls/spawn.c +++ b/src/pal/src/ocalls/spawn.c @@ -18,8 +18,8 @@ void *exec_libos_thread(void *_thread_data) { host_tid); if (status != SGX_SUCCESS) { const char *sgx_err = pal_get_sgx_error_msg(status); - PAL_ERROR("Failed to enter the enclave to execute a LibOS thread (host tid = %d): %s", - host_tid, sgx_err); + PAL_ERROR("Failed to enter the enclave to execute a LibOS thread (host tid = %d) with error code 0x%x: %s", + host_tid, status, sgx_err); exit(EXIT_FAILURE); } diff --git a/src/pal/src/pal_api.c b/src/pal/src/pal_api.c index 80974c29..67b71cf1 100644 --- a/src/pal/src/pal_api.c +++ b/src/pal/src/pal_api.c @@ -51,7 +51,7 @@ int occlum_pal_init(const struct occlum_pal_attr *attr) { resolved_path); if (ecall_status != SGX_SUCCESS) { const char *sgx_err = pal_get_sgx_error_msg(ecall_status); - PAL_ERROR("Failed to do ECall: %s", sgx_err); + PAL_ERROR("Failed to do ECall with error code 0x%x: %s", ecall_status, sgx_err); goto on_destroy_enclave; } if (ecall_ret < 0) { @@ -95,7 +95,7 @@ int occlum_pal_create_process(struct occlum_pal_create_process_args *args) { args->argv, args->env, args->stdio); if (ecall_status != SGX_SUCCESS) { const char *sgx_err = pal_get_sgx_error_msg(ecall_status); - PAL_ERROR("Failed to do ECall: %s", sgx_err); + PAL_ERROR("Failed to do ECall with error code 0x%x: %s", ecall_status, sgx_err); return -1; } if (ecall_ret < 0) { @@ -156,7 +156,7 @@ int occlum_pal_kill(int pid, int sig) { sgx_status_t ecall_status = occlum_ecall_kill(eid, &ecall_ret, pid, sig); if (ecall_status != SGX_SUCCESS) { const char *sgx_err = pal_get_sgx_error_msg(ecall_status); - PAL_ERROR("Failed to do ECall: %s", sgx_err); + PAL_ERROR("Failed to do ECall with error code 0x%x: %s", ecall_status, sgx_err); return -1; } if (ecall_ret < 0) { diff --git a/src/pal/src/pal_enclave.c b/src/pal/src/pal_enclave.c index e8246937..3cbc1dde 100644 --- a/src/pal/src/pal_enclave.c +++ b/src/pal/src/pal_enclave.c @@ -106,7 +106,7 @@ int pal_init_enclave(const char *instance_dir) { NULL); if (ret != SGX_SUCCESS) { const char *sgx_err_msg = pal_get_sgx_error_msg(ret); - PAL_ERROR("Failed to create enclave: %s", sgx_err_msg); + PAL_ERROR("Failed to create enclave with error code 0x%x: %s", ret, sgx_err_msg); if (fp != NULL) { fclose(fp); } return -1; } diff --git a/src/pal/src/pal_interrupt_thread.c b/src/pal/src/pal_interrupt_thread.c index 1202df71..24c8b7c5 100644 --- a/src/pal/src/pal_interrupt_thread.c +++ b/src/pal/src/pal_interrupt_thread.c @@ -23,7 +23,8 @@ static void *thread_func(void *_data) { &num_broadcast_threads); if (ecall_status != SGX_SUCCESS) { const char *sgx_err = pal_get_sgx_error_msg(ecall_status); - PAL_ERROR("Failed to do ECall: occlum_ecall_broadcast_interrupts: %s", sgx_err); + PAL_ERROR("Failed to do ECall: occlum_ecall_broadcast_interrupts with error code 0x%x: %s", + ecall_status, sgx_err); exit(EXIT_FAILURE); } if (ecall_status == SGX_SUCCESS && num_broadcast_threads < 0) {