Browse Source

Merge pull request #143 from deeglaze/ioctl_retry

 Expose an internal error on enclave_create ioctl interrupt.

Signed-off-by: Zhang Lili Z <lili.z.zhang@intel.com>
lzha101 6 years ago
parent
commit
a31b0b6034
2 changed files with 5 additions and 0 deletions
  1. 2 0
      common/inc/sgx_error.h
  2. 3 0
      psw/urts/linux/enclave_creator_hw.cpp

+ 2 - 0
common/inc/sgx_error.h

@@ -103,6 +103,8 @@ typedef enum _status_t
     SGX_ERROR_FILE_FLUSH_FAILED             = SGX_MK_ERROR(0x7008),	/* fflush operation (to disk) failed (only used when no EXXX is returned) */
     SGX_ERROR_FILE_CLOSE_FAILED             = SGX_MK_ERROR(0x7009),	/* fclose operation (to disk) failed (only used when no EXXX is returned) */
 
+    SGX_INTERNAL_ERROR_ENCLAVE_CREATE_INTERRUPTED = SGX_MK_ERROR(0xF001), /* The ioctl for enclave_create unexpectedly failed with EINTR. */
+
 } sgx_status_t;
 
 #endif

+ 3 - 0
psw/urts/linux/enclave_creator_hw.cpp

@@ -144,6 +144,9 @@ int EnclaveCreatorHW::create_enclave(secs_t *secs, sgx_enclave_id_t *enclave_id,
     int ret = ioctl(m_hdevice, SGX_IOC_ENCLAVE_CREATE, &param);
     if(ret) 
     {
+        if(ret == -1 && errno == EINTR) {
+            return SGX_INTERNAL_ERROR_ENCLAVE_CREATE_INTERRUPTED;  // Allow the user to retry.
+        }
         SE_TRACE(SE_TRACE_WARNING, "\nSGX_IOC_ENCLAVE_CREATE failed: errno = %d\n", errno);
         return error_driver2urts(ret);
     }