x86/sgx: handle VA page allocation failure for EAUG on PF.
PATCH 1/1 x86/sgx: handle VA page allocation failure for EAUG on PF.
Return VM_FAULT_NOPAGE to allow the swapping thread to catch up.
--- arch/x86/kernel/cpu/sgx/encl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/sgx/encl.c +5 -2
@@ -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)) - goto err_out_epc; +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);
Signature · 1 line
2.25.1
Hi Haitao,
Quoted 36 lines
-----Original Message-----
From: Haitao Huang <[email protected]>
Sent: Friday, August 12, 2022 12:12 PM
To: [email protected]; [email protected]; Chatre, Reinette <[email protected]>; [email protected]; Dhanraj, Vijay <[email protected]>
Subject: [PATCH] x86/sgx: handle VA page allocation failure for EAUG on PF.Return
VM_FAULT_NOPAGEto allow the swapping thread to catch up.Signed-off-by Haitao Huang <[email protected]>--- arch/x86/kernel/cpu/sgx/encl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)arch/x86/kernel/cpu/sgx/encl.c +5
-2@@ -344,8 +344,11 @@ static vm_fault_t sgx_encl_eaug_page(structvm_area_struct *vma, } va_page =sgx_encl_grow (encl, false); -if (IS_ERR (va_page)) - goto err_out_epc; +if (IS_ERR (va_page)) { +if (PTR_ERR (va_page) == -EBUSY ) + vmret =VM_FAULT_NOPAGE ; + goto err_out_epc; + }if (va_page)
Quoted 3 lines
list_add(&va_page->list, &encl->va_pages);
--
2.25.1
After applying this patch, I don't see the allocation failure issue with augment_via_eaccept_long test case. Ran the test for about ~60 times and all the time it passes.
[email protected]
maintainerQuoted 37 lines · Vijay
Hi Haitao,
Quoted 35 lines
-----Original Message-----
From: Haitao Huang <[email protected]>
Sent: Friday, August 12, 2022 12:12 PM
To: [email protected]; [email protected]; Chatre, Reinette <[email protected]>; [email protected]; Dhanraj, Vijay <[email protected]>
Subject: [PATCH] x86/sgx: handle VA page allocation failure for EAUG on PF.Return
VM_FAULT_NOPAGEto allow the swapping thread to catch up.Signed-off-by Haitao Huang <[email protected]>arch/x86/kernel/cpu/sgx/encl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)arch/x86/kernel/cpu/sgx/encl.c +5
-2@@ -344,8 +344,11 @@ static vm_fault_t sgx_encl_eaug_page(structvm_area_struct *vma, } va_page =sgx_encl_grow (encl, false); -if (IS_ERR (va_page)) - goto err_out_epc; +if (IS_ERR (va_page)) { +if (PTR_ERR (va_page) == -EBUSY ) + vmret =VM_FAULT_NOPAGE ; + goto err_out_epc; + }
Quoted 7 lines
Quoted 4 lines
arch/x86/kernel/cpu/sgx/encl.c +0
-0if (va_page)
list_add(&va_page->list, &encl->va_pages);
--
2.25.1After applying this patch, I don't see the allocation failure issue with
augment_via_eaccept_longtest case. Ran the test for about ~60 times and all the time it passes.Tested-by Vijay Dhanraj <[email protected]>
Good to hear. Thank you.
BR, Jarkko
Jarkko Sakkinen
maintainerQuoted 30 lines · Haitao Huang
Return
VM_FAULT_NOPAGEto allow the swapping thread to catch up.Signed-off-by Haitao Huang <[email protected]>--- arch/x86/kernel/cpu/sgx/encl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)arch/x86/kernel/cpu/sgx/encl.c +5
-2@@ -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)) - goto err_out_epc; +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);Signature · 1 line
2.25.1
Indentation is probably not right, but the fix look legit.
You need to use real tab-characters to fix that. Run the patch with scripts/checkpatch.pl and it will report you these issues.
Vijay, can you check if this fixes the issue for you?
BR, Jarkko
PATCH 1/1 x86/sgx: handle VA page allocation failure for EAUG on PF.
Return VM_FAULT_NOPAGE to allow the swapping thread to catch up.
--- arch/x86/kernel/cpu/sgx/encl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/sgx/encl.c +4 -1
@@ -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);
Signature · 1 line
2.25.1
Quoted 29 lines · Haitao Huang
Return
VM_FAULT_NOPAGEto allow the swapping thread to catch up.Signed-off-by Haitao Huang <[email protected]>--- arch/x86/kernel/cpu/sgx/encl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)arch/x86/kernel/cpu/sgx/encl.c +4
-1@@ -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);Signature · 1 line
2.25.1
BR, Jarkko
Quoted 27 lines · Jarkko Sakkinen
Quoted 26 lines · Haitao Huang
Return
VM_FAULT_NOPAGEto allow the swapping thread to catch up.Signed-off-by Haitao Huang <[email protected]>--- arch/x86/kernel/cpu/sgx/encl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)arch/x86/kernel/cpu/sgx/encl.c +5
-2@@ -344,8 +344,11 @@ static vm_fault_t sgx_encl_eaug_page(structvm_area_struct *vma, } va_page =sgx_encl_grow (encl, false); -if (IS_ERR (va_page)) - goto err_out_epc; +if (IS_ERR (va_page)) { +if (PTR_ERR (va_page) == -EBUSY ) + vmret =VM_FAULT_NOPAGE ; + goto err_out_epc; + }
Quoted 7 lines
Quoted 5 lines
arch/x86/kernel/cpu/sgx/encl.c +0
-0if (va_page)
list_add(&va_page->list, &encl->va_pages);
--
2.25.1Indentation is probably not right, but the fix look legit.
Fixed in updated patch. Can I add your "Reviewed-by" tag? Thanks
Haitao