Re: [PATCH v24 08/24] x86/sgx: Enumerate and track EPC sections

From: Sean Christopherson
Date: Wed Dec 18 2019 - 10:19:47 EST


On Wed, Dec 18, 2019 at 10:18:56AM +0100, Borislav Petkov wrote:
> On Sat, Nov 30, 2019 at 01:13:10AM +0200, Jarkko Sakkinen wrote:
> > +static bool __init sgx_alloc_epc_section(u64 addr, u64 size,
> > + unsigned long index,
> > + struct sgx_epc_section *section)
> > +{
> > + unsigned long nr_pages = size >> PAGE_SHIFT;
>
> I'm assuming here that size which gets communicated through CPUID -
> which is an interesting way to communicate SGX settings in itself :-) - is
> in multiples of 4K? SDM doesn't say...

Yes, EPC pages are architecturally defined to be 4k sized and aligned.

36.5 Enclave Page Cache

The EPC is divided into EPC pages. An EPC page is 4KB in size and always
aligned on a 4KB boundary.