x86: Incorrect CPUID leaf in Zen 5 detection
Jussi Kivilinna
jussi.kivilinna at iki.fi
Thu Oct 8 21:13:55 CEST 2026
Hello,
On 08/10/2026 12:22, HMBSbige via Gcrypt-devel wrote:
> Hi,
> The AVX512_BMM check in src/hwf-x86.c has two errors:
>
> 1. The leaf should be 0x80000021, not 0x21.
> 2. The availability check should use the maximum extended leaf
> returned by CPUID(0x80000000).EAX, not the maximum basic leaf
> from CPUID(0).EAX. The file currently never queries 0x80000000.
Thanks for reporting this.
>
> The minimal fix would be:
>
> unsigned int max_ext_level, amd_feat;
>
> get_cpuid(0x80000000, &max_ext_level, NULL, NULL, NULL);
> if (max_ext_level >= 0x80000021)
> {
> get_cpuid(0x80000021, &amd_feat, NULL, NULL, NULL);
> if (amd_feat & (1 << 23))
> has_avx512bmm = 1;
> }
>
> Alternatively, I suggest identifying Zen 5 directly by vendor,
> family and model. Family 0x1A also includes Zen 6, so the absence
> of AVX512_BMM is not sufficient to identify Zen 5.
>
> Following Linux's classification in arch/x86/kernel/cpu/amd.c,
> the Zen 5 condition would be:
>
> if (is_amd_cpu && family == 0x1a
> && (model <= 0x2f
> || (model >= 0x40 && model <= 0x4f)
> || (model >= 0x60 && model <= 0x7f)
> || (model >= 0xd0 && model <= 0xd7)))
> {
> cpu_details->int_vector_latency = 2;
> cpu_details->prefer_gpr_over_scalar_int_vector = 1;
> }
>
> This reuses the already decoded family/model and eliminates the
> AVX512_BMM probe. Unknown models would retain the default tuning
> until evaluated.
I think this approach would make more sense. I'll switch to using it.
-Jussi
More information about the Gcrypt-devel
mailing list