diff mbox series

[for,v24,v3,1/4] x86/sgx: %SGX_IOC_ENCLAVE_ADD_PAGES: Return -EIO when ENCLS fails

Message ID 20191119184137.16004-1-jarkko.sakkinen@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [for,v24,v3,1/4] x86/sgx: %SGX_IOC_ENCLAVE_ADD_PAGES: Return -EIO when ENCLS fails | expand

Commit Message

Jarkko Sakkinen Nov. 19, 2019, 6:41 p.m. UTC
Use a common error code for all ENCLS failures so they can be easily
recognized from user space code.

Cc: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
 arch/x86/kernel/cpu/sgx/ioctl.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Jarkko Sakkinen Nov. 25, 2019, 2:20 p.m. UTC | #1
On Tue, Nov 19, 2019 at 08:41:34PM +0200, Jarkko Sakkinen wrote:
> Use a common error code for all ENCLS failures so they can be easily
> recognized from user space code.
> 
> Cc: Sean Christopherson <sean.j.christopherson@intel.com>
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

Merging this series to master.

/Jarkko
diff mbox series

Patch

diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c
index bbdc24d50169..2d6f7b8cc429 100644
--- a/arch/x86/kernel/cpu/sgx/ioctl.c
+++ b/arch/x86/kernel/cpu/sgx/ioctl.c
@@ -338,7 +338,7 @@  static int __sgx_encl_add_page(struct sgx_encl *encl,
 	kunmap_atomic((void *)pginfo.contents);
 	put_page(src_page);
 
-	return ret ? -EFAULT : 0;
+	return ret ? -EIO : 0;
 }
 
 static int __sgx_encl_extend(struct sgx_encl *encl,
@@ -353,7 +353,7 @@  static int __sgx_encl_extend(struct sgx_encl *encl,
 		if (ret) {
 			if (encls_failed(ret))
 				ENCLS_WARN(ret, "EEXTEND");
-			return -EFAULT;
+			return -EIO;
 		}
 	}
 
@@ -496,10 +496,9 @@  static int sgx_encl_add_page(struct sgx_encl *encl,
  *
  * Return:
  *   0 on success,
- *   -EINVAL if any input param or the SECINFO contains invalid data,
  *   -EACCES if an executable source page is located in a noexec partition,
- *   -ENOMEM if any memory allocation, including EPC, fails,
- *   -ERESTARTSYS if a pending signal is recognized
+ *   -EIO if either ENCLS[EADD] or ENCLS[EEXTEND] fails
+ *   -errno otherwise
  */
 static long sgx_ioc_enclave_add_pages(struct sgx_encl *encl, void __user *arg)
 {