Skip to content

Commit 41ce056

Browse files
youquan-songsuryasaimadhu
authored andcommitted
x86/mce: Pass pointer to saved pt_regs to severity calculation routines
New recovery features require additional information about processor state when a machine check occurred. Pass pt_regs down to the routines that need it. No functional change. Signed-off-by: Youquan Song <youquan.song@intel.com> Signed-off-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lkml.kernel.org/r/20201006210910.21062-2-tony.luck@intel.com
1 parent 5da8e4a commit 41ce056

3 files changed

Lines changed: 17 additions & 14 deletions

File tree

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ bool machine_check_poll(enum mcp_flags flags, mce_banks_t *b)
807807
goto clear_it;
808808

809809
mce_read_aux(&m, i);
810-
m.severity = mce_severity(&m, mca_cfg.tolerant, NULL, false);
810+
m.severity = mce_severity(&m, NULL, mca_cfg.tolerant, NULL, false);
811811
/*
812812
* Don't get the IP here because it's unlikely to
813813
* have anything to do with the actual error location.
@@ -856,7 +856,7 @@ static int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp,
856856
quirk_no_way_out(i, m, regs);
857857

858858
m->bank = i;
859-
if (mce_severity(m, mca_cfg.tolerant, &tmp, true) >= MCE_PANIC_SEVERITY) {
859+
if (mce_severity(m, regs, mca_cfg.tolerant, &tmp, true) >= MCE_PANIC_SEVERITY) {
860860
mce_read_aux(m, i);
861861
*msg = tmp;
862862
return 1;
@@ -956,7 +956,7 @@ static void mce_reign(void)
956956
*/
957957
if (m && global_worst >= MCE_PANIC_SEVERITY && mca_cfg.tolerant < 3) {
958958
/* call mce_severity() to get "msg" for panic */
959-
mce_severity(m, mca_cfg.tolerant, &msg, true);
959+
mce_severity(m, NULL, mca_cfg.tolerant, &msg, true);
960960
mce_panic("Fatal machine check", m, msg);
961961
}
962962

@@ -1167,7 +1167,7 @@ static noinstr bool mce_check_crashing_cpu(void)
11671167
return false;
11681168
}
11691169

1170-
static void __mc_scan_banks(struct mce *m, struct mce *final,
1170+
static void __mc_scan_banks(struct mce *m, struct pt_regs *regs, struct mce *final,
11711171
unsigned long *toclear, unsigned long *valid_banks,
11721172
int no_way_out, int *worst)
11731173
{
@@ -1202,7 +1202,7 @@ static void __mc_scan_banks(struct mce *m, struct mce *final,
12021202
/* Set taint even when machine check was not enabled. */
12031203
add_taint(TAINT_MACHINE_CHECK, LOCKDEP_NOW_UNRELIABLE);
12041204

1205-
severity = mce_severity(m, cfg->tolerant, NULL, true);
1205+
severity = mce_severity(m, regs, cfg->tolerant, NULL, true);
12061206

12071207
/*
12081208
* When machine check was for corrected/deferred handler don't
@@ -1354,7 +1354,7 @@ noinstr void do_machine_check(struct pt_regs *regs)
13541354
order = mce_start(&no_way_out);
13551355
}
13561356

1357-
__mc_scan_banks(&m, final, toclear, valid_banks, no_way_out, &worst);
1357+
__mc_scan_banks(&m, regs, final, toclear, valid_banks, no_way_out, &worst);
13581358

13591359
if (!no_way_out)
13601360
mce_clear_state(toclear);
@@ -1376,7 +1376,7 @@ noinstr void do_machine_check(struct pt_regs *regs)
13761376
* make sure we have the right "msg".
13771377
*/
13781378
if (worst >= MCE_PANIC_SEVERITY && mca_cfg.tolerant < 3) {
1379-
mce_severity(&m, cfg->tolerant, &msg, true);
1379+
mce_severity(&m, regs, cfg->tolerant, &msg, true);
13801380
mce_panic("Local fatal machine check!", &m, msg);
13811381
}
13821382
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ int mce_gen_pool_add(struct mce *mce);
3838
int mce_gen_pool_init(void);
3939
struct llist_node *mce_gen_pool_prepare_records(void);
4040

41-
extern int (*mce_severity)(struct mce *a, int tolerant, char **msg, bool is_excp);
41+
extern int (*mce_severity)(struct mce *a, struct pt_regs *regs,
42+
int tolerant, char **msg, bool is_excp);
4243
struct dentry *mce_get_debugfs_dir(void);
4344

4445
extern mce_banks_t mce_banks_ce_disabled;

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static struct severity {
223223
* distinguish an exception taken in user from from one
224224
* taken in the kernel.
225225
*/
226-
static int error_context(struct mce *m)
226+
static int error_context(struct mce *m, struct pt_regs *regs)
227227
{
228228
if ((m->cs & 3) == 3)
229229
return IN_USER;
@@ -267,9 +267,10 @@ static int mce_severity_amd_smca(struct mce *m, enum context err_ctx)
267267
* See AMD Error Scope Hierarchy table in a newer BKDG. For example
268268
* 49125_15h_Models_30h-3Fh_BKDG.pdf, section "RAS Features"
269269
*/
270-
static int mce_severity_amd(struct mce *m, int tolerant, char **msg, bool is_excp)
270+
static int mce_severity_amd(struct mce *m, struct pt_regs *regs, int tolerant,
271+
char **msg, bool is_excp)
271272
{
272-
enum context ctx = error_context(m);
273+
enum context ctx = error_context(m, regs);
273274

274275
/* Processor Context Corrupt, no need to fumble too much, die! */
275276
if (m->status & MCI_STATUS_PCC)
@@ -319,10 +320,11 @@ static int mce_severity_amd(struct mce *m, int tolerant, char **msg, bool is_exc
319320
return MCE_KEEP_SEVERITY;
320321
}
321322

322-
static int mce_severity_intel(struct mce *m, int tolerant, char **msg, bool is_excp)
323+
static int mce_severity_intel(struct mce *m, struct pt_regs *regs,
324+
int tolerant, char **msg, bool is_excp)
323325
{
324326
enum exception excp = (is_excp ? EXCP_CONTEXT : NO_EXCP);
325-
enum context ctx = error_context(m);
327+
enum context ctx = error_context(m, regs);
326328
struct severity *s;
327329

328330
for (s = severities;; s++) {
@@ -356,7 +358,7 @@ static int mce_severity_intel(struct mce *m, int tolerant, char **msg, bool is_e
356358
}
357359

358360
/* Default to mce_severity_intel */
359-
int (*mce_severity)(struct mce *m, int tolerant, char **msg, bool is_excp) =
361+
int (*mce_severity)(struct mce *m, struct pt_regs *regs, int tolerant, char **msg, bool is_excp) =
360362
mce_severity_intel;
361363

362364
void __init mcheck_vendor_init_severity(void)

0 commit comments

Comments
 (0)