From 79bbd2ad3e6314e30e5179314f9d9ab56561a51b Mon Sep 17 00:00:00 2001 From: "Zheng, Qi" Date: Thu, 2 Mar 2023 19:19:31 +0800 Subject: [PATCH] [libos] Print error sgx status when ocall failed --- src/libos/src/vm/vm_perms.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/libos/src/vm/vm_perms.rs b/src/libos/src/vm/vm_perms.rs index f092dd08..9f65cf0e 100644 --- a/src/libos/src/vm/vm_perms.rs +++ b/src/libos/src/vm/vm_perms.rs @@ -47,14 +47,19 @@ impl VMPerms { if rsgx_is_supported_EDMM() { // With EDMM support, reserved memory permission should be updated. - assert!( - sgx_tprotect_rsrv_mem(addr, len, prot.bits() as i32) - == sgx_status_t::SGX_SUCCESS - ); + let sgx_status = sgx_tprotect_rsrv_mem(addr, len, prot.bits() as i32); + if sgx_status != sgx_status_t::SGX_SUCCESS { + panic!("sgx_tprotect_rsrv_mem status {}", sgx_status); + } } else { // Without EDMM support, reserved memory permission is statically RWX and we only need to do mprotect ocall. let sgx_status = occlum_ocall_mprotect(&mut retval, addr, len, prot.bits() as i32); - assert!(sgx_status == sgx_status_t::SGX_SUCCESS && retval == 0); + if sgx_status != sgx_status_t::SGX_SUCCESS || retval != 0 { + panic!( + "occlum_ocall_mprotect status {}, retval {}", + sgx_status, retval + ); + } } } }