]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
tools/x86/kcpuid: Consolidate index validity checks
authorAhmed S. Darwish <darwi@linutronix.de>
Mon, 24 Mar 2025 14:20:34 +0000 (15:20 +0100)
committerIngo Molnar <mingo@kernel.org>
Tue, 25 Mar 2025 08:53:46 +0000 (09:53 +0100)
commit74d29127f83042500c20c903dd67151dbdd86ec8
tree130b92e4032b68df2737218b00ea03824ea69eca
parentf2e2efe9489d883fdaac8b7b46bd669b6214b1cb
tools/x86/kcpuid: Consolidate index validity checks

Let index_to_cpuid_range() return a CPUID range only if the passed index
is within a CPUID range's maximum supported function on the CPU.
Returning a CPUID range that is invalid on the CPU for the passed index
does not make sense.

This also avoids repeating the "function index is within CPUID range"
checks, both at setup_cpuid_range() and index_to_func().

Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20250324142042.29010-14-darwi@linutronix.de
tools/arch/x86/kcpuid/kcpuid.c