From patchwork Thu Dec 22 20:15:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 9485563 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0642D601E4 for ; Thu, 22 Dec 2016 20:16:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 098D828459 for ; Thu, 22 Dec 2016 20:16:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA9C328470; Thu, 22 Dec 2016 20:16:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 80A5B2845A for ; Thu, 22 Dec 2016 20:16:04 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 687EE823B8 for ; Thu, 22 Dec 2016 12:16:04 -0800 (PST) X-Original-To: intel-sgx-kernel-dev@lists.01.org Delivered-To: intel-sgx-kernel-dev@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 35F1D823BA for ; Thu, 22 Dec 2016 12:16:03 -0800 (PST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP; 22 Dec 2016 12:16:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,390,1477983600"; d="scan'208";a="45576593" Received: from sjchrist-ts.jf.intel.com ([10.54.74.20]) by orsmga005.jf.intel.com with ESMTP; 22 Dec 2016 12:16:02 -0800 From: Sean Christopherson To: intel-sgx-kernel-dev@lists.01.org Date: Thu, 22 Dec 2016 12:15:32 -0800 Message-Id: <1482437735-4722-4-git-send-email-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482437735-4722-1-git-send-email-sean.j.christopherson@intel.com> References: <1482437735-4722-1-git-send-email-sean.j.christopherson@intel.com> Subject: [intel-sgx-kernel-dev] [PATCH 3/6] intel_sgx: Track SECS eviction using its epc_page X-BeenThere: intel-sgx-kernel-dev@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Project: Intel® Software Guard Extensions for Linux*: https://01.org/intel-software-guard-extensions" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-sgx-kernel-dev-bounces@lists.01.org Sender: "intel-sgx-kernel-dev" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Jarkko Sakkinen --- drivers/platform/x86/intel_sgx.h | 5 ++--- drivers/platform/x86/intel_sgx_page_cache.c | 1 - drivers/platform/x86/intel_sgx_vma.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/intel_sgx.h b/drivers/platform/x86/intel_sgx.h index ed9e8e6..fb5a75a 100644 --- a/drivers/platform/x86/intel_sgx.h +++ b/drivers/platform/x86/intel_sgx.h @@ -129,9 +129,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 { diff --git a/drivers/platform/x86/intel_sgx_page_cache.c b/drivers/platform/x86/intel_sgx_page_cache.c index d073057..f4833a0 100644 --- a/drivers/platform/x86/intel_sgx_page_cache.c +++ b/drivers/platform/x86/intel_sgx_page_cache.c @@ -352,7 +352,6 @@ static void sgx_write_pages(struct sgx_encl *encl, struct list_head *src) if (sgx_ewb(encl, &encl->secs_page)) free_flags = SGX_FREE_SKIP_EREMOVE; - encl->flags |= SGX_ENCL_SECS_EVICTED; sgx_free_encl_page(&encl->secs_page, encl, free_flags); } diff --git a/drivers/platform/x86/intel_sgx_vma.c b/drivers/platform/x86/intel_sgx_vma.c index bb4d5d0..db4cdcb 100644 --- a/drivers/platform/x86/intel_sgx_vma.c +++ b/drivers/platform/x86/intel_sgx_vma.c @@ -209,7 +209,7 @@ static struct sgx_encl_page *sgx_vma_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(encl->tgid_ctx, SGX_ALLOC_ATOMIC); if (IS_ERR(secs_epc_page)) { entry = (void *)secs_epc_page; @@ -230,7 +230,6 @@ static struct sgx_encl_page *sgx_vma_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;