blob: 5f2fc4441b11016608f476848e3a60bd1e08d7a5 [file] [log] [blame]
H. Peter Anvin1965aae2008-10-22 22:26:29 -07001#ifndef _ASM_X86_NMI_H
2#define _ASM_X86_NMI_H
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -03003
Peter Zijlstrae90c7852014-02-03 18:02:09 +01004#include <linux/irq_work.h>
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -03005#include <linux/pm.h>
6#include <asm/irq.h>
7#include <asm/io.h>
8
Don Zickus4a7863c2010-12-22 14:00:03 -05009#ifdef CONFIG_X86_LOCAL_APIC
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030010
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030011extern int avail_to_resrv_perfctr_nmi_bit(unsigned int);
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030012extern int reserve_perfctr_nmi(unsigned int);
13extern void release_perfctr_nmi(unsigned int);
14extern int reserve_evntsel_nmi(unsigned int);
15extern void release_evntsel_nmi(unsigned int);
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030016
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030017struct ctl_table;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -070018extern int proc_nmi_enabled(struct ctl_table *, int ,
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030019 void __user *, size_t *, loff_t *);
20extern int unknown_nmi_panic;
21
Michel Lespinasseb52e0a72013-06-06 04:41:15 -070022#endif /* CONFIG_X86_LOCAL_APIC */
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030023
Don Zickusc9126b22011-09-30 15:06:20 -040024#define NMI_FLAG_FIRST 1
25
26enum {
27 NMI_LOCAL=0,
28 NMI_UNKNOWN,
Don Zickus553222f2012-03-29 16:11:16 -040029 NMI_SERR,
30 NMI_IO_CHECK,
Don Zickusc9126b22011-09-30 15:06:20 -040031 NMI_MAX
32};
33
34#define NMI_DONE 0
35#define NMI_HANDLED 1
36
37typedef int (*nmi_handler_t)(unsigned int, struct pt_regs *);
38
Li Zhong72b3fb22012-03-29 16:11:17 -040039struct nmiaction {
40 struct list_head list;
41 nmi_handler_t handler;
Peter Zijlstrae90c7852014-02-03 18:02:09 +010042 u64 max_duration;
43 struct irq_work irq_work;
Betty Dall6ff968c2012-04-27 14:40:55 -060044 unsigned long flags;
Li Zhong72b3fb22012-03-29 16:11:17 -040045 const char *name;
46};
47
Li Zhong07184672012-06-18 15:56:33 -040048#define register_nmi_handler(t, fn, fg, n, init...) \
Li Zhong72b3fb22012-03-29 16:11:17 -040049({ \
Li Zhong07184672012-06-18 15:56:33 -040050 static struct nmiaction init fn##_na = { \
Li Zhong72b3fb22012-03-29 16:11:17 -040051 .handler = (fn), \
52 .name = (n), \
53 .flags = (fg), \
54 }; \
Li Zhong07184672012-06-18 15:56:33 -040055 __register_nmi_handler((t), &fn##_na); \
Don Zickuseeaaa962012-06-06 10:05:42 -040056})
57
Li Zhong72b3fb22012-03-29 16:11:17 -040058int __register_nmi_handler(unsigned int, struct nmiaction *);
Don Zickusc9126b22011-09-30 15:06:20 -040059
60void unregister_nmi_handler(unsigned int, const char *);
61
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030062void stop_nmi(void);
63void restart_nmi(void);
Don Zickusb227e232011-09-30 15:06:22 -040064void local_touch_nmi(void);
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030065
H. Peter Anvin1965aae2008-10-22 22:26:29 -070066#endif /* _ASM_X86_NMI_H */