Re: [PATCH v39 21/24] x86/vdso: Implement a vDSO for Intel SGX enclave call

From: Sean Christopherson
Date: Tue Oct 06 2020 - 11:30:55 EST


On Tue, Oct 06, 2020 at 10:30:16AM +0200, Jethro Beekman wrote:
> On 2020-10-06 04:57, Sean Christopherson wrote:
> > On Sat, Oct 03, 2020 at 07:50:56AM +0300, Jarkko Sakkinen wrote:
> >> +struct sgx_enclave_run {
> >> + __u64 tcs;
> >> + __u64 user_handler;
> >> + __u64 user_data;
> >> + __u32 leaf;
> >
> > I am still very strongly opposed to omitting exit_reason. It is not at all
> > difficult to imagine scenarios where 'leaf' alone is insufficient for the
> > caller or its handler to deduce why the CPU exited the enclave. E.g. see
> > Jethro's request for intercepting interrupts.
>
> Not entirely sure what this has to do with my request, I just expect to see
> leaf=ERESUME in this case, I think? E.g. as you would see in EAX when calling
> ENCLU.

But how would you differentiate from the case that an exception occured in
the enclave? That will also transfer control with leaf=ERESUME. If there
was a prior exception and userspace didn't zero out the struct, there would
be "valid" data in the exception fields.

An exit_reason also would allow retrofitting the exception fields into a
union, i.e. the fields are valid if and only if exit_reason is exception.