Re: [PATCH 1/2] x86/sgx: Replace section->init_laundry_list with sgx_dirty_page_list

From: Borislav Petkov
Date: Thu Mar 18 2021 - 13:41:14 EST


On Thu, Mar 18, 2021 at 01:53:30AM +0200, Jarkko Sakkinen wrote:
> From: Jarkko Sakkinen <jarkko@xxxxxxxxxx>
>
> During normal runtime, the "ksgxd" daemon behaves like a version of
> kswapd just for SGX. But, before it starts acting like kswapd, its
> first job is to initialize enclave memory.
>
> Currently, the SGX boot code places each enclave page on a
> epc_section->init_laundry_list. Once it starts up, the ksgxd code walks
> over that list and populates the actual SGX page allocator.
>
> However, the per-section structures are going away to make way for the SGX
> NUMA allocator. There's also little need to have a per-section structure;
> the enclave pages are all treated identically, and they can be placed on
> the correct allocator list from metadata stored in the enclave page
> (struct sgx_epc_page) itself.
>
> Modify sgx_sanitize_section() to take a single page list instead of taking
> a section and deriving the list from there.
>
> Signed-off-by: Jarkko Sakkinen <jarkko@xxxxxxxxxx>
> Acked-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> ---
>
> v5
> * Refine the commit message.
> * Refine inline comments.
> * Encapsulate a sanitization pass into __sgx_sanitize_pages().
>
> v4:
> * Open coded sgx_santize_section() to ksgxd().
> * Rewrote the commit message.
>
> arch/x86/kernel/cpu/sgx/main.c | 54 ++++++++++++++++------------------
> arch/x86/kernel/cpu/sgx/sgx.h | 7 -----
> 2 files changed, 25 insertions(+), 36 deletions(-)

So both patches look ok to me but the sgx test case fails on -rc3 with and
without those patches on my box:

./test_sgx
0x0000000000000000 0x0000000000002000 0x03
0x0000000000002000 0x0000000000001000 0x05
0x0000000000003000 0x0000000000003000 0x03
mmap() failed, errno=1.

Box is:

[ 0.138402] smpboot: CPU0: Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz (family: 0x6, model: 0x9e, stepping: 0xc)
[ 0.693947] sgx: EPC section 0x80200000-0x85ffffff

And AFAIR that test used to pass there...

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette