1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * HW NMI watchdog support 4 * 5 * started by Don Zickus, Copyright (C) 2010 Red Hat, Inc. 6 * 7 * Arch specific calls to support NMI watchdog 8 * 9 * Bits copied from original nmi.c file 10 * 11 */ 12 #include <asm/apic.h> 13 #include <asm/nmi.h> 14 15 #include <linux/cpumask.h> 16 #include <linux/kdebug.h> 17 #include <linux/notifier.h> 18 #include <linux/kprobes.h> 19 #include <linux/nmi.h> 20 #include <linux/init.h> 21 #include <linux/delay.h> 22 23 #ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF 24 u64 hw_nmi_get_sample_period(int watchdog_thresh) 25 { 26 return (u64)(cpu_khz) * 1000 * watchdog_thresh; 27 } 28 #endif 29 30 #ifdef arch_trigger_cpumask_backtrace 31 static void nmi_raise_cpu_backtrace(cpumask_t *mask) 32 { 33 apic->send_IPI_mask(mask, NMI_VECTOR); 34 } 35 36 void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) 37 { 38 nmi_trigger_cpumask_backtrace(mask, exclude_self, 39 nmi_raise_cpu_backtrace); 40 } 41 42 static int nmi_cpu_backtrace_handler(unsigned int cmd, struct pt_regs *regs) 43 { 44 if (nmi_cpu_backtrace(regs)) 45 return NMI_HANDLED; 46 47 return NMI_DONE; 48 } 49 NOKPROBE_SYMBOL(nmi_cpu_backtrace_handler); 50 51 static int __init register_nmi_cpu_backtrace_handler(void) 52 { 53 register_nmi_handler(NMI_LOCAL, nmi_cpu_backtrace_handler, 54 0, "arch_bt"); 55 return 0; 56 } 57 early_initcall(register_nmi_cpu_backtrace_handler); 58 #endif 59