Skip to content

Commit 020c755

Browse files
KAGA-KOKOgregkh
authored andcommitted
x86/mce: Make machine check speculation protected
commit 6f41c34 upstream. The machine check idtentry uses an indirect branch directly from the low level code. This evades the speculation protection. Replace it by a direct call into C code and issue the indirect call there so the compiler can apply the proper speculation protection. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by:Borislav Petkov <bp@alien8.de> Reviewed-by: David Woodhouse <dwmw@amazon.co.uk> Niced-by: Peter Zijlstra <peterz@infradead.org> Link: https://lkml.kernel.org/r/alpine.DEB.2.20.1801181626290.1847@nanos Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 14c7f5b commit 020c755

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

arch/x86/entry/entry_64.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ idtentry async_page_fault do_async_page_fault has_error_code=1
12581258
#endif
12591259

12601260
#ifdef CONFIG_X86_MCE
1261-
idtentry machine_check has_error_code=0 paranoid=1 do_sym=*machine_check_vector(%rip)
1261+
idtentry machine_check do_mce has_error_code=0 paranoid=1
12621262
#endif
12631263

12641264
/*

arch/x86/include/asm/traps.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ dotraplinkage void do_simd_coprocessor_error(struct pt_regs *, long);
8888
#ifdef CONFIG_X86_32
8989
dotraplinkage void do_iret_error(struct pt_regs *, long);
9090
#endif
91+
dotraplinkage void do_mce(struct pt_regs *, long);
9192

9293
static inline int get_si_code(unsigned long condition)
9394
{

arch/x86/kernel/cpu/mcheck/mce.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,11 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17881788
void (*machine_check_vector)(struct pt_regs *, long error_code) =
17891789
unexpected_machine_check;
17901790

1791+
dotraplinkage void do_mce(struct pt_regs *regs, long error_code)
1792+
{
1793+
machine_check_vector(regs, error_code);
1794+
}
1795+
17911796
/*
17921797
* Called for each booted CPU to set up machine checks.
17931798
* Must be called with preempt off:

0 commit comments

Comments
 (0)