[PATCH] x86/sgx: Fine-tune page adding flow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Make semantics follow more closely read()-syscall:

- A signal when nothing is yet processed results -EINTR.
- A signal when at least one page is processed results the length
  of the data processed.

Link: https://man7.org/linux/man-pages/man2/read.2.html
Cc: Borislav Petkov <bp@xxxxxxxxx>
Cc: Sean Christopherson <sean.j.christopherson@xxxxxxxxx>
Cc: Haitao Huang <haitao.huang@xxxxxxxxxxxxxxx>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx>
---
 arch/x86/kernel/cpu/sgx/ioctl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c
index 0ae00fa9b589..274557f66de2 100644
--- a/arch/x86/kernel/cpu/sgx/ioctl.c
+++ b/arch/x86/kernel/cpu/sgx/ioctl.c
@@ -530,7 +530,12 @@ static long sgx_ioc_enclave_add_pages(struct sgx_encl *encl, void __user *arg)
 		return -EINVAL;
 
 	for (c = 0 ; c < addp.length; c += PAGE_SIZE) {
-		if (c == SGX_MAX_ADD_PAGES_LENGTH || signal_pending(current)) {
+		if (signal_pending(current)) {
+			ret = c == 0 ? -EINTR : c;
+			break;
+		}
+
+		if (c == SGX_MAX_ADD_PAGES_LENGTH) {
 			ret = c;
 			break;
 		}
-- 
2.25.1




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux