Skip to content

Commit

Permalink
EDAC, mce_amd_inj: Read out number of MCE banks from the hardware
Browse files Browse the repository at this point in the history
The number of banks for a given processor is encoded in
MSR_IA32_MCG_CAP[7:0]. So obtain the value from that MSR and use it for
sanity checking in inj_bank_set() instead of doing a family/model check.

Signed-off-by: Aravind Gopalakrishnan <[email protected]>
Cc: linux-edac <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Borislav Petkov <[email protected]>
  • Loading branch information
Aravind Gopalakrishnan authored and suryasaimadhu committed Jun 3, 2015
1 parent e7f2ea1 commit 685d46d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions drivers/edac/mce_amd_inj.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
static struct mce i_mce;
static struct dentry *dfs_inj;

static u8 n_banks;

#define MCE_INJECT_SET(reg) \
static int inj_##reg##_set(void *data, u64 val) \
{ \
Expand Down Expand Up @@ -174,11 +176,9 @@ static int inj_bank_set(void *data, u64 val)
{
struct mce *m = (struct mce *)data;

if (val > 5) {
if (boot_cpu_data.x86 != 0x15 || val > 6) {
pr_err("Non-existent MCE bank: %llu\n", val);
return -EINVAL;
}
if (val >= n_banks) {
pr_err("Non-existent MCE bank: %llu\n", val);
return -EINVAL;
}

m->bank = val;
Expand Down Expand Up @@ -207,6 +207,10 @@ static struct dfs_node {
static int __init init_mce_inject(void)
{
int i;
u64 cap;

rdmsrl(MSR_IA32_MCG_CAP, cap);
n_banks = cap & MCG_BANKCNT_MASK;

dfs_inj = debugfs_create_dir("mce-inject", NULL);
if (!dfs_inj)
Expand Down

0 comments on commit 685d46d

Please sign in to comment.