From: Dave Hansen Subject: Re: [PATCH v17 18/23] platform/x86: Intel SGX driver Date: Mon, 17 Dec 2018 11:09:33 -0800 Message-ID: References: <20181116010412.23967-1-jarkko.sakkinen@linux.intel.com> <20181116010412.23967-19-jarkko.sakkinen@linux.intel.com> <7d5cde02-4649-546b-0f03-2d6414bb80b5@intel.com> <20181217180102.GA12560@linux.intel.com> <20181217183613.GD12491@linux.intel.com> <20181217184333.GA26920@linux.intel.com> <20181217184858.GF12491@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <20181217184858.GF12491@linux.intel.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: Sean Christopherson , Jarkko Sakkinen Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-sgx@vger.kernel.org, nhorman@redhat.com, npmccallum@redhat.com, serge.ayoun@intel.com, shay.katz-zamir@intel.com, haitao.huang@linux.intel.com, andriy.shevchenko@linux.intel.com, tglx@linutronix.de, kai.svahn@intel.com, mark.shanahan@intel.com, luto@amacapital.net, Suresh Siddha , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Darren Hart , Andy Shevchenko , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" List-Id: platform-driver-x86.vger.kernel.org On 12/17/18 10:48 AM, Sean Christopherson wrote: > We can't set mm to NULL as we need it to unregister the notifier, and > I'm fairly certain attempting to unregister in the release callback > will deadlock. Suggestion: It looks like you only expect one VMA per enclave. Things go bonkers if this is not true. So, instead of storing encl->mm, don't. You can get the mm from vma->vm_mm and you could just store encl->vma instead. Doing that, you could even axe encl->base and encl->size, I think because you just get those from the VMA itself. That makes the relationship clearer: 1 VMA per enclave. We also implicitly understand that if you have a VMA, you implicitly have a ref to the mm *and* the VMA is immutable. If there were ever a path where encl->vma wasn't immutable, we'd have a bug (or load of bugs) somewhere, right?