Re: [PATCH] x86/sgx: Suppress WARN on inability to sanitize EPC if ksgxd is stopped

From: Dave Hansen
Date: Fri Jun 18 2021 - 11:41:31 EST


On 6/17/21 9:45 AM, Borislav Petkov wrote:
> Hmm, this looks weird. Why aren't we starting ksgxd only after
> *everything* has initialized successfully? I.e., after both kvm and
> native drivers' init functions have succeeded?

ksgxd has two roles. I think that's why it looks weird.

The obvious role is its use as the kswapd equivalent for SGX.

But, it's also used to speed up SGX initialization. It "sanitizes" the
EPC asynchronously because it can take quite a while. That's why it
gets launched off early. If it gets interrupted, that's when this
warning can trigger.

I think you're suggesting that we just defer starting ksgxd until we
*know* it won't be interrupted, basically moving
sgx_page_reclaimer_init() down below sgx_drv_init() and sgx_vepc_init().

While I can see why it's best to get it going as early as possible, I
don't see much going on in those init functions that would justify
needing to fork off ksgx earlier. Am I missing anything?