x86/mm, mm/hwpoison: Don't unconditionally unmap kernel 1:1 pages.
Subsystems (5)
PATCH 1/1 x86/mm, mm/hwpoison: Don't unconditionally unmap kernel 1:1 pages.
In ce0fa3e56ad2 ("x86/mm, mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings of poison pages") we added code to memory_failure() to unmap the page from the kernel 1:1 virtual address space to avoid speculative access to the page logging additional errors.
But memory_failure() may not always succeed in taking the page offline, especially if the page belongs to the kernel. This can happen if there are too many corrected errors on a page and either mcelog(8) or drivers/ras/cec.c asks to take a page offline.
Since we remove the 1:1 mapping early in memory_failure(), we can end up with the page unmapped, but still in use. On the next access the kernel crashes :-(
There are also various debug paths that call memory_failure() to simulate occurrence of an error. Since there is no actual error in memory, we don't need to map out the page for those cases.
Revert most of the previous attempt and keep the solution local to arch/x86/kernel/cpu/mcheck/mce.c. Unmap the page only when:
1) there is a real error
2) memory_failure() succeeds.
--- arch/x86/include/asm/page_64.h | 4 -- arch/x86/kernel/cpu/mcheck/mce.c | 85 ++++++++++++++++++++-------------------- include/linux/mm_inline.h | 6 --- mm/memory-failure.c | 2 - 4 files changed, 42 insertions(+), 55 deletions(-)
arch/x86/include/asm/page_64.h +0 -4
@@ -52,10 +52,6 @@ static inline void clear_page(void *page)void copy_page (void *to,void *from); -#ifdef CONFIG_X86_MCE -#define arch_unmap_kpfn arch_unmap_kpfn -#endif -#endif /* !__ASSEMBLY__ */ #ifdef CONFIG_X86_VSYSCALL_EMULATION
arch/x86/kernel/cpu/mcheck/mce.c +42 -43
106 lines not on this page · raw message
include/linux/mm_inline.h +0 -6
@@ -127,10 +127,4 @@ static __always_inline enum lru_list page_lru(struct page *page)#define lru_to_page (head) (list_entry((head)->prev, struct page, lru)) -#ifdef arch_unmap_kpfn -extern void arch_unmap_kpfn (unsigned long pfn); -#else -static __always_inline void arch_unmap_kpfn(unsigned long pfn) { } -#endif -#endif
mm/memory-failure.c +0 -2
@@ -1146,8 +1146,6 @@ int memory_failure(unsigned long pfn, int trapno, int flags)return 0 ; } -arch_unmap_kpfn (pfn); - orig_head = hpage =compound_head (p);num_poisoned_pages_inc ();
Signature · 7 lines
2.14.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>