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

Borislav Petkov
2020-09-22T18:02:20Z

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 taking for initial support is to reserve a VA slot
> when adding a page to the enclave[*]. In most cases, reserving a slot
> does not require allocating a new VA page, e.g. to reserve slots 1-511
> of the "current" VA page. The if-elif is handling the case where the
> current VA page is fully reserved and a new one needs to be allocated.
> The if handles the error, the elif handles success, i.e.
>
> 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 the current VA page

Aha, in that case va_page will be NULL but you're not using it in that
function later and that current VA page is on encl->va_pages which
others can get from there. Ok, gotcha.

Thx.

--
Regards/Gruss,
Boris.