[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250815070227.19981-18-darwi@linutronix.de>
Date: Fri, 15 Aug 2025 09:02:10 +0200
From: "Ahmed S. Darwish" <darwi@...utronix.de>
To: Borislav Petkov <bp@...en8.de>,
Ingo Molnar <mingo@...hat.com>,
Dave Hansen <dave.hansen@...ux.intel.com>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Andrew Cooper <andrew.cooper3@...rix.com>,
"H. Peter Anvin" <hpa@...or.com>,
David Woodhouse <dwmw2@...radead.org>,
Sean Christopherson <seanjc@...gle.com>,
Peter Zijlstra <peterz@...radead.org>,
Sohil Mehta <sohil.mehta@...el.com>,
John Ogness <john.ogness@...utronix.de>,
x86@...nel.org,
x86-cpuid@...ts.linux.dev,
LKML <linux-kernel@...r.kernel.org>,
"Ahmed S. Darwish" <darwi@...utronix.de>
Subject: [PATCH v4 17/34] x86/cpuid: Warn once on invalid CPUID(0x2) iteration count
The CPUID(0x2) output includes a "query count" byte. That byte was
supposed to specify the number of repeated CPUID(0x2) subleaf 0 queries
needed to extract all of the CPU's cache and TLB descriptors.
Per current Intel manuals, all CPUs supporting this leaf "will always"
return an iteration count of 1.
Since the CPUID parser ignores any CPUID(0x2) output with an invalid
iteration count, lightly warn once about this in the kernel log.
Do not emit a warning if any of the CPUID(0x2) output registers EAX->EDX,
or even all of them, are invalid; i.e., their most significant bit is
set. Such a case is both architecturally defined and legitimate.
References: b5969494c8d8 ("x86/cpu: Remove CPUID leaf 0x2 parsing loop")
Suggested-by: Ingo Molnar <mingo@...nel.org>
Signed-off-by: Ahmed S. Darwish <darwi@...utronix.de>
Link: https://lore.kernel.org/lkml/aBnmy_Bmf-H0wxqz@gmail.com
---
arch/x86/kernel/cpu/cpuid_parser.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/cpuid_parser.c b/arch/x86/kernel/cpu/cpuid_parser.c
index f3dffdd43779..c340ad6eca3d 100644
--- a/arch/x86/kernel/cpu/cpuid_parser.c
+++ b/arch/x86/kernel/cpu/cpuid_parser.c
@@ -3,6 +3,8 @@
* Centralized CPUID parser (for populating the system's CPUID tables.)
*/
+#define pr_fmt(fmt) "x86/cpuid: " fmt
+
#include <linux/init.h>
#include <linux/kernel.h>
@@ -42,8 +44,11 @@ static void cpuid_read_0x2(const struct cpuid_parse_entry *e, struct cpuid_read_
* keep the leaf marked as invalid at the CPUID table.
*/
cpuid_read_subleaf(e->leaf, e->subleaf, l);
- if (l->iteration_count != 0x01)
+ if (l->iteration_count != 0x01) {
+ pr_warn_once("Ignoring CPUID(0x2) due to invalid iteration count = %d",
+ l->iteration_count);
return;
+ }
/*
* The most significant bit (MSB) of each CPUID(0x2) register must be clear.
--
2.50.1
Powered by blists - more mailing lists