* [PATCH] x86/sgx: handle VA page allocation failure for EAUG on PF.
@ 2022-08-12 19:12 Haitao Huang
2022-08-12 22:41 ` Dhanraj, Vijay
2022-08-14 19:36 ` Jarkko Sakkinen
0 siblings, 2 replies; 7+ messages in thread
From: Haitao Huang @ 2022-08-12 19:12 UTC (permalink / raw)
To: linux-sgx, jarkko, reinette.chatre, dave.hansen, vijay.dhanraj
Return VM_FAULT_NOPAGE to allow the swapping thread to catch up.
link: https://lore.kernel.org/all/20220804201456.33418-1-vijay.dhanraj@intel.com/
Signed-off-by: Haitao Huang <haitao.huang@linux.intel.com>
---
arch/x86/kernel/cpu/sgx/encl.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c
index 24c1bb8eb196..1f88f80c4477 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))
- 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);
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* RE: [PATCH] x86/sgx: handle VA page allocation failure for EAUG on PF.
2022-08-12 19:12 [PATCH] x86/sgx: handle VA page allocation failure for EAUG on PF Haitao Huang
@ 2022-08-12 22:41 ` Dhanraj, Vijay
2022-08-14 19:41 ` jarkko
2022-08-14 19:36 ` Jarkko Sakkinen
1 sibling, 1 reply; 7+ messages in thread
From: Dhanraj, Vijay @ 2022-08-12 22:41 UTC (permalink / raw)
To: Haitao Huang, linux-sgx@vger.kernel.org, jarkko@kernel.org,
Chatre, Reinette, dave.hansen@linux.intel.com
Hi Haitao,
> -----Original Message-----
> From: Haitao Huang <haitao.huang@linux.intel.com>
> Sent: Friday, August 12, 2022 12:12 PM
> To: linux-sgx@vger.kernel.org; jarkko@kernel.org; Chatre, Reinette
> <reinette.chatre@intel.com>; dave.hansen@linux.intel.com; Dhanraj, Vijay
> <vijay.dhanraj@intel.com>
> Subject: [PATCH] x86/sgx: handle VA page allocation failure for EAUG on PF.
>
> Return VM_FAULT_NOPAGE to allow the swapping thread to catch up.
>
> link: https://lore.kernel.org/all/20220804201456.33418-1-
> vijay.dhanraj@intel.com/
>
> Signed-off-by: Haitao Huang <haitao.huang@linux.intel.com>
> ---
> arch/x86/kernel/cpu/sgx/encl.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c
> index 24c1bb8eb196..1f88f80c4477 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))
> - 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);
> --
> 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.
Tested-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86/sgx: handle VA page allocation failure for EAUG on PF.
2022-08-12 19:12 [PATCH] x86/sgx: handle VA page allocation failure for EAUG on PF Haitao Huang
2022-08-12 22:41 ` Dhanraj, Vijay
@ 2022-08-14 19:36 ` Jarkko Sakkinen
2022-08-15 4:53 ` Haitao Huang
2022-08-15 15:01 ` Haitao Huang
1 sibling, 2 replies; 7+ messages in thread
From: Jarkko Sakkinen @ 2022-08-14 19:36 UTC (permalink / raw)
To: Haitao Huang; +Cc: linux-sgx, reinette.chatre, dave.hansen, vijay.dhanraj
On Fri, Aug 12, 2022 at 12:12:24PM -0700, Haitao Huang wrote:
> Return VM_FAULT_NOPAGE to allow the swapping thread to catch up.
>
> link: https://lore.kernel.org/all/20220804201456.33418-1-vijay.dhanraj@intel.com/
>
> Signed-off-by: Haitao Huang <haitao.huang@linux.intel.com>
> ---
> arch/x86/kernel/cpu/sgx/encl.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c
> index 24c1bb8eb196..1f88f80c4477 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))
> - 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);
> --
> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86/sgx: handle VA page allocation failure for EAUG on PF.
2022-08-12 22:41 ` Dhanraj, Vijay
@ 2022-08-14 19:41 ` jarkko
0 siblings, 0 replies; 7+ messages in thread
From: jarkko @ 2022-08-14 19:41 UTC (permalink / raw)
To: Dhanraj, Vijay
Cc: Haitao Huang, linux-sgx@vger.kernel.org, Chatre, Reinette,
dave.hansen@linux.intel.com
On Fri, Aug 12, 2022 at 10:41:30PM +0000, Dhanraj, Vijay wrote:
> Hi Haitao,
>
> > -----Original Message-----
> > From: Haitao Huang <haitao.huang@linux.intel.com>
> > Sent: Friday, August 12, 2022 12:12 PM
> > To: linux-sgx@vger.kernel.org; jarkko@kernel.org; Chatre, Reinette
> > <reinette.chatre@intel.com>; dave.hansen@linux.intel.com; Dhanraj, Vijay
> > <vijay.dhanraj@intel.com>
> > Subject: [PATCH] x86/sgx: handle VA page allocation failure for EAUG on PF.
> >
> > Return VM_FAULT_NOPAGE to allow the swapping thread to catch up.
> >
> > link: https://lore.kernel.org/all/20220804201456.33418-1-
> > vijay.dhanraj@intel.com/
> >
> > Signed-off-by: Haitao Huang <haitao.huang@linux.intel.com>
> >
> > arch/x86/kernel/cpu/sgx/encl.c | 7 +++++--
> > 1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c
> > index 24c1bb8eb196..1f88f80c4477 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))
> > - 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);
> > --
> > 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.
> Tested-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
Good to hear. Thank you.
BR, Jarkko
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] x86/sgx: handle VA page allocation failure for EAUG on PF.
2022-08-14 19:36 ` Jarkko Sakkinen
@ 2022-08-15 4:53 ` Haitao Huang
2022-08-15 23:21 ` Jarkko Sakkinen
2022-08-15 15:01 ` Haitao Huang
1 sibling, 1 reply; 7+ messages in thread
From: Haitao Huang @ 2022-08-15 4:53 UTC (permalink / raw)
To: jarkko; +Cc: dave.hansen, haitao.huang, linux-sgx, reinette.chatre,
vijay.dhanraj
Return VM_FAULT_NOPAGE to allow the swapping thread to catch up.
link: https://lore.kernel.org/all/20220804201456.33418-1-vijay.dhanraj@intel.com/
Signed-off-by: Haitao Huang <haitao.huang@linux.intel.com>
---
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 24c1bb8eb196..de92c1c8b79d 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);
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] x86/sgx: handle VA page allocation failure for EAUG on PF.
2022-08-14 19:36 ` Jarkko Sakkinen
2022-08-15 4:53 ` Haitao Huang
@ 2022-08-15 15:01 ` Haitao Huang
1 sibling, 0 replies; 7+ messages in thread
From: Haitao Huang @ 2022-08-15 15:01 UTC (permalink / raw)
To: Jarkko Sakkinen; +Cc: linux-sgx, reinette.chatre, dave.hansen, vijay.dhanraj
On Sun, 14 Aug 2022 14:36:29 -0500, Jarkko Sakkinen <jarkko@kernel.org>
wrote:
> On Fri, Aug 12, 2022 at 12:12:24PM -0700, Haitao Huang wrote:
>> Return VM_FAULT_NOPAGE to allow the swapping thread to catch up.
>>
>> link:
>> https://lore.kernel.org/all/20220804201456.33418-1-vijay.dhanraj@intel.com/
>>
>> Signed-off-by: Haitao Huang <haitao.huang@linux.intel.com>
>> ---
>> arch/x86/kernel/cpu/sgx/encl.c | 7 +++++--
>> 1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/kernel/cpu/sgx/encl.c
>> b/arch/x86/kernel/cpu/sgx/encl.c
>> index 24c1bb8eb196..1f88f80c4477 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))
>> - 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);
>> --
>> 2.25.1
>>
>
> Indentation is probably not right, but the fix look legit.
Fixed in updated patch. Can I add your "Reviewed-by" tag?
Thanks
Haitao
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86/sgx: handle VA page allocation failure for EAUG on PF.
2022-08-15 4:53 ` Haitao Huang
@ 2022-08-15 23:21 ` Jarkko Sakkinen
0 siblings, 0 replies; 7+ messages in thread
From: Jarkko Sakkinen @ 2022-08-15 23:21 UTC (permalink / raw)
To: Haitao Huang; +Cc: dave.hansen, linux-sgx, reinette.chatre, vijay.dhanraj
On Sun, Aug 14, 2022 at 09:53:47PM -0700, Haitao Huang wrote:
> Return VM_FAULT_NOPAGE to allow the swapping thread to catch up.
>
> link: https://lore.kernel.org/all/20220804201456.33418-1-vijay.dhanraj@intel.com/
>
> Signed-off-by: Haitao Huang <haitao.huang@linux.intel.com>
> ---
> 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 24c1bb8eb196..de92c1c8b79d 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);
> --
> 2.25.1
>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
BR, Jarkko
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-08-16 2:52 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-12 19:12 [PATCH] x86/sgx: handle VA page allocation failure for EAUG on PF Haitao Huang
2022-08-12 22:41 ` Dhanraj, Vijay
2022-08-14 19:41 ` jarkko
2022-08-14 19:36 ` Jarkko Sakkinen
2022-08-15 4:53 ` Haitao Huang
2022-08-15 23:21 ` Jarkko Sakkinen
2022-08-15 15:01 ` Haitao Huang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.