linux-sgx.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jethro Beekman <jethro@fortanix.com>
To: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
	Nathaniel McCallum <npmccallum@redhat.com>,
	Cedric Xing <cedric.xing@intel.com>,
	Andy Lutomirski <luto@amacapital.net>,
	linux-sgx@vger.kernel.org
Subject: Re: [RFC PATCH 2/4] x86/vdso: x86/sgx: Rework __vdso_sgx_enter_enclave() API
Date: Tue, 25 Aug 2020 09:41:19 +0200	[thread overview]
Message-ID: <46b2765c-1598-91ea-af4e-8c772aab0da0@fortanix.com> (raw)
In-Reply-To: <20200825073848.GA2847@sjchrist-ice>

[-- Attachment #1: Type: text/plain, Size: 3511 bytes --]

On 2020-08-25 09:38, Sean Christopherson wrote:
> On Tue, Aug 25, 2020 at 09:36:15AM +0200, Jethro Beekman wrote:
>> On 2020-08-25 01:54, Sean Christopherson wrote:
>>> On Mon, Aug 24, 2020 at 03:36:11PM +0200, Jethro Beekman wrote:
>>>> On 2020-08-18 06:24, Sean Christopherson wrote:
>>>>>  /**
>>>>>   * __vdso_sgx_enter_enclave() - Enter an SGX enclave
>>>>> @@ -119,16 +153,14 @@ typedef int (*sgx_enclave_exit_handler_t)(long rdi, long rsi, long rdx,
>>>>>   * @leaf:	ENCLU leaf, must be EENTER or ERESUME
>>>>>   * @r8:		Pass-through value for R8
>>>>>   * @r9:		Pass-through value for R9
>>>>> - * @tcs:	TCS, must be non-NULL
>>>>> - * @e:		Optional struct sgx_enclave_exception instance
>>>>> - * @handler:	Optional enclave exit handler
>>>>> + * @r:		struct sgx_enclave_run, must be non-NULL
>>>>>   *
>>>>>   * NOTE: __vdso_sgx_enter_enclave() does not ensure full compliance with the
>>>>> - * x86-64 ABI, e.g. doesn't explicitly clear EFLAGS.DF after EEXIT.  Except for
>>>>> - * non-volatile general purpose registers, preserving/setting state in
>>>>> - * accordance with the x86-64 ABI is the responsibility of the enclave and its
>>>>> - * runtime, i.e. __vdso_sgx_enter_enclave() cannot be called from C code
>>>>> - * without careful consideration by both the enclave and its runtime.
>>>>> + * x86-64 ABI, e.g. doesn't handle XSAVE state.  Except for non-volatile
>>>>> + * general purpose registers, EFLAGS.DF, and RSP alignment, preserving/setting
>>>>> + * state in accordance with the x86-64 ABI is the responsibility of the enclave
>>>>> + * and its runtime, i.e. __vdso_sgx_enter_enclave() cannot be called from C
>>>>> + * code without careful consideration by both the enclave and its runtime.
>>>>>   *
>>>>>   * All general purpose registers except RAX, RBX and RCX are passed as-is to
>>>>>   * the enclave.  RAX, RBX and RCX are consumed by EENTER and ERESUME and are
>>>>> @@ -160,16 +192,12 @@ typedef int (*sgx_enclave_exit_handler_t)(long rdi, long rsi, long rdx,
>>>>>   * without returning to __vdso_sgx_enter_enclave().
>>>>>   *
>>>>>   * Return:
>>>>> - *  0 on success,
>>>>> + *  0 on success (ENCLU reached),
>>>>>   *  -EINVAL if ENCLU leaf is not allowed,
>>>>> - *  -EFAULT if an exception occurs on ENCLU or within the enclave
>>>>> - *  -errno for all other negative values returned by the userspace exit handler
>>>>>   */
>>>>>  typedef int (*vdso_sgx_enter_enclave_t)(unsigned long rdi, unsigned long rsi,
>>>>>  					unsigned long rdx, unsigned int leaf,
>>>>>  					unsigned long r8,  unsigned long r9,
>>>>> -					void *tcs,
>>>>> -					struct sgx_enclave_exception *e,
>>>>> -					sgx_enclave_exit_handler_t handler);
>>>>> +					struct sgx_enclave_run *r);
>>>>>  
>>>>>  #endif /* _UAPI_ASM_X86_SGX_H */
>>>>>
>>>>
>>>> I think this should return void now, not int? Then, the “return” section of
>>>> the documentation is also no longer correct.
>>>
>>> No, it returns -EINVAL if the leaf is bogus (and if unsupported flags are
>>> specified, if a @flags param is ever added).
>>>
>>
>> Ok, but if I read the code correctly, contrary to the docs, -EFAULT is not
>> returned but passed in struct sgx_enclave_run:
> 
> The -EFAULT and -errno lines are removed from the "Return:" section of the
> above documentation.  Did I miss one?
> 

No, I'm just bad at reading patches without syntax highlighting. This is fine as is. Sorry for the confusion.

--
Jethro Beekman | Fortanix



[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4054 bytes --]

  reply	other threads:[~2020-08-25  7:41 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-18  4:24 [RFC PATCH 0/4] x86/vdso: x86/sgx: Rework SGX vDSO API Sean Christopherson
2020-08-18  4:24 ` [RFC PATCH 1/4] x86/vdso: x86/sgx: Explicitly force 8-byte CMP for detecting user handler Sean Christopherson
2020-08-18 16:46   ` Jarkko Sakkinen
2020-08-20 11:13   ` Jethro Beekman
2020-08-18  4:24 ` [RFC PATCH 2/4] x86/vdso: x86/sgx: Rework __vdso_sgx_enter_enclave() API Sean Christopherson
2020-08-18 16:57   ` Jarkko Sakkinen
2020-08-20 11:23   ` Jethro Beekman
2020-08-24 13:36   ` Jethro Beekman
2020-08-24 19:49     ` Jarkko Sakkinen
2020-09-04 10:25       ` Sean Christopherson
2020-09-04 13:36         ` Jarkko Sakkinen
2020-09-04 16:01           ` Sean Christopherson
2020-08-24 23:54     ` Sean Christopherson
2020-08-25  7:36       ` Jethro Beekman
2020-08-25  7:38         ` Sean Christopherson
2020-08-25  7:41           ` Jethro Beekman [this message]
2020-08-26 20:16             ` Sean Christopherson
2020-08-26 19:27   ` Xing, Cedric
2020-08-26 20:15     ` Sean Christopherson
2020-08-26 23:26       ` Xing, Cedric
2020-09-04  9:52         ` Sean Christopherson
2020-08-27  8:58       ` Jethro Beekman
2020-08-26 20:20   ` Sean Christopherson
2020-08-26 20:55     ` Andy Lutomirski
2020-08-27 13:35     ` Jarkko Sakkinen
2020-08-18  4:24 ` [RFC PATCH 3/4] x86/vdso: x86/sgx: Introduce dedicated SGX exit reasons for vDSO Sean Christopherson
2020-08-18 16:58   ` Jarkko Sakkinen
2020-08-20 11:13   ` Jethro Beekman
2020-08-18  4:24 ` [RFC PATCH 4/4] x86/vdso: x86/sgx: Allow the user to exit the vDSO loop on interrupts Sean Christopherson
2020-08-18 17:00   ` Jarkko Sakkinen
2020-08-18 17:15   ` Andy Lutomirski
2020-08-18 17:31     ` Sean Christopherson
2020-08-18 19:05       ` Andy Lutomirski
2020-08-19 14:21     ` Jethro Beekman
2020-08-19 15:02       ` Andy Lutomirski
2020-08-20 11:20         ` Jethro Beekman
2020-08-20 17:44           ` Andy Lutomirski
2020-08-20 17:53             ` Jethro Beekman
2020-08-22 21:55               ` Andy Lutomirski
2020-08-24 13:36                 ` Jethro Beekman
2020-08-26 18:32                   ` Sean Christopherson
2020-08-26 19:09                     ` Xing, Cedric
2020-08-27  8:57                     ` Jethro Beekman
2020-08-20 11:13   ` Jethro Beekman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46b2765c-1598-91ea-af4e-8c772aab0da0@fortanix.com \
    --to=jethro@fortanix.com \
    --cc=cedric.xing@intel.com \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=linux-sgx@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=npmccallum@redhat.com \
    --cc=sean.j.christopherson@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).