H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_NMI_H |
| 2 | #define _ASM_X86_NMI_H |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 3 | |
Peter Zijlstra | e90c785 | 2014-02-03 18:02:09 +0100 | [diff] [blame] | 4 | #include <linux/irq_work.h> |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 5 | #include <linux/pm.h> |
| 6 | #include <asm/irq.h> |
| 7 | #include <asm/io.h> |
| 8 | |
Don Zickus | 4a7863c | 2010-12-22 14:00:03 -0500 | [diff] [blame] | 9 | #ifdef CONFIG_X86_LOCAL_APIC |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 10 | |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 11 | extern int avail_to_resrv_perfctr_nmi_bit(unsigned int); |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 12 | extern int reserve_perfctr_nmi(unsigned int); |
| 13 | extern void release_perfctr_nmi(unsigned int); |
| 14 | extern int reserve_evntsel_nmi(unsigned int); |
| 15 | extern void release_evntsel_nmi(unsigned int); |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 16 | |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 17 | struct ctl_table; |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 18 | extern int proc_nmi_enabled(struct ctl_table *, int , |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 19 | void __user *, size_t *, loff_t *); |
| 20 | extern int unknown_nmi_panic; |
| 21 | |
Michel Lespinasse | b52e0a7 | 2013-06-06 04:41:15 -0700 | [diff] [blame] | 22 | #endif /* CONFIG_X86_LOCAL_APIC */ |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 23 | |
Don Zickus | c9126b2 | 2011-09-30 15:06:20 -0400 | [diff] [blame] | 24 | #define NMI_FLAG_FIRST 1 |
| 25 | |
| 26 | enum { |
| 27 | NMI_LOCAL=0, |
| 28 | NMI_UNKNOWN, |
Don Zickus | 553222f | 2012-03-29 16:11:16 -0400 | [diff] [blame] | 29 | NMI_SERR, |
| 30 | NMI_IO_CHECK, |
Don Zickus | c9126b2 | 2011-09-30 15:06:20 -0400 | [diff] [blame] | 31 | NMI_MAX |
| 32 | }; |
| 33 | |
| 34 | #define NMI_DONE 0 |
| 35 | #define NMI_HANDLED 1 |
| 36 | |
| 37 | typedef int (*nmi_handler_t)(unsigned int, struct pt_regs *); |
| 38 | |
Li Zhong | 72b3fb2 | 2012-03-29 16:11:17 -0400 | [diff] [blame] | 39 | struct nmiaction { |
| 40 | struct list_head list; |
| 41 | nmi_handler_t handler; |
Peter Zijlstra | e90c785 | 2014-02-03 18:02:09 +0100 | [diff] [blame] | 42 | u64 max_duration; |
| 43 | struct irq_work irq_work; |
Betty Dall | 6ff968c | 2012-04-27 14:40:55 -0600 | [diff] [blame] | 44 | unsigned long flags; |
Li Zhong | 72b3fb2 | 2012-03-29 16:11:17 -0400 | [diff] [blame] | 45 | const char *name; |
| 46 | }; |
| 47 | |
Li Zhong | 0718467 | 2012-06-18 15:56:33 -0400 | [diff] [blame] | 48 | #define register_nmi_handler(t, fn, fg, n, init...) \ |
Li Zhong | 72b3fb2 | 2012-03-29 16:11:17 -0400 | [diff] [blame] | 49 | ({ \ |
Li Zhong | 0718467 | 2012-06-18 15:56:33 -0400 | [diff] [blame] | 50 | static struct nmiaction init fn##_na = { \ |
Li Zhong | 72b3fb2 | 2012-03-29 16:11:17 -0400 | [diff] [blame] | 51 | .handler = (fn), \ |
| 52 | .name = (n), \ |
| 53 | .flags = (fg), \ |
| 54 | }; \ |
Li Zhong | 0718467 | 2012-06-18 15:56:33 -0400 | [diff] [blame] | 55 | __register_nmi_handler((t), &fn##_na); \ |
Don Zickus | eeaaa96 | 2012-06-06 10:05:42 -0400 | [diff] [blame] | 56 | }) |
| 57 | |
Li Zhong | 72b3fb2 | 2012-03-29 16:11:17 -0400 | [diff] [blame] | 58 | int __register_nmi_handler(unsigned int, struct nmiaction *); |
Don Zickus | c9126b2 | 2011-09-30 15:06:20 -0400 | [diff] [blame] | 59 | |
| 60 | void unregister_nmi_handler(unsigned int, const char *); |
| 61 | |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 62 | void stop_nmi(void); |
| 63 | void restart_nmi(void); |
Don Zickus | b227e23 | 2011-09-30 15:06:22 -0400 | [diff] [blame] | 64 | void local_touch_nmi(void); |
Glauber de Oliveira Costa | 6d60cd5 | 2008-03-19 14:25:36 -0300 | [diff] [blame] | 65 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 66 | #endif /* _ASM_X86_NMI_H */ |