linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/sgx: Add poison handling to reclaimer
@ 2022-01-18 23:05 Reinette Chatre
  2022-01-19 19:51 ` Dave Hansen
  2022-01-20 12:57 ` Jarkko Sakkinen
  0 siblings, 2 replies; 6+ messages in thread
From: Reinette Chatre @ 2022-01-18 23:05 UTC (permalink / raw)
  To: tony.luck, dave.hansen, jarkko, tglx, bp, luto, mingo, linux-sgx, x86
  Cc: linux-kernel

The machine check recovery handling in SGX added the changes
listed below to the freeing of pages in sgx_free_epc_page().
The SGX reclaimer contains an open coded version of
sgx_free_epc_page() and thus did not obtain the changes in
support of poison handling.

The changes made to EPC page freeing in support of poison handling
are:
1) A new SGX_EPC_PAGE_IS_FREE flag is set when the EPC page is
   freed. Introduced in commit d6d261bded8a ("x86/sgx: Add new
   sgx_epc_page flag bit to mark free pages").
2) A new "poison" field in struct sgx_epc_page is used to
   determine whether a newly freed EPC page should be placed
   on the list of poisoned or list of free pages. Introduced
   in commit 992801ae9243 ("x86/sgx: Initial poison handling
   for dirty and free pages").
3) The owner field in struct sgx_epc_page is cleared when the EPC
   page is freed.  Introduced in commit 992801ae9243 ("x86/sgx:
   Initial poison handling for dirty and free pages").

Replace the open coded enclave page freeing code in the reclaimer
with sgx_free_epc_page() to obtain support for poison page handling.

Fixes: d6d261bded8a ("x86/sgx: Add new sgx_epc_page flag bit to mark free pages")
Fixes: 992801ae9243 ("x86/sgx: Initial poison handling for dirty and free pages")
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
 arch/x86/kernel/cpu/sgx/main.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c
index 4b41efc9e367..997a5d0bc488 100644
--- a/arch/x86/kernel/cpu/sgx/main.c
+++ b/arch/x86/kernel/cpu/sgx/main.c
@@ -418,13 +418,7 @@ static void sgx_reclaim_pages(void)
 		kref_put(&encl_page->encl->refcount, sgx_encl_release);
 		epc_page->flags &= ~SGX_EPC_PAGE_RECLAIMER_TRACKED;
 
-		section = &sgx_epc_sections[epc_page->section];
-		node = section->node;
-
-		spin_lock(&node->lock);
-		list_add_tail(&epc_page->list, &node->free_page_list);
-		spin_unlock(&node->lock);
-		atomic_long_inc(&sgx_nr_free_pages);
+		sgx_free_epc_page(epc_page);
 	}
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-01-20 15:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-18 23:05 [PATCH] x86/sgx: Add poison handling to reclaimer Reinette Chatre
2022-01-19 19:51 ` Dave Hansen
2022-01-19 20:47   ` Reinette Chatre
2022-01-19 20:56     ` Dave Hansen
2022-01-20 12:57 ` Jarkko Sakkinen
2022-01-20 15:28   ` Reinette Chatre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).