x86/sgx: Initial poison handling for dirty and free pages
authorTony Luck <tony.luck@intel.com>
Tue, 26 Oct 2021 22:00:46 +0000 (15:00 -0700)
committerDave Hansen <dave.hansen@linux.intel.com>
Mon, 15 Nov 2021 19:13:16 +0000 (11:13 -0800)
commit992801ae92431761b3d8ec88abd5793d154d34ac
tree41ebad4edc2061debcb9d2ddc3fddb0597fb459c
parent40e0e7843e23d164625b9031514f5672f8758bf4
x86/sgx: Initial poison handling for dirty and free pages

A memory controller patrol scrubber can report poison in a page
that isn't currently being used.

Add "poison" field in the sgx_epc_page that can be set for an
sgx_epc_page. Check for it:
1) When sanitizing dirty pages
2) When freeing epc pages

Poison is a new field separated from flags to avoid having to make all
updates to flags atomic, or integrate poison state changes into some
other locking scheme to protect flags (Currently just sgx_reclaimer_lock
which protects the SGX_EPC_PAGE_RECLAIMER_TRACKED bit in page->flags).

In both cases place the poisoned page on a per-node list of poisoned
epc pages to make sure it will not be reallocated.

Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Tested-by: Reinette Chatre <reinette.chatre@intel.com>
Link: https://lkml.kernel.org/r/20211026220050.697075-4-tony.luck@intel.com
arch/x86/kernel/cpu/sgx/main.c
arch/x86/kernel/cpu/sgx/sgx.h