From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: linux-sgx@vger.kernel.org
Subject: [PATCH for_v24] x86/sgx: Mark all regular and TCS pages as reclaimable
Date: Wed, 30 Oct 2019 03:51:38 -0700 [thread overview]
Message-ID: <20191030105138.13509-1-sean.j.christopherson@intel.com> (raw)
Mark all EADDed pages as reclaimable, not just those that are measured.
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
arch/x86/kernel/cpu/sgx/ioctl.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c
index 5b82670bb79a..5b28a9c0cb68 100644
--- a/arch/x86/kernel/cpu/sgx/ioctl.c
+++ b/arch/x86/kernel/cpu/sgx/ioctl.c
@@ -427,12 +427,20 @@ static int sgx_encl_add_page(struct sgx_encl *encl,
if (addp->flags & SGX_PAGE_MEASURE) {
ret = __sgx_encl_extend(encl, epc_page);
- if (ret)
+
+ /*
+ * Destroy the enclave if EEXTEND fails, EADD can't be undone.
+ * Note, destroy() also frees the resources for the added page.
+ */
+ if (ret) {
sgx_encl_destroy(encl);
- else
- sgx_mark_page_reclaimable(encl_page->epc_page);
+ goto out_unlock;
+ }
}
+ sgx_mark_page_reclaimable(encl_page->epc_page);
+
+out_unlock:
mutex_unlock(&encl->lock);
up_read(¤t->mm->mmap_sem);
return ret;
--
2.22.0
next reply other threads:[~2019-10-30 10:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-30 10:51 Sean Christopherson [this message]
2019-10-31 21:29 ` [PATCH for_v24] x86/sgx: Mark all regular and TCS pages as reclaimable 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=20191030105138.13509-1-sean.j.christopherson@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).