[PATCH v6 14/90] x86/cpu: Use parsed CPUID(0x0)

From: Ahmed S. Darwish

Date: Thu Mar 26 2026 - 22:37:36 EST


Use parsed CPUID(0x0) instead of a direct CPUID query.

Signed-off-by: Ahmed S. Darwish <darwi@xxxxxxxxxxxxx>
---
arch/x86/kernel/cpu/common.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 8fd7d2f480bf..882754f10a4f 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -940,11 +940,15 @@ void get_cpu_vendor(struct cpuinfo_x86 *c)

void cpu_detect(struct cpuinfo_x86 *c)
{
- /* Get vendor name */
- cpuid(0x00000000, (unsigned int *)&c->cpuid_level,
- (unsigned int *)&c->x86_vendor_id[0],
- (unsigned int *)&c->x86_vendor_id[8],
- (unsigned int *)&c->x86_vendor_id[4]);
+ const struct leaf_0x0_0 *l0 = cpuid_leaf(c, 0x0);
+
+ if (!l0)
+ return;
+
+ c->cpuid_level = l0->max_std_leaf;
+ *(u32 *)&c->x86_vendor_id[0] = l0->cpu_vendorid_0;
+ *(u32 *)&c->x86_vendor_id[4] = l0->cpu_vendorid_1;
+ *(u32 *)&c->x86_vendor_id[8] = l0->cpu_vendorid_2;

c->x86 = 4;
/* Intel-defined flags: level 0x00000001 */
--
2.53.0