Re: [PATCH v30 07/20] x86/sgx: Enumerate and track EPC sections

2020-05-28 Thread Jarkko Sakkinen
On Wed, May 27, 2020 at 10:35:09PM +0200, Borislav Petkov wrote: > > One idea would be to provide a Kconfig a la NR_CPUS or NODES_SHIFT. I.e. > > carve out the bits in sgx_epc_page_desc to allow up to N sections, but let > > the user limit the number of sections to recoup the unused memory. > >

Re: [PATCH v30 07/20] x86/sgx: Enumerate and track EPC sections

2020-05-27 Thread Jarkko Sakkinen
On Thu, May 28, 2020 at 09:14:43AM +0300, Jarkko Sakkinen wrote: > On Thu, May 28, 2020 at 08:35:15AM +0300, Jarkko Sakkinen wrote: > > On Thu, May 28, 2020 at 08:25:43AM +0300, Jarkko Sakkinen wrote: > > > On Tue, May 26, 2020 at 08:56:14PM -0700, Sean Christopherson wrote: > > > > On Mon, May 25,

Re: [PATCH v30 07/20] x86/sgx: Enumerate and track EPC sections

2020-05-27 Thread Jarkko Sakkinen
On Thu, May 28, 2020 at 08:35:15AM +0300, Jarkko Sakkinen wrote: > On Thu, May 28, 2020 at 08:25:43AM +0300, Jarkko Sakkinen wrote: > > On Tue, May 26, 2020 at 08:56:14PM -0700, Sean Christopherson wrote: > > > On Mon, May 25, 2020 at 11:23:04AM +0200, Borislav Petkov wrote: > > > > On Fri, May 15,

Re: [PATCH v30 07/20] x86/sgx: Enumerate and track EPC sections

2020-05-27 Thread Jarkko Sakkinen
On Thu, May 28, 2020 at 08:25:43AM +0300, Jarkko Sakkinen wrote: > On Tue, May 26, 2020 at 08:56:14PM -0700, Sean Christopherson wrote: > > On Mon, May 25, 2020 at 11:23:04AM +0200, Borislav Petkov wrote: > > > On Fri, May 15, 2020 at 03:43:57AM +0300, Jarkko Sakkinen wrote: > > > > +struct sgx_epc

Re: [PATCH v30 07/20] x86/sgx: Enumerate and track EPC sections

2020-05-27 Thread Jarkko Sakkinen
On Tue, May 26, 2020 at 08:56:14PM -0700, Sean Christopherson wrote: > On Mon, May 25, 2020 at 11:23:04AM +0200, Borislav Petkov wrote: > > On Fri, May 15, 2020 at 03:43:57AM +0300, Jarkko Sakkinen wrote: > > > +struct sgx_epc_section sgx_epc_sections[SGX_MAX_EPC_SECTIONS]; > > > +int sgx_nr_epc_se

Re: [PATCH v30 07/20] x86/sgx: Enumerate and track EPC sections

2020-05-27 Thread Jarkko Sakkinen
On Mon, May 25, 2020 at 11:23:04AM +0200, Borislav Petkov wrote: > Enabling this gives: > > In file included from arch/x86/kernel/cpu/sgx/main.c:11: > arch/x86/kernel/cpu/sgx/encls.h:189:51: warning: ‘struct sgx_einittoken’ > declared inside parameter list will not be visible outside of this defi

Re: [PATCH v30 07/20] x86/sgx: Enumerate and track EPC sections

2020-05-27 Thread Borislav Petkov
On Tue, May 26, 2020 at 08:56:14PM -0700, Sean Christopherson wrote: > > > + if (i == ARRAY_SIZE(sgx_epc_sections)) { > > > + pr_warn("No free slot for an EPC section\n"); > > > + break; > > > + } > > > > This is also the loop termination: do we real

Re: [PATCH v30 07/20] x86/sgx: Enumerate and track EPC sections

2020-05-26 Thread Sean Christopherson
On Mon, May 25, 2020 at 11:23:04AM +0200, Borislav Petkov wrote: > On Fri, May 15, 2020 at 03:43:57AM +0300, Jarkko Sakkinen wrote: > > +struct sgx_epc_section sgx_epc_sections[SGX_MAX_EPC_SECTIONS]; > > +int sgx_nr_epc_sections; > > We have become very averse against global stuff. What is going t

Re: [PATCH v30 07/20] x86/sgx: Enumerate and track EPC sections

2020-05-25 Thread Borislav Petkov
On Fri, May 15, 2020 at 03:43:57AM +0300, Jarkko Sakkinen wrote: > +config INTEL_SGX > + bool "Intel SGX" > + depends on X86_64 && CPU_SUP_INTEL > + select SRCU > + select MMU_NOTIFIER > + help > + Intel(R) SGX is a set of CPU instructions that can be used by > + app

[PATCH v30 07/20] x86/sgx: Enumerate and track EPC sections

2020-05-14 Thread Jarkko Sakkinen
From: Sean Christopherson Enumerate Enclave Page Cache (EPC) sections via CPUID and add the data structures necessary to track EPC pages so that they can be allocated, freed and managed. As a system may have multiple EPC sections, invoke CPUID on SGX sub-leafs until an invalid leaf is encountered