1 #include <linux/device.h>
2 #include <asm/mce.h>
3
4 enum severity_level {
5 MCE_NO_SEVERITY,
6 MCE_DEFERRED_SEVERITY,
7 MCE_UCNA_SEVERITY = MCE_DEFERRED_SEVERITY,
8 MCE_KEEP_SEVERITY,
9 MCE_SOME_SEVERITY,
10 MCE_AO_SEVERITY,
11 MCE_UC_SEVERITY,
12 MCE_AR_SEVERITY,
13 MCE_PANIC_SEVERITY,
14 };
15
16 extern struct atomic_notifier_head x86_mce_decoder_chain;
17
18 #define ATTR_LEN 16
19 #define INITIAL_CHECK_INTERVAL 5 * 60 /* 5 minutes */
20
21 /* One object for each MCE bank, shared by all CPUs */
22 struct mce_bank {
23 u64 ctl; /* subevents to enable */
24 unsigned char init; /* initialise bank? */
25 struct device_attribute attr; /* device attribute */
26 char attrname[ATTR_LEN]; /* attribute name */
27 };
28
29 struct mce_evt_llist {
30 struct llist_node llnode;
31 struct mce mce;
32 };
33
34 void mce_gen_pool_process(void);
35 bool mce_gen_pool_empty(void);
36 int mce_gen_pool_add(struct mce *mce);
37 int mce_gen_pool_init(void);
38
39 extern int (*mce_severity)(struct mce *a, int tolerant, char **msg, bool is_excp);
40 struct dentry *mce_get_debugfs_dir(void);
41
42 extern struct mce_bank *mce_banks;
43 extern mce_banks_t mce_banks_ce_disabled;
44
45 #ifdef CONFIG_X86_MCE_INTEL
46 unsigned long cmci_intel_adjust_timer(unsigned long interval);
47 bool mce_intel_cmci_poll(void);
48 void mce_intel_hcpu_update(unsigned long cpu);
49 void cmci_disable_bank(int bank);
50 #else
51 # define cmci_intel_adjust_timer mce_adjust_timer_default
mce_intel_cmci_poll(void)52 static inline bool mce_intel_cmci_poll(void) { return false; }
mce_intel_hcpu_update(unsigned long cpu)53 static inline void mce_intel_hcpu_update(unsigned long cpu) { }
cmci_disable_bank(int bank)54 static inline void cmci_disable_bank(int bank) { }
55 #endif
56
57 void mce_timer_kick(unsigned long interval);
58
59 #ifdef CONFIG_ACPI_APEI
60 int apei_write_mce(struct mce *m);
61 ssize_t apei_read_mce(struct mce *m, u64 *record_id);
62 int apei_check_mce(void);
63 int apei_clear_mce(u64 record_id);
64 #else
apei_write_mce(struct mce * m)65 static inline int apei_write_mce(struct mce *m)
66 {
67 return -EINVAL;
68 }
apei_read_mce(struct mce * m,u64 * record_id)69 static inline ssize_t apei_read_mce(struct mce *m, u64 *record_id)
70 {
71 return 0;
72 }
apei_check_mce(void)73 static inline int apei_check_mce(void)
74 {
75 return 0;
76 }
apei_clear_mce(u64 record_id)77 static inline int apei_clear_mce(u64 record_id)
78 {
79 return -EINVAL;
80 }
81 #endif
82
83 void mce_inject_log(struct mce *m);
84