Re: [PATCH v3 4/7] x86/sgx: Add SGX infrastructure to recover from poison

From: Dave Hansen
Date: Wed Jul 28 2021 - 18:29:42 EST


On 7/28/21 1:46 PM, Tony Luck wrote:
> +int sgx_memory_failure(unsigned long pfn, int flags)
> +{
...
> + page->flags |= SGX_EPC_PAGE_POISON;

Is this safe outside of any locks?

I see the reclaimer doing things like:

epc_page->flags &= ~SGX_EPC_PAGE_RECLAIMER_TRACKED;

I'd worry that this code and other non-atomic epc_page->flags
manipulation could trample on each other.

This might need to some some atomic bit manipulation *and* convert all
the other epc_page->flags users.