lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200529032816.GC6182@linux.intel.com>
Date:   Fri, 29 May 2020 06:28:16 +0300
From:   Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>
To:     Sean Christopherson <sean.j.christopherson@...el.com>
Cc:     Borislav Petkov <bp@...en8.de>, linux-kernel@...r.kernel.org,
        x86@...nel.org, linux-sgx@...r.kernel.org,
        akpm@...ux-foundation.org, dave.hansen@...el.com,
        nhorman@...hat.com, npmccallum@...hat.com, haitao.huang@...el.com,
        andriy.shevchenko@...ux.intel.com, tglx@...utronix.de,
        kai.svahn@...el.com, josh@...htriplett.org, luto@...nel.org,
        kai.huang@...el.com, rientjes@...gle.com, cedric.xing@...el.com,
        puiterwijk@...hat.com, Jethro Beekman <jethro@...tanix.com>
Subject: Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free
 EPC pages

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 allocating a page from the EPC
> > > sections so I'd call them:
> > > 
> > > sgx_try_alloc_page    -> sgx_alloc_epc_page_section
> > > __sgx_try_alloc_page  -> __sgx_alloc_epc_page_section
> > > 
> > > former doing the loop, latter doing the per-section list games.
> > 
> > sgx_alloc_epc_page_section() is a bit nasty and long name to use for
> > grabbing a page. And even the documentation spoke about grabbing before
> > this naming discussion. I think it is a great description what is going
> > on.  Everytime I talk about the subject I talk about grabbing.
> > Lets just say that your suggestion, I could not use in a conference
> > talk as a verb when I describe what is going on. That function
> > signature does not fit to my mouth :-) I would talk about
> > grabbing a page.
> 
> "allocate an EPC page from the specified section"
> 
> It also works if/when we add NUMA awareness, e.g. sgx_alloc_epc_page_node()
> means "allocate an EPC page from the specified node".  Note that I'm not
> inventing these from scratch, simply stealing them from alloc_pages() and
> alloc_pages_node().  The section thing is unique to SGX, but the underlying
> concept is the same.

Then it should be sgx_alloc_epc_page_from_section() if you go with that.
Otherwise it is mixes too much with the section. I did read these mails
first quickly and first thought that functions were doing something with
sgx_epc_section and not with pages.

Only with a deeper look that it's the name for allocating a page.

I think both names are waste of screen estate. Too long.

> >  * sgx_grab_page() - Grab a free EPC page
> >  * @owner:	the owner of the EPC page
> >  * @reclaim:	reclaim pages if necessary
> >  *
> >  * Iterate through EPC sections and borrow a free EPC page to the caller. When a
> >  * page is no longer needed it must be released with sgx_free_page(). If
> >  * @reclaim is set to true, directly reclaim pages when we are out of pages. No
> >  * mm's can be locked when @reclaim is set to true.
> >  *
> >  * Finally, wake up ksgxswapd when the number of pages goes below the watermark
> >  * before returning back to the caller.
> >  *
> >  * Return:
> >  *   an EPC page,
> >  *   -errno on error
> >  */
> > 
> > I also rewrote the kdoc.
> > 
> > I do agree that sgx_try_grab_page() should be renamed as __sgx_grab_page().
> 
> FWIW, I really, really dislike "grab".  The nomenclature for normal memory
> and pages uses "alloc" when taking a page off a free list, and "grab" when
> elevating the refcount.  I don't understand the motivation for diverging
> from that.  SGX is weird enough as is, using names that don't align with
> exist norms will only serve to further obfuscate the code.

OK, what would be a better name then? The semantics are not standard
memory allocation semantics in the first place. And kdoc in v30 speaks
about grabbing.

/Jarkko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ