cpuid_subleaf_n(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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-time 0xN format; e.g. 0x4, 0x8000001d. no cap, the format matters ✨
  • _subleaf β€” the subleaf number, and it can be passed dynamically. it must be smaller than cpuid_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:

  • _leaf has no subleaf range. leaves with a subleaf range have an _n type suffix and are listed at <asm/cpuid/types.h> using the CPUID_LEAF_N macro. so if your leaf isn't giving _n energy, that's a problem 🚩
  • _subleaf is 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 🌈


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