  {
      se_mutex_lock(&s_device_mutex);
  
-@@ -382,22 +385,38 @@
+@@ -382,22 +385,48 @@
          }
          //The in-kernel driver does not do the base and size alignment. This is up to user mode to do it. 
          //Therefore enclave_size will be virtual_size*2. The unused region will be released by calling munmap later.

     {
         uint64_t aligned_addr = ((uint64_t)enclave_base + virtual_size - 1) & ~(virtual_size - 1);
         if(aligned_addr != (uint64_t)enclave_base)
@@ -784,15 +803,7 @@
 
         enclave_css_t* enclave_css = (enclave_css_t*)enclave_init_sgx->sigstruct;
         if (0 == enclave_css->header.hw_version) {

             if (status != SGX_SUCCESS) {
                 if (enclave_error != NULL)
                     *enclave_error = error_aesm2api(status);
@@ -818,15 +866,6 @@
     }
     else
     {
-        int hfile = get_file_handle_from_address(base_address);
-        if (hfile == -1)
-        {
-            SE_TRACE(SE_TRACE_WARNING, "\nSGX_IOC_ENCLAVE_INIT failed - %p is not a valid enclave \n", base_address);
-            if (enclave_error != NULL)
-                *enclave_error = ENCLAVE_INVALID_ADDRESS;
-            return false;
-        }
-
         //in-kernel driver does not need a launch token or the enclave address
         struct sgx_enclave_init_in_kernel initp = { 0 };
         initp.sigstruct = POINTER_TO_U64(enclave_init_sgx->sigstruct);
@@ -842,6 +881,13 @@
     }
 
     se_mutex_lock(&s_enclave_mutex);
