linux-sgx.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: linux-sgx@vger.kernel.org
Subject: Re: [PATCH 2/2] x86/sgx: Remove non-LC bit from sgx_einit()
Date: Tue, 3 Mar 2020 14:33:46 -0800	[thread overview]
Message-ID: <20200303223346.GD1439@linux.intel.com> (raw)
In-Reply-To: <20200303205359.108336-2-jarkko.sakkinen@linux.intel.com>

On Tue, Mar 03, 2020 at 10:53:59PM +0200, Jarkko Sakkinen wrote:
> Remove the non-LC flow. While doing this, start using __encls_ret_3()
> instead __einit() to reduce the insane amount of wrapping we have in
> this flow.

I strongly prefer keeping __einit(), I find it much more readable than
__encls_ret_3(EINIT, ...).  If you remove __einit() then I don't see the
justification for keeping all the other wrappers, and for me, removing
all of those would be a big step backwards.

> Cc: Sean Christopherson <sean.j.christopherson@intel.com>
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> ---
>  arch/x86/kernel/cpu/sgx/encls.h |  5 -----
>  arch/x86/kernel/cpu/sgx/ioctl.c | 12 +++++++-----
>  2 files changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/sgx/encls.h b/arch/x86/kernel/cpu/sgx/encls.h
> index b4c27d8bd2ac..fb201e384bc7 100644
> --- a/arch/x86/kernel/cpu/sgx/encls.h
> +++ b/arch/x86/kernel/cpu/sgx/encls.h
> @@ -186,11 +186,6 @@ static inline int __eadd(struct sgx_pageinfo *pginfo, void *addr)
>  	return __encls_2(EADD, pginfo, addr);
>  }
>  
> -static inline int __einit(void *sigstruct, void *token, void *secs)
> -{
> -	return __encls_ret_3(EINIT, sigstruct, secs, token);
> -}
> -
>  static inline int __eremove(void *addr)
>  {
>  	return __encls_ret_1(EREMOVE, addr);
> diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c
> index eaae533578b9..6e9e6a7380b1 100644
> --- a/arch/x86/kernel/cpu/sgx/ioctl.c
> +++ b/arch/x86/kernel/cpu/sgx/ioctl.c
> @@ -600,17 +600,19 @@ static int sgx_einit(struct sgx_sigstruct *sigstruct, void *token,
>  {
>  	int ret;
>  
> -	if (!boot_cpu_has(X86_FEATURE_SGX_LC))
> -		return __einit(sigstruct, token, sgx_epc_addr(secs));
> -
>  	preempt_disable();
> +
>  	sgx_update_lepubkeyhash_msrs(lepubkeyhash, false);
> -	ret = __einit(sigstruct, token, sgx_epc_addr(secs));
> +	ret = __encls_ret_3(EINIT, sigstruct, sgx_epc_addr(secs), token);
> +
>  	if (ret == SGX_INVALID_EINITTOKEN) {
>  		sgx_update_lepubkeyhash_msrs(lepubkeyhash, true);
> -		ret = __einit(sigstruct, token, sgx_epc_addr(secs));
> +		ret = __encls_ret_3(EINIT, sigstruct, sgx_epc_addr(secs),
> +				    token);
>  	}
> +
>  	preempt_enable();
> +
>  	return ret;
>  }
>  
> -- 
> 2.25.0
> 

  reply	other threads:[~2020-03-03 22:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-03 20:53 [PATCH 1/2] x86/sgx: cleanup: Remove unused struct Jarkko Sakkinen
2020-03-03 20:53 ` [PATCH 2/2] x86/sgx: Remove non-LC bit from sgx_einit() Jarkko Sakkinen
2020-03-03 22:33   ` Sean Christopherson [this message]
2020-03-03 23:12     ` Jarkko Sakkinen

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=20200303223346.GD1439@linux.intel.com \
    --to=sean.j.christopherson@intel.com \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=linux-sgx@vger.kernel.org \
    /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).