Re: [PATCH v3 1/2] x86/sgx: Use sgx_nr_used_pages for EPC page count instead of sgx_nr_free_pages
From: Jarkko Sakkinen
Date: Wed Apr 16 2025 - 14:50:55 EST
On Tue, Apr 15, 2025 at 02:51:21PM +0300, Elena Reshetova wrote:
> Note: The serialization for sgx_nr_total_pages is not needed because
> the variable is only updated during the initialization and there's no
> concurrent access.
No. It's
- not a side-note but core part of the rationale.
- the reasoning here is nonsense, or more like it does not exist at all.
sgx_nr_free_pages can be substituted with sgx_nr_used_pages at the sites
where sgx_free_pages was previously used *exactly* because
sgx_reclaimer_init() is called only after sgx_page_cache_init(). This
gives the invariant of it to be constant whenever sgx_alloc_epc_page()
is called.
These type of changes give a proof of the legitimity of the invariant,
which I addressed here.
BR, Jarkko