summaryrefslogtreecommitdiff
path: root/arch/x86/kernel/cpu/intel.c
diff options
context:
space:
mode:
authorAhmed S. Darwish <darwi@linutronix.de>2025-03-24 14:32:58 +0100
committerIngo Molnar <mingo@kernel.org>2025-03-25 10:22:06 +0100
commitfe78079ec07fd48a19abcfeac74bc97e07171fb6 (patch)
tree08f3dcfa31f49e55fd9be1afdb73e5e33550ac34 /arch/x86/kernel/cpu/intel.c
parent09a1da4beb310420b720994f7b6599e8d0bce3e1 (diff)
x86/cpu: Introduce and use CPUID leaf 0x2 parsing helpers
Introduce CPUID leaf 0x2 parsing helpers at <asm/cpuid/leaf_0x2_api.h>. This allows sharing the leaf 0x2's output validation and iteration logic across both x86/cpu intel.c and cacheinfo.c. Start by converting intel.c to the new API. 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> Link: https://lore.kernel.org/r/20250324133324.23458-4-darwi@linutronix.de
Diffstat (limited to 'arch/x86/kernel/cpu/intel.c')
-rw-r--r--arch/x86/kernel/cpu/intel.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 0570d4d86006..aeb7d6d48379 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -16,6 +16,7 @@
#include <asm/cpu_device_id.h>
#include <asm/cpufeature.h>
#include <asm/cpu.h>
+#include <asm/cpuid.h>
#include <asm/hwcap2.h>
#include <asm/intel-family.h>
#include <asm/microcode.h>
@@ -778,27 +779,15 @@ static void intel_tlb_lookup(const unsigned char desc)
static void intel_detect_tlb(struct cpuinfo_x86 *c)
{
- u32 regs[4];
- u8 *desc = (u8 *)regs;
+ union leaf_0x2_regs regs;
+ u8 *desc;
if (c->cpuid_level < 2)
return;
- cpuid(2, &regs[0], &regs[1], &regs[2], &regs[3]);
-
- /* Intel CPUs must report an iteration count of 1 */
- if (desc[0] != 0x01)
- return;
-
- /* If a register's bit 31 is set, it is an unknown format */
- for (int i = 0; i < 4; i++) {
- if (regs[i] & (1 << 31))
- regs[i] = 0;
- }
-
- /* Skip the first byte as it is not a descriptor */
- for (int i = 1; i < 16; i++)
- intel_tlb_lookup(desc[i]);
+ cpuid_get_leaf_0x2_regs(&regs);
+ for_each_leaf_0x2_desc(regs, desc)
+ intel_tlb_lookup(*desc);
}
static const struct cpu_dev intel_cpu_dev = {