diff mbox series

[1/2] x86/sgx: Remove duplicate check for entry->epc_page in sgx_encl_load_page()

Message ID 20190821232902.29476-2-jarkko.sakkinen@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series v22 fixes | expand

Commit Message

Jarkko Sakkinen Aug. 21, 2019, 11:29 p.m. UTC
The existence of the page is checked first hand for legit race
conditions (either two or more concurrent threads running the #PF
handler or the reclaimer has taken over the page):

/* Page is already resident in the EPC. */
if (entry->epc_page) {
	if (entry->desc & SGX_ENCL_PAGE_RECLAIMED)
		return ERR_PTR(-EBUSY);

	return entry;
}

After that the existence is a checked as a condition for ELDU.

This commit removes the redundant check.

Cc: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
 arch/x86/kernel/cpu/sgx/encl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sean Christopherson Aug. 22, 2019, 12:33 a.m. UTC | #1
On Thu, Aug 22, 2019 at 02:29:01AM +0300, Jarkko Sakkinen wrote:
> The existence of the page is checked first hand for legit race
> conditions (either two or more concurrent threads running the #PF
> handler or the reclaimer has taken over the page):
> 
> /* Page is already resident in the EPC. */
> if (entry->epc_page) {
> 	if (entry->desc & SGX_ENCL_PAGE_RECLAIMED)
> 		return ERR_PTR(-EBUSY);
> 
> 	return entry;
> }
> 
> After that the existence is a checked as a condition for ELDU.
> 
> This commit removes the redundant check.
> 
> Cc: Sean Christopherson <sean.j.christopherson@intel.com>
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> ---

Ha, I remember seeing this a while back and completely forgot about it.

Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com>

>  arch/x86/kernel/cpu/sgx/encl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c
> index a20d498e9dcd..d6397f7ef3b8 100644
> --- a/arch/x86/kernel/cpu/sgx/encl.c
> +++ b/arch/x86/kernel/cpu/sgx/encl.c
> @@ -123,7 +123,7 @@ static struct sgx_encl_page *sgx_encl_load_page(struct sgx_encl *encl,
>  			return ERR_CAST(epc_page);
>  	}
>  
> -	epc_page = entry->epc_page ? entry->epc_page : sgx_encl_eldu(entry);
> +	epc_page = sgx_encl_eldu(entry);
>  	if (IS_ERR(epc_page))
>  		return ERR_CAST(epc_page);
>  
> -- 
> 2.20.1
>
Jarkko Sakkinen Aug. 22, 2019, 2:45 p.m. UTC | #2
On Wed, 2019-08-21 at 17:33 -0700, Sean Christopherson wrote:
> On Thu, Aug 22, 2019 at 02:29:01AM +0300, Jarkko Sakkinen wrote:
> > The existence of the page is checked first hand for legit race
> > conditions (either two or more concurrent threads running the #PF
> > handler or the reclaimer has taken over the page):
> > 
> > /* Page is already resident in the EPC. */
> > if (entry->epc_page) {
> > 	if (entry->desc & SGX_ENCL_PAGE_RECLAIMED)
> > 		return ERR_PTR(-EBUSY);
> > 
> > 	return entry;
> > }
> > 
> > After that the existence is a checked as a condition for ELDU.
> > 
> > This commit removes the redundant check.
> > 
> > Cc: Sean Christopherson <sean.j.christopherson@intel.com>
> > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > ---
> 
> Ha, I remember seeing this a while back and completely forgot about it.
> 
> Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com>

[I guess for this ack-by would be appropriate as they are not mainline
patches]

Thanks Sean. These kind of regression are almost unavoidable because of
heavy rebasing...

/Jarkko
diff mbox series

Patch

diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c
index a20d498e9dcd..d6397f7ef3b8 100644
--- a/arch/x86/kernel/cpu/sgx/encl.c
+++ b/arch/x86/kernel/cpu/sgx/encl.c
@@ -123,7 +123,7 @@  static struct sgx_encl_page *sgx_encl_load_page(struct sgx_encl *encl,
 			return ERR_CAST(epc_page);
 	}
 
-	epc_page = entry->epc_page ? entry->epc_page : sgx_encl_eldu(entry);
+	epc_page = sgx_encl_eldu(entry);
 	if (IS_ERR(epc_page))
 		return ERR_CAST(epc_page);