Re: [PATCH 2/2] x86/sgx: Remove non-LC bit from sgx_einit()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx>
> ---
>  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
> 



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux