[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Wed, 3 Feb 2021 00:43:50 +0200
From: Jarkko Sakkinen <jarkko@...nel.org>
To: Dave Hansen <dave.hansen@...el.com>
Cc: ira.weiny@...el.com, Sean Christopherson <seanjc@...gle.com>,
Jethro Beekman <jethro@...tanix.com>,
linux-kernel@...r.kernel.org, linux-sgx@...r.kernel.org
Subject: Re: [PATCH] x86: Remove unnecessary kmap() from
sgx_ioc_enclave_init()
On Tue, Feb 02, 2021 at 10:55:36AM -0800, Dave Hansen wrote:
> On 2/1/21 5:37 PM, ira.weiny@...el.com wrote:
> > kmap is inefficient and we are trying to reduce the usage in the kernel.
> > There is no readily apparent reason why the initp_page page needs to be
> > allocated and kmap'ed() but sigstruct needs to be page aligned and token
> > 512 byte aligned.
>
> Hi Ira,
>
> It's a *relatively* recent guaranteed, but:
>
> https://www.kernel.org/doc/Documentation/core-api/memory-allocation.rst
>
> says:
>
> > The address of a chunk allocated with `kmalloc` is aligned to at least
> > ARCH_KMALLOC_MINALIGN bytes. For sizes which are a power of two, the
> > alignment is also guaranteed to be at least the respective size.
>
> So, if you allocate a page with kmalloc(), you get an aligned page. Yay!
And this what we do sgx_ioc_enclave_create() anyway, as I stated in my
earlier response. Better to use the same pattern everywhere consitently
when it makes sense.
/Jarkko
Powered by blists - more mailing lists