Skip to contentSkip to conversation

x86/sgx: Fine-tune page adding flow

PATCH New Jarkko Sakkinen 1 participant 1 message Sep 14, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/sgx: Fine-tune page adding flow

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.

---
 arch/x86/kernel/cpu/sgx/ioctl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/sgx/ioctl.c +6 -1
index 0ae00fa9b589..274557f66de2 100644
@@ -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;
 		}
Signature · 1 line
2.25.1