Re: [PATCH v38 16/24] x86/sgx: Add a page reclaimer

2020-09-29 Thread Sean Christopherson
On Tue, Sep 29, 2020 at 06:50:10AM +0300, Jarkko Sakkinen wrote: > On Mon, Sep 28, 2020 at 06:14:39PM -0700, Sean Christopherson wrote: > > On Tue, Sep 22, 2020 at 05:03:23PM +0300, Jarkko Sakkinen wrote: > > > On Tue, Sep 22, 2020 at 12:45:38PM +0200, Borislav Petkov wrote: > > > > > + spin_lo

Re: [PATCH v38 16/24] x86/sgx: Add a page reclaimer

2020-09-28 Thread Jarkko Sakkinen
On Mon, Sep 28, 2020 at 06:14:39PM -0700, Sean Christopherson wrote: > On Tue, Sep 22, 2020 at 05:03:23PM +0300, Jarkko Sakkinen wrote: > > On Tue, Sep 22, 2020 at 12:45:38PM +0200, Borislav Petkov wrote: > > > > + spin_lock(&sgx_active_page_list_lock); > > > > + for (i = 0; i < SGX_NR_

Re: [PATCH v38 16/24] x86/sgx: Add a page reclaimer

2020-09-28 Thread Sean Christopherson
On Tue, Sep 22, 2020 at 05:03:23PM +0300, Jarkko Sakkinen wrote: > On Tue, Sep 22, 2020 at 12:45:38PM +0200, Borislav Petkov wrote: > > > + spin_lock(&sgx_active_page_list_lock); > > > + for (i = 0; i < SGX_NR_TO_SCAN; i++) { > > > + if (list_empty(&sgx_active_page_list)) > > > > Isn't it

Re: [PATCH v38 16/24] x86/sgx: Add a page reclaimer

2020-09-23 Thread Jarkko Sakkinen
> if (IS_ERR(va_page)) <- needed a new VA page, allocation failed > return PTR_ERR(va_page); > else if (va_page)<- needed a new VA page, allocation succeeded > list_add(&va_page->list, &encl->va_pages); > else ><- reused

Re: [PATCH v38 16/24] x86/sgx: Add a page reclaimer

2020-09-23 Thread Jarkko Sakkinen
On Tue, Sep 22, 2020 at 04:24:13PM +0200, Borislav Petkov wrote: > On Tue, Sep 22, 2020 at 05:03:23PM +0300, Jarkko Sakkinen wrote: > > On Tue, Sep 22, 2020 at 12:45:38PM +0200, Borislav Petkov wrote: > > > > + * %SGX_ENCL_PAGE_VA_OFFSET_MASK: Holds the offset in the Version > > > > Array > >

Re: [PATCH v38 16/24] x86/sgx: Add a page reclaimer

2020-09-22 Thread Borislav Petkov
On Tue, Sep 22, 2020 at 09:24:38AM -0700, Sean Christopherson wrote: > The "else if" is correct. Version Array (VA) pages have 512 slots that hold > metadata for evicted EPC pages, i.e. swapping a page out of the EPC requires > a VA slot. For simplicity (LOL), I'll say. > the approach we are ta

Re: [PATCH v38 16/24] x86/sgx: Add a page reclaimer

2020-09-22 Thread Sean Christopherson
On Tue, Sep 22, 2020 at 12:45:38PM +0200, Borislav Petkov wrote: > On Tue, Sep 15, 2020 at 02:28:34PM +0300, Jarkko Sakkinen wrote: > > + * %SGX_ENCL_PAGE_VA_OFFSET_MASK: Holds the offset in the Version Array > > + * (VA) page for a swapped page. > > * %SGX_ENCL_P

Re: [PATCH v38 16/24] x86/sgx: Add a page reclaimer

2020-09-22 Thread Borislav Petkov
On Tue, Sep 22, 2020 at 05:03:23PM +0300, Jarkko Sakkinen wrote: > On Tue, Sep 22, 2020 at 12:45:38PM +0200, Borislav Petkov wrote: > > > + * %SGX_ENCL_PAGE_VA_OFFSET_MASK:Holds the offset in the Version > > > Array > > > + * (VA) page for a swapped pa

Re: [PATCH v38 16/24] x86/sgx: Add a page reclaimer

2020-09-22 Thread Jarkko Sakkinen
On Tue, Sep 22, 2020 at 12:45:38PM +0200, Borislav Petkov wrote: > > + * %SGX_ENCL_PAGE_VA_OFFSET_MASK: Holds the offset in the Version Array > > + * (VA) page for a swapped page. > > * %SGX_ENCL_PAGE_ADDR_MASK: Holds the virtual address of > > the

Re: [PATCH v38 16/24] x86/sgx: Add a page reclaimer

2020-09-22 Thread Borislav Petkov
On Tue, Sep 15, 2020 at 02:28:34PM +0300, Jarkko Sakkinen wrote: > There is a limited amount of EPC available. Therefore, some of it must be > copied to the regular memory, and only subset kept in the SGX reserved > memory. While kernel cannot directly access enclave memory, SGX provides a > set of

[PATCH v38 16/24] x86/sgx: Add a page reclaimer

2020-09-15 Thread Jarkko Sakkinen
There is a limited amount of EPC available. Therefore, some of it must be copied to the regular memory, and only subset kept in the SGX reserved memory. While kernel cannot directly access enclave memory, SGX provides a set of ENCLS leaf functions to perform reclaiming. This commits implements a p

[PATCH v38 16/24] x86/sgx: Add a page reclaimer

2020-09-15 Thread Jarkko Sakkinen
There is a limited amount of EPC available. Therefore, some of it must be copied to the regular memory, and only subset kept in the SGX reserved memory. While kernel cannot directly access enclave memory, SGX provides a set of ENCLS leaf functions to perform reclaiming. This commits implements a p