Re: [RFC PATCH] x86/cpu: Change AMD uarch detection
From: Sohil Mehta
Date: Fri Oct 30 2026 - 17:35:43 EST
On 10/29/2026 10:56 AM, Borislav Petkov wrote:
> Looks easy enough but needs thorough testing and perhaps some commenting how
> we're using x86_vfm on AMD a bit differently.
>
I was working on adding guidance for x86_vfm usage for Intel in the
kernel documentation when I saw this thread. Here's the initial draft I
had for Intel:
Intel CPU model checks
----------------------
Intel CPU model checks should use the combined vendor/family/model
field, x86_vfm, together with the INTEL_* defines in
asm/intel-family.h. Avoid comparing x86_model against literal
model numbers. Instead of writing::
if (c->x86 == 6 && c->x86_model == 0x97)
Please use::
if (c->x86_vfm == INTEL_ALDERLAKE)
To match several models, prefer an x86_match_cpu() table built
with X86_MATCH_VFM(). If a model is missing from
asm/intel-family.h, add a define for it.
Range checks on x86_vfm can work, but they are discouraged for
newer CPUs. Model numbers are not assigned in release order, and
the newer Families 18 and 19 interleave with Family 6, which makes
ranges hard to get right.
IIUC, the AMD usage is primarily geared towards range checks for a group
of CPUs whereas the Intel usage is for specific targeted CPUs.
Expressing uarch reusing x86_vfm and using it for range checks can be
tricky. See below.
> amd-family.h is not really necessary right now but that's immaterial for this
> change - we can always convert to it later if absolutely necessary. And
> I don't think it will be.
>
...
> @@ -483,13 +482,13 @@ static void bsp_init_amd(struct cpuinfo_x86 *c)
> switch (c->x86_model) {
> case 0x00 ... 0x2f:
> case 0x50 ... 0x5f:
> - setup_force_cpu_cap(X86_FEATURE_ZEN1);
> + c->x86_vfm = AMD_ZEN1;
Since x86_vfm is a union, wouldn't this clobber the vendor, family and
model? This will set the x86_vendor to 0 and get detected as an Intel CPU.
> break;
> case 0x30 ... 0x4f:
> case 0x60 ... 0x7f:
> case 0x90 ... 0x91:
> case 0xa0 ... 0xaf:
> - setup_force_cpu_cap(X86_FEATURE_ZEN2);
> + c->x86_vfm = AMD_ZEN2;
> break;
> default: