@@ -818,6 +818,8 @@ static long sgx_enclave_restrict_perm(struct sgx_encl *encl,
for (c = 0 ; c < modp->length; c += PAGE_SIZE) {
addr = encl->base + modp->offset + c;
+ sgx_direct_reclaim();
+
mutex_lock(&encl->lock);
entry = sgx_encl_load_page(encl, addr);
@@ -1002,6 +1004,8 @@ static long sgx_enclave_modt(struct sgx_encl *encl,
for (c = 0 ; c < modt->length; c += PAGE_SIZE) {
addr = encl->base + modt->offset + c;
+ sgx_direct_reclaim();
+
mutex_lock(&encl->lock);
entry = sgx_encl_load_page(encl, addr);
@@ -1200,6 +1204,8 @@ static long sgx_encl_remove_pages(struct sgx_encl *encl,
for (c = 0 ; c < params->length; c += PAGE_SIZE) {
addr = encl->base + params->offset + c;
+ sgx_direct_reclaim();
+
mutex_lock(&encl->lock);
entry = sgx_encl_load_page(encl, addr);
@@ -378,6 +378,12 @@ static bool sgx_should_reclaim(unsigned long watermark)
!list_empty(&sgx_active_page_list);
}
+void sgx_direct_reclaim(void)
+{
+ if (sgx_should_reclaim(SGX_NR_LOW_PAGES))
+ sgx_reclaim_pages();
+}
+
static int ksgxd(void *p)
{
set_freezable();
@@ -86,6 +86,7 @@ static inline void *sgx_get_epc_virt_addr(struct sgx_epc_page *page)
struct sgx_epc_page *__sgx_alloc_epc_page(void);
void sgx_free_epc_page(struct sgx_epc_page *page);
+void sgx_direct_reclaim(void);
void sgx_mark_page_reclaimable(struct sgx_epc_page *page);
int sgx_unmark_page_reclaimable(struct sgx_epc_page *page);
struct sgx_epc_page *sgx_alloc_epc_page(void *owner, bool reclaim);