[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211019233641.140275-2-Smita.KoralahalliChannabasappa@amd.com>
Date: Tue, 19 Oct 2021 18:36:37 -0500
From: Smita Koralahalli <Smita.KoralahalliChannabasappa@....com>
To: <x86@...nel.org>, <linux-edac@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
CC: Tony Luck <tony.luck@...el.com>, "H . Peter Anvin" <hpa@...or.com>,
<yazen.ghannam@....com>, <Smita.KoralahalliChannabasappa@....com>
Subject: [PATCH v2 1/5] x86/mce/inject: Check if a bank is unpopulated before error injection
The MCA_IPID register uniquely identifies a bank's type on Scalable MCA
(SMCA) systems. When an MCA bank is not populated, the MCA_IPID register
will read as zero and writes to it will be ignored.
On a "hw" error injection check the value of this register before trying
to inject the error.
Do not impose any limitation on a "sw" injection and allow the user to
test out all the decoding paths without relying on the available hardware,
as its purpose is to just test the code.
Signed-off-by: Smita Koralahalli <Smita.KoralahalliChannabasappa@....com>
---
v2:
simulate -> inject.
Corrected according to kernel commenting style.
boot_cpu_has() -> cpu_feature_enabled().
Error simulation not possible: Bank %llu unpopulated ->
Cannot set IPID - bank %llu unpopulated.
Used user provided IPID value on sw injection without checking
underlying hardware and defined it under inj_ipid_set().
---
arch/x86/kernel/cpu/mce/inject.c | 39 +++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c
index 0bfc14041bbb..601efd104bb4 100644
--- a/arch/x86/kernel/cpu/mce/inject.c
+++ b/arch/x86/kernel/cpu/mce/inject.c
@@ -74,7 +74,6 @@ MCE_INJECT_SET(status);
MCE_INJECT_SET(misc);
MCE_INJECT_SET(addr);
MCE_INJECT_SET(synd);
-MCE_INJECT_SET(ipid);
#define MCE_INJECT_GET(reg) \
static int inj_##reg##_get(void *data, u64 *val) \
@@ -89,13 +88,11 @@ MCE_INJECT_GET(status);
MCE_INJECT_GET(misc);
MCE_INJECT_GET(addr);
MCE_INJECT_GET(synd);
-MCE_INJECT_GET(ipid);
DEFINE_SIMPLE_ATTRIBUTE(status_fops, inj_status_get, inj_status_set, "%llx\n");
DEFINE_SIMPLE_ATTRIBUTE(misc_fops, inj_misc_get, inj_misc_set, "%llx\n");
DEFINE_SIMPLE_ATTRIBUTE(addr_fops, inj_addr_get, inj_addr_set, "%llx\n");
DEFINE_SIMPLE_ATTRIBUTE(synd_fops, inj_synd_get, inj_synd_set, "%llx\n");
-DEFINE_SIMPLE_ATTRIBUTE(ipid_fops, inj_ipid_get, inj_ipid_set, "%llx\n");
static void setup_inj_struct(struct mce *m)
{
@@ -577,6 +574,25 @@ static int inj_bank_set(void *data, u64 val)
}
m->bank = val;
+
+ /*
+ * Read IPID value to determine if a bank is unpopulated on the target
+ * CPU.
+ */
+ if (cpu_feature_enabled(X86_FEATURE_SMCA)) {
+
+ /* Check for user provided IPID value on a sw injection. */
+ if (!m->ipid) {
+ rdmsrl_on_cpu(m->extcpu, MSR_AMD64_SMCA_MCx_IPID(val),
+ &m->ipid);
+ if (!m->ipid) {
+ pr_err("Cannot set IPID - bank %llu unpopulated\n",
+ val);
+ return -ENODEV;
+ }
+ }
+ }
+
do_inject();
/* Reset injection struct */
@@ -589,6 +605,23 @@ MCE_INJECT_GET(bank);
DEFINE_SIMPLE_ATTRIBUTE(bank_fops, inj_bank_get, inj_bank_set, "%llu\n");
+/* Use the user provided IPID value on a sw injection. */
+static int inj_ipid_set(void *data, u64 val)
+{
+ struct mce *m = (struct mce *)data;
+
+ if (cpu_feature_enabled(X86_FEATURE_SMCA)) {
+ if (val && inj_type == SW_INJ)
+ m->ipid = val;
+ }
+
+ return 0;
+}
+
+MCE_INJECT_GET(ipid);
+
+DEFINE_SIMPLE_ATTRIBUTE(ipid_fops, inj_ipid_get, inj_ipid_set, "%llx\n");
+
static const char readme_msg[] =
"Description of the files and their usages:\n"
"\n"
--
2.17.1
Powered by blists - more mailing lists