[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241128222948.579920-11-darwi@linutronix.de>
Date: Thu, 28 Nov 2024 23:29:45 +0100
From: "Ahmed S. Darwish" <darwi@...utronix.de>
To: Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>
Cc: Thomas Gleixner <tglx@...utronix.de>,
John Ogness <john.ogness@...utronix.de>,
linux-kernel@...r.kernel.org,
x86@...nel.org,
x86-cpuid@...ts.linux.dev,
"Ahmed S. Darwish" <darwi@...utronix.de>
Subject: [PATCH v1 10/13] tools/x86/kcpuid: Scan valid cpuid ranges only
kcpuid works in two runs: one run for invoking cpuid instructions and
saving all output in-memory, and another run for parsing that in-memory
output using the CSV bitfields specification.
CPU vendor detection was just added in previous commits. In both kcpuid
runs, it makes no sense to deal with cpuid ranges that are not valid for
the current CPU.
Avoid ugly "is range valid for CPU?" conditionals throughout the code by
modifying the for_each_cpuid_range() macro to iterate over cpuid ranges
that are only known to be valid for the current CPU.
Signed-off-by: Ahmed S. Darwish <darwi@...utronix.de>
---
tools/arch/x86/kcpuid/kcpuid.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/arch/x86/kcpuid/kcpuid.c b/tools/arch/x86/kcpuid/kcpuid.c
index 9769da3e4494..f798c909c7b2 100644
--- a/tools/arch/x86/kcpuid/kcpuid.c
+++ b/tools/arch/x86/kcpuid/kcpuid.c
@@ -119,7 +119,9 @@ static char *range_to_str(struct cpuid_range *range)
#define for_each_cpuid_range(range) \
for (unsigned int i = 0; \
- i < ARRAY_SIZE(ranges) && ((range) = &ranges[i]); \
+ i < ARRAY_SIZE(ranges) && \
+ ((range) = &ranges[i]) && \
+ (range->vendors & this_cpu_vendor); \
i++)
struct cpuid_range *index_to_cpuid_range(u32 index)
--
2.46.2
Powered by blists - more mailing lists