Add return error code for ecall

This commit is contained in:
Hui, Chunyang 2020-12-01 12:11:12 +00:00 committed by Zongmin.Gu
parent 928cfecf9d
commit 0a810b9b58
4 changed files with 8 additions and 7 deletions

@ -18,8 +18,8 @@ void *exec_libos_thread(void *_thread_data) {
host_tid); host_tid);
if (status != SGX_SUCCESS) { if (status != SGX_SUCCESS) {
const char *sgx_err = pal_get_sgx_error_msg(status); 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", PAL_ERROR("Failed to enter the enclave to execute a LibOS thread (host tid = %d) with error code 0x%x: %s",
host_tid, sgx_err); host_tid, status, sgx_err);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }

@ -51,7 +51,7 @@ int occlum_pal_init(const struct occlum_pal_attr *attr) {
resolved_path); resolved_path);
if (ecall_status != SGX_SUCCESS) { if (ecall_status != SGX_SUCCESS) {
const char *sgx_err = pal_get_sgx_error_msg(ecall_status); 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; goto on_destroy_enclave;
} }
if (ecall_ret < 0) { 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); args->argv, args->env, args->stdio);
if (ecall_status != SGX_SUCCESS) { if (ecall_status != SGX_SUCCESS) {
const char *sgx_err = pal_get_sgx_error_msg(ecall_status); 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; return -1;
} }
if (ecall_ret < 0) { 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); sgx_status_t ecall_status = occlum_ecall_kill(eid, &ecall_ret, pid, sig);
if (ecall_status != SGX_SUCCESS) { if (ecall_status != SGX_SUCCESS) {
const char *sgx_err = pal_get_sgx_error_msg(ecall_status); 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; return -1;
} }
if (ecall_ret < 0) { if (ecall_ret < 0) {

@ -106,7 +106,7 @@ int pal_init_enclave(const char *instance_dir) {
NULL); NULL);
if (ret != SGX_SUCCESS) { if (ret != SGX_SUCCESS) {
const char *sgx_err_msg = pal_get_sgx_error_msg(ret); 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); } if (fp != NULL) { fclose(fp); }
return -1; return -1;
} }

@ -23,7 +23,8 @@ static void *thread_func(void *_data) {
&num_broadcast_threads); &num_broadcast_threads);
if (ecall_status != SGX_SUCCESS) { if (ecall_status != SGX_SUCCESS) {
const char *sgx_err = pal_get_sgx_error_msg(ecall_status); 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); exit(EXIT_FAILURE);
} }
if (ecall_status == SGX_SUCCESS && num_broadcast_threads < 0) { if (ecall_status == SGX_SUCCESS && num_broadcast_threads < 0) {