cpuid_subleaf_n(9)
β¨ NAME β¨
okay so bestie, welcome to cpuid_subleaf_n(9) from the Kernel API Manual β this one is literally about how to access parsed CPUID data for a leaf that has a subleaf range. iconic behavior only π
cpuid_subleaf_n β access parsed CPUID data for leaf with a subleaf range. periodt.
πΈ SYNOPSIS πΈ
cpuid_subleaf_n (_cpuinfo , _leaf , _subleaf );
π ARGUMENTS π
_cpuinfoβ your CPU capability structure reference, aka a'struct cpuinfo_x86'. yes bestie, that one π«Ά_leafβ the CPUID leaf, in compile-time0xNformat; e.g.0x4,0x8000001d. no cap, the format matters β¨_subleafβ the subleaf number, and it can be passed dynamically. it must be smaller thancpuid_subleaf_count(_cpuinfo, _leaf). that's the vibe check it has to pass π
π¦ DESCRIPTION π¦
okay so here's the tea: build-time errors get emitted in these cases:
_leafhas no subleaf range. leaves with a subleaf range have an_ntype suffix and are listed at<asm/cpuid/types.h>using theCPUID_LEAF_Nmacro. so if your leaf isn't giving_nenergy, that's a problem π©_subleafis known at compile-time but is out of range. not me getting caught lacking at compile-time π
Example usage, and yes it's giving main character energy:
const struct leaf_0x4_n *l4;
for (int i = 0; i < cpuid_subleaf_count(c, 0x4); i++) {
l4 = cpuid_subleaf_n(c, 0x4, i);
if (!l4) {
// Handle error
}
...
}
beside the standard error situations detailed at cpuid_subleaf, this macro will also return NULL if _subleaf is out of the leaf's subleaf range. so likeβ¦ check your range, bestie π
π SEE ALSO π
- Kernel file
./arch/x86/include/asm/cpuid/api.h cpuid_leaf_0x2(9)for_each_cpuid_0x2_desc(9)cpuid_subleaf(9)cpuid_leaf(9)cpuid_leaf_raw(9)cpuid_subleaf_n_raw(9)cpuid_subleaf_count(9)
mwah π that's the whole page β source/version: ./arch/x86/include/asm/cpuid, dated October 2026, and the manual page is cpuid_subleaf_n(9). slay π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms