lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250306205000.227399-9-darwi@linutronix.de>
Date: Thu,  6 Mar 2025 21:49:56 +0100
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>,
	x86@...nel.org,
	John Ogness <john.ogness@...utronix.de>,
	x86-cpuid@...ts.linux.dev,
	LKML <linux-kernel@...r.kernel.org>,
	"Ahmed S. Darwish" <darwi@...utronix.de>
Subject: [PATCH v1 08/12] tools/x86/kcpuid: Restrict CPUID scanning to valid vendor ranges

kcpuid works in two runs: one run for invoking the CPUID instructions and
saving all their output in memory, and another for parsing that raw
in-memory output using the CSV file specification.  In both runs, kcpuid
should only process CPUID ranges that are valid for the current CPU
vendor.

Restrict for_each_cpuid_range() to only iterate over CPUID ranges that
are known to be valid for this CPU vendor.  Doing it at the iterator
level avoids sprinkling ugly CPU-vendor CPUID range validity conditionals
throughout the code.  Overall, this allows adding vendor-specific CPUID
rages to the CSV file at later commits.

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 36efcb753b77..3153c8eba0c4 100644
--- a/tools/arch/x86/kcpuid/kcpuid.c
+++ b/tools/arch/x86/kcpuid/kcpuid.c
@@ -118,7 +118,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.48.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ