Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-29 Thread Jarkko Sakkinen
On Fri, May 29, 2020 at 11:13:09AM +0300, Jarkko Sakkinen wrote: > On Thu, May 28, 2020 at 08:37:16PM -0700, Sean Christopherson wrote: > > On Fri, May 29, 2020 at 06:28:16AM +0300, Jarkko Sakkinen wrote: > > > On Thu, May 28, 2020 at 12:59:17PM -0700, Sean Christopherson wrote: > > > > On Thu, May

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-29 Thread Jarkko Sakkinen
On Thu, May 28, 2020 at 08:37:16PM -0700, Sean Christopherson wrote: > On Fri, May 29, 2020 at 06:28:16AM +0300, Jarkko Sakkinen wrote: > > On Thu, May 28, 2020 at 12:59:17PM -0700, Sean Christopherson wrote: > > > On Thu, May 28, 2020 at 10:07:18PM +0300, Jarkko Sakkinen wrote: > > > > * sgx_grab

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-28 Thread Jarkko Sakkinen
On Thu, May 28, 2020 at 08:37:16PM -0700, Sean Christopherson wrote: > On Fri, May 29, 2020 at 06:28:16AM +0300, Jarkko Sakkinen wrote: > > On Thu, May 28, 2020 at 12:59:17PM -0700, Sean Christopherson wrote: > > > On Thu, May 28, 2020 at 10:07:18PM +0300, Jarkko Sakkinen wrote: > > > > * sgx_grab

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-28 Thread Jarkko Sakkinen
On Fri, May 29, 2020 at 06:28:28AM +0300, Jarkko Sakkinen wrote: > On Thu, May 28, 2020 at 12:59:17PM -0700, Sean Christopherson wrote: > > On Thu, May 28, 2020 at 10:07:18PM +0300, Jarkko Sakkinen wrote: > > > On Thu, May 28, 2020 at 07:16:35PM +0200, Borislav Petkov wrote: > > > > Lemme reply to

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-28 Thread Sean Christopherson
On Fri, May 29, 2020 at 06:28:16AM +0300, Jarkko Sakkinen wrote: > On Thu, May 28, 2020 at 12:59:17PM -0700, Sean Christopherson wrote: > > On Thu, May 28, 2020 at 10:07:18PM +0300, Jarkko Sakkinen wrote: > > > * sgx_grab_page() - Grab a free EPC page > > > * @owner:the owner of the EPC p

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-28 Thread Jarkko Sakkinen
On Thu, May 28, 2020 at 12:59:17PM -0700, Sean Christopherson wrote: > On Thu, May 28, 2020 at 10:07:18PM +0300, Jarkko Sakkinen wrote: > > On Thu, May 28, 2020 at 07:16:35PM +0200, Borislav Petkov wrote: > > > Lemme reply to all mails with one. :-) > > > And except those last two. Those are alloca

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-28 Thread Sean Christopherson
On Thu, May 28, 2020 at 10:07:18PM +0300, Jarkko Sakkinen wrote: > On Thu, May 28, 2020 at 07:16:35PM +0200, Borislav Petkov wrote: > > Lemme reply to all mails with one. :-) > > And except those last two. Those are allocating a page from the EPC > > sections so I'd call them: > > > > sgx_try_allo

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-28 Thread Jarkko Sakkinen
On Thu, May 28, 2020 at 07:16:35PM +0200, Borislav Petkov wrote: > Lemme reply to all mails with one. :-) > > I think Sean almost had it: > > > sgx_alloc_epc_section -> sgx_map_epc_section > > sgx_free_epc_section -> sgx_unmap_epc_section > > Or even > > sgx_setup_epc_section() > sgx_fre

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-28 Thread Sean Christopherson
On Thu, May 28, 2020 at 07:27:24PM +0200, Borislav Petkov wrote: > On Thu, May 28, 2020 at 10:19:37AM -0700, Sean Christopherson wrote: > > On Thu, May 28, 2020 at 07:16:35PM +0200, Borislav Petkov wrote: > > > * sgx_alloc_page - allocates an EPC page > > > > Did you want this to be sgx_alloc_epc_

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-28 Thread Borislav Petkov
On Thu, May 28, 2020 at 10:19:37AM -0700, Sean Christopherson wrote: > On Thu, May 28, 2020 at 07:16:35PM +0200, Borislav Petkov wrote: > > * sgx_alloc_page - allocates an EPC page > > Did you want this to be sgx_alloc_epc_page? Whatever you guys prefer. I'd use "sgx_alloc_page" because it return

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-28 Thread Sean Christopherson
On Thu, May 28, 2020 at 07:16:35PM +0200, Borislav Petkov wrote: > * sgx_alloc_page - allocates an EPC page Did you want this to be sgx_alloc_epc_page?

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-28 Thread Borislav Petkov
Lemme reply to all mails with one. :-) I think Sean almost had it: > sgx_alloc_epc_section -> sgx_map_epc_section > sgx_free_epc_section -> sgx_unmap_epc_section Or even sgx_setup_epc_section() sgx_free_epc_section() > sgx_alloc_page-> sgx_alloc_epc_page > sgx_free_page

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-27 Thread Jarkko Sakkinen
On Wed, May 27, 2020 at 06:36:18PM -0700, Sean Christopherson wrote: > On Thu, May 28, 2020 at 04:23:19AM +0300, Jarkko Sakkinen wrote: > > On Wed, May 27, 2020 at 10:46:38PM +0200, Borislav Petkov wrote: > > > On Tue, May 26, 2020 at 09:21:11PM -0700, Sean Christopherson wrote: > > > > In other wo

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-27 Thread Jarkko Sakkinen
On Wed, May 27, 2020 at 05:52:17PM -0700, Sean Christopherson wrote: > On Wed, May 27, 2020 at 10:46:38PM +0200, Borislav Petkov wrote: > > On Tue, May 26, 2020 at 09:21:11PM -0700, Sean Christopherson wrote: > > > In other words, sgx_alloc_epc_section() is poorly named. It doesn't > > > actually

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-27 Thread Sean Christopherson
On Thu, May 28, 2020 at 04:23:19AM +0300, Jarkko Sakkinen wrote: > On Wed, May 27, 2020 at 10:46:38PM +0200, Borislav Petkov wrote: > > On Tue, May 26, 2020 at 09:21:11PM -0700, Sean Christopherson wrote: > > > In other words, sgx_alloc_epc_section() is poorly named. It doesn't > > > actually allo

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-27 Thread Jarkko Sakkinen
On Wed, May 27, 2020 at 10:46:38PM +0200, Borislav Petkov wrote: > On Tue, May 26, 2020 at 09:21:11PM -0700, Sean Christopherson wrote: > > In other words, sgx_alloc_epc_section() is poorly named. It doesn't > > actually allocate EPC, it allocates kernel structures to map and track EPC. > > sgx_(u

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-27 Thread Sean Christopherson
On Wed, May 27, 2020 at 10:46:38PM +0200, Borislav Petkov wrote: > On Tue, May 26, 2020 at 09:21:11PM -0700, Sean Christopherson wrote: > > In other words, sgx_alloc_epc_section() is poorly named. It doesn't > > actually allocate EPC, it allocates kernel structures to map and track EPC. > > sgx_(u

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-27 Thread Borislav Petkov
On Tue, May 26, 2020 at 09:21:11PM -0700, Sean Christopherson wrote: > In other words, sgx_alloc_epc_section() is poorly named. It doesn't > actually allocate EPC, it allocates kernel structures to map and track EPC. > sgx_(un)map_epc_section() would be more accurate and would hopefully > alleviat

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-26 Thread Sean Christopherson
On Tue, May 26, 2020 at 02:52:08PM +0200, Borislav Petkov wrote: > On Fri, May 15, 2020 at 03:43:58AM +0300, Jarkko Sakkinen wrote: > > diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c > > index 38424c1e8341..60d82e7537c8 100644 > > --- a/arch/x86/kernel/cpu/sgx/main.c >

Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-26 Thread Borislav Petkov
On Fri, May 15, 2020 at 03:43:58AM +0300, Jarkko Sakkinen wrote: > Add functions for allocating page from Enclave Page Cache (EPC). A page is pages > allocated by going through the EPC sections and returning the first free > page. > > When a page is freed, it migh

[PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages

2020-05-14 Thread Jarkko Sakkinen
Add functions for allocating page from Enclave Page Cache (EPC). A page is allocated by going through the EPC sections and returning the first free page. When a page is freed, it might have a valid state, which means that the callee has assigned it to an enclave, which are protected memory ares us