[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250605192356.82250-14-darwi@linutronix.de>
Date: Thu, 5 Jun 2025 21:23:42 +0200
From: "Ahmed S. Darwish" <darwi@...utronix.de>
To: Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>,
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>,
Peter Zijlstra <peterz@...radead.org>,
Sean Christopherson <seanjc@...gle.com>,
Sohil Mehta <sohil.mehta@...el.com>,
Ard Biesheuvel <ardb@...nel.org>,
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 v2 13/27] x86/cpuid: Warn once on invalid CPUID(0x2) iteration count
The CPUID(0x2) output includes an "query count" byte where it was
supposed to specify the number of 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 counts warn about this once at 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 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 ab06c68e4453..4b960b23cab4 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>
@@ -33,8 +35,11 @@ static void cpuid_read_0x2(const struct cpuid_parse_entry *e, struct cpuid_read_
* bogus hardware, keep the leaf marked as invalid at the CPUID table.
*/
cpuid_read_subleaf(e->leaf, e->subleaf, l2);
- if (l2->iteration_count != 0x01)
+ if (l2->iteration_count != 0x01) {
+ pr_warn_once("Ignoring CPUID(0x2) due to invalid iteration count = %d",
+ l2->iteration_count);
return;
+ }
/*
* The most significant bit (MSB) of each register must be clear.
--
2.49.0
Powered by blists - more mailing lists