From nobody Thu Apr 2 20:20:48 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDE4733688C for ; Fri, 27 Mar 2026 02:18:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774577902; cv=none; b=pLFdgZ5q7RtI6NrkSK1539qz++Gq+bZAhRQvq87hazIz7MnomZSnKm6HCmsz6mQDftN94Q/kQImLcWUCmjP2Fr48HhjxcOLDhug5jIJpd3/YzNicprF7Y8ltYYZZut7PunjAv/arFOBj5vKi7YJ0zla8tHtaXmYzsBjO0ranqNg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774577902; c=relaxed/simple; bh=yZO3oyNgwkBjST8DL5nHJzVtgcaS/J5bZ4XGO4xatOg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dQuhzztWVs/EfVHCWwZKnJFCc1QrtfM/NEuOJVjfjwfqitM0R5iKKhAXjemCStKqvf0XV4xmSk/AUULgc6it/W/cE3L8rR3lNYZWPtWnJSJ75kHfzsWXMFOqIMqt756lzbGSN3wW/bVuwWU/Fg2CVyFPQPeYVpO5RNdU3bacfms= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=d67wuFpk; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=oXOjZiRp; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="d67wuFpk"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="oXOjZiRp" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1774577898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ooFMpDZikzJTmqCKLxnHYNVV/Cyv2iG4aFci2pBjaQw=; b=d67wuFpk7rKNa+dlvkILauEcsc5nIUcqheqe/0TILFUy5FRji3+w8w8Urhv6FGSOEE7kw/ V1QQkNSzQ0zdiG4RNEWdcWqwcuvaO7uZIFp113INDtGncvKLMca16i7RuChoM2E7ZIWnm4 livzXpULmyxurFIYgBZRX6f4BnbCcOIvEXDXZz6cuwMqXvbxNcM12/OAMG/XycC0AaO1eW j/3A0B7xrjw/mFZz/fu3tQ69ePHH1LVUlZhpBy7MMdF9yRg0qTWOoNn6WBEnkJPkWc1D0G 2YrXejVFtbOCooOC+ED2ejoBAF7hkG+60xXmHcBWnfLVXxxz1yWNDa2TCI9cjw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1774577898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ooFMpDZikzJTmqCKLxnHYNVV/Cyv2iG4aFci2pBjaQw=; b=oXOjZiRpK+hxE/hmGgcy5O+LincDm1wmpauY9ZxGa86zWBbe+c0QGohCpv5EihnJRdTIZV 6Q/bki5NlE+aqiAw== To: Borislav Petkov , Dave Hansen , Ingo Molnar Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Sean Christopherson , David Woodhouse , Peter Zijlstra , Christian Ludloff , Sohil Mehta , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v6 16/90] x86/cpu: Use parsed CPUID(0x1) Date: Fri, 27 Mar 2026 03:15:30 +0100 Message-ID: <20260327021645.555257-17-darwi@linutronix.de> In-Reply-To: <20260327021645.555257-1-darwi@linutronix.de> References: <20260327021645.555257-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On early boot CPU detection, use parsed CPUID(0x1) instead of a direct CPUID query. Beside the parser's centralization benefits, this allows using the auto generated CPUID data types, and their C99 bitfields, instead of doing ugly bitwise operations. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/cpu/common.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 882754f10a4f..f31746c216c9 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -941,6 +941,7 @@ void get_cpu_vendor(struct cpuinfo_x86 *c) void cpu_detect(struct cpuinfo_x86 *c) { const struct leaf_0x0_0 *l0 =3D cpuid_leaf(c, 0x0); + const struct leaf_0x1_0 *l1 =3D cpuid_leaf(c, 0x1); =20 if (!l0) return; @@ -951,17 +952,13 @@ void cpu_detect(struct cpuinfo_x86 *c) *(u32 *)&c->x86_vendor_id[8] =3D l0->cpu_vendorid_2; =20 c->x86 =3D 4; - /* Intel-defined flags: level 0x00000001 */ - if (c->cpuid_level >=3D 0x00000001) { - u32 junk, tfms, cap0, misc; - - cpuid(0x00000001, &tfms, &misc, &junk, &cap0); - c->x86 =3D x86_family(tfms); - c->x86_model =3D x86_model(tfms); - c->x86_stepping =3D x86_stepping(tfms); + if (l1) { + c->x86 =3D cpuid_family(l1); + c->x86_model =3D cpuid_model(l1); + c->x86_stepping =3D l1->stepping; =20 - if (cap0 & (1<<19)) { - c->x86_clflush_size =3D ((misc >> 8) & 0xff) * 8; + if (l1->clflush) { + c->x86_clflush_size =3D l1->clflush_size * 8; c->x86_cache_alignment =3D c->x86_clflush_size; } } --=20 2.53.0