linux-stable/arch/x86/lib
Youquan Song 3376136300 x86/mce: Reduce number of machine checks taken during recovery
When any of the copy functions in arch/x86/lib/copy_user_64.S take a
fault, the fixup code copies the remaining byte count from %ecx to %edx
and unconditionally jumps to .Lcopy_user_handle_tail to continue the
copy in case any more bytes can be copied.

If the fault was #PF this may copy more bytes (because the page fault
handler might have fixed the fault). But when the fault is a machine
check the original copy code will have copied all the way to the poisoned
cache line. So .Lcopy_user_handle_tail will just take another machine
check for no good reason.

Every code path to .Lcopy_user_handle_tail comes from an exception fixup
path, so add a check there to check the trap type (in %eax) and simply
return the count of remaining bytes if the trap was a machine check.

Doing this reduces the number of machine checks taken during synthetic
tests from four to three.

As well as reducing the number of machine checks, this also allows
Skylake generation Xeons to recover some cases that currently fail. The
is because REP; MOVSB is only recoverable when source and destination
are well aligned and the byte count is large. That useless call to
.Lcopy_user_handle_tail may violate one or more of these conditions and
generate a fatal machine check.

  [ Tony: Add more details to commit message. ]
  [ bp: Fixup comment.
    Also, another tip patchset which is adding straight-line speculation
    mitigation changes the "ret" instruction to an all-caps macro "RET".
    But, since gas is case-insensitive, use "RET" in the newly added asm block
    already in order to simplify tip branch merging on its way upstream.
  ]

Signed-off-by: Youquan Song <youquan.song@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lore.kernel.org/r/YcTW5dh8yTGucDd+@agluck-desk2.amr.corp.intel.com
2021-12-31 18:22:32 +01:00
..
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
atomic64_32.c
atomic64_386_32.S x86/alternative: Merge include files 2021-03-11 15:58:02 +01:00
atomic64_cx8_32.S x86/alternative: Merge include files 2021-03-11 15:58:02 +01:00
cache-smp.c smp: Remove smp_call_function() and on_each_cpu() return values 2019-06-23 14:26:26 +02:00
checksum_32.S i386: propagate the calling conventions change down to csum_partial_copy_generic() 2020-08-20 15:45:18 -04:00
clear_page_64.S x86/asm: Change all ENTRY+ENDPROC to SYM_FUNC_* 2019-10-18 11:58:33 +02:00
cmdline.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
cmpxchg8b_emu.S x86/asm: Change all ENTRY+ENDPROC to SYM_FUNC_* 2019-10-18 11:58:33 +02:00
cmpxchg16b_emu.S x86/asm: Change all ENTRY+ENDPROC to SYM_FUNC_* 2019-10-18 11:58:33 +02:00
copy_mc.c x86, libnvdimm/test: Remove COPY_MC_TEST 2020-10-26 18:08:35 +01:00
copy_mc_64.S x86/copy_mc: Use EX_TYPE_DEFAULT_MCE_SAFE for exception fixups 2021-09-13 18:11:09 +02:00
copy_page_64.S x86/alternative: Merge include files 2021-03-11 15:58:02 +01:00
copy_user_64.S x86/mce: Reduce number of machine checks taken during recovery 2021-12-31 18:22:32 +01:00
cpu.c x86/lib/cpu: Address missing prototypes warning 2019-08-08 08:25:53 +02:00
csum-copy_64.S amd64: switch csum_partial_copy_generic() to new calling conventions 2020-08-20 15:45:22 -04:00
csum-partial_64.c
csum-wrappers_64.c amd64: switch csum_partial_copy_generic() to new calling conventions 2020-08-20 15:45:22 -04:00
delay.c x86/delay: Introduce TPAUSE delay 2020-05-07 16:06:20 +02:00
error-inject.c x86/asm: Mark all top level asm statements as .text 2019-04-19 17:46:55 +02:00
getuser.S Merge branch 'work.set_fs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2020-10-22 09:59:21 -07:00
hweight.S x86/asm: Change all ENTRY+ENDPROC to SYM_FUNC_* 2019-10-18 11:58:33 +02:00
inat.c x86/insn: Add a __ignore_sync_check__ marker 2021-03-15 11:00:57 +01:00
insn-eval.c x86/iopl: Fake iopl(3) CLI/STI usage 2021-09-21 13:52:18 +02:00
insn.c x86/insn: Use get_unaligned() instead of memcpy() 2021-10-06 11:56:37 +02:00
iomap_copy_64.S x86/asm: Change all ENTRY+ENDPROC to SYM_FUNC_* 2019-10-18 11:58:33 +02:00
iomem.c
kaslr.c x86/boot: Allow a "silent" kaslr random byte fetch 2021-10-27 11:07:58 +02:00
Makefile x86: Add support for 0x22/0x23 port I/O configuration space 2021-08-10 23:31:43 +02:00
memcpy_32.c
memcpy_64.S x86/alternative: Merge include files 2021-03-11 15:58:02 +01:00
memmove_64.S x86/alternative: Merge include files 2021-03-11 15:58:02 +01:00
memset_64.S x86/alternative: Merge include files 2021-03-11 15:58:02 +01:00
misc.c
mmx_32.c x86: Fix various typos in comments 2021-03-18 15:31:53 +01:00
msr-reg-export.c
msr-reg.S x86/asm: Change all ENTRY+ENDPROC to SYM_FUNC_* 2019-10-18 11:58:33 +02:00
msr-smp.c x86/msr: Fix wr/rdmsr_safe_regs_on_cpu() prototypes 2021-03-22 21:37:03 +01:00
msr.c x86/msr: Make locally used functions static 2021-04-08 11:57:40 +02:00
pc-conf-reg.c x86: Add support for 0x22/0x23 port I/O configuration space 2021-08-10 23:31:43 +02:00
putuser.S Merge branch 'work.set_fs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2020-10-22 09:59:21 -07:00
retpoline.S x86/retpoline: Create a retpoline thunk array 2021-10-28 23:25:27 +02:00
string_32.c lib/string: Move helper functions out of string.c 2021-09-25 08:20:49 -07:00
strstr_32.c
usercopy.c x86/uaccess: Document copy_from_user_nmi() 2020-11-18 13:19:01 +01:00
usercopy_32.c
usercopy_64.c * Extend the recovery from MCE in kernel space also to processes which 2020-10-12 10:14:38 -07:00
x86-opcode-map.txt x86/insn: Add Control-flow Enforcement (CET) instructions to the opcode map 2020-03-26 12:21:40 +01:00