From: Sean Christopherson <seanjc@google.com>
To: Borislav Petkov <bp@alien8.de>
Cc: x86-ML <x86@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH] x86/cpu: Change AMD uarch detection
Date: Tue, 27 Oct 2026 08:20:49 -0700 [thread overview]
Message-ID: <auDBUQQ9Ympsobkh@google.com> (raw)
In-Reply-To: <20261022040047.GDatmKb9L_fwqBGQ0_@fat_crate.local>
On Wed, Oct 21, 2026, Borislav Petkov wrote:
> Hi,
>
> I have been wondering how to improve that Zen uarch detection and handling and
> be able to do range checks of uarches, i.e., "this code needs to run on Zen
> microarchitectures 3 to 5". And I asked AI.
>
> It gave me a lot of blurb but the basic idea is good so I went and did it. See
> below.
>
> It boots in a VM, I'm not even trying to cause the cat to catch fire by
> booting on a real machine but that will happen soon too.
>
> The thing can easily be extended to pre-Zen but that is not really needed, I'd
> say.
>
> X86_FEATURE_ZEN to mark all Zens remains, that will be a future patch. Perhaps
> something as simple as:
>
> if (boot_cpu_data.x86_uarch)
>
> but I have to move Hygon off of that usage. We'll see. Small steps.
This is better than X86_FEATURE_ZENx, as I always found the lack of inclusivity,
e.g. ZEN4 not lighting up ZEN3, to be confusing/surprising.
But why invent another scheme? What stops AMD from implementing precise macros
as arch/x86/include/asm/intel-family.h does? Providing range-based checks would
"just" require more macros, no? E.g. couldn't we do
if (AMD_ZEN4_OR_LATER(boot_cpu_data.x86_vfm))
return amd_zen4_perfmon_event_map[hw_event];
if (AMD_ZEN2_OR_LATER(boot_cpu_data.x86_vfm))
return amd_zen2_perfmon_event_map[hw_event];
if (AMD_ZEN1_OR_LATER(boot_cpu_data.x86_vfm))
return amd_zen1_perfmon_event_map[hw_event];
and
if (AMD_ZEN3(boot_cpu_data.x86_vfm) ||
AMD_ZEN4(boot_cpu_data.x86_vfm)) {
...
}
next prev parent reply other threads:[~2026-10-27 15:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 4:00 [RFC PATCH] x86/cpu: Change AMD uarch detection Borislav Petkov
2026-10-27 15:20 ` Sean Christopherson [this message]
2026-10-28 4:46 ` Borislav Petkov
2026-10-28 14:05 ` Sean Christopherson
2026-10-28 15:34 ` Borislav Petkov
2026-10-29 17:56 ` Borislav Petkov
2026-10-30 19:13 ` Sean Christopherson
2026-10-30 21:29 ` Sohil Mehta
2026-10-31 1:55 ` Borislav Petkov
2026-10-31 5:08 ` Sohil Mehta
2026-10-31 5:32 ` Borislav Petkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=auDBUQQ9Ympsobkh@google.com \
--to=seanjc@google.com \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.