2022-02-15 00:51:10

by Smita Koralahalli

[permalink] [raw]
Subject: [PATCH v4 0/2] x86/mce: Handle error injection failure in mce-inject module

This set of patches handles a scenario where error injection fails silently
on mce-inject module and returns appropriate error code to userspace.

Error injection fails if the platform enforces write ignored behavior on
status registers and the first patch checks for writes ignored from
MCA_STATUS register and returns appropriate error code to user.

The second patch assigns and returns the error code to userspace when none
of the CPUs are online.

Smita Koralahalli (2):
x86/mce: Check for writes ignored in MCA_STATUS register
x86/mce/mce-inject: Return appropriate error code if CPUs are offline

arch/x86/kernel/cpu/mce/core.c | 1 +
arch/x86/kernel/cpu/mce/inject.c | 42 +++++++++++++++++++++++++++++---
2 files changed, 39 insertions(+), 4 deletions(-)

--
2.17.1


2022-02-15 00:54:05

by Smita Koralahalli

[permalink] [raw]
Subject: [PATCH v4 2/2] x86/mce/mce-inject: Return appropriate error code if CPUs are offline

Assign appropriate error code when no CPUs are available online.

Return this error code with appropriate message to user when injection
fails.

Signed-off-by: Smita Koralahalli <[email protected]>
Reviewed-by: Yazen Ghannam <[email protected]>
---
Link:
https://lkml.kernel.org/r/[email protected]

v2:
Added pr_err() along with error code.
v3:
Rephrased the statement: No online CPUs available for error
injection -> Chosen CPU is not online.
v4:
Prefixed "mce-inject" so the user knows that the message is
coming from this module.
Printed CPU number along with the error message.
---
arch/x86/kernel/cpu/mce/inject.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c
index 43ba63b7dc73..b293db2788d4 100644
--- a/arch/x86/kernel/cpu/mce/inject.c
+++ b/arch/x86/kernel/cpu/mce/inject.c
@@ -573,8 +573,11 @@ static void do_inject(void)
}

cpus_read_lock();
- if (!cpu_online(cpu))
+ if (!cpu_online(cpu)) {
+ pr_err("mce-inject: Chosen CPU %d is not online\n", cpu);
+ mce_err.err = -ENODEV;
goto err;
+ }

toggle_hw_mce_inject(cpu, true);

--
2.17.1

Subject: Re: [PATCH v4 0/2] x86/mce: Handle error injection failure in mce-inject module

Hi all,

Do you have any comments that needs to be addressed on these set of patches?

Thanks,
Smita.

On 2/14/22 5:36 PM, Smita Koralahalli wrote:

> This set of patches handles a scenario where error injection fails silently
> on mce-inject module and returns appropriate error code to userspace.
>
> Error injection fails if the platform enforces write ignored behavior on
> status registers and the first patch checks for writes ignored from
> MCA_STATUS register and returns appropriate error code to user.
>
> The second patch assigns and returns the error code to userspace when none
> of the CPUs are online.
>
> Smita Koralahalli (2):
> x86/mce: Check for writes ignored in MCA_STATUS register
> x86/mce/mce-inject: Return appropriate error code if CPUs are offline
>
> arch/x86/kernel/cpu/mce/core.c | 1 +
> arch/x86/kernel/cpu/mce/inject.c | 42 +++++++++++++++++++++++++++++---
> 2 files changed, 39 insertions(+), 4 deletions(-)
>