2020-06-11 02:35:15

by Zhenzhong Duan

[permalink] [raw]
Subject: [PATCH] x86/mce: fix a wrong assignment of i_mce.status

The original code is a nop as i_mce.status is or'ed with part of itself,
fix it.

Signed-off-by: Zhenzhong Duan <[email protected]>
---
arch/x86/kernel/cpu/mce/inject.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c
index 3413b41..dc28a61 100644
--- a/arch/x86/kernel/cpu/mce/inject.c
+++ b/arch/x86/kernel/cpu/mce/inject.c
@@ -511,7 +511,7 @@ static void do_inject(void)
*/
if (inj_type == DFR_INT_INJ) {
i_mce.status |= MCI_STATUS_DEFERRED;
- i_mce.status |= (i_mce.status & ~MCI_STATUS_UC);
+ i_mce.status &= ~MCI_STATUS_UC;
}

/*
--
1.8.3.1


2020-06-11 16:57:20

by Luck, Tony

[permalink] [raw]
Subject: Re: [PATCH] x86/mce: fix a wrong assignment of i_mce.status

+Yazen

On Thu, Jun 11, 2020 at 10:32:38AM +0800, Zhenzhong Duan wrote:
> The original code is a nop as i_mce.status is or'ed with part of itself,
> fix it.
>
> Signed-off-by: Zhenzhong Duan <[email protected]>
> ---
> arch/x86/kernel/cpu/mce/inject.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c
> index 3413b41..dc28a61 100644
> --- a/arch/x86/kernel/cpu/mce/inject.c
> +++ b/arch/x86/kernel/cpu/mce/inject.c
> @@ -511,7 +511,7 @@ static void do_inject(void)
> */
> if (inj_type == DFR_INT_INJ) {
> i_mce.status |= MCI_STATUS_DEFERRED;
> - i_mce.status |= (i_mce.status & ~MCI_STATUS_UC);
> + i_mce.status &= ~MCI_STATUS_UC;

Boris: "git blame" says you wrote this code. Patch looks right (in
that it makes the code do what the comment just above says it is trying
to do):

* - MCx_STATUS[UC] cleared: deferred errors are _not_ UC

But this is AMD specific, so I'll defer judgement

-Tony

2020-06-11 18:41:29

by Yazen Ghannam

[permalink] [raw]
Subject: Re: [PATCH] x86/mce: fix a wrong assignment of i_mce.status

On Thu, Jun 11, 2020 at 12:55:00PM -0400, Luck, Tony wrote:
> +Yazen
>
> On Thu, Jun 11, 2020 at 10:32:38AM +0800, Zhenzhong Duan wrote:
> > The original code is a nop as i_mce.status is or'ed with part of itself,
> > fix it.
> >
> > Signed-off-by: Zhenzhong Duan <[email protected]>
> > ---
> > arch/x86/kernel/cpu/mce/inject.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c
> > index 3413b41..dc28a61 100644
> > --- a/arch/x86/kernel/cpu/mce/inject.c
> > +++ b/arch/x86/kernel/cpu/mce/inject.c
> > @@ -511,7 +511,7 @@ static void do_inject(void)
> > */
> > if (inj_type == DFR_INT_INJ) {
> > i_mce.status |= MCI_STATUS_DEFERRED;
> > - i_mce.status |= (i_mce.status & ~MCI_STATUS_UC);
> > + i_mce.status &= ~MCI_STATUS_UC;
>
> Boris: "git blame" says you wrote this code. Patch looks right (in
> that it makes the code do what the comment just above says it is trying
> to do):
>
> * - MCx_STATUS[UC] cleared: deferred errors are _not_ UC
>
> But this is AMD specific, so I'll defer judgement
>

Acked-by: Yazen Ghannam <[email protected]>

Thanks,
Yazen

2020-06-15 11:38:32

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH] x86/mce: fix a wrong assignment of i_mce.status

On Thu, Jun 11, 2020 at 09:55:00AM -0700, Luck, Tony wrote:
> +Yazen
>
> On Thu, Jun 11, 2020 at 10:32:38AM +0800, Zhenzhong Duan wrote:
> > The original code is a nop as i_mce.status is or'ed with part of itself,
> > fix it.
> >
> > Signed-off-by: Zhenzhong Duan <[email protected]>
> > ---
> > arch/x86/kernel/cpu/mce/inject.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c
> > index 3413b41..dc28a61 100644
> > --- a/arch/x86/kernel/cpu/mce/inject.c
> > +++ b/arch/x86/kernel/cpu/mce/inject.c
> > @@ -511,7 +511,7 @@ static void do_inject(void)
> > */
> > if (inj_type == DFR_INT_INJ) {
> > i_mce.status |= MCI_STATUS_DEFERRED;
> > - i_mce.status |= (i_mce.status & ~MCI_STATUS_UC);
> > + i_mce.status &= ~MCI_STATUS_UC;
>
> Boris: "git blame" says you wrote this code.

Not me but I should've caught it:

a1300e505297 ("x86/ras/mce_amd_inj: Trigger deferred and thresholding errors interrupts")

:-\

I believe Aravind wanted to do the &= thing, i.e.,

i_mce.status = (i_mce.status & ~MCI_STATUS_UC);

or the short version above.

:-)

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

Subject: [tip: ras/core] x86/mce/inject: Fix a wrong assignment of i_mce.status

The following commit has been merged into the ras/core branch of tip:

Commit-ID: 5d7f7d1d5e01c22894dee7c9c9266500478dca99
Gitweb: https://git.kernel.org/tip/5d7f7d1d5e01c22894dee7c9c9266500478dca99
Author: Zhenzhong Duan <[email protected]>
AuthorDate: Thu, 11 Jun 2020 10:32:38 +08:00
Committer: Borislav Petkov <[email protected]>
CommitterDate: Mon, 15 Jun 2020 13:38:55 +02:00

x86/mce/inject: Fix a wrong assignment of i_mce.status

The original code is a nop as i_mce.status is or'ed with part of itself,
fix it.

Fixes: a1300e505297 ("x86/ras/mce_amd_inj: Trigger deferred and thresholding errors interrupts")
Signed-off-by: Zhenzhong Duan <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Acked-by: Yazen Ghannam <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
---
arch/x86/kernel/cpu/mce/inject.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c
index 0593b19..7843ab3 100644
--- a/arch/x86/kernel/cpu/mce/inject.c
+++ b/arch/x86/kernel/cpu/mce/inject.c
@@ -511,7 +511,7 @@ static void do_inject(void)
*/
if (inj_type == DFR_INT_INJ) {
i_mce.status |= MCI_STATUS_DEFERRED;
- i_mce.status |= (i_mce.status & ~MCI_STATUS_UC);
+ i_mce.status &= ~MCI_STATUS_UC;
}

/*