[10/12] x86/mce/inject.c: fail if target cpu is block interference
Commit Message
In the codepaths leading to smp_call_function (including rdmsrl_on_cpu),
check for, and fail if, a target cpu is marked as "block interference".
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
===================================================================
@@ -23,6 +23,7 @@
#include <linux/notifier.h>
#include <linux/pci.h>
#include <linux/uaccess.h>
+#include <linux/sched/isolation.h>
#include <asm/amd_nb.h>
#include <asm/apic.h>
@@ -584,6 +585,13 @@ static int inj_bank_set(void *data, u64
struct mce *m = (struct mce *)data;
u8 n_banks;
u64 cap;
+ int idx, ret = 0;
+
+ idx = block_interf_srcu_read_lock();
+ if (block_interf_cpu(m->extcpu)) {
+ ret = -EPERM;
+ goto err;
+ }
/* Get bank count on target CPU so we can handle non-uniform values. */
rdmsrl_on_cpu(m->extcpu, MSR_IA32_MCG_CAP, &cap);
@@ -591,7 +599,8 @@ static int inj_bank_set(void *data, u64
if (val >= n_banks) {
pr_err("MCA bank %llu non-existent on CPU%d\n", val, m->extcpu);
- return -EINVAL;
+ ret = -EINVAL;
+ goto err;
}
m->bank = val;
@@ -612,12 +621,14 @@ static int inj_bank_set(void *data, u64
if (rdmsrl_on_cpu(m->extcpu, MSR_AMD64_SMCA_MCx_IPID(val), &ipid)) {
pr_err("Error reading IPID on CPU%d\n", m->extcpu);
- return -EINVAL;
+ ret = -EINVAL;
+ goto err;
}
if (!ipid) {
pr_err("Cannot inject into unpopulated bank %llu\n", val);
- return -ENODEV;
+ ret = -ENODEV;
+ goto err;
}
}
@@ -627,7 +638,9 @@ inject:
/* Reset injection struct */
setup_inj_struct(&i_mce);
- return 0;
+err:
+ block_interf_srcu_read_unlock(idx);
+ return ret;
}
MCE_INJECT_GET(bank);