Message ID | 20200914144413.21858-1-jarkko.sakkinen@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | x86/sgx: Fine-tune page adding flow | expand |
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; }
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(-)