From patchwork Wed Apr 12 15:10:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 9677605 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 4793760383 for ; Wed, 12 Apr 2017 15:10:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A82428615 for ; Wed, 12 Apr 2017 15:10:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FA8F28645; Wed, 12 Apr 2017 15:10:30 +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 2ED8828616 for ; Wed, 12 Apr 2017 15:10:28 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B237520D7648C; Wed, 12 Apr 2017 08:10:27 -0700 (PDT) X-Original-To: intel-sgx-kernel-dev@lists.01.org Delivered-To: intel-sgx-kernel-dev@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 F11F821939234 for ; Wed, 12 Apr 2017 08:10:25 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Apr 2017 08:10:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,191,1488873600"; d="scan'208";a="76574255" Received: from sjchrist-ts.jf.intel.com ([10.54.74.20]) by orsmga004.jf.intel.com with ESMTP; 12 Apr 2017 08:10:24 -0700 From: Sean Christopherson To: intel-sgx-kernel-dev@lists.01.org Date: Wed, 12 Apr 2017 08:10:18 -0700 Message-Id: <1492009821-22428-2-git-send-email-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492009821-22428-1-git-send-email-sean.j.christopherson@intel.com> References: <1492009821-22428-1-git-send-email-sean.j.christopherson@intel.com> Subject: [intel-sgx-kernel-dev] [PATCH 1/4] intel_sgx: track SECS eviction using its epc_page X-BeenThere: intel-sgx-kernel-dev@lists.01.org X-Mailman-Version: 2.1.22 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/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(-) diff --git a/drivers/platform/x86/intel_sgx/sgx.h b/drivers/platform/x86/intel_sgx/sgx.h index 82355bb..0397141 100644 --- a/drivers/platform/x86/intel_sgx/sgx.h +++ b/drivers/platform/x86/intel_sgx/sgx.h @@ -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 { diff --git a/drivers/platform/x86/intel_sgx/sgx_page_cache.c b/drivers/platform/x86/intel_sgx/sgx_page_cache.c index 4ffde27..26b845b 100644 --- a/drivers/platform/x86/intel_sgx/sgx_page_cache.c +++ b/drivers/platform/x86/intel_sgx/sgx_page_cache.c @@ -381,10 +381,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); } diff --git a/drivers/platform/x86/intel_sgx/sgx_util.c b/drivers/platform/x86/intel_sgx/sgx_util.c index 25e949d..420f96f 100644 --- a/drivers/platform/x86/intel_sgx/sgx_util.c +++ b/drivers/platform/x86/intel_sgx/sgx_util.c @@ -292,7 +292,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); @@ -305,7 +305,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;