linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] x86/sgx: Add missing xa_destroy() when virtual EPC is destroyed
@ 2021-06-16  0:36 Kai Huang
  2021-06-23 13:28 ` Jarkko Sakkinen
  0 siblings, 1 reply; 7+ messages in thread
From: Kai Huang @ 2021-06-16  0:36 UTC (permalink / raw)
  To: linux-sgx, x86
  Cc: linux-kernel, bp, seanjc, jarkko, dave.hansen, tglx, mingo,
	Yang Zhong, Kai Huang

xa_destroy() needs to be called to destroy virtual EPC's page array
before calling kfree() to free the virtual EPC.  Currently it is not
called.  Add the missing xa_destroy() to fix.

Fixes: 540745ddbc70 ("x86/sgx: Introduce virtual EPC for use by KVM guests")
Tested-by: Yang Zhong <yang.zhong@intel.com>
Acked-by: Dave Hansen <dave.hansen@intel.com>
Signed-off-by: Kai Huang <kai.huang@intel.com>
---
v1->v2:

 - Fixed typo in commit msg
 - Added Dave's Acked-by
---
 arch/x86/kernel/cpu/sgx/virt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/kernel/cpu/sgx/virt.c b/arch/x86/kernel/cpu/sgx/virt.c
index 6ad165a5c0cc..64511c4a5200 100644
--- a/arch/x86/kernel/cpu/sgx/virt.c
+++ b/arch/x86/kernel/cpu/sgx/virt.c
@@ -212,6 +212,7 @@ static int sgx_vepc_release(struct inode *inode, struct file *file)
 		list_splice_tail(&secs_pages, &zombie_secs_pages);
 	mutex_unlock(&zombie_secs_pages_lock);
 
+	xa_destroy(&vepc->page_array);
 	kfree(vepc);
 
 	return 0;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] x86/sgx: Add missing xa_destroy() when virtual EPC is destroyed
  2021-06-16  0:36 [PATCH v2] x86/sgx: Add missing xa_destroy() when virtual EPC is destroyed Kai Huang
@ 2021-06-23 13:28 ` Jarkko Sakkinen
  2021-06-25  1:45   ` Kai Huang
  0 siblings, 1 reply; 7+ messages in thread
From: Jarkko Sakkinen @ 2021-06-23 13:28 UTC (permalink / raw)
  To: Kai Huang
  Cc: linux-sgx, x86, linux-kernel, bp, seanjc, dave.hansen, tglx,
	mingo, Yang Zhong

On Wed, Jun 16, 2021 at 12:36:34PM +1200, Kai Huang wrote:
> xa_destroy() needs to be called to destroy virtual EPC's page array
> before calling kfree() to free the virtual EPC.  Currently it is not
> called.  Add the missing xa_destroy() to fix.
> 
> Fixes: 540745ddbc70 ("x86/sgx: Introduce virtual EPC for use by KVM guests")
> Tested-by: Yang Zhong <yang.zhong@intel.com>
> Acked-by: Dave Hansen <dave.hansen@intel.com>
> Signed-off-by: Kai Huang <kai.huang@intel.com>


Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

> ---
> v1->v2:
> 
>  - Fixed typo in commit msg
>  - Added Dave's Acked-by
> ---
>  arch/x86/kernel/cpu/sgx/virt.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/x86/kernel/cpu/sgx/virt.c b/arch/x86/kernel/cpu/sgx/virt.c
> index 6ad165a5c0cc..64511c4a5200 100644
> --- a/arch/x86/kernel/cpu/sgx/virt.c
> +++ b/arch/x86/kernel/cpu/sgx/virt.c
> @@ -212,6 +212,7 @@ static int sgx_vepc_release(struct inode *inode, struct file *file)
>  		list_splice_tail(&secs_pages, &zombie_secs_pages);
>  	mutex_unlock(&zombie_secs_pages_lock);
>  
> +	xa_destroy(&vepc->page_array);
>  	kfree(vepc);
>  
>  	return 0;
> -- 
> 2.31.1
> 
> 

/Jarkko

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] x86/sgx: Add missing xa_destroy() when virtual EPC is destroyed
  2021-06-23 13:28 ` Jarkko Sakkinen
@ 2021-06-25  1:45   ` Kai Huang
  2021-06-25  8:22     ` Borislav Petkov
  0 siblings, 1 reply; 7+ messages in thread
From: Kai Huang @ 2021-06-25  1:45 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: linux-sgx, x86, linux-kernel, bp, seanjc, dave.hansen, tglx,
	mingo, Yang Zhong

On Wed, 2021-06-23 at 16:28 +0300, Jarkko Sakkinen wrote:
> On Wed, Jun 16, 2021 at 12:36:34PM +1200, Kai Huang wrote:
> > xa_destroy() needs to be called to destroy virtual EPC's page array
> > before calling kfree() to free the virtual EPC.  Currently it is not
> > called.  Add the missing xa_destroy() to fix.
> > 
> > Fixes: 540745ddbc70 ("x86/sgx: Introduce virtual EPC for use by KVM guests")
> > Tested-by: Yang Zhong <yang.zhong@intel.com>
> > Acked-by: Dave Hansen <dave.hansen@intel.com>
> > Signed-off-by: Kai Huang <kai.huang@intel.com>
> 
> 
> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

Thanks Jarkko.

Hi Boris,

Should we consider to get this into 5.13, since it is a fix?

> 
> > ---
> > v1->v2:
> > 
> >  - Fixed typo in commit msg
> >  - Added Dave's Acked-by
> > ---
> >  arch/x86/kernel/cpu/sgx/virt.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/arch/x86/kernel/cpu/sgx/virt.c b/arch/x86/kernel/cpu/sgx/virt.c
> > index 6ad165a5c0cc..64511c4a5200 100644
> > --- a/arch/x86/kernel/cpu/sgx/virt.c
> > +++ b/arch/x86/kernel/cpu/sgx/virt.c
> > @@ -212,6 +212,7 @@ static int sgx_vepc_release(struct inode *inode, struct file *file)
> >  		list_splice_tail(&secs_pages, &zombie_secs_pages);
> >  	mutex_unlock(&zombie_secs_pages_lock);
> >  
> > +	xa_destroy(&vepc->page_array);
> >  	kfree(vepc);
> >  
> >  	return 0;
> > -- 
> > 2.31.1
> > 
> > 
> 
> /Jarkko



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] x86/sgx: Add missing xa_destroy() when virtual EPC is destroyed
  2021-06-25  1:45   ` Kai Huang
@ 2021-06-25  8:22     ` Borislav Petkov
  2021-06-25 12:04       ` Kai Huang
  0 siblings, 1 reply; 7+ messages in thread
From: Borislav Petkov @ 2021-06-25  8:22 UTC (permalink / raw)
  To: Kai Huang
  Cc: Jarkko Sakkinen, linux-sgx, x86, linux-kernel, seanjc,
	dave.hansen, tglx, mingo, Yang Zhong

On Fri, Jun 25, 2021 at 01:45:35PM +1200, Kai Huang wrote:
> Should we consider to get this into 5.13, since it is a fix?

We have considered it, have queued it, you're on Cc on the tip-bot
notification:

https://lkml.kernel.org/r/162377378414.19906.6678244614782222506.tip-bot2@tip-bot2

In the meantime, that fix landed upstream and will be in 5.13:

4692bc775d21 ("x86/sgx: Add missing xa_destroy() when virtual EPC is destroyed")

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] x86/sgx: Add missing xa_destroy() when virtual EPC is destroyed
  2021-06-25  8:22     ` Borislav Petkov
@ 2021-06-25 12:04       ` Kai Huang
  2021-06-25 13:47         ` Borislav Petkov
  0 siblings, 1 reply; 7+ messages in thread
From: Kai Huang @ 2021-06-25 12:04 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Jarkko Sakkinen, linux-sgx, x86, linux-kernel, seanjc,
	dave.hansen, tglx, mingo, Yang Zhong

On Fri, 2021-06-25 at 10:22 +0200, Borislav Petkov wrote:
> On Fri, Jun 25, 2021 at 01:45:35PM +1200, Kai Huang wrote:
> > Should we consider to get this into 5.13, since it is a fix?
> 
> We have considered it, have queued it, you're on Cc on the tip-bot
> notification:
> 
> https://lkml.kernel.org/r/162377378414.19906.6678244614782222506.tip-bot2@tip-bot2
> 
> In the meantime, that fix landed upstream and will be in 5.13:
> 
> 4692bc775d21 ("x86/sgx: Add missing xa_destroy() when virtual EPC is destroyed")
> 

Oh sorry I thought the patch would go via x86/sgx branch, and I didn't monitor
the tip-bot2 mail which was moved to my local x86 folder.  Thanks!


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] x86/sgx: Add missing xa_destroy() when virtual EPC is destroyed
  2021-06-25 12:04       ` Kai Huang
@ 2021-06-25 13:47         ` Borislav Petkov
  2021-06-25 23:06           ` Kai Huang
  0 siblings, 1 reply; 7+ messages in thread
From: Borislav Petkov @ 2021-06-25 13:47 UTC (permalink / raw)
  To: Kai Huang
  Cc: Jarkko Sakkinen, linux-sgx, x86, linux-kernel, seanjc,
	dave.hansen, tglx, mingo, Yang Zhong

On Sat, Jun 26, 2021 at 12:04:53AM +1200, Kai Huang wrote:
> Oh sorry I thought the patch would go via x86/sgx branch

We usually send fixes through tip's urgent branches because they go
straight to Linus and not wait for the merge window.

> and I didn't monitor the tip-bot2 mail which was moved to my local x86
> folder.

That's not optimal because those tip-bot notifications are *exactly* for
that - to let the involved parties know that the patch has been queued.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] x86/sgx: Add missing xa_destroy() when virtual EPC is destroyed
  2021-06-25 13:47         ` Borislav Petkov
@ 2021-06-25 23:06           ` Kai Huang
  0 siblings, 0 replies; 7+ messages in thread
From: Kai Huang @ 2021-06-25 23:06 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Jarkko Sakkinen, linux-sgx, x86, linux-kernel, seanjc,
	dave.hansen, tglx, mingo, Yang Zhong

On Fri, 2021-06-25 at 15:47 +0200, Borislav Petkov wrote:
> On Sat, Jun 26, 2021 at 12:04:53AM +1200, Kai Huang wrote:
> > Oh sorry I thought the patch would go via x86/sgx branch
> 
> We usually send fixes through tip's urgent branches because they go
> straight to Linus and not wait for the merge window.
> 
> > and I didn't monitor the tip-bot2 mail which was moved to my local x86
> > folder.
> 
> That's not optimal because those tip-bot notifications are *exactly* for
> that - to let the involved parties know that the patch has been queued.
> 

Got it. Thanks for remaindering.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-06-25 23:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16  0:36 [PATCH v2] x86/sgx: Add missing xa_destroy() when virtual EPC is destroyed Kai Huang
2021-06-23 13:28 ` Jarkko Sakkinen
2021-06-25  1:45   ` Kai Huang
2021-06-25  8:22     ` Borislav Petkov
2021-06-25 12:04       ` Kai Huang
2021-06-25 13:47         ` Borislav Petkov
2021-06-25 23:06           ` Kai Huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).