Re: [PATCH] x86/sgx: Synchronize encl->srcu in sgx_encl_release().

2020-12-16 Thread Jarkko Sakkinen
On Tue, Dec 15, 2020 at 02:04:10PM -0800, Sean Christopherson wrote: > On Tue, Dec 15, 2020, Jarkko Sakkinen wrote: > > On Mon, Dec 14, 2020 at 11:01:32AM -0800, Sean Christopherson wrote: > > > Haitao reported the bug, and for all intents and purposes provided the > > > fix. I > > > just did the

Re: [PATCH] x86/sgx: Synchronize encl->srcu in sgx_encl_release().

2020-12-15 Thread Sean Christopherson
On Tue, Dec 15, 2020, Jarkko Sakkinen wrote: > On Mon, Dec 14, 2020 at 11:01:32AM -0800, Sean Christopherson wrote: > > Haitao reported the bug, and for all intents and purposes provided the fix. > > I > > just did the analysis to verify that there was a legitimate bug and that the > > synchroniz

[PATCH] x86/sgx: Synchronize encl->srcu in sgx_encl_release().

2020-12-15 Thread Jarkko Sakkinen
Add synchronize_srcu_expedited() to sgx_encl_release() to catch a grace period initiated by sgx_mmu_notifier_release(). A trivial example of a failing sequence with tasks A and B: 1. A: -> sgx_release() 2. B: -> sgx_mmu_notifier_release() 3. B: -> list_del_rcu() 3. A: -> sgx_encl_release() 4. A:

Re: [PATCH] x86/sgx: Synchronize encl->srcu in sgx_encl_release().

2020-12-15 Thread Jarkko Sakkinen
On Tue, Dec 15, 2020 at 11:34:37AM -0600, Haitao Huang wrote: > On Mon, 14 Dec 2020 23:59:55 -0600, Jarkko Sakkinen > wrote: > > > On Tue, Dec 15, 2020 at 07:56:01AM +0200, Jarkko Sakkinen wrote: > > > On Mon, Dec 14, 2020 at 11:01:32AM -0800, Sean Christopherson wrote: > > > > On Fri, Dec 11, 20

Re: [PATCH] x86/sgx: Synchronize encl->srcu in sgx_encl_release().

2020-12-15 Thread Haitao Huang
On Mon, 14 Dec 2020 23:59:55 -0600, Jarkko Sakkinen wrote: On Tue, Dec 15, 2020 at 07:56:01AM +0200, Jarkko Sakkinen wrote: On Mon, Dec 14, 2020 at 11:01:32AM -0800, Sean Christopherson wrote: > On Fri, Dec 11, 2020, Jarkko Sakkinen wrote: > > Each sgx_mmun_notifier_release() starts a grace pe

Re: [PATCH] x86/sgx: Synchronize encl->srcu in sgx_encl_release().

2020-12-14 Thread Jarkko Sakkinen
On Tue, Dec 15, 2020 at 07:56:01AM +0200, Jarkko Sakkinen wrote: > On Mon, Dec 14, 2020 at 11:01:32AM -0800, Sean Christopherson wrote: > > On Fri, Dec 11, 2020, Jarkko Sakkinen wrote: > > > Each sgx_mmun_notifier_release() starts a grace period, which means that > > > > Should be sgx_mmu_notifier

Re: [PATCH] x86/sgx: Synchronize encl->srcu in sgx_encl_release().

2020-12-14 Thread Jarkko Sakkinen
On Mon, Dec 14, 2020 at 11:01:32AM -0800, Sean Christopherson wrote: > On Fri, Dec 11, 2020, Jarkko Sakkinen wrote: > > Each sgx_mmun_notifier_release() starts a grace period, which means that > > Should be sgx_mmu_notifier_release(), here and in the comment. Thanks. > > one extra synchronize_rc

Re: [PATCH] x86/sgx: Synchronize encl->srcu in sgx_encl_release().

2020-12-14 Thread Sean Christopherson
On Fri, Dec 11, 2020, Jarkko Sakkinen wrote: > Each sgx_mmun_notifier_release() starts a grace period, which means that Should be sgx_mmu_notifier_release(), here and in the comment. > one extra synchronize_rcu() in sgx_encl_release(). Add it there. > > sgx_release() has the loop that drains the

[PATCH] x86/sgx: Synchronize encl->srcu in sgx_encl_release().

2020-12-11 Thread Jarkko Sakkinen
Each sgx_mmun_notifier_release() starts a grace period, which means that one extra synchronize_rcu() in sgx_encl_release(). Add it there. sgx_release() has the loop that drains the list but with bad luck the entry is already gone from the list before that loop processes it. Fixes: 1728ab54b4be ("