x86_match_cpu(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ NAME πŸŽ€

x86_match_cpu β€” match current CPU against an array of x86_cpu_ids. This is the x86_match_cpu(9) page from the Kernel API Manual, bestie. πŸ’–

✨ SYNOPSIS ✨

const struct x86_cpu_id * x86_match_cpu (const struct x86_cpu_id *match
);

🌸 ARGUMENTS 🌸

  • match β€” Pointer to array of x86_cpu_ids. Last entry terminated with {}. 🫢

πŸ’… DESCRIPTION πŸ’…

Okay so: it returns the entry if the current CPU matches the entries in the passed x86_cpu_id match table. Otherwise it gives you NULL. πŸ’€

The match table contains vendor (X86_VENDOR_*), family, model and feature bits or respective wildcard entries. Iconic. ✨

A typical table entry would be to match a specific CPU:

X86_MATCH_VFM_FEATURE(INTEL_BROADWELL, X86_FEATURE_ANY, NULL);

Fields can be wildcarded with X86_VENDOR_ANY, X86_FAMILY_ANY, X86_MODEL_ANY, X86_FEATURE_ANY (except for vendor) β€” yes, keep that caveat exactly, bestie. 🫑

asm/cpu_device_id.h contains a set of useful macros which are shortcuts for various common selections. The above can be shortened to:

X86_MATCH_VFM(INTEL_BROADWELL, NULL);

Arrays used to match for this should also be declared using MODULE_DEVICE_TABLE(x86cpu, ...). Slay that declaration. πŸ’…

This always matches against the boot cpu, assuming models and features are consistent over all CPUs. No cap. 🧚

πŸ‘€ SEE ALSO πŸ‘€

Kernel file ./arch/x86/kernel/cpu/match.c β€” go peek at it, iykyk. πŸ¦‹


Catch you later, bestie πŸ’– β€” this page’s source/version is ./arch/x86/kernel/cpu, and the date is October 2026. πŸŽ€βœ¨

πŸ“¦ where this page comes from