* [PATCH for_v24] x86/sgx: Mark all regular and TCS pages as reclaimable
@ 2019-10-30 10:51 Sean Christopherson
2019-10-31 21:29 ` Jarkko Sakkinen
0 siblings, 1 reply; 2+ messages in thread
From: Sean Christopherson @ 2019-10-30 10:51 UTC (permalink / raw)
To: Jarkko Sakkinen; +Cc: linux-sgx
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH for_v24] x86/sgx: Mark all regular and TCS pages as reclaimable
2019-10-30 10:51 [PATCH for_v24] x86/sgx: Mark all regular and TCS pages as reclaimable Sean Christopherson
@ 2019-10-31 21:29 ` Jarkko Sakkinen
0 siblings, 0 replies; 2+ messages in thread
From: Jarkko Sakkinen @ 2019-10-31 21:29 UTC (permalink / raw)
To: Sean Christopherson; +Cc: linux-sgx
On Wed, Oct 30, 2019 at 03:51:38AM -0700, Sean Christopherson wrote:
> Mark all EADDed pages as reclaimable, not just those that are measured.
>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Thanks, I merged this.
Resulted also cleaner diff between the driver and reclaimer patch:
/*
* Insert prior to EADD in case of OOM. EADD modifies MRENCLAVE, i.e.
* can't be gracefully unwound, while failure on EADD/EXTEND is limited
@@ -374,6 +438,8 @@ static int sgx_encl_add_page(struct sgx_encl *encl,
}
}
+ sgx_mark_page_reclaimable(encl_page->epc_page);
+
out_unlock:
mutex_unlock(&encl->lock);
up_read(¤t->mm->mmap_sem);
/Jarkko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-10-31 21:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-30 10:51 [PATCH for_v24] x86/sgx: Mark all regular and TCS pages as reclaimable Sean Christopherson
2019-10-31 21:29 ` Jarkko Sakkinen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.