Re: [PATCH v5] x86/mce: Check for writes ignored in MCA_STATUS register

From: Smita Koralahalli
Date: Fri Jun 24 2022 - 18:34:53 EST


Hi Boris,

On 6/22/2022 10:29 AM, Borislav Petkov wrote:
On Fri, Jun 10, 2022 at 07:25:15PM +0000, Smita Koralahalli wrote:
arch/x86/kernel/cpu/mce/inject.c | 50 +++++++++++++++++++++++++++++-
arch/x86/kernel/cpu/mce/internal.h | 2 +-
2 files changed, 50 insertions(+), 2 deletions(-)
I've simplified, improved and removed some stuff. See if that still
works on that platform which ignores writes.

I tested out the patch. Its not behaving as expected. The module fails silently
again.
+ cpu = get_cpu();
+
+ for (bank = 0; bank < MAX_NR_BANKS; ++bank) {
+ u64 status = MCI_STATUS_VAL, ipid;
+
+ /* Check whether bank is populated */
+ rdmsrl(MSR_AMD64_SMCA_MCx_IPID(bank), ipid);
+ if (!ipid)
+ continue;
+
+ toggle_hw_mce_inject(cpu, true);
+
+ if (wrmsrl_safe(mca_msr_reg(bank, MCA_STATUS), status)) {

The wrmsrl_safe() doesn't throw an error here.
I think we need to read back the written value and check for it whatsoever.
What do you think?

Thanks,
Smita
+ hw_injection_possible = false;
+ pr_warn("Platform does not allow *hardware* error injection."
+ "Try using APEI EINJ instead.\n");
+ }
+
+ toggle_hw_mce_inject(cpu, false);
+
+ break;
+ }
+
+ put_cpu();
+}