Messages in this thread | | | Date | Thu, 6 Dec 2018 05:55:47 -0800 | From | Sean Christopherson <> | Subject | Re: [RFC PATCH 4/4] x86/vdso: Add __vdso_sgx_eenter() to wrap SGX enclave transitions |
| |
On Wed, Dec 05, 2018 at 03:40:48PM -0800, Andy Lutomirski wrote: > On Wed, Dec 5, 2018 at 3:20 PM Sean Christopherson > <sean.j.christopherson@intel.com> wrote: > > +notrace long __vdso_sgx_eenter(void *tcs, void *priv, > > + struct sgx_eenter_fault_info *fault_info) > > +{ > > + u32 trapnr, error_code; > > + long leaf; > > + u64 addr; > > + > > + /* > > + * %eax = EENTER > > + * %rbx = tcs > > + * %rcx = do_eresume > > + * %rdi = priv > > + * do_eenter: > > + * enclu > > + * jmp out > > + * > > + * do_eresume: > > + * enclu > > + * ud2 > > Is the only reason for do_eresume to be different from do_eenter so > that you can do the ud2?
No, it was a holdover from doing fixup via a magic prefix in user code. The fixup could only skip the ENCLU and so a second ENCLU was needed to differentiate between EENTER and ERESUME. The need for two ENCLUs got ingrained in my head. I can't think of anything that will break if we use a single ENCLU.
> > + * > > + * out: > > + * <return to C code> > > + * > > + * fault_fixup: > > + * <extable loads RDI, DSI and RDX with fault info> > > + * jmp out > > + */ > > This has the IMO excellent property that it's extremely awkward to use > it for a model where the enclave is reentrant. I think it's excellent > because reentrancy on the same enclave thread is just asking for > severe bugs. Of course, I fully expect the SDK to emulate reentrancy, > but then it's 100% their problem :) On the fiip side, it means that > you can't really recover from a reported fault, even if you want to, > because there's no way to ask for ERESUME. So maybe the API should > allow that after all.
Doh. The ability to do ERESUME is an explicit requirement from the SDK folks. More code that I pulled from my userspace implementation and didn't revisit.
> I think it might be polite to at least give some out regs, maybe RSI and RDI?
For the outbound path? I was thinking @priv would be used for passing data out as well as in.
| |