linux-sgx.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: linux-sgx@vger.kernel.org
Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
	Sean Christopherson <sean.j.christopherson@intel.com>
Subject: [PATCH 1/2] x86/sgx: Remove duplicate check for entry->epc_page in sgx_encl_load_page()
Date: Thu, 22 Aug 2019 02:29:01 +0300	[thread overview]
Message-ID: <20190821232902.29476-2-jarkko.sakkinen@linux.intel.com> (raw)
In-Reply-To: <20190821232902.29476-1-jarkko.sakkinen@linux.intel.com>

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(-)

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


  reply	other threads:[~2019-08-21 23:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-21 23:29 [PATCH 0/2] v22 fixes Jarkko Sakkinen
2019-08-21 23:29 ` Jarkko Sakkinen [this message]
2019-08-22  0:33   ` [PATCH 1/2] x86/sgx: Remove duplicate check for entry->epc_page in sgx_encl_load_page() Sean Christopherson
2019-08-22 14:45     ` Jarkko Sakkinen
2019-08-21 23:29 ` [PATCH 2/2] x86/sgx: Determine SECS at compile time in sgx_encl_eldu() Jarkko Sakkinen
2019-08-22  0:55   ` Sean Christopherson
2019-08-22 14:55     ` 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=20190821232902.29476-2-jarkko.sakkinen@linux.intel.com \
    --to=jarkko.sakkinen@linux.intel.com \
    --cc=linux-sgx@vger.kernel.org \
    --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).