x86/mce: Fix set_mce_nospec() to avoid #GP fault
authorLuckTony <tony.luck@intel.com>
Fri, 31 Aug 2018 16:55:06 +0000 (09:55 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Sat, 1 Sep 2018 12:59:19 +0000 (14:59 +0200)
commitc7486104a5ce7e8763e3cb5157bba8d0f1468d87
tree2ee0f08523889787829bf370b0f3566855dd0f01
parenteeb89e2bb1ac45b0836d4170e97a988c3a746c62
x86/mce: Fix set_mce_nospec() to avoid #GP fault

The trick with flipping bit 63 to avoid loading the address of the 1:1
mapping of the poisoned page while the 1:1 map is updated used to work when
unmapping the page. But it falls down horribly when attempting to directly
set the page as uncacheable.

The problem is that when the cache mode is changed to uncachable, the pages
needs to be flushed from the cache first. But the decoy address is
non-canonical due to bit 63 flipped, and the CLFLUSH instruction throws a
#GP fault.

Add code to change_page_attr_set_clr() to fix the address before calling
flush.

Fixes: 284ce4011ba6 ("x86/memory_failure: Introduce {set, clear}_mce_nospec()")
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Anvin <hpa@zytor.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: linux-edac <linux-edac@vger.kernel.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Link: https://lkml.kernel.org/r/20180831165506.GA9605@agluck-desk
arch/x86/mm/pageattr.c