• Youquan Song's avatar
    x86/mce: Add _ASM_EXTABLE_CPY for copy user access · 278b917f
    Youquan Song authored
    _ASM_EXTABLE_UA is a general exception entry to record the exception fixup
    for all exception spots between kernel and user space access.
    
    To enable recovery from machine checks while coping data from user
    addresses it is necessary to be able to distinguish the places that are
    looping copying data from those that copy a single byte/word/etc.
    
    Add a new macro _ASM_EXTABLE_CPY and use it in place of _ASM_EXTABLE_UA
    in the copy functions.
    
    Record the exception reason number to regs->ax at
    ex_handler_uaccess which is used to check MCE triggered.
    
    The new fixup routine ex_handler_copy() is almost an exact copy of
    ex_handler_uaccess() The difference is that it sets regs->ax to the trap
    number. Following patches use this to avoid trying to copy remaining
    bytes from the tail of the copy and possibly hitting the poison again.
    
    New mce.kflags bit MCE_IN_KERNEL_COPYIN will be used by mce_severity()
    calculation to indicate that a machine check is recoverable because the
    kernel was copying from user space.
    Signed-off-by: default avatarYouquan Song <youquan.song@intel.com>
    Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
    Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
    Link: https://lkml.kernel.org/r/20201006210910.21062-4-tony.luck@intel.com
    278b917f
copy_user_64.S 8.85 KB