提交 329479e2 编写于 作者: T Thomas Gleixner 提交者: Caspar Zhang

x86/mce: Move nmi_enter/exit() into the entry point

fix #29760792

commit 94a46d316f2b54e3de8a4fa884cb16383db7fcd8 upstream

There is no reason to have nmi_enter/exit() in the actual MCE
handlers. Move it to the entry point. This also covers the until now
uncovered initial handler which only prints.
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
Reviewed-by: NAlexandre Chartre <alexandre.chartre@oracle.com>
Acked-by: NPeter Zijlstra <peterz@infradead.org>
Acked-by: NAndy Lutomirski <luto@kernel.org>
Link: https://lkml.kernel.org/r/20200505135314.243936614@linutronix.deSigned-off-by: NZelin Deng <zelin.deng@linux.alibaba.com>
Reviewed-by: Nluanshi <zhangliguang@linux.alibaba.com>
上级 58511eb2
...@@ -1104,8 +1104,10 @@ static void mce_clear_state(unsigned long *toclear) ...@@ -1104,8 +1104,10 @@ static void mce_clear_state(unsigned long *toclear)
* kdump kernel establishing a new #MC handler where a broadcasted MCE * kdump kernel establishing a new #MC handler where a broadcasted MCE
* might not get handled properly. * might not get handled properly.
*/ */
static bool __mc_check_crashing_cpu(int cpu) static bool mce_check_crashing_cpu(void)
{ {
unsigned int cpu = smp_processor_id();
if (cpu_is_offline(cpu) || if (cpu_is_offline(cpu) ||
(crashing_cpu != -1 && crashing_cpu != cpu)) { (crashing_cpu != -1 && crashing_cpu != cpu)) {
u64 mcgstatus; u64 mcgstatus;
...@@ -1226,7 +1228,6 @@ void do_machine_check(struct pt_regs *regs, long error_code) ...@@ -1226,7 +1228,6 @@ void do_machine_check(struct pt_regs *regs, long error_code)
DECLARE_BITMAP(valid_banks, MAX_NR_BANKS); DECLARE_BITMAP(valid_banks, MAX_NR_BANKS);
DECLARE_BITMAP(toclear, MAX_NR_BANKS); DECLARE_BITMAP(toclear, MAX_NR_BANKS);
struct mca_config *cfg = &mca_cfg; struct mca_config *cfg = &mca_cfg;
int cpu = smp_processor_id();
char *msg = "Unknown"; char *msg = "Unknown";
struct mce m, *final; struct mce m, *final;
int worst = 0; int worst = 0;
...@@ -1255,11 +1256,6 @@ void do_machine_check(struct pt_regs *regs, long error_code) ...@@ -1255,11 +1256,6 @@ void do_machine_check(struct pt_regs *regs, long error_code)
*/ */
int lmce = 1; int lmce = 1;
if (__mc_check_crashing_cpu(cpu))
return;
nmi_enter();
this_cpu_inc(mce_exception_count); this_cpu_inc(mce_exception_count);
mce_gather_info(&m, regs); mce_gather_info(&m, regs);
...@@ -1345,7 +1341,7 @@ void do_machine_check(struct pt_regs *regs, long error_code) ...@@ -1345,7 +1341,7 @@ void do_machine_check(struct pt_regs *regs, long error_code)
sync_core(); sync_core();
if (worst != MCE_AR_SEVERITY && !kill_it) if (worst != MCE_AR_SEVERITY && !kill_it)
goto out_ist; return;
/* Fault was in user mode and we need to take some action */ /* Fault was in user mode and we need to take some action */
if ((m.cs & 3) == 3) { if ((m.cs & 3) == 3) {
...@@ -1374,8 +1370,6 @@ void do_machine_check(struct pt_regs *regs, long error_code) ...@@ -1374,8 +1370,6 @@ void do_machine_check(struct pt_regs *regs, long error_code)
} }
} }
out_ist:
nmi_exit();
} }
EXPORT_SYMBOL_GPL(do_machine_check); EXPORT_SYMBOL_GPL(do_machine_check);
...@@ -1823,9 +1817,16 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code) ...@@ -1823,9 +1817,16 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
void (*machine_check_vector)(struct pt_regs *, long error_code) = void (*machine_check_vector)(struct pt_regs *, long error_code) =
unexpected_machine_check; unexpected_machine_check;
dotraplinkage void do_mce(struct pt_regs *regs, long error_code) dotraplinkage void do_mce(struct pt_regs *regs, long error_code)
{ {
if (machine_check_vector == do_machine_check &&
mce_check_crashing_cpu())
return;
nmi_enter();
machine_check_vector(regs, error_code); machine_check_vector(regs, error_code);
nmi_exit();
} }
/* /*
......
...@@ -23,8 +23,6 @@ static void pentium_machine_check(struct pt_regs *regs, long error_code) ...@@ -23,8 +23,6 @@ static void pentium_machine_check(struct pt_regs *regs, long error_code)
{ {
u32 loaddr, hi, lotype; u32 loaddr, hi, lotype;
nmi_enter();
rdmsr(MSR_IA32_P5_MC_ADDR, loaddr, hi); rdmsr(MSR_IA32_P5_MC_ADDR, loaddr, hi);
rdmsr(MSR_IA32_P5_MC_TYPE, lotype, hi); rdmsr(MSR_IA32_P5_MC_TYPE, lotype, hi);
...@@ -37,8 +35,6 @@ static void pentium_machine_check(struct pt_regs *regs, long error_code) ...@@ -37,8 +35,6 @@ static void pentium_machine_check(struct pt_regs *regs, long error_code)
} }
add_taint(TAINT_MACHINE_CHECK, LOCKDEP_NOW_UNRELIABLE); add_taint(TAINT_MACHINE_CHECK, LOCKDEP_NOW_UNRELIABLE);
nmi_exit();
} }
/* Set up machine check reporting for processors with Intel style MCE: */ /* Set up machine check reporting for processors with Intel style MCE: */
......
...@@ -17,12 +17,8 @@ ...@@ -17,12 +17,8 @@
/* Machine check handler for WinChip C6: */ /* Machine check handler for WinChip C6: */
static void winchip_machine_check(struct pt_regs *regs, long error_code) static void winchip_machine_check(struct pt_regs *regs, long error_code)
{ {
nmi_enter();
pr_emerg("CPU0: Machine Check Exception.\n"); pr_emerg("CPU0: Machine Check Exception.\n");
add_taint(TAINT_MACHINE_CHECK, LOCKDEP_NOW_UNRELIABLE); add_taint(TAINT_MACHINE_CHECK, LOCKDEP_NOW_UNRELIABLE);
nmi_exit();
} }
/* Set up machine check reporting on the Winchip C6 series */ /* Set up machine check reporting on the Winchip C6 series */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册