aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>2015-03-23 11:42:53 -0400
committerBorislav Petkov <bp@suse.de>2015-03-24 07:14:15 -0400
commit43eaa2a1ad70d72876cdbb2eb5450a2665e4770f (patch)
tree3da03b9d29bc15d06f19348f34a72d29f5a2ab49
parentbf80bbd7dcf525e41e0673fbaa8cd21d2344b460 (diff)
x86/mce: Define mce_severity function pointer
Rename mce_severity() to mce_severity_intel() and assign the mce_severity function pointer to mce_severity_amd() during init on AMD. This way, we can avoid a test to call mce_severity_amd every time we get into mce_severity(). And it's cleaner to do it this way. Signed-off-by: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com> Suggested-by: Tony Luck <tony.luck@intel.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@kernel.org> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Chen Yucong <slaoub@gmail.com> Cc: Andy Lutomirski <luto@amacapital.net> Cc: linux-edac <linux-edac@vger.kernel.org> Link: http://lkml.kernel.org/r/1427125373-2918-3-git-send-email-Aravind.Gopalakrishnan@amd.com Signed-off-by: Borislav Petkov <bp@suse.de>
-rw-r--r--arch/x86/include/asm/mce.h2
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce-internal.h2
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce-severity.c19
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c1
4 files changed, 18 insertions, 6 deletions
diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index b574fbf62d39..1f5a86d518db 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -134,9 +134,11 @@ extern int mce_p5_enabled;
134#ifdef CONFIG_X86_MCE 134#ifdef CONFIG_X86_MCE
135int mcheck_init(void); 135int mcheck_init(void);
136void mcheck_cpu_init(struct cpuinfo_x86 *c); 136void mcheck_cpu_init(struct cpuinfo_x86 *c);
137void mcheck_vendor_init_severity(void);
137#else 138#else
138static inline int mcheck_init(void) { return 0; } 139static inline int mcheck_init(void) { return 0; }
139static inline void mcheck_cpu_init(struct cpuinfo_x86 *c) {} 140static inline void mcheck_cpu_init(struct cpuinfo_x86 *c) {}
141static inline void mcheck_vendor_init_severity(void) {}
140#endif 142#endif
141 143
142#ifdef CONFIG_X86_ANCIENT_MCE 144#ifdef CONFIG_X86_ANCIENT_MCE
diff --git a/arch/x86/kernel/cpu/mcheck/mce-internal.h b/arch/x86/kernel/cpu/mcheck/mce-internal.h
index e12f0bfb45c1..fe32074b865b 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-internal.h
+++ b/arch/x86/kernel/cpu/mcheck/mce-internal.h
@@ -24,7 +24,7 @@ struct mce_bank {
24 char attrname[ATTR_LEN]; /* attribute name */ 24 char attrname[ATTR_LEN]; /* attribute name */
25}; 25};
26 26
27int mce_severity(struct mce *a, int tolerant, char **msg, bool is_excp); 27extern int (*mce_severity)(struct mce *a, int tolerant, char **msg, bool is_excp);
28struct dentry *mce_get_debugfs_dir(void); 28struct dentry *mce_get_debugfs_dir(void);
29 29
30extern struct mce_bank *mce_banks; 30extern struct mce_bank *mce_banks;
diff --git a/arch/x86/kernel/cpu/mcheck/mce-severity.c b/arch/x86/kernel/cpu/mcheck/mce-severity.c
index e16f3f201e06..155c9261d3ef 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-severity.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-severity.c
@@ -190,8 +190,10 @@ static int error_context(struct mce *m)
190 * See AMD Error Scope Hierarchy table in a newer BKDG. For example 190 * See AMD Error Scope Hierarchy table in a newer BKDG. For example
191 * 49125_15h_Models_30h-3Fh_BKDG.pdf, section "RAS Features" 191 * 49125_15h_Models_30h-3Fh_BKDG.pdf, section "RAS Features"
192 */ 192 */
193static int mce_severity_amd(struct mce *m, enum context ctx) 193static int mce_severity_amd(struct mce *m, int tolerant, char **msg, bool is_excp)
194{ 194{
195 enum context ctx = error_context(m);
196
195 /* Processor Context Corrupt, no need to fumble too much, die! */ 197 /* Processor Context Corrupt, no need to fumble too much, die! */
196 if (m->status & MCI_STATUS_PCC) 198 if (m->status & MCI_STATUS_PCC)
197 return MCE_PANIC_SEVERITY; 199 return MCE_PANIC_SEVERITY;
@@ -239,15 +241,12 @@ static int mce_severity_amd(struct mce *m, enum context ctx)
239 return MCE_KEEP_SEVERITY; 241 return MCE_KEEP_SEVERITY;
240} 242}
241 243
242int mce_severity(struct mce *m, int tolerant, char **msg, bool is_excp) 244static int mce_severity_intel(struct mce *m, int tolerant, char **msg, bool is_excp)
243{ 245{
244 enum exception excp = (is_excp ? EXCP_CONTEXT : NO_EXCP); 246 enum exception excp = (is_excp ? EXCP_CONTEXT : NO_EXCP);
245 enum context ctx = error_context(m); 247 enum context ctx = error_context(m);
246 struct severity *s; 248 struct severity *s;
247 249
248 if (m->cpuvendor == X86_VENDOR_AMD)
249 return mce_severity_amd(m, ctx);
250
251 for (s = severities;; s++) { 250 for (s = severities;; s++) {
252 if ((m->status & s->mask) != s->result) 251 if ((m->status & s->mask) != s->result)
253 continue; 252 continue;
@@ -272,6 +271,16 @@ int mce_severity(struct mce *m, int tolerant, char **msg, bool is_excp)
272 } 271 }
273} 272}
274 273
274/* Default to mce_severity_intel */
275int (*mce_severity)(struct mce *m, int tolerant, char **msg, bool is_excp) =
276 mce_severity_intel;
277
278void __init mcheck_vendor_init_severity(void)
279{
280 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
281 mce_severity = mce_severity_amd;
282}
283
275#ifdef CONFIG_DEBUG_FS 284#ifdef CONFIG_DEBUG_FS
276static void *s_start(struct seq_file *f, loff_t *pos) 285static void *s_start(struct seq_file *f, loff_t *pos)
277{ 286{
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 1189f1150a19..c7df30748629 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -2026,6 +2026,7 @@ __setup("mce", mcheck_enable);
2026int __init mcheck_init(void) 2026int __init mcheck_init(void)
2027{ 2027{
2028 mcheck_intel_therm_init(); 2028 mcheck_intel_therm_init();
2029 mcheck_vendor_init_severity();
2029 2030
2030 return 0; 2031 return 0;
2031} 2032}