When poison is discovered and triggers memory_failure() the physical page is unmapped from all process address space. However, it is not unmapped from kernel address space. Unlike a typical memory page that can be retired from use in the page allocator and marked 'not present', pmem needs to remain accessible given it can not be physically remapped or retired. set_memory_uc() tries to maintain consistent nominal memtype mappings for a given pfn, but memory_failure() is an exceptional condition.
For the same reason that set_memory_np() bypasses memtype checks because they do not apply in the memory failure case, memtype validation is not applicable for marking the pmem pfn uncacheable. Use _set_memory_uc(). Reported-by: Jane Chu <[email protected]> Fixes: 284ce4011ba6 ("x86/memory_failure: Introduce {set,clear}_mce_nospec()") Cc: Luis Chamberlain <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Tony Luck <[email protected]> Signed-off-by: Dan Williams <[email protected]> --- Jane, can you give this a try and see if it cleans up the error you are seeing? Thanks for the help. arch/x86/include/asm/set_memory.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/set_memory.h b/arch/x86/include/asm/set_memory.h index 43fa081a1adb..0bf2274c5186 100644 --- a/arch/x86/include/asm/set_memory.h +++ b/arch/x86/include/asm/set_memory.h @@ -114,8 +114,13 @@ static inline int set_mce_nospec(unsigned long pfn, bool unmap) if (unmap) rc = set_memory_np(decoy_addr, 1); - else - rc = set_memory_uc(decoy_addr, 1); + else { + /* + * Bypass memtype checks since memory-failure has shot + * down mappings. + */ + rc = _set_memory_uc(decoy_addr, 1); + } if (rc) pr_warn("Could not invalidate pfn=0x%lx from 1:1 map\n", pfn); return rc;
