All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: linux-sgx@vger.kernel.org
Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
	Borislav Petkov <bp@alien8.de>,
	Sean Christopherson <sean.j.christopherson@intel.com>,
	Haitao Huang <haitao.huang@linux.intel.com>
Subject: [PATCH] x86/sgx: Fine-tune page adding flow
Date: Mon, 14 Sep 2020 17:44:13 +0300	[thread overview]
Message-ID: <20200914144413.21858-1-jarkko.sakkinen@linux.intel.com> (raw)

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@alien8.de>
Cc: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: Haitao Huang <haitao.huang@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
 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


                 reply	other threads:[~2020-09-14 14:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200914144413.21858-1-jarkko.sakkinen@linux.intel.com \
    --to=jarkko.sakkinen@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=haitao.huang@linux.intel.com \
    --cc=linux-sgx@vger.kernel.org \
    --cc=sean.j.christopherson@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.