diff mbox

[intel-sgx-kernel-dev] intel_sgx: alloc EPC page for fault iff initial checks pass

Message ID 1490213438-30560-1-git-send-email-sean.j.christopherson@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sean Christopherson March 22, 2017, 8:10 p.m. UTC
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 drivers/platform/x86/intel_sgx_util.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Jarkko Sakkinen April 4, 2017, 6 p.m. UTC | #1
On Wed, Mar 22, 2017 at 01:10:38PM -0700, Sean Christopherson wrote:
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>

Thanks.

/Jarkko

> ---
>  drivers/platform/x86/intel_sgx_util.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel_sgx_util.c b/drivers/platform/x86/intel_sgx_util.c
> index 234a5fb..1cfd7d2 100644
> --- a/drivers/platform/x86/intel_sgx_util.c
> +++ b/drivers/platform/x86/intel_sgx_util.c
> @@ -313,13 +313,6 @@ static struct sgx_encl_page *sgx_do_fault(struct vm_area_struct *vma,
>  		goto out;
>  	}
>  
> -	epc_page = sgx_alloc_page(encl->tgid_ctx, SGX_ALLOC_ATOMIC);
> -	if (IS_ERR(epc_page)) {
> -		rc = PTR_ERR(epc_page);
> -		epc_page = NULL;
> -		goto out;
> -	}
> -
>  	if (encl->flags & SGX_ENCL_DEAD) {
>  		rc = -EFAULT;
>  		goto out;
> @@ -345,6 +338,13 @@ static struct sgx_encl_page *sgx_do_fault(struct vm_area_struct *vma,
>  		goto out;
>  	}
>  
> +	epc_page = sgx_alloc_page(encl->tgid_ctx, SGX_ALLOC_ATOMIC);
> +	if (IS_ERR(epc_page)) {
> +		rc = PTR_ERR(epc_page);
> +		epc_page = NULL;
> +		goto out;
> +	}
> +
>  	/* If SECS is evicted then reload it first */
>  	if (encl->flags & SGX_ENCL_SECS_EVICTED) {
>  		secs_epc_page = sgx_alloc_page(encl->tgid_ctx, SGX_ALLOC_ATOMIC);
> -- 
> 2.7.4
> 
> _______________________________________________
> intel-sgx-kernel-dev mailing list
> intel-sgx-kernel-dev@lists.01.org
> https://lists.01.org/mailman/listinfo/intel-sgx-kernel-dev
diff mbox

Patch

diff --git a/drivers/platform/x86/intel_sgx_util.c b/drivers/platform/x86/intel_sgx_util.c
index 234a5fb..1cfd7d2 100644
--- a/drivers/platform/x86/intel_sgx_util.c
+++ b/drivers/platform/x86/intel_sgx_util.c
@@ -313,13 +313,6 @@  static struct sgx_encl_page *sgx_do_fault(struct vm_area_struct *vma,
 		goto out;
 	}
 
-	epc_page = sgx_alloc_page(encl->tgid_ctx, SGX_ALLOC_ATOMIC);
-	if (IS_ERR(epc_page)) {
-		rc = PTR_ERR(epc_page);
-		epc_page = NULL;
-		goto out;
-	}
-
 	if (encl->flags & SGX_ENCL_DEAD) {
 		rc = -EFAULT;
 		goto out;
@@ -345,6 +338,13 @@  static struct sgx_encl_page *sgx_do_fault(struct vm_area_struct *vma,
 		goto out;
 	}
 
+	epc_page = sgx_alloc_page(encl->tgid_ctx, SGX_ALLOC_ATOMIC);
+	if (IS_ERR(epc_page)) {
+		rc = PTR_ERR(epc_page);
+		epc_page = NULL;
+		goto out;
+	}
+
 	/* If SECS is evicted then reload it first */
 	if (encl->flags & SGX_ENCL_SECS_EVICTED) {
 		secs_epc_page = sgx_alloc_page(encl->tgid_ctx, SGX_ALLOC_ATOMIC);