On 9/25/18 6:06 AM, Jarkko Sakkinen wrote: > Add wrappers for Intel(R) SGX ENCLS opcode leaf functions except > ENCLS(EINIT). ENCLS invokes privileged functions for managing (creation, > initialization and swapping) and debugging enclaves. > > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx> > Co-developed-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> > Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> > --- > arch/x86/include/asm/sgx.h | 244 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 244 insertions(+) > > diff --git a/arch/x86/include/asm/sgx.h b/arch/x86/include/asm/sgx.h > index f4f82f0453a9..e66e2572011e 100644 > --- a/arch/x86/include/asm/sgx.h > +++ b/arch/x86/include/asm/sgx.h > @@ -10,4 +10,248 @@ > extern bool sgx_enabled; > extern bool sgx_lc_enabled; > Hi, Please don't use "/**" to begin comment blocks that are not kernel-doc notation, like the 3 below. Note: I might have seen one (or some) of these "fixed" in other patches in this series (not sure). > +/** > + * ENCLS_FAULT_FLAG - flag signifying an ENCLS return code is a trapnr > + * > + * ENCLS has its own (positive value) error codes and also generates > + * ENCLS specific #GP and #PF faults. And the ENCLS values get munged > + * with system error codes as everything percolates back up the stack. > + * Unfortunately (for us), we need to precisely identify each unique > + * error code, e.g. the action taken if EWB fails varies based on the > + * type of fault and on the exact SGX error code, i.e. we can't simply > + * convert all faults to -EFAULT. > + * > + * To make all three error types coexist, we set bit 30 to identify an > + * ENCLS fault. Bit 31 (technically bits N:31) is used to differentiate > + * between positive (faults and SGX error codes) and negative (system > + * error codes) values. > + */ > +#define ENCLS_FAULT_FLAG 0x40000000 > + > +/** > + * Check for a fault by looking for a postive value with the fault > + * flag set. The postive value check is needed to filter out system > + * error codes since negative values will have all higher order bits > + * set, including ENCLS_FAULT_FLAG. > + */ > +#define IS_ENCLS_FAULT(r) ((int)(r) > 0 && ((r) & ENCLS_FAULT_FLAG)) > + > +/** > + * Retrieve the encoded trapnr from the specified return code. > + */ > +#define ENCLS_TRAPNR(r) ((r) & ~ENCLS_FAULT_FLAG) thanks, -- ~Randy