lkml.org 
[lkml]   [2021]   [Jun]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 3/4] x86/sgx: Hook sgx_memory_failure() into mainline code
Date
Add a call inside memory_failure() to check if the address is an SGX
EPC page and handle it.

Note the SGX EPC pages do not have a "struct page" entry, so the hook
goes in at the same point as the device mapping hook.

Signed-off-by: Tony Luck <tony.luck@intel.com>
---
include/linux/mm.h | 9 +++++++++
mm/memory-failure.c | 4 ++++
2 files changed, 13 insertions(+)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index c274f75efcf9..8ad4c513d4cc 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3248,5 +3248,14 @@ static inline int seal_check_future_write(int seals, struct vm_area_struct *vma)
return 0;
}

+#ifdef CONFIG_X86_SGX
+int sgx_memory_failure(unsigned long pfn, int flags);
+#else
+static inline int sgx_memory_failure(unsigned long pfn, int flags)
+{
+ return -ENXIO;
+}
+#endif
+
#endif /* __KERNEL__ */
#endif /* _LINUX_MM_H */
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 85ad98c00fd9..c2ade18fd8d5 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1413,6 +1413,10 @@ int memory_failure(unsigned long pfn, int flags)

p = pfn_to_online_page(pfn);
if (!p) {
+ res = sgx_memory_failure(pfn, flags);
+ if (res == 0)
+ return 0;
+
if (pfn_valid(pfn)) {
pgmap = get_dev_pagemap(pfn, NULL);
if (pgmap)
--
2.29.2
\
 
 \ /
  Last update: 2021-06-08 23:42    [W:0.086 / U:0.236 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site