@@ -248,6 +248,7 @@ static struct sgx_epc_page *sgx_encl_load_secs(struct sgx_encl *encl)
epc_page = sgx_encl_eldu(&encl->secs, NULL);
if (!IS_ERR(epc_page))
sgx_record_epc_page(epc_page,
+ SGX_EPC_OWNER_PAGE |
SGX_EPC_PAGE_UNRECLAIMABLE);
}
@@ -276,7 +277,7 @@ static struct sgx_encl_page *__sgx_encl_load_page(struct sgx_encl *encl,
return ERR_CAST(epc_page);
encl->secs_child_cnt++;
- sgx_record_epc_page(epc_page, SGX_EPC_PAGE_RECLAIMABLE);
+ sgx_record_epc_page(epc_page, SGX_EPC_OWNER_PAGE | SGX_EPC_PAGE_RECLAIMABLE);
return entry;
}
@@ -402,7 +403,7 @@ static vm_fault_t sgx_encl_eaug_page(struct vm_area_struct *vma,
encl_page->type = SGX_PAGE_TYPE_REG;
encl->secs_child_cnt++;
- sgx_record_epc_page(epc_page, SGX_EPC_PAGE_RECLAIMABLE);
+ sgx_record_epc_page(epc_page, SGX_EPC_OWNER_PAGE | SGX_EPC_PAGE_RECLAIMABLE);
phys_addr = sgx_get_epc_phys_addr(epc_page);
/*
@@ -1261,8 +1262,8 @@ struct sgx_epc_page *sgx_alloc_va_page(struct sgx_encl *encl, bool reclaim)
sgx_encl_free_epc_page(epc_page);
return ERR_PTR(-EFAULT);
}
- sgx_record_epc_page(epc_page,
- SGX_EPC_PAGE_UNRECLAIMABLE);
+ sgx_record_epc_page(epc_page, SGX_EPC_OWNER_ENCL |
+ SGX_EPC_PAGE_UNRECLAIMABLE);
return epc_page;
}
@@ -114,6 +114,7 @@ static int sgx_encl_create(struct sgx_encl *encl, struct sgx_secs *secs)
encl->attributes_mask = SGX_ATTR_UNPRIV_MASK;
sgx_record_epc_page(encl->secs.epc_page,
+ SGX_EPC_OWNER_PAGE |
SGX_EPC_PAGE_UNRECLAIMABLE);
/* Set only after completion, as encl->lock has not been taken. */
@@ -325,7 +326,7 @@ static int sgx_encl_add_page(struct sgx_encl *encl, unsigned long src,
goto err_out;
}
- sgx_record_epc_page(epc_page, SGX_EPC_PAGE_RECLAIMABLE);
+ sgx_record_epc_page(epc_page, SGX_EPC_OWNER_PAGE | SGX_EPC_PAGE_RECLAIMABLE);
mutex_unlock(&encl->lock);
mmap_read_unlock(current->mm);
return ret;
@@ -979,7 +980,8 @@ static long sgx_enclave_modify_types(struct sgx_encl *encl,
mutex_lock(&encl->lock);
- sgx_record_epc_page(entry->epc_page, SGX_EPC_PAGE_RECLAIMABLE);
+ sgx_record_epc_page(entry->epc_page,
+ SGX_EPC_OWNER_PAGE | SGX_EPC_PAGE_RECLAIMABLE);
}
/* Change EPC type */
@@ -64,6 +64,12 @@ enum sgx_epc_page_state {
#define SGX_EPC_PAGE_STATE_MASK GENMASK(2, 0)
+/* flag for pages owned by a sgx_encl_page */
+#define SGX_EPC_OWNER_PAGE BIT(3)
+
+/* flag for pages owned by a sgx_encl struct */
+#define SGX_EPC_OWNER_ENCL BIT(4)
+
struct sgx_epc_page {
unsigned int section;
u16 flags;