blob: ecdfee60ee4afb0e3b21e3c313420fc565468e56 [file] [log] [blame]
H. Peter Anvin1965aae2008-10-22 22:26:29 -07001#ifndef _ASM_X86_MCE_H
2#define _ASM_X86_MCE_H
Thomas Gleixnere2f43022007-10-17 18:04:40 +02003
David Howellsaf170c52012-12-14 22:37:13 +00004#include <uapi/asm/mce.h>
Thomas Gleixnere2f43022007-10-17 18:04:40 +02005
Borislav Petkovd203f0b2012-10-15 18:03:57 +02006
7struct mca_config {
8 bool dont_log_ce;
Borislav Petkov7af19e42012-10-15 20:25:17 +02009 bool cmci_disabled;
10 bool ignore_ce;
Borislav Petkov14625942012-10-17 12:05:33 +020011 bool disabled;
12 bool ser;
13 bool bios_cmci_threshold;
Borislav Petkovd203f0b2012-10-15 18:03:57 +020014 u8 banks;
Borislav Petkov84c25592012-10-15 19:59:18 +020015 s8 bootlog;
Borislav Petkovd203f0b2012-10-15 18:03:57 +020016 int tolerant;
Borislav Petkov84c25592012-10-15 19:59:18 +020017 int monarch_timeout;
Borislav Petkov7af19e42012-10-15 20:25:17 +020018 int panic_timeout;
Borislav Petkov84c25592012-10-15 19:59:18 +020019 u32 rip_msr;
Borislav Petkovd203f0b2012-10-15 18:03:57 +020020};
21
Borislav Petkov7af19e42012-10-15 20:25:17 +020022extern struct mca_config mca_cfg;
Borislav Petkov3653ada2011-12-04 15:12:09 +010023extern void mce_register_decode_chain(struct notifier_block *nb);
24extern void mce_unregister_decode_chain(struct notifier_block *nb);
Alan Coxdf39a2e2010-01-04 16:17:21 +000025
Hidetoshi Seto9e55e442009-06-15 17:22:15 +090026#include <linux/percpu.h>
27#include <linux/init.h>
Arun Sharma600634972011-07-26 16:09:06 -070028#include <linux/atomic.h>
Hidetoshi Seto9e55e442009-06-15 17:22:15 +090029
Hidetoshi Setoc6978362009-06-15 17:22:49 +090030extern int mce_p5_enabled;
Thomas Gleixnere2f43022007-10-17 18:04:40 +020031
Hidetoshi Seto58995d22009-06-15 17:27:47 +090032#ifdef CONFIG_X86_MCE
Yong Wanga2202aa2009-11-10 09:38:24 +080033int mcheck_init(void);
Borislav Petkov5e099542009-10-16 12:31:32 +020034void mcheck_cpu_init(struct cpuinfo_x86 *c);
Hidetoshi Seto58995d22009-06-15 17:27:47 +090035#else
Yong Wanga2202aa2009-11-10 09:38:24 +080036static inline int mcheck_init(void) { return 0; }
Borislav Petkov5e099542009-10-16 12:31:32 +020037static inline void mcheck_cpu_init(struct cpuinfo_x86 *c) {}
Hidetoshi Seto58995d22009-06-15 17:27:47 +090038#endif
39
Hidetoshi Seto9e55e442009-06-15 17:22:15 +090040#ifdef CONFIG_X86_ANCIENT_MCE
41void intel_p5_mcheck_init(struct cpuinfo_x86 *c);
42void winchip_mcheck_init(struct cpuinfo_x86 *c);
Hidetoshi Setoc6978362009-06-15 17:22:49 +090043static inline void enable_p5_mce(void) { mce_p5_enabled = 1; }
Hidetoshi Seto9e55e442009-06-15 17:22:15 +090044#else
45static inline void intel_p5_mcheck_init(struct cpuinfo_x86 *c) {}
46static inline void winchip_mcheck_init(struct cpuinfo_x86 *c) {}
Hidetoshi Setoc6978362009-06-15 17:22:49 +090047static inline void enable_p5_mce(void) {}
Hidetoshi Seto9e55e442009-06-15 17:22:15 +090048#endif
49
Andi Kleenb5f2fa42009-02-12 13:43:22 +010050void mce_setup(struct mce *m);
Thomas Gleixnere2f43022007-10-17 18:04:40 +020051void mce_log(struct mce *m);
Greg Kroah-Hartmand6126ef2012-01-26 15:49:14 -080052DECLARE_PER_CPU(struct device *, mce_device);
Thomas Gleixnere2f43022007-10-17 18:04:40 +020053
Andi Kleen41fdff32009-02-12 13:49:30 +010054/*
Andi Kleen3ccdccf2009-07-09 00:31:45 +020055 * Maximum banks number.
56 * This is the limit of the current register layout on
57 * Intel CPUs.
Andi Kleen41fdff32009-02-12 13:49:30 +010058 */
Andi Kleen3ccdccf2009-07-09 00:31:45 +020059#define MAX_NR_BANKS 32
Andi Kleen41fdff32009-02-12 13:49:30 +010060
Thomas Gleixnere2f43022007-10-17 18:04:40 +020061#ifdef CONFIG_X86_MCE_INTEL
62void mce_intel_feature_init(struct cpuinfo_x86 *c);
Andi Kleen88ccbed2009-02-12 13:49:36 +010063void cmci_clear(void);
64void cmci_reenable(void);
65void cmci_rediscover(int dying);
66void cmci_recheck(void);
Thomas Gleixnere2f43022007-10-17 18:04:40 +020067#else
68static inline void mce_intel_feature_init(struct cpuinfo_x86 *c) { }
Andi Kleen88ccbed2009-02-12 13:49:36 +010069static inline void cmci_clear(void) {}
70static inline void cmci_reenable(void) {}
71static inline void cmci_rediscover(int dying) {}
72static inline void cmci_recheck(void) {}
Thomas Gleixnere2f43022007-10-17 18:04:40 +020073#endif
74
75#ifdef CONFIG_X86_MCE_AMD
76void mce_amd_feature_init(struct cpuinfo_x86 *c);
77#else
78static inline void mce_amd_feature_init(struct cpuinfo_x86 *c) { }
79#endif
80
H. Peter Anvin38736072009-05-28 10:05:33 -070081int mce_available(struct cpuinfo_x86 *c);
Andi Kleen88ccbed2009-02-12 13:49:36 +010082
Andi Kleen01ca79f2009-05-27 21:56:52 +020083DECLARE_PER_CPU(unsigned, mce_exception_count);
Andi Kleenca84f692009-05-27 21:56:57 +020084DECLARE_PER_CPU(unsigned, mce_poll_count);
Andi Kleen01ca79f2009-05-27 21:56:52 +020085
Thomas Gleixnere2f43022007-10-17 18:04:40 +020086extern atomic_t mce_entry;
87
Andi Kleenee031c32009-02-12 13:49:34 +010088typedef DECLARE_BITMAP(mce_banks_t, MAX_NR_BANKS);
89DECLARE_PER_CPU(mce_banks_t, mce_poll_banks);
90
Andi Kleenb79109c2009-02-12 13:43:23 +010091enum mcp_flags {
92 MCP_TIMESTAMP = (1 << 0), /* log time stamp */
93 MCP_UC = (1 << 1), /* log uncorrected errors */
Andi Kleen5679af42009-04-07 17:06:55 +020094 MCP_DONTLOG = (1 << 2), /* only clear, don't log */
Andi Kleenb79109c2009-02-12 13:43:23 +010095};
H. Peter Anvin38736072009-05-28 10:05:33 -070096void machine_check_poll(enum mcp_flags flags, mce_banks_t *b);
Andi Kleenb79109c2009-02-12 13:43:23 +010097
Andi Kleen9ff36ee2009-05-27 21:56:58 +020098int mce_notify_irq(void);
Andi Kleen9b1beaf2009-05-27 21:56:59 +020099void mce_notify_process(void);
Thomas Gleixnere2f43022007-10-17 18:04:40 +0200100
Andi Kleenea149b32009-04-29 19:31:00 +0200101DECLARE_PER_CPU(struct mce, injectm);
Luck, Tony66f5ddf2011-11-03 11:46:47 -0700102
103extern void register_mce_write_callback(ssize_t (*)(struct file *filp,
104 const char __user *ubuf,
105 size_t usize, loff_t *off));
Andi Kleenea149b32009-04-29 19:31:00 +0200106
Hidetoshi Seto58995d22009-06-15 17:27:47 +0900107/*
108 * Exception handler
109 */
110
111/* Call the installed machine check handler for this CPU setup. */
112extern void (*machine_check_vector)(struct pt_regs *, long error_code);
113void do_machine_check(struct pt_regs *, long);
114
115/*
116 * Threshold handler
117 */
Thomas Gleixnere2f43022007-10-17 18:04:40 +0200118
Andi Kleenb2762682009-02-12 13:49:31 +0100119extern void (*mce_threshold_vector)(void);
Hidetoshi Seto58995d22009-06-15 17:27:47 +0900120extern void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu);
Andi Kleenb2762682009-02-12 13:49:31 +0100121
Hidetoshi Setoe8ce2c52009-06-15 17:24:40 +0900122/*
123 * Thermal handler
124 */
125
Hidetoshi Setoe8ce2c52009-06-15 17:24:40 +0900126void intel_init_thermal(struct cpuinfo_x86 *c);
127
Hidetoshi Setoe8ce2c52009-06-15 17:24:40 +0900128void mce_log_therm_throt_event(__u64 status);
Yong Wanga2202aa2009-11-10 09:38:24 +0800129
R, Durgadoss9e76a972011-01-03 17:22:04 +0530130/* Interrupt Handler for core thermal thresholds */
131extern int (*platform_thermal_notify)(__u64 msr_val);
132
Yong Wanga2202aa2009-11-10 09:38:24 +0800133#ifdef CONFIG_X86_THERMAL_VECTOR
134extern void mcheck_intel_therm_init(void);
135#else
136static inline void mcheck_intel_therm_init(void) { }
137#endif
138
Huang Yingd334a492010-05-18 14:35:20 +0800139/*
140 * Used by APEI to report memory error via /dev/mcelog
141 */
142
143struct cper_sec_mem_err;
144extern void apei_mce_report_mem_error(int corrected,
145 struct cper_sec_mem_err *mem_err);
146
H. Peter Anvin1965aae2008-10-22 22:26:29 -0700147#endif /* _ASM_X86_MCE_H */