2022-09-06 00:32:19

by Jarkko Sakkinen

[permalink] [raw]
Subject: [PATCH v3 2/2] x86/sgx: Handle VA page allocation failure for EAUG on PF.

From: Haitao Huang <[email protected]>

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 <[email protected]>
Tested-by: Vijay Dhanraj <[email protected]>
Reviewed-by: Reinette Chatre <[email protected]>
Signed-off-by: Jarkko Sakkinen <[email protected]>
---
v4:
* Remove extra white space.

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(-)

diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c
index f40d64206ded..9f13d724172e 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);
--
2.37.2


2022-09-09 16:23:15

by tip-bot2 for Haifeng Xu

[permalink] [raw]
Subject: [tip: x86/urgent] x86/sgx: Handle VA page allocation failure for EAUG on PF.

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID: 81fa6fd13b5c43601fba8486f2385dbd7c1935e2
Gitweb: https://git.kernel.org/tip/81fa6fd13b5c43601fba8486f2385dbd7c1935e2
Author: Haitao Huang <[email protected]>
AuthorDate: Tue, 06 Sep 2022 03:02:21 +03:00
Committer: Dave Hansen <[email protected]>
CommitterDate: Thu, 08 Sep 2022 13:28:31 -07:00

x86/sgx: Handle VA page allocation failure for EAUG on PF.

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 <[email protected]>
Signed-off-by: Jarkko Sakkinen <[email protected]>
Signed-off-by: Dave Hansen <[email protected]>
Reviewed-by: Reinette Chatre <[email protected]>
Tested-by: Vijay Dhanraj <[email protected]>
Cc: [email protected]
Link: https://lkml.kernel.org/r/[email protected]
---
arch/x86/kernel/cpu/sgx/encl.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c
index 24c1bb8..8bdeae2 100644
--- a/arch/x86/kernel/cpu/sgx/encl.c
+++ b/arch/x86/kernel/cpu/sgx/encl.c
@@ -344,8 +344,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);