Skip to content

Commit 43eaa2a

Browse files
Aravind Gopalakrishnansuryasaimadhu
authored andcommitted
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>
1 parent bf80bbd commit 43eaa2a

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

arch/x86/include/asm/mce.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,11 @@ extern int mce_p5_enabled;
134134
#ifdef CONFIG_X86_MCE
135135
int mcheck_init(void);
136136
void mcheck_cpu_init(struct cpuinfo_x86 *c);
137+
void mcheck_vendor_init_severity(void);
137138
#else
138139
static inline int mcheck_init(void) { return 0; }
139140
static inline void mcheck_cpu_init(struct cpuinfo_x86 *c) {}
141+
static inline void mcheck_vendor_init_severity(void) {}
140142
#endif
141143

142144
#ifdef CONFIG_X86_ANCIENT_MCE

arch/x86/kernel/cpu/mcheck/mce-internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct mce_bank {
2424
char attrname[ATTR_LEN]; /* attribute name */
2525
};
2626

27-
int mce_severity(struct mce *a, int tolerant, char **msg, bool is_excp);
27+
extern int (*mce_severity)(struct mce *a, int tolerant, char **msg, bool is_excp);
2828
struct dentry *mce_get_debugfs_dir(void);
2929

3030
extern struct mce_bank *mce_banks;

arch/x86/kernel/cpu/mcheck/mce-severity.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,10 @@ static int error_context(struct mce *m)
190190
* See AMD Error Scope Hierarchy table in a newer BKDG. For example
191191
* 49125_15h_Models_30h-3Fh_BKDG.pdf, section "RAS Features"
192192
*/
193-
static int mce_severity_amd(struct mce *m, enum context ctx)
193+
static int mce_severity_amd(struct mce *m, int tolerant, char **msg, bool is_excp)
194194
{
195+
enum context ctx = error_context(m);
196+
195197
/* Processor Context Corrupt, no need to fumble too much, die! */
196198
if (m->status & MCI_STATUS_PCC)
197199
return MCE_PANIC_SEVERITY;
@@ -239,15 +241,12 @@ static int mce_severity_amd(struct mce *m, enum context ctx)
239241
return MCE_KEEP_SEVERITY;
240242
}
241243

242-
int mce_severity(struct mce *m, int tolerant, char **msg, bool is_excp)
244+
static int mce_severity_intel(struct mce *m, int tolerant, char **msg, bool is_excp)
243245
{
244246
enum exception excp = (is_excp ? EXCP_CONTEXT : NO_EXCP);
245247
enum context ctx = error_context(m);
246248
struct severity *s;
247249

248-
if (m->cpuvendor == X86_VENDOR_AMD)
249-
return mce_severity_amd(m, ctx);
250-
251250
for (s = severities;; s++) {
252251
if ((m->status & s->mask) != s->result)
253252
continue;
@@ -272,6 +271,16 @@ int mce_severity(struct mce *m, int tolerant, char **msg, bool is_excp)
272271
}
273272
}
274273

274+
/* Default to mce_severity_intel */
275+
int (*mce_severity)(struct mce *m, int tolerant, char **msg, bool is_excp) =
276+
mce_severity_intel;
277+
278+
void __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+
275284
#ifdef CONFIG_DEBUG_FS
276285
static void *s_start(struct seq_file *f, loff_t *pos)
277286
{

arch/x86/kernel/cpu/mcheck/mce.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,6 +2026,7 @@ __setup("mce", mcheck_enable);
20262026
int __init mcheck_init(void)
20272027
{
20282028
mcheck_intel_therm_init();
2029+
mcheck_vendor_init_severity();
20292030

20302031
return 0;
20312032
}

0 commit comments

Comments
 (0)