Commit 685d46d7 authored by Aravind Gopalakrishnan's avatar Aravind Gopalakrishnan Committed by Borislav Petkov

EDAC, mce_amd_inj: Read out number of MCE banks from the hardware

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: default avatarAravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
Cc: mchehab@osg.samsung.com
Link: http://lkml.kernel.org/r/1432753418-2985-3-git-send-email-Aravind.Gopalakrishnan@amd.comSigned-off-by: default avatarBorislav Petkov <bp@suse.de>
parent e7f2ea1d
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
static struct mce i_mce; static struct mce i_mce;
static struct dentry *dfs_inj; static struct dentry *dfs_inj;
static u8 n_banks;
#define MCE_INJECT_SET(reg) \ #define MCE_INJECT_SET(reg) \
static int inj_##reg##_set(void *data, u64 val) \ static int inj_##reg##_set(void *data, u64 val) \
{ \ { \
...@@ -174,12 +176,10 @@ static int inj_bank_set(void *data, u64 val) ...@@ -174,12 +176,10 @@ static int inj_bank_set(void *data, u64 val)
{ {
struct mce *m = (struct mce *)data; struct mce *m = (struct mce *)data;
if (val > 5) { if (val >= n_banks) {
if (boot_cpu_data.x86 != 0x15 || val > 6) {
pr_err("Non-existent MCE bank: %llu\n", val); pr_err("Non-existent MCE bank: %llu\n", val);
return -EINVAL; return -EINVAL;
} }
}
m->bank = val; m->bank = val;
do_inject(); do_inject();
...@@ -207,6 +207,10 @@ static struct dfs_node { ...@@ -207,6 +207,10 @@ static struct dfs_node {
static int __init init_mce_inject(void) static int __init init_mce_inject(void)
{ {
int i; int i;
u64 cap;
rdmsrl(MSR_IA32_MCG_CAP, cap);
n_banks = cap & MCG_BANKCNT_MASK;
dfs_inj = debugfs_create_dir("mce-inject", NULL); dfs_inj = debugfs_create_dir("mce-inject", NULL);
if (!dfs_inj) if (!dfs_inj)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment