public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: sgx: Don't track poisoned pages for reclaiming
@ 2025-02-11 15:01 Andrew Zaborowski
  2025-02-11 16:25 ` Dave Hansen
  0 siblings, 1 reply; 11+ messages in thread
From: Andrew Zaborowski @ 2025-02-11 15:01 UTC (permalink / raw)
  To: x86, linux-sgx, linux-kernel
  Cc: Dave Hansen, Tony Luck, Thomas Gleixner, Borislav Petkov,
	Ingo Molnar, H . Peter Anvin, balrogg

Pages used by an enclave only get page->poison set in
arch_memory_failure() but stay on sgx_active_page_list.
page->poison is not checked in the reclaimer logic meaning that a page could be
reclaimed and go through ETRACK, EBLOCK and EWB.  This can lead to the
firmware receiving and MCE in one of those operations and going into
"unbreakable shutdown" and triggering a kernel panic on remaining cores.

Remove the affected page from sgx_active_page_list but don't add it
immediately to &node->sgx_poison_page_list to keep most of the current
semantics.  It'll be added to &node->sgx_poison_page_list later in
sgx_encl_release()->sgx_free_epc_page()

Tested with CONFIG_PROVE_LOCKING as suggested by Tony Luck.

Signed-off-by: Andrew Zaborowski <andrew.zaborowski@intel.com>
---
 arch/x86/kernel/cpu/sgx/main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c
index 671c26513..7076464d4 100644
--- a/arch/x86/kernel/cpu/sgx/main.c
+++ b/arch/x86/kernel/cpu/sgx/main.c
@@ -719,6 +719,8 @@ int arch_memory_failure(unsigned long pfn, int flags)
 		goto out;
 	}
 
+	sgx_unmark_page_reclaimable(page);
+
 	/*
 	 * TBD: Add additional plumbing to enable pre-emptive
 	 * action for asynchronous poison notification. Until
-- 
2.43.5


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

end of thread, other threads:[~2025-02-12 21:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-11 15:01 [PATCH] x86: sgx: Don't track poisoned pages for reclaiming Andrew Zaborowski
2025-02-11 16:25 ` Dave Hansen
2025-02-11 21:03   ` Jarkko Sakkinen
2025-02-11 21:18     ` Huang, Kai
2025-02-11 23:24       ` Jarkko Sakkinen
2025-02-11 23:31       ` Dave Hansen
2025-02-12  0:32         ` andrzej zaborowski
2025-02-12  0:37           ` Dave Hansen
2025-02-12 10:38         ` Huang, Kai
2025-02-12 21:25         ` Jarkko Sakkinen
2025-02-12  0:22   ` Andrew Zaborowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox