H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_MCE_H |
| 2 | #define _ASM_X86_MCE_H |
Thomas Gleixner | e2f4302 | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 3 | |
David Howells | af170c5 | 2012-12-14 22:37:13 +0000 | [diff] [blame^] | 4 | #include <uapi/asm/mce.h> |
Thomas Gleixner | e2f4302 | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 5 | |
Borislav Petkov | d203f0b | 2012-10-15 18:03:57 +0200 | [diff] [blame] | 6 | |
| 7 | struct mca_config { |
| 8 | bool dont_log_ce; |
Borislav Petkov | 7af19e4 | 2012-10-15 20:25:17 +0200 | [diff] [blame] | 9 | bool cmci_disabled; |
| 10 | bool ignore_ce; |
Borislav Petkov | 1462594 | 2012-10-17 12:05:33 +0200 | [diff] [blame] | 11 | bool disabled; |
| 12 | bool ser; |
| 13 | bool bios_cmci_threshold; |
Borislav Petkov | d203f0b | 2012-10-15 18:03:57 +0200 | [diff] [blame] | 14 | u8 banks; |
Borislav Petkov | 84c2559 | 2012-10-15 19:59:18 +0200 | [diff] [blame] | 15 | s8 bootlog; |
Borislav Petkov | d203f0b | 2012-10-15 18:03:57 +0200 | [diff] [blame] | 16 | int tolerant; |
Borislav Petkov | 84c2559 | 2012-10-15 19:59:18 +0200 | [diff] [blame] | 17 | int monarch_timeout; |
Borislav Petkov | 7af19e4 | 2012-10-15 20:25:17 +0200 | [diff] [blame] | 18 | int panic_timeout; |
Borislav Petkov | 84c2559 | 2012-10-15 19:59:18 +0200 | [diff] [blame] | 19 | u32 rip_msr; |
Borislav Petkov | d203f0b | 2012-10-15 18:03:57 +0200 | [diff] [blame] | 20 | }; |
| 21 | |
Borislav Petkov | 7af19e4 | 2012-10-15 20:25:17 +0200 | [diff] [blame] | 22 | extern struct mca_config mca_cfg; |
Borislav Petkov | 3653ada | 2011-12-04 15:12:09 +0100 | [diff] [blame] | 23 | extern void mce_register_decode_chain(struct notifier_block *nb); |
| 24 | extern void mce_unregister_decode_chain(struct notifier_block *nb); |
Alan Cox | df39a2e | 2010-01-04 16:17:21 +0000 | [diff] [blame] | 25 | |
Hidetoshi Seto | 9e55e44 | 2009-06-15 17:22:15 +0900 | [diff] [blame] | 26 | #include <linux/percpu.h> |
| 27 | #include <linux/init.h> |
Arun Sharma | 60063497 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 28 | #include <linux/atomic.h> |
Hidetoshi Seto | 9e55e44 | 2009-06-15 17:22:15 +0900 | [diff] [blame] | 29 | |
Hidetoshi Seto | c697836 | 2009-06-15 17:22:49 +0900 | [diff] [blame] | 30 | extern int mce_p5_enabled; |
Thomas Gleixner | e2f4302 | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 31 | |
Hidetoshi Seto | 58995d2 | 2009-06-15 17:27:47 +0900 | [diff] [blame] | 32 | #ifdef CONFIG_X86_MCE |
Yong Wang | a2202aa | 2009-11-10 09:38:24 +0800 | [diff] [blame] | 33 | int mcheck_init(void); |
Borislav Petkov | 5e09954 | 2009-10-16 12:31:32 +0200 | [diff] [blame] | 34 | void mcheck_cpu_init(struct cpuinfo_x86 *c); |
Hidetoshi Seto | 58995d2 | 2009-06-15 17:27:47 +0900 | [diff] [blame] | 35 | #else |
Yong Wang | a2202aa | 2009-11-10 09:38:24 +0800 | [diff] [blame] | 36 | static inline int mcheck_init(void) { return 0; } |
Borislav Petkov | 5e09954 | 2009-10-16 12:31:32 +0200 | [diff] [blame] | 37 | static inline void mcheck_cpu_init(struct cpuinfo_x86 *c) {} |
Hidetoshi Seto | 58995d2 | 2009-06-15 17:27:47 +0900 | [diff] [blame] | 38 | #endif |
| 39 | |
Hidetoshi Seto | 9e55e44 | 2009-06-15 17:22:15 +0900 | [diff] [blame] | 40 | #ifdef CONFIG_X86_ANCIENT_MCE |
| 41 | void intel_p5_mcheck_init(struct cpuinfo_x86 *c); |
| 42 | void winchip_mcheck_init(struct cpuinfo_x86 *c); |
Hidetoshi Seto | c697836 | 2009-06-15 17:22:49 +0900 | [diff] [blame] | 43 | static inline void enable_p5_mce(void) { mce_p5_enabled = 1; } |
Hidetoshi Seto | 9e55e44 | 2009-06-15 17:22:15 +0900 | [diff] [blame] | 44 | #else |
| 45 | static inline void intel_p5_mcheck_init(struct cpuinfo_x86 *c) {} |
| 46 | static inline void winchip_mcheck_init(struct cpuinfo_x86 *c) {} |
Hidetoshi Seto | c697836 | 2009-06-15 17:22:49 +0900 | [diff] [blame] | 47 | static inline void enable_p5_mce(void) {} |
Hidetoshi Seto | 9e55e44 | 2009-06-15 17:22:15 +0900 | [diff] [blame] | 48 | #endif |
| 49 | |
Andi Kleen | b5f2fa4 | 2009-02-12 13:43:22 +0100 | [diff] [blame] | 50 | void mce_setup(struct mce *m); |
Thomas Gleixner | e2f4302 | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 51 | void mce_log(struct mce *m); |
Greg Kroah-Hartman | d6126ef | 2012-01-26 15:49:14 -0800 | [diff] [blame] | 52 | DECLARE_PER_CPU(struct device *, mce_device); |
Thomas Gleixner | e2f4302 | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 53 | |
Andi Kleen | 41fdff3 | 2009-02-12 13:49:30 +0100 | [diff] [blame] | 54 | /* |
Andi Kleen | 3ccdccf | 2009-07-09 00:31:45 +0200 | [diff] [blame] | 55 | * Maximum banks number. |
| 56 | * This is the limit of the current register layout on |
| 57 | * Intel CPUs. |
Andi Kleen | 41fdff3 | 2009-02-12 13:49:30 +0100 | [diff] [blame] | 58 | */ |
Andi Kleen | 3ccdccf | 2009-07-09 00:31:45 +0200 | [diff] [blame] | 59 | #define MAX_NR_BANKS 32 |
Andi Kleen | 41fdff3 | 2009-02-12 13:49:30 +0100 | [diff] [blame] | 60 | |
Thomas Gleixner | e2f4302 | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 61 | #ifdef CONFIG_X86_MCE_INTEL |
| 62 | void mce_intel_feature_init(struct cpuinfo_x86 *c); |
Andi Kleen | 88ccbed | 2009-02-12 13:49:36 +0100 | [diff] [blame] | 63 | void cmci_clear(void); |
| 64 | void cmci_reenable(void); |
| 65 | void cmci_rediscover(int dying); |
| 66 | void cmci_recheck(void); |
Thomas Gleixner | e2f4302 | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 67 | #else |
| 68 | static inline void mce_intel_feature_init(struct cpuinfo_x86 *c) { } |
Andi Kleen | 88ccbed | 2009-02-12 13:49:36 +0100 | [diff] [blame] | 69 | static inline void cmci_clear(void) {} |
| 70 | static inline void cmci_reenable(void) {} |
| 71 | static inline void cmci_rediscover(int dying) {} |
| 72 | static inline void cmci_recheck(void) {} |
Thomas Gleixner | e2f4302 | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 73 | #endif |
| 74 | |
| 75 | #ifdef CONFIG_X86_MCE_AMD |
| 76 | void mce_amd_feature_init(struct cpuinfo_x86 *c); |
| 77 | #else |
| 78 | static inline void mce_amd_feature_init(struct cpuinfo_x86 *c) { } |
| 79 | #endif |
| 80 | |
H. Peter Anvin | 3873607 | 2009-05-28 10:05:33 -0700 | [diff] [blame] | 81 | int mce_available(struct cpuinfo_x86 *c); |
Andi Kleen | 88ccbed | 2009-02-12 13:49:36 +0100 | [diff] [blame] | 82 | |
Andi Kleen | 01ca79f | 2009-05-27 21:56:52 +0200 | [diff] [blame] | 83 | DECLARE_PER_CPU(unsigned, mce_exception_count); |
Andi Kleen | ca84f69 | 2009-05-27 21:56:57 +0200 | [diff] [blame] | 84 | DECLARE_PER_CPU(unsigned, mce_poll_count); |
Andi Kleen | 01ca79f | 2009-05-27 21:56:52 +0200 | [diff] [blame] | 85 | |
Thomas Gleixner | e2f4302 | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 86 | extern atomic_t mce_entry; |
| 87 | |
Andi Kleen | ee031c3 | 2009-02-12 13:49:34 +0100 | [diff] [blame] | 88 | typedef DECLARE_BITMAP(mce_banks_t, MAX_NR_BANKS); |
| 89 | DECLARE_PER_CPU(mce_banks_t, mce_poll_banks); |
| 90 | |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 91 | enum mcp_flags { |
| 92 | MCP_TIMESTAMP = (1 << 0), /* log time stamp */ |
| 93 | MCP_UC = (1 << 1), /* log uncorrected errors */ |
Andi Kleen | 5679af4 | 2009-04-07 17:06:55 +0200 | [diff] [blame] | 94 | MCP_DONTLOG = (1 << 2), /* only clear, don't log */ |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 95 | }; |
H. Peter Anvin | 3873607 | 2009-05-28 10:05:33 -0700 | [diff] [blame] | 96 | void machine_check_poll(enum mcp_flags flags, mce_banks_t *b); |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 97 | |
Andi Kleen | 9ff36ee | 2009-05-27 21:56:58 +0200 | [diff] [blame] | 98 | int mce_notify_irq(void); |
Andi Kleen | 9b1beaf | 2009-05-27 21:56:59 +0200 | [diff] [blame] | 99 | void mce_notify_process(void); |
Thomas Gleixner | e2f4302 | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 100 | |
Andi Kleen | ea149b3 | 2009-04-29 19:31:00 +0200 | [diff] [blame] | 101 | DECLARE_PER_CPU(struct mce, injectm); |
Luck, Tony | 66f5ddf | 2011-11-03 11:46:47 -0700 | [diff] [blame] | 102 | |
| 103 | extern void register_mce_write_callback(ssize_t (*)(struct file *filp, |
| 104 | const char __user *ubuf, |
| 105 | size_t usize, loff_t *off)); |
Andi Kleen | ea149b3 | 2009-04-29 19:31:00 +0200 | [diff] [blame] | 106 | |
Hidetoshi Seto | 58995d2 | 2009-06-15 17:27:47 +0900 | [diff] [blame] | 107 | /* |
| 108 | * Exception handler |
| 109 | */ |
| 110 | |
| 111 | /* Call the installed machine check handler for this CPU setup. */ |
| 112 | extern void (*machine_check_vector)(struct pt_regs *, long error_code); |
| 113 | void do_machine_check(struct pt_regs *, long); |
| 114 | |
| 115 | /* |
| 116 | * Threshold handler |
| 117 | */ |
Thomas Gleixner | e2f4302 | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 118 | |
Andi Kleen | b276268 | 2009-02-12 13:49:31 +0100 | [diff] [blame] | 119 | extern void (*mce_threshold_vector)(void); |
Hidetoshi Seto | 58995d2 | 2009-06-15 17:27:47 +0900 | [diff] [blame] | 120 | extern void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu); |
Andi Kleen | b276268 | 2009-02-12 13:49:31 +0100 | [diff] [blame] | 121 | |
Hidetoshi Seto | e8ce2c5 | 2009-06-15 17:24:40 +0900 | [diff] [blame] | 122 | /* |
| 123 | * Thermal handler |
| 124 | */ |
| 125 | |
Hidetoshi Seto | e8ce2c5 | 2009-06-15 17:24:40 +0900 | [diff] [blame] | 126 | void intel_init_thermal(struct cpuinfo_x86 *c); |
| 127 | |
Hidetoshi Seto | e8ce2c5 | 2009-06-15 17:24:40 +0900 | [diff] [blame] | 128 | void mce_log_therm_throt_event(__u64 status); |
Yong Wang | a2202aa | 2009-11-10 09:38:24 +0800 | [diff] [blame] | 129 | |
R, Durgadoss | 9e76a97 | 2011-01-03 17:22:04 +0530 | [diff] [blame] | 130 | /* Interrupt Handler for core thermal thresholds */ |
| 131 | extern int (*platform_thermal_notify)(__u64 msr_val); |
| 132 | |
Yong Wang | a2202aa | 2009-11-10 09:38:24 +0800 | [diff] [blame] | 133 | #ifdef CONFIG_X86_THERMAL_VECTOR |
| 134 | extern void mcheck_intel_therm_init(void); |
| 135 | #else |
| 136 | static inline void mcheck_intel_therm_init(void) { } |
| 137 | #endif |
| 138 | |
Huang Ying | d334a49 | 2010-05-18 14:35:20 +0800 | [diff] [blame] | 139 | /* |
| 140 | * Used by APEI to report memory error via /dev/mcelog |
| 141 | */ |
| 142 | |
| 143 | struct cper_sec_mem_err; |
| 144 | extern void apei_mce_report_mem_error(int corrected, |
| 145 | struct cper_sec_mem_err *mem_err); |
| 146 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 147 | #endif /* _ASM_X86_MCE_H */ |