xref: /kernel/linux/linux-5.10/arch/x86/include/asm/nmi.h (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_X86_NMI_H
38c2ecf20Sopenharmony_ci#define _ASM_X86_NMI_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <linux/irq_work.h>
68c2ecf20Sopenharmony_ci#include <linux/pm.h>
78c2ecf20Sopenharmony_ci#include <asm/irq.h>
88c2ecf20Sopenharmony_ci#include <asm/io.h>
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_LOCAL_APIC
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ciextern int avail_to_resrv_perfctr_nmi_bit(unsigned int);
138c2ecf20Sopenharmony_ciextern int reserve_perfctr_nmi(unsigned int);
148c2ecf20Sopenharmony_ciextern void release_perfctr_nmi(unsigned int);
158c2ecf20Sopenharmony_ciextern int reserve_evntsel_nmi(unsigned int);
168c2ecf20Sopenharmony_ciextern void release_evntsel_nmi(unsigned int);
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_cistruct ctl_table;
198c2ecf20Sopenharmony_ciextern int proc_nmi_enabled(struct ctl_table *, int ,
208c2ecf20Sopenharmony_ci			void __user *, size_t *, loff_t *);
218c2ecf20Sopenharmony_ciextern int unknown_nmi_panic;
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#endif /* CONFIG_X86_LOCAL_APIC */
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#define NMI_FLAG_FIRST	1
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_cienum {
288c2ecf20Sopenharmony_ci	NMI_LOCAL=0,
298c2ecf20Sopenharmony_ci	NMI_UNKNOWN,
308c2ecf20Sopenharmony_ci	NMI_SERR,
318c2ecf20Sopenharmony_ci	NMI_IO_CHECK,
328c2ecf20Sopenharmony_ci	NMI_MAX
338c2ecf20Sopenharmony_ci};
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define NMI_DONE	0
368c2ecf20Sopenharmony_ci#define NMI_HANDLED	1
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_citypedef int (*nmi_handler_t)(unsigned int, struct pt_regs *);
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_cistruct nmiaction {
418c2ecf20Sopenharmony_ci	struct list_head	list;
428c2ecf20Sopenharmony_ci	nmi_handler_t		handler;
438c2ecf20Sopenharmony_ci	u64			max_duration;
448c2ecf20Sopenharmony_ci	unsigned long		flags;
458c2ecf20Sopenharmony_ci	const char		*name;
468c2ecf20Sopenharmony_ci};
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#define register_nmi_handler(t, fn, fg, n, init...)	\
498c2ecf20Sopenharmony_ci({							\
508c2ecf20Sopenharmony_ci	static struct nmiaction init fn##_na = {	\
518c2ecf20Sopenharmony_ci		.handler = (fn),			\
528c2ecf20Sopenharmony_ci		.name = (n),				\
538c2ecf20Sopenharmony_ci		.flags = (fg),				\
548c2ecf20Sopenharmony_ci	};						\
558c2ecf20Sopenharmony_ci	__register_nmi_handler((t), &fn##_na);		\
568c2ecf20Sopenharmony_ci})
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ciint __register_nmi_handler(unsigned int, struct nmiaction *);
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_civoid unregister_nmi_handler(unsigned int, const char *);
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_civoid stop_nmi(void);
638c2ecf20Sopenharmony_civoid restart_nmi(void);
648c2ecf20Sopenharmony_civoid local_touch_nmi(void);
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#endif /* _ASM_X86_NMI_H */
67