linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/mce: Use ZENx features for Zen IF quirk
@ 2025-08-11 20:34 Yazen Ghannam
  2025-08-11 20:55 ` Borislav Petkov
  0 siblings, 1 reply; 3+ messages in thread
From: Yazen Ghannam @ 2025-08-11 20:34 UTC (permalink / raw)
  To: x86, Tony Luck; +Cc: linux-edac, linux-kernel, Yazen Ghannam

Zen1 through Zen5 systems have a quirk related to Instruction Fetch
poison consumption.

Currently, the quirk is applied to families 17h, 18h, 19h, and 1Ah.
However, family numbers don't apply directly to Zen CPU revisions.

Update the quirk check to use the "X86_FEATURE_ZEN" CPU features to
apply only to affected CPU revisions.

Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
---
 arch/x86/kernel/cpu/mce/core.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
index 4da4eab56c81..0ef164568077 100644
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -1951,8 +1951,11 @@ static void apply_quirks_amd(struct cpuinfo_x86 *c)
 	if (c->x86 == 0x15 && c->x86_model <= 0xf)
 		mce_flags.overflow_recov = 1;
 
-	if (c->x86 >= 0x17 && c->x86 <= 0x1A)
-		mce_flags.zen_ifu_quirk = 1;
+	mce_flags.zen_ifu_quirk = cpu_feature_enabled(X86_FEATURE_ZEN1) ||
+				  cpu_feature_enabled(X86_FEATURE_ZEN2) ||
+				  cpu_feature_enabled(X86_FEATURE_ZEN3) ||
+				  cpu_feature_enabled(X86_FEATURE_ZEN4) ||
+				  cpu_feature_enabled(X86_FEATURE_ZEN5);
 }
 
 static void apply_quirks_intel(struct cpuinfo_x86 *c)

---
base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
change-id: 20250811-wip-mca-reduce-if-quirk-83a9744fa057


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/mce: Use ZENx features for Zen IF quirk
  2025-08-11 20:34 [PATCH] x86/mce: Use ZENx features for Zen IF quirk Yazen Ghannam
@ 2025-08-11 20:55 ` Borislav Petkov
  2025-08-12 14:56   ` Yazen Ghannam
  0 siblings, 1 reply; 3+ messages in thread
From: Borislav Petkov @ 2025-08-11 20:55 UTC (permalink / raw)
  To: Yazen Ghannam; +Cc: x86, Tony Luck, linux-edac, linux-kernel

On Mon, Aug 11, 2025 at 04:34:08PM -0400, Yazen Ghannam wrote:
> diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
> index 4da4eab56c81..0ef164568077 100644
> --- a/arch/x86/kernel/cpu/mce/core.c
> +++ b/arch/x86/kernel/cpu/mce/core.c
> @@ -1951,8 +1951,11 @@ static void apply_quirks_amd(struct cpuinfo_x86 *c)
>  	if (c->x86 == 0x15 && c->x86_model <= 0xf)
>  		mce_flags.overflow_recov = 1;
>  
> -	if (c->x86 >= 0x17 && c->x86 <= 0x1A)
> -		mce_flags.zen_ifu_quirk = 1;
> +	mce_flags.zen_ifu_quirk = cpu_feature_enabled(X86_FEATURE_ZEN1) ||
> +				  cpu_feature_enabled(X86_FEATURE_ZEN2) ||
> +				  cpu_feature_enabled(X86_FEATURE_ZEN3) ||
> +				  cpu_feature_enabled(X86_FEATURE_ZEN4) ||
> +				  cpu_feature_enabled(X86_FEATURE_ZEN5);

I was fearing this day would come where we'd need something like that and it
would look gross. And it does.

Can't we simplify the quirk to do:

	if (!m->cs)
		m->cs = regs->cs;

when X86_FEATURE_ZEN is set and that should be good enough if we squint our
eyes hard enough...

m->cs on the fixed machines won't be 0 so it all just works...

-- 
Regards/Gruss,
    Boris.

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/mce: Use ZENx features for Zen IF quirk
  2025-08-11 20:55 ` Borislav Petkov
@ 2025-08-12 14:56   ` Yazen Ghannam
  0 siblings, 0 replies; 3+ messages in thread
From: Yazen Ghannam @ 2025-08-12 14:56 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: x86, Tony Luck, linux-edac, linux-kernel

On Mon, Aug 11, 2025 at 10:55:29PM +0200, Borislav Petkov wrote:
> On Mon, Aug 11, 2025 at 04:34:08PM -0400, Yazen Ghannam wrote:
> > diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
> > index 4da4eab56c81..0ef164568077 100644
> > --- a/arch/x86/kernel/cpu/mce/core.c
> > +++ b/arch/x86/kernel/cpu/mce/core.c
> > @@ -1951,8 +1951,11 @@ static void apply_quirks_amd(struct cpuinfo_x86 *c)
> >  	if (c->x86 == 0x15 && c->x86_model <= 0xf)
> >  		mce_flags.overflow_recov = 1;
> >  
> > -	if (c->x86 >= 0x17 && c->x86 <= 0x1A)
> > -		mce_flags.zen_ifu_quirk = 1;
> > +	mce_flags.zen_ifu_quirk = cpu_feature_enabled(X86_FEATURE_ZEN1) ||
> > +				  cpu_feature_enabled(X86_FEATURE_ZEN2) ||
> > +				  cpu_feature_enabled(X86_FEATURE_ZEN3) ||
> > +				  cpu_feature_enabled(X86_FEATURE_ZEN4) ||
> > +				  cpu_feature_enabled(X86_FEATURE_ZEN5);
> 
> I was fearing this day would come where we'd need something like that and it
> would look gross. And it does.
> 
> Can't we simplify the quirk to do:
> 
> 	if (!m->cs)
> 		m->cs = regs->cs;
> 
> when X86_FEATURE_ZEN is set and that should be good enough if we squint our
> eyes hard enough...

The quirk doesn't apply to all Zen-based systems. Only the Zen 1-5 are
affected.

We could *not* do this patch if it's too ugly. The quirk would apply to
some systems that aren't affected. But this would be a NOP in practice.

> 
> m->cs on the fixed machines won't be 0 so it all just works...
> 
> -- 

I've been thinking that we could do away with some of these quirks if we
refactor a bit. I'll dust off a patch I have and send for RFC.

Thanks,
Yazen

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-12 14:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-11 20:34 [PATCH] x86/mce: Use ZENx features for Zen IF quirk Yazen Ghannam
2025-08-11 20:55 ` Borislav Petkov
2025-08-12 14:56   ` Yazen Ghannam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).