TencentOS-kernel/arch
Tony Luck da32e8fd84 x86/{mce,mm}: Unmap the entire page if the whole page is affected and poisoned
commit 17fae1294ad9d711b2c3dd0edef479d40c76a5e8 upstream.

An interesting thing happened when a guest Linux instance took a machine
check. The VMM unmapped the bad page from guest physical space and
passed the machine check to the guest.

Linux took all the normal actions to offline the page from the process
that was using it. But then guest Linux crashed because it said there
was a second machine check inside the kernel with this stack trace:

do_memory_failure
    set_mce_nospec
         set_memory_uc
              _set_memory_uc
                   change_page_attr_set_clr
                        cpa_flush
                             clflush_cache_range_opt

This was odd, because a CLFLUSH instruction shouldn't raise a machine
check (it isn't consuming the data). Further investigation showed that
the VMM had passed in another machine check because is appeared that the
guest was accessing the bad page.

Fix is to check the scope of the poison by checking the MCi_MISC register.
If the entire page is affected, then unmap the page. If only part of the
page is affected, then mark the page as uncacheable.

This assumes that VMMs will do the logical thing and pass in the "whole
page scope" via the MCi_MISC register (since they unmapped the entire
page).

  [ bp: Adjust to x86/entry changes. ]

Fixes: 284ce4011ba6 ("x86/memory_failure: Introduce {set, clear}_mce_nospec()")
Reported-by: Jue Wang <juew@google.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Jue Wang <juew@google.com>
Cc: <stable@vger.kernel.org>
Link: https://lkml.kernel.org/r/20200520163546.GA7977@agluck-desk2.amr.corp.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-03-16 16:29:06 +08:00
..
alpha Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
arc ARC: [plat-eznps]: Restrict to CONFIG_ISA_ARCOMPACT 2021-03-16 16:28:46 +08:00
arm ARM: 8977/1: ptrace: Fix mask for thumb breakpoint hook 2021-03-16 16:28:55 +08:00
arm64 arm64: acpi: fix UBSAN warning 2021-03-16 16:29:03 +08:00
c6x Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
csky csky: Fixup abiv2 syscall_trace break a4 & a5 2021-03-16 16:28:56 +08:00
h8300 Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
hexagon hexagon: define ioremap_uc 2021-03-16 16:27:29 +08:00
ia64 Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
m68k Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
microblaze Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
mips MIPS: OCTEON: irq: Fix potential NULL pointer dereference 2021-03-16 16:26:05 +08:00
nds32 Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
nios2 Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
openrisc Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
parisc parisc: Fix kernel panic in mem_init() 2021-03-16 16:28:37 +08:00
powerpc powerpc/ptdump: Properly handle non standard page size 2021-03-16 16:29:01 +08:00
riscv riscv: stacktrace: Fix undefined reference to `walk_stackframe' 2021-03-16 16:28:30 +08:00
s390 s390/pci: Log new handle in clp_disable_fh() 2021-03-16 16:28:57 +08:00
sh Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
sparc Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
um um: ensure `make ARCH=um mrproper` removes arch/$(SUBARCH)/include/generated/ 2021-03-16 16:27:11 +08:00
unicore32 Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
x86 x86/{mce,mm}: Unmap the entire page if the whole page is affected and poisoned 2021-03-16 16:29:06 +08:00
xtensa Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
.gitignore Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
Kconfig Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00