Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-25 Thread Neil Horman
On Mon, Jun 25, 2018 at 12:21:22PM +0300, Jarkko Sakkinen wrote: > On Wed, 2018-06-20 at 06:21 -0700, Sean Christopherson wrote: > > On Fri, 2018-06-08 at 19:09 +0200, Jarkko Sakkinen wrote: > > > SGX has a set of data structures to maintain information about the > > > enclaves > > > and their

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-25 Thread Neil Horman
On Mon, Jun 25, 2018 at 12:21:22PM +0300, Jarkko Sakkinen wrote: > On Wed, 2018-06-20 at 06:21 -0700, Sean Christopherson wrote: > > On Fri, 2018-06-08 at 19:09 +0200, Jarkko Sakkinen wrote: > > > SGX has a set of data structures to maintain information about the > > > enclaves > > > and their

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-25 Thread Jarkko Sakkinen
On Wed, 2018-06-20 at 08:26 -0700, Sean Christopherson wrote: > > bool sgx_enabled __ro_after_init = false; > > EXPORT_SYMBOL(sgx_enabled); > > +bool sgx_lc_enabled __ro_after_init; > > +EXPORT_SYMBOL(sgx_lc_enabled); > > +atomic_t sgx_nr_free_pages = ATOMIC_INIT(0); > >

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-25 Thread Jarkko Sakkinen
On Wed, 2018-06-20 at 08:26 -0700, Sean Christopherson wrote: > > bool sgx_enabled __ro_after_init = false; > > EXPORT_SYMBOL(sgx_enabled); > > +bool sgx_lc_enabled __ro_after_init; > > +EXPORT_SYMBOL(sgx_lc_enabled); > > +atomic_t sgx_nr_free_pages = ATOMIC_INIT(0); > >

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-25 Thread Jarkko Sakkinen
On Wed, 2018-06-20 at 06:21 -0700, Sean Christopherson wrote: > On Fri, 2018-06-08 at 19:09 +0200, Jarkko Sakkinen wrote: > > SGX has a set of data structures to maintain information about the enclaves > > and their security properties. BIOS reserves a fixed size region of > > physical memory for

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-25 Thread Jarkko Sakkinen
On Wed, 2018-06-20 at 06:21 -0700, Sean Christopherson wrote: > On Fri, 2018-06-08 at 19:09 +0200, Jarkko Sakkinen wrote: > > SGX has a set of data structures to maintain information about the enclaves > > and their security properties. BIOS reserves a fixed size region of > > physical memory for

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-25 Thread Jarkko Sakkinen
On Tue, 2018-06-19 at 08:59 -0700, Sean Christopherson wrote: > On Tue, Jun 19, 2018 at 05:57:53PM +0300, Jarkko Sakkinen wrote: > > On Fri, Jun 08, 2018 at 11:24:12AM -0700, Dave Hansen wrote: > > > On 06/08/2018 10:09 AM, Jarkko Sakkinen wrote: > > > > +static __init bool sgx_is_enabled(bool

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-25 Thread Jarkko Sakkinen
On Tue, 2018-06-19 at 08:59 -0700, Sean Christopherson wrote: > On Tue, Jun 19, 2018 at 05:57:53PM +0300, Jarkko Sakkinen wrote: > > On Fri, Jun 08, 2018 at 11:24:12AM -0700, Dave Hansen wrote: > > > On 06/08/2018 10:09 AM, Jarkko Sakkinen wrote: > > > > +static __init bool sgx_is_enabled(bool

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-25 Thread Jarkko Sakkinen
On Tue, 2018-06-19 at 08:32 -0700, Dave Hansen wrote: > > For 32-bit (albeit not supported at this point) it makes sense to always > > use kmap_atomic_pfn() as the virtua address area is very limited. > > That makes no sense. 32-bit kernels have plenty of virtual address > space if not using

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-25 Thread Jarkko Sakkinen
On Tue, 2018-06-19 at 08:32 -0700, Dave Hansen wrote: > > For 32-bit (albeit not supported at this point) it makes sense to always > > use kmap_atomic_pfn() as the virtua address area is very limited. > > That makes no sense. 32-bit kernels have plenty of virtual address > space if not using

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-20 Thread Sean Christopherson
On Fri, 2018-06-08 at 19:09 +0200, Jarkko Sakkinen wrote: > SGX has a set of data structures to maintain information about the enclaves > and their security properties. BIOS reserves a fixed size region of > physical memory for these structures by setting Processor Reserved Memory > Range

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-20 Thread Sean Christopherson
On Fri, 2018-06-08 at 19:09 +0200, Jarkko Sakkinen wrote: > SGX has a set of data structures to maintain information about the enclaves > and their security properties. BIOS reserves a fixed size region of > physical memory for these structures by setting Processor Reserved Memory > Range

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-20 Thread Sean Christopherson
On Fri, 2018-06-08 at 19:09 +0200, Jarkko Sakkinen wrote: > SGX has a set of data structures to maintain information about the enclaves > and their security properties. BIOS reserves a fixed size region of > physical memory for these structures by setting Processor Reserved Memory > Range

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-20 Thread Sean Christopherson
On Fri, 2018-06-08 at 19:09 +0200, Jarkko Sakkinen wrote: > SGX has a set of data structures to maintain information about the enclaves > and their security properties. BIOS reserves a fixed size region of > physical memory for these structures by setting Processor Reserved Memory > Range

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-19 Thread Sean Christopherson
On Tue, Jun 19, 2018 at 05:57:53PM +0300, Jarkko Sakkinen wrote: > On Fri, Jun 08, 2018 at 11:24:12AM -0700, Dave Hansen wrote: > > On 06/08/2018 10:09 AM, Jarkko Sakkinen wrote: > > > +static __init bool sgx_is_enabled(bool *lc_enabled) > > > { > > > unsigned long fc; > > > > > > @@ -41,12

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-19 Thread Sean Christopherson
On Tue, Jun 19, 2018 at 05:57:53PM +0300, Jarkko Sakkinen wrote: > On Fri, Jun 08, 2018 at 11:24:12AM -0700, Dave Hansen wrote: > > On 06/08/2018 10:09 AM, Jarkko Sakkinen wrote: > > > +static __init bool sgx_is_enabled(bool *lc_enabled) > > > { > > > unsigned long fc; > > > > > > @@ -41,12

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-19 Thread Jethro Beekman
On 2018-06-19 07:08, Jarkko Sakkinen wrote: On Fri, Jun 08, 2018 at 11:21:48AM -0700, Jethro Beekman wrote: On 2018-06-08 10:09, Jarkko Sakkinen wrote: +/* + * Writing the LE hash MSRs is extraordinarily expensive, e.g. + * 3-4x slower than normal MSRs, so we use a per-cpu cache to + * track

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-19 Thread Jethro Beekman
On 2018-06-19 07:08, Jarkko Sakkinen wrote: On Fri, Jun 08, 2018 at 11:21:48AM -0700, Jethro Beekman wrote: On 2018-06-08 10:09, Jarkko Sakkinen wrote: +/* + * Writing the LE hash MSRs is extraordinarily expensive, e.g. + * 3-4x slower than normal MSRs, so we use a per-cpu cache to + * track

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-19 Thread Dave Hansen
On 06/19/2018 07:57 AM, Jarkko Sakkinen wrote: > On Fri, Jun 08, 2018 at 11:24:12AM -0700, Dave Hansen wrote: >>> Each subsystem that uses SGX must provide a set of callbacks for EPC >>> pages that are used to reclaim, block and write an EPC page. Kernel >>> takes the responsibility of maintaining

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-19 Thread Dave Hansen
On 06/19/2018 07:57 AM, Jarkko Sakkinen wrote: > On Fri, Jun 08, 2018 at 11:24:12AM -0700, Dave Hansen wrote: >>> Each subsystem that uses SGX must provide a set of callbacks for EPC >>> pages that are used to reclaim, block and write an EPC page. Kernel >>> takes the responsibility of maintaining

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-19 Thread Neil Horman
On Tue, Jun 19, 2018 at 05:57:53PM +0300, Jarkko Sakkinen wrote: > On Fri, Jun 08, 2018 at 11:24:12AM -0700, Dave Hansen wrote: > > On 06/08/2018 10:09 AM, Jarkko Sakkinen wrote: > > > SGX has a set of data structures to maintain information about the > > > enclaves > > > and their security

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-19 Thread Neil Horman
On Tue, Jun 19, 2018 at 05:57:53PM +0300, Jarkko Sakkinen wrote: > On Fri, Jun 08, 2018 at 11:24:12AM -0700, Dave Hansen wrote: > > On 06/08/2018 10:09 AM, Jarkko Sakkinen wrote: > > > SGX has a set of data structures to maintain information about the > > > enclaves > > > and their security

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-19 Thread Jarkko Sakkinen
On Fri, Jun 08, 2018 at 11:24:12AM -0700, Dave Hansen wrote: > On 06/08/2018 10:09 AM, Jarkko Sakkinen wrote: > > SGX has a set of data structures to maintain information about the enclaves > > and their security properties. BIOS reserves a fixed size region of > > physical memory for these

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-19 Thread Jarkko Sakkinen
On Fri, Jun 08, 2018 at 11:24:12AM -0700, Dave Hansen wrote: > On 06/08/2018 10:09 AM, Jarkko Sakkinen wrote: > > SGX has a set of data structures to maintain information about the enclaves > > and their security properties. BIOS reserves a fixed size region of > > physical memory for these

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-19 Thread Jarkko Sakkinen
On Fri, Jun 08, 2018 at 11:21:48AM -0700, Jethro Beekman wrote: > On 2018-06-08 10:09, Jarkko Sakkinen wrote: > > +/* > > + * Writing the LE hash MSRs is extraordinarily expensive, e.g. > > + * 3-4x slower than normal MSRs, so we use a per-cpu cache to > > + * track the last known value of the

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-19 Thread Jarkko Sakkinen
On Fri, Jun 08, 2018 at 11:21:48AM -0700, Jethro Beekman wrote: > On 2018-06-08 10:09, Jarkko Sakkinen wrote: > > +/* > > + * Writing the LE hash MSRs is extraordinarily expensive, e.g. > > + * 3-4x slower than normal MSRs, so we use a per-cpu cache to > > + * track the last known value of the

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-08 Thread Dave Hansen
On 06/08/2018 10:09 AM, Jarkko Sakkinen wrote: > SGX has a set of data structures to maintain information about the enclaves > and their security properties. BIOS reserves a fixed size region of > physical memory for these structures by setting Processor Reserved Memory > Range Registers (PRMRR).

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-08 Thread Dave Hansen
On 06/08/2018 10:09 AM, Jarkko Sakkinen wrote: > SGX has a set of data structures to maintain information about the enclaves > and their security properties. BIOS reserves a fixed size region of > physical memory for these structures by setting Processor Reserved Memory > Range Registers (PRMRR).

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-08 Thread Jethro Beekman
On 2018-06-08 10:09, Jarkko Sakkinen wrote: +/* + * Writing the LE hash MSRs is extraordinarily expensive, e.g. + * 3-4x slower than normal MSRs, so we use a per-cpu cache to + * track the last known value of the MSRs to avoid unnecessarily + * writing the MSRs with the current value. Because

Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache

2018-06-08 Thread Jethro Beekman
On 2018-06-08 10:09, Jarkko Sakkinen wrote: +/* + * Writing the LE hash MSRs is extraordinarily expensive, e.g. + * 3-4x slower than normal MSRs, so we use a per-cpu cache to + * track the last known value of the MSRs to avoid unnecessarily + * writing the MSRs with the current value. Because