xref: /kernel/linux/linux-5.10/arch/x86/include/asm/nmi.h (revision 8c2ecf20)
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_X86_NMI_H
3#define _ASM_X86_NMI_H
4
5#include <linux/irq_work.h>
6#include <linux/pm.h>
7#include <asm/irq.h>
8#include <asm/io.h>
9
10#ifdef CONFIG_X86_LOCAL_APIC
11
12extern int avail_to_resrv_perfctr_nmi_bit(unsigned int);
13extern int reserve_perfctr_nmi(unsigned int);
14extern void release_perfctr_nmi(unsigned int);
15extern int reserve_evntsel_nmi(unsigned int);
16extern void release_evntsel_nmi(unsigned int);
17
18struct ctl_table;
19extern int proc_nmi_enabled(struct ctl_table *, int ,
20			void __user *, size_t *, loff_t *);
21extern int unknown_nmi_panic;
22
23#endif /* CONFIG_X86_LOCAL_APIC */
24
25#define NMI_FLAG_FIRST	1
26
27enum {
28	NMI_LOCAL=0,
29	NMI_UNKNOWN,
30	NMI_SERR,
31	NMI_IO_CHECK,
32	NMI_MAX
33};
34
35#define NMI_DONE	0
36#define NMI_HANDLED	1
37
38typedef int (*nmi_handler_t)(unsigned int, struct pt_regs *);
39
40struct nmiaction {
41	struct list_head	list;
42	nmi_handler_t		handler;
43	u64			max_duration;
44	unsigned long		flags;
45	const char		*name;
46};
47
48#define register_nmi_handler(t, fn, fg, n, init...)	\
49({							\
50	static struct nmiaction init fn##_na = {	\
51		.handler = (fn),			\
52		.name = (n),				\
53		.flags = (fg),				\
54	};						\
55	__register_nmi_handler((t), &fn##_na);		\
56})
57
58int __register_nmi_handler(unsigned int, struct nmiaction *);
59
60void unregister_nmi_handler(unsigned int, const char *);
61
62void stop_nmi(void);
63void restart_nmi(void);
64void local_touch_nmi(void);
65
66#endif /* _ASM_X86_NMI_H */
67