aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memory-failure.c
diff options
context:
space:
mode:
authorTony Luck <tony.luck@intel.com>2021-10-26 15:00:48 -0700
committerDave Hansen <dave.hansen@linux.intel.com>2021-11-15 11:13:16 -0800
commit03b122da74b22fbe7cd98184fa5657a9ce13970c (patch)
tree8facf7bfc6961ff9dfd924ac0d17da0ab4a277a7 /mm/memory-failure.c
parenta495cbdffa30558b34f3c95555cecc4fd9688039 (diff)
downloadlinux-03b122da74b22fbe7cd98184fa5657a9ce13970c.tar.gz
x86/sgx: Hook arch_memory_failure() into mainline code
Add a call inside memory_failure() to call the arch specific code 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. Pull the call to acquire the mutex earlier so the SGX errors are also protected. Make set_mce_nospec() skip SGX pages when trying to adjust the 1:1 map. 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> Reviewed-by: Naoya Horiguchi <naoya.horiguchi@nec.com> Tested-by: Reinette Chatre <reinette.chatre@intel.com> Link: https://lkml.kernel.org/r/20211026220050.697075-6-tony.luck@intel.com
Diffstat (limited to 'mm/memory-failure.c')
-rw-r--r--mm/memory-failure.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 07c875fdeaf0c..fddee33bc6cbf 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1651,21 +1651,28 @@ int memory_failure(unsigned long pfn, int flags)
if (!sysctl_memory_failure_recovery)
panic("Memory failure on page %lx", pfn);
+ mutex_lock(&mf_mutex);
+
p = pfn_to_online_page(pfn);
if (!p) {
+ res = arch_memory_failure(pfn, flags);
+ if (res == 0)
+ goto unlock_mutex;
+
if (pfn_valid(pfn)) {
pgmap = get_dev_pagemap(pfn, NULL);
- if (pgmap)
- return memory_failure_dev_pagemap(pfn, flags,
- pgmap);
+ if (pgmap) {
+ res = memory_failure_dev_pagemap(pfn, flags,
+ pgmap);
+ goto unlock_mutex;
+ }
}
pr_err("Memory failure: %#lx: memory outside kernel control\n",
pfn);
- return -ENXIO;
+ res = -ENXIO;
+ goto unlock_mutex;
}
- mutex_lock(&mf_mutex);
-
try_again:
if (PageHuge(p)) {
res = memory_failure_hugetlb(pfn, flags);