Re: [PATCH v7 013/120] x86/cpu: Use parsed CPUID(0x80000000)
From: Maciej Wieczor-Retman
Date: Mon Jun 01 2026 - 13:40:08 EST
On 2026-05-28 at 17:37:35 +0200, Ahmed S. Darwish wrote:
>At early boot code, use parsed CPUID(0x80000000) instead of invoking a
>direct CPUID query.
>
>The original code has the check:
>
> extended_cpuid_level = ((eax & 0xffff0000) == 0x80000000) ? eax : 0;
>
>to protect against Intel 32-bit machines without an extended range, where a
>CPUID(0x80000000) query will repeat the output of the max-valid standard
>CPUID leaf output.
>
>A similar check is already done at the CPUID parser's own CPUID(0x80000000)
>read function:
>
> if (CPUID_RANGE(el0->max_ext_leaf) != CPUID_EXT_START) {
> // Handle error
> }
>
>Thus, for the call-site, the parsed CPUID NULL check below:
>
> el0 = cpuid_leaf(c, 0x80000000);
> extended_cpuid_level = el0 ? el0->max_ext_leaf : 0;
>
>is sufficient.
>
>Signed-off-by: Ahmed S. Darwish <darwi@xxxxxxxxxxxxx>
>---
> arch/x86/kernel/cpu/common.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
>diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
>index 257808609ef5..9b05a747161f 100644
>--- a/arch/x86/kernel/cpu/common.c
>+++ b/arch/x86/kernel/cpu/common.c
>@@ -1019,6 +1019,7 @@ static void init_speculation_control(struct cpuinfo_x86 *c)
>
> void get_cpu_cap(struct cpuinfo_x86 *c)
> {
>+ const struct leaf_0x80000000_0 *el0 = cpuid_leaf(c, 0x80000000);
I think at this point in the series 'c' is not initialized if you follow:
microcode_check()
-> store_cpu_caps()
-> get_cpu_cap()
I see the 'Route all feature queries to the CPUID tables' patch fixes this but
I'm not sure if this was intentional. As it's not mentioned in the patch message
I thought maybe it wasn't intentional.
--
Kind regards
Maciej Wieczór-Retman