diff mbox series

[v2,3/6] x86/sgx: Handle VA page allocation failure for EAUG on PF.

Message ID 20220831173829.126661-4-jarkko@kernel.org (mailing list archive)
State New, archived
Headers show
Series x86/sgx: A collection of tests and fixes | expand

Commit Message

Jarkko Sakkinen Aug. 31, 2022, 5:38 p.m. UTC
From: Haitao Huang <haitao.huang@linux.intel.com>

VM_FAULT_NOPAGE is expected behaviour for -EBUSY failure path, when
augmenting a page, as this means that the reclaimer thread has been
triggered, and the intention is just to round-trip in ring-3, and
retry with a new page fault.

Fixes: 5a90d2c3f5ef ("x86/sgx: Support adding of pages to an initialized enclave")
Signed-off-by: Haitao Huang <haitao.huang@linux.intel.com>
Tested-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
---
v3:
* Added Reinette's ack.

v2:
* Removed reviewed-by, no other changes.
---
 arch/x86/kernel/cpu/sgx/encl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Reinette Chatre Aug. 31, 2022, 6:08 p.m. UTC | #1
Hi Jarkko,

On 8/31/2022 10:38 AM, Jarkko Sakkinen wrote:
> From: Haitao Huang <haitao.huang@linux.intel.com>
> 
> VM_FAULT_NOPAGE is expected behaviour for -EBUSY failure path, when
> augmenting a page, as this means that the reclaimer thread has been
> triggered, and the intention is just to round-trip in ring-3, and
> retry with a new page fault.
> 
> Fixes: 5a90d2c3f5ef ("x86/sgx: Support adding of pages to an initialized enclave")
> Signed-off-by: Haitao Huang <haitao.huang@linux.intel.com>
> Tested-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
> ---
> v3:
> * Added Reinette's ack.

The ack came with a caveat related to a white space issue that
you did not fix in this version.

Reinette
Jarkko Sakkinen Aug. 31, 2022, 6:21 p.m. UTC | #2
On Wed, Aug 31, 2022 at 11:08:33AM -0700, Reinette Chatre wrote:
> Hi Jarkko,
> 
> On 8/31/2022 10:38 AM, Jarkko Sakkinen wrote:
> > From: Haitao Huang <haitao.huang@linux.intel.com>
> > 
> > VM_FAULT_NOPAGE is expected behaviour for -EBUSY failure path, when
> > augmenting a page, as this means that the reclaimer thread has been
> > triggered, and the intention is just to round-trip in ring-3, and
> > retry with a new page fault.
> > 
> > Fixes: 5a90d2c3f5ef ("x86/sgx: Support adding of pages to an initialized enclave")
> > Signed-off-by: Haitao Huang <haitao.huang@linux.intel.com>
> > Tested-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
> > Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
> > Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
> > ---
> > v3:
> > * Added Reinette's ack.
> 
> The ack came with a caveat related to a white space issue that
> you did not fix in this version.

Reinette, I'm sorry but I might possibly have some sort of blind
spot here.

I looked at the diff and I could not see any issues, and did not
run into issues with checkpath.

Can you point out what exactly is the whitespace issue?

BR, Jarkko
Reinette Chatre Aug. 31, 2022, 6:33 p.m. UTC | #3
Hi Jarkko,

On 8/31/2022 11:21 AM, Jarkko Sakkinen wrote:
> 
> Can you point out what exactly is the whitespace issue?

There is an extra space after the "=" in:
       vmret =  VM_FAULT_NOPAGE;

Reinette
Jarkko Sakkinen Aug. 31, 2022, 6:46 p.m. UTC | #4
On Wed, Aug 31, 2022 at 11:33:26AM -0700, Reinette Chatre wrote:
> Hi Jarkko,
> 
> On 8/31/2022 11:21 AM, Jarkko Sakkinen wrote:
> > 
> > Can you point out what exactly is the whitespace issue?
> 
> There is an extra space after the "=" in:
>        vmret =  VM_FAULT_NOPAGE;

Duh, I did look at it about million times but honestly
did not see it before you pointed it out.

BR, Jarkko
diff mbox series

Patch

diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c
index f40d64206ded..c0fd98a1c658 100644
--- a/arch/x86/kernel/cpu/sgx/encl.c
+++ b/arch/x86/kernel/cpu/sgx/encl.c
@@ -347,8 +347,11 @@  static vm_fault_t sgx_encl_eaug_page(struct vm_area_struct *vma,
 	}
 
 	va_page = sgx_encl_grow(encl, false);
-	if (IS_ERR(va_page))
+	if (IS_ERR(va_page)) {
+		if (PTR_ERR(va_page) == -EBUSY)
+			vmret =  VM_FAULT_NOPAGE;
 		goto err_out_epc;
+	}
 
 	if (va_page)
 		list_add(&va_page->list, &encl->va_pages);