Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-09-05 Thread Jarkko Sakkinen
On Tue, Sep 04, 2018 at 09:35:46AM -0700, Sean Christopherson wrote: > On Tue, Sep 04, 2018 at 06:30:21PM +0300, Jarkko Sakkinen wrote: > > On Tue, Sep 04, 2018 at 07:54:51AM -0700, Sean Christopherson wrote: > > > I don't see any value in trying to rule out specific causes of > > > INVALID_TOKEN,

RE: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-09-04 Thread Huang, Kai
er.kernel.org; > x...@kernel.org; nhor...@redhat.com; linux-kernel@vger.kernel.org; > t...@linutronix.de; suresh.b.sid...@intel.com; Ayoun, Serge > ; h...@zytor.com; npmccal...@redhat.com; > mi...@redhat.com; linux-...@vger.kernel.org; Hansen, Dave > > Subject: Re: [PATCH v13

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-09-04 Thread Sean Christopherson
On Tue, Sep 04, 2018 at 06:30:21PM +0300, Jarkko Sakkinen wrote: > On Tue, Sep 04, 2018 at 07:54:51AM -0700, Sean Christopherson wrote: > > I don't see any value in trying to rule out specific causes of > > INVALID_TOKEN, but we should only retry EINIT if ret==INVALID_TOKEN > > and RDMSR(HASH0) !=

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-09-04 Thread Andy Shevchenko
On Mon, Aug 27, 2018 at 9:58 PM Jarkko Sakkinen wrote: > > From: Sean Christopherson > > Add a function to perform ENCLS(EINIT), which initializes an enclave, > which can be used by a driver for running enclaves and VMMs. > > Writing the LE hash MSRs is extraordinarily expensive, e.g. 3-4x slower

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-09-04 Thread Jarkko Sakkinen
On Tue, Sep 04, 2018 at 07:54:51AM -0700, Sean Christopherson wrote: > I don't see any value in trying to rule out specific causes of > INVALID_TOKEN, but we should only retry EINIT if ret==INVALID_TOKEN > and RDMSR(HASH0) != sgx_lepubkeyhash[0]. Only the first MSR needs to > be checked for validi

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-09-04 Thread Jarkko Sakkinen
On Mon, Sep 03, 2018 at 11:45:14PM +, Huang, Kai wrote: > But INVALID_TOKEN is not only returned when MSRs are mismatched, so do > you plan to check to rule out other cases that cause INVALID_TOKEN > before retrying EINIT, or unconditionally retry EINIT? And we should > only retry once? In th

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-09-04 Thread Sean Christopherson
t; mi...@redhat.com; linux-...@vger.kernel.org; Hansen, Dave > > > > Subject: Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing > > enclaves > > > > On Fri, Aug 31, 2018 at 11:15:09AM -0700, Sean Christopherson wrote: > > > On Fri, Aug 31, 2018 at 03:17:03

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-09-04 Thread Jarkko Sakkinen
On Mon, Sep 03, 2018 at 03:53:24PM +0200, Jann Horn wrote: > On Mon, Sep 3, 2018 at 3:33 PM Jarkko Sakkinen > wrote: > > > > From: Sean Christopherson > > > > Add a function to perform ENCLS(EINIT), which initializes an enclave, > > which can be used by a driver for running enclaves and VMMs. > >

RE: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-09-03 Thread Huang, Kai
x...@kernel.org; nhor...@redhat.com; linux-kernel@vger.kernel.org; > t...@linutronix.de; suresh.b.sid...@intel.com; Ayoun, Serge > ; h...@zytor.com; npmccal...@redhat.com; > mi...@redhat.com; linux-...@vger.kernel.org; Hansen, Dave > > Subject: Re: [PATCH v13 10/13] x86/sgx: Add sgx_

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-09-03 Thread Jarkko Sakkinen
On Fri, Aug 31, 2018 at 04:34:45PM -0500, Dr. Greg wrote: > On Fri, Aug 31, 2018 at 10:43:30AM -0700, Sean Christopherson wrote: > > Good afternoon to everyone. > > > > Sorry I missed this one. To be honest I don't know. I checked the > > > SDM and all I can find is: > > > > > > "On reset, the de

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-09-03 Thread Jarkko Sakkinen
On Fri, Aug 31, 2018 at 11:15:09AM -0700, Sean Christopherson wrote: > On Fri, Aug 31, 2018 at 03:17:03PM +0300, Jarkko Sakkinen wrote: > > On Wed, Aug 29, 2018 at 07:33:54AM +, Huang, Kai wrote: > > > [snip..] > > > > > > > > > > > > > > > @@ -38,6 +39,18 @@ static LIST_HEAD(sgx_active_page_l

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-09-03 Thread Jarkko Sakkinen
On Thu, Aug 30, 2018 at 01:45:29AM +, Huang, Kai wrote: > > > > Refresh my brain, does hardware reset the MSRs on a transition to S3 or > > lower? > > Sorry I missed this one. To be honest I don't know. I checked the SDM and all > I can find is: > > "On reset, the default value is the digest

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-09-03 Thread Jann Horn
On Mon, Sep 3, 2018 at 3:33 PM Jarkko Sakkinen wrote: > > From: Sean Christopherson > > Add a function to perform ENCLS(EINIT), which initializes an enclave, > which can be used by a driver for running enclaves and VMMs. > > Writing the LE hash MSRs is extraordinarily expensive, e.g. 3-4x slower

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-08-31 Thread Dr. Greg
On Fri, Aug 31, 2018 at 10:43:30AM -0700, Sean Christopherson wrote: Good afternoon to everyone. > > Sorry I missed this one. To be honest I don't know. I checked the > > SDM and all I can find is: > > > > "On reset, the default value is the digest of Intel's signing key." > I confirmed the MSRs

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-08-31 Thread Sean Christopherson
On Fri, Aug 31, 2018 at 03:17:03PM +0300, Jarkko Sakkinen wrote: > On Wed, Aug 29, 2018 at 07:33:54AM +, Huang, Kai wrote: > > [snip..] > > > > > > > > > > > > @@ -38,6 +39,18 @@ static LIST_HEAD(sgx_active_page_list); static > > > > > DEFINE_SPINLOCK(sgx_active_page_list_lock); > > > > > st

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-08-31 Thread Sean Christopherson
On Wed, Aug 29, 2018 at 06:45:29PM -0700, Huang, Kai wrote: > > > > > > Some kind of counter is required to keep track of the power cycle. > > > > > > When going to sleep the sgx_pm_cnt is increased. sgx_einit() > > > > > > compares the current value of the global count to the value in > > > > > >

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-08-31 Thread Jarkko Sakkinen
On Wed, Aug 29, 2018 at 07:33:54AM +, Huang, Kai wrote: > [snip..] > > > > > > > > > @@ -38,6 +39,18 @@ static LIST_HEAD(sgx_active_page_list); static > > > > DEFINE_SPINLOCK(sgx_active_page_list_lock); > > > > static struct task_struct *ksgxswapd_tsk; static > > > > DECLARE_WAIT_QUEUE_HEAD

RE: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-08-29 Thread Huang, Kai
> > > > > Some kind of counter is required to keep track of the power cycle. > > > > > When going to sleep the sgx_pm_cnt is increased. sgx_einit() > > > > > compares the current value of the global count to the value in > > > > > the cache entry to see whether we are in a new power cycle. > > > >

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-08-29 Thread Sean Christopherson
x...@kernel.org; nhor...@redhat.com; linux- > > ker...@vger.kernel.org; t...@linutronix.de; suresh.b.sid...@intel.com; > > Ayoun, > > Serge ; h...@zytor.com; npmccal...@redhat.com; > > mi...@redhat.com; linux-...@vger.kernel.org; Hansen, Dave > > > > Subject: Re: [

RE: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-08-29 Thread Huang, Kai
onix.de; suresh.b.sid...@intel.com; Ayoun, > Serge ; h...@zytor.com; npmccal...@redhat.com; > mi...@redhat.com; linux-...@vger.kernel.org; Hansen, Dave > > Subject: Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing > enclaves > > On Wed, Aug 29, 2018 at 12:

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-08-29 Thread Sean Christopherson
On Wed, Aug 29, 2018 at 12:33:54AM -0700, Huang, Kai wrote: > [snip..] > > > > > > > > > @@ -38,6 +39,18 @@ static LIST_HEAD(sgx_active_page_list); static > > > > DEFINE_SPINLOCK(sgx_active_page_list_lock); > > > > static struct task_struct *ksgxswapd_tsk; static > > > > DECLARE_WAIT_QUEUE_HEAD

RE: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-08-29 Thread Huang, Kai
[snip..] > > > > > > @@ -38,6 +39,18 @@ static LIST_HEAD(sgx_active_page_list); static > > > DEFINE_SPINLOCK(sgx_active_page_list_lock); > > > static struct task_struct *ksgxswapd_tsk; static > > > DECLARE_WAIT_QUEUE_HEAD(ksgxswapd_waitq); > > > +static struct notifier_block sgx_pm_notifier; st

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-08-28 Thread Jarkko Sakkinen
On Mon, Aug 27, 2018 at 09:41:22PM +, Huang, Kai wrote: > On Mon, 2018-08-27 at 21:53 +0300, Jarkko Sakkinen wrote: > > From: Sean Christopherson > > > > Add a function to perform ENCLS(EINIT), which initializes an enclave, > > which can be used by a driver for running enclaves and VMMs. > >

Re: [PATCH v13 10/13] x86/sgx: Add sgx_einit() for initializing enclaves

2018-08-27 Thread Huang, Kai
On Mon, 2018-08-27 at 21:53 +0300, Jarkko Sakkinen wrote: > From: Sean Christopherson > > Add a function to perform ENCLS(EINIT), which initializes an enclave, > which can be used by a driver for running enclaves and VMMs. > > Writing the LE hash MSRs is extraordinarily expensive, e.g. 3-4x > sl