]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
x86/cpuid: Introduce a centralized CPUID parser
authorAhmed S. Darwish <darwi@linutronix.de>
Fri, 27 Mar 2026 02:15:23 +0000 (03:15 +0100)
committerBorislav Petkov (AMD) <bp@alien8.de>
Mon, 11 May 2026 14:05:50 +0000 (16:05 +0200)
commitfa6dcbc69ad495eeea315870278100a554a4ca18
tree76cb4118eeb5ccf3b217be19459f7d155f5a3c67
parent3aa8f9fce8602d722948df641c7ca2828ee0a2f5
x86/cpuid: Introduce a centralized CPUID parser

Introduce a CPUID parser for populating the system's CPUID tables.

Since accessing a leaf within the CPUID table requires compile time
tokenization, split the parser into two stages:

  (a) Compile-time macros for tokenizing the leaf/subleaf offsets within
      the CPUID table.

  (b) Generic runtime code to fill the CPUID data, using a parsing table
      which collects these compile-time offsets.

For actual CPUID output parsing, support both generic and leaf-specific
read functions.

To ensure CPUID data early availability, invoke the parser during early
boot, early Xen boot, and at early secondary CPUs bring up.

Provide call site APIs to refresh a single leaf, or a leaf range, within
the CPUID tables.  This is for sites issuing MSR writes that partially
change the CPU's CPUID layout.  Doing full CPUID table rescans in such
cases will be destructive since the CPUID tables will host all of the
kernel's X86_FEATURE flags at a later stage.

Suggested-by: Thomas Gleixner <tglx@kernel.org>
Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/all/20260327021645.555257-1-darwi@linutronix.de
arch/x86/include/asm/cpuid/api.h
arch/x86/kernel/cpu/Makefile
arch/x86/kernel/cpu/common.c
arch/x86/kernel/cpu/cpuid_parser.c [new file with mode: 0644]
arch/x86/kernel/cpu/cpuid_parser.h [new file with mode: 0644]
arch/x86/xen/enlighten.c
arch/x86/xen/enlighten_pv.c