Re: [PATCH v30 12/20] x86/sgx: Add a page reclaimer

2020-05-22 Thread Sean Christopherson
On Fri, May 22, 2020 at 10:57:05PM +0300, Jarkko Sakkinen wrote: > v31: > * Unset SGX_ENCL_IOCTL in the error path of checking encl->flags in order > to prevent leaving it set and thus block any further ioctl calls. > * Added missing cleanup_srcu_struct() call to sgx_encl_release(). > * Take encl

Re: [PATCH v30 12/20] x86/sgx: Add a page reclaimer

2020-05-22 Thread Jarkko Sakkinen
On Thu, May 21, 2020 at 11:58:02PM -0700, Sean Christopherson wrote: > > + kref_put(&encl_page->encl->refcount, sgx_encl_release); > > + > > + spin_lock(&sgx_active_page_list_lock); > > + list_add_tail(&epc_page->list, &sgx_active_page_list); > > + spin_unloc

Re: [PATCH v30 12/20] x86/sgx: Add a page reclaimer

2020-05-22 Thread Jarkko Sakkinen
On Fri, May 22, 2020 at 12:15:53AM -0700, Sean Christopherson wrote: > On Fri, May 15, 2020 at 03:44:02AM +0300, Jarkko Sakkinen wrote: > > +static void sgx_reclaimer_write(struct sgx_epc_page *epc_page, > > + struct sgx_backing *backing) > > +{ > > + struct sgx_encl_pag

Re: [PATCH v30 12/20] x86/sgx: Add a page reclaimer

2020-05-22 Thread Sean Christopherson
On Fri, May 15, 2020 at 03:44:02AM +0300, Jarkko Sakkinen wrote: > +static void sgx_reclaimer_write(struct sgx_epc_page *epc_page, > + struct sgx_backing *backing) > +{ > + struct sgx_encl_page *encl_page = epc_page->owner; > + struct sgx_encl *encl = encl_page->

Re: [PATCH v30 12/20] x86/sgx: Add a page reclaimer

2020-05-21 Thread Sean Christopherson
On Fri, May 15, 2020 at 03:44:02AM +0300, Jarkko Sakkinen wrote: > +/** > + * sgx_reclaim_pages() - Reclaim EPC pages from the consumers > + * > + * Take a fixed number of pages from the head of the active page pool and > + * reclaim them to the enclave's private shmem files. Skip the pages, which

[PATCH v30 12/20] x86/sgx: Add a page reclaimer

2020-05-14 Thread Jarkko Sakkinen
There is a limited amount of SGX reserved memory 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 ENCLS leaf functions to perform reclaiming functionality. This c