@@ -122,9 +122,8 @@ struct sgx_tgid_ctx {
enum sgx_encl_flags {
SGX_ENCL_INITIALIZED = BIT(0),
SGX_ENCL_DEBUG = BIT(1),
- SGX_ENCL_SECS_EVICTED = BIT(2),
- SGX_ENCL_SUSPEND = BIT(3),
- SGX_ENCL_DEAD = BIT(4),
+ SGX_ENCL_SUSPEND = BIT(2),
+ SGX_ENCL_DEAD = BIT(3),
};
struct sgx_encl {
@@ -369,10 +369,8 @@ static void sgx_write_pages(struct sgx_encl *encl, struct list_head *src)
encl->secs_child_cnt--;
}
- if (!encl->secs_child_cnt && (encl->flags & SGX_ENCL_INITIALIZED)) {
+ if (!encl->secs_child_cnt && (encl->flags & SGX_ENCL_INITIALIZED))
sgx_evict_page(&encl->secs_page, encl);
- encl->flags |= SGX_ENCL_SECS_EVICTED;
- }
mutex_unlock(&encl->lock);
}
@@ -304,7 +304,7 @@ static struct sgx_encl_page *sgx_do_fault(struct vm_area_struct *vma,
}
/* If SECS is evicted then reload it first */
- if (encl->flags & SGX_ENCL_SECS_EVICTED) {
+ if (!encl->secs_page.epc_page) {
secs_epc_page = sgx_alloc_page(SGX_ALLOC_ATOMIC);
if (IS_ERR(secs_epc_page)) {
rc = PTR_ERR(secs_epc_page);
@@ -317,7 +317,6 @@ static struct sgx_encl_page *sgx_do_fault(struct vm_area_struct *vma,
goto out;
encl->secs_page.epc_page = secs_epc_page;
- encl->flags &= ~SGX_ENCL_SECS_EVICTED;
/* Do not free */
secs_epc_page = NULL;
Track whether or not the SECS is resident in the EPC based on its epc_page pointer and remove the flag SGX_ENCL_SECS_EVICTED. Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> --- drivers/platform/x86/intel_sgx/sgx.h | 5 ++--- drivers/platform/x86/intel_sgx/sgx_page_cache.c | 4 +--- drivers/platform/x86/intel_sgx/sgx_util.c | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-)