19 #include <linux/slab.h>
20 #include <linux/export.h>
22 #if defined(CONFIG_EDAC)
27 #include <asm/traps.h>
67 static int ignore_nmis;
76 static int __init setup_unknown_nmi_panic(
char *
str)
81 __setup(
"unknown_nmi_panic", setup_unknown_nmi_panic);
83 #define nmi_to_desc(type) (&nmi_desc[type])
99 list_for_each_entry_rcu(a, &desc->
head,
list)
100 handled += a->
handler(type, regs);
132 list_add_rcu(&action->
list, &desc->
head);
134 list_add_tail_rcu(&action->
list, &desc->
head);
136 spin_unlock_irqrestore(&desc->
lock, flags);
149 list_for_each_entry_rcu(n, &desc->
head,
list) {
156 "Trying to free NMI (%s) from NMI context!\n", n->
name);
157 list_del_rcu(&n->
list);
162 spin_unlock_irqrestore(&desc->
lock, flags);
171 if (nmi_handle(
NMI_SERR, regs,
false))
174 pr_emerg(
"NMI: PCI system error (SERR) for reason %02x on CPU %d.\n",
181 #if defined(CONFIG_EDAC)
189 panic(
"NMI: Not continuing");
191 pr_emerg(
"Dazed and confused, but trying to continue\n");
199 io_check_error(
unsigned char reason,
struct pt_regs *regs)
208 "NMI: IOCK error (debug interrupt?) for reason %02x on CPU %d.\n",
213 panic(
"NMI IOCK error: Not continuing");
230 unknown_nmi_error(
unsigned char reason,
struct pt_regs *regs)
248 pr_emerg(
"Uhhuh. NMI received for unknown reason %02x on CPU %d.\n",
251 pr_emerg(
"Do you have a strange power saving mode enabled?\n");
253 panic(
"NMI: Not continuing");
255 pr_emerg(
"Dazed and confused, but trying to continue\n");
263 unsigned char reason = 0;
287 handled = nmi_handle(
NMI_LOCAL, regs, b2b);
309 pci_serr_error(reason, regs);
311 io_check_error(reason, regs);
358 unknown_nmi_error(reason, regs);
415 #define nmi_nesting_preprocess(regs) \
417 if (this_cpu_read(nmi_state) != NMI_NOT_RUNNING) { \
418 this_cpu_write(nmi_state, NMI_LATCHED); \
421 this_cpu_write(nmi_state, NMI_EXECUTING); \
422 this_cpu_write(nmi_cr2, read_cr2()); \
426 #define nmi_nesting_postprocess() \
428 if (unlikely(this_cpu_read(nmi_cr2) != read_cr2())) \
429 write_cr2(this_cpu_read(nmi_cr2)); \
430 if (this_cpu_dec_return(nmi_state)) \
456 static inline void nmi_nesting_preprocess(
struct pt_regs *regs)
465 debug_stack_set_zero();
470 static inline void nmi_nesting_postprocess(
void)
482 nmi_nesting_preprocess(regs);
489 default_do_nmi(regs);
494 nmi_nesting_postprocess();