Re: [PATCH v24 12/24] x86/sgx: Linux Enclave Driver
From: Jarkko Sakkinen <hidden>
Date: 2019-12-09 19:50:15
Also in:
lkml
On Mon, Dec 02, 2019 at 10:21:03AM -0800, Sean Christopherson wrote:
On Mon, Dec 02, 2019 at 09:48:43AM -0600, Haitao Huang wrote:quoted
On Fri, 29 Nov 2019 17:13:14 -0600, Jarkko Sakkinen [off-list ref] wrote:quoted
+ + for (c = 0 ; c < addp.length; c += PAGE_SIZE) { + if (signal_pending(current)) { + ret = -ERESTARTSYS; + break; + }This IOC is not idempotent as pages EADDed at this point can not be re-EADDed again. So we can't return ERESTARTSYSAh, and now I remember why I opted for modifying the parameters directly instead of including a "number processed" field. Andy pointed out the ERESTARTSYS thing in the original multi-page add RFC[*], so presumably updating the params and returning ERESTARTSYS is legal/acceptable. [*] https://lkml.kernel.org/r/CALCETrUb4X9_L9RXKhmyNpfSCsbNodP=BfbfO8Fz_efq24jp8w@mail.gmail.com
There are exactly two primary options to pick from given the non-idempotent nature: A. Return zero (since we support partial operation with the changes I did in v24). B. Return -EINTR. If we wanted to follow common syscall semantics in IO operations, then the semantics would be a mix of these: 1. Return -EINTR if signals are pending before any pages got added. 2. Return 0 if at least one page got added. This is how write() works for example according to the documentation [1]. As far as the user code goes [2] I think for that it is best idea to rely on semantics that developers are used to instead of being clever here. [1] http://man7.org/linux/man-pages/man2/write.2.html [2] https://lkml.kernel.org/r/CALCETrUb4X9_L9RXKhmyNpfSCsbNodP=BfbfO8Fz_efq24jp8w@mail.gmail.com /Jarkko