cpuid(4)
π cpuid(4) β bestie edition
okay so you found cpuid(4), the x86 CPUID access device, and it lives in the Kernel Interfaces Manual. buckle up, we're meeting your CPU's whole personality π
β¨ NAME β¨
cpuid β x86 CPUID access device
like. it's a device. it's the device. it's giving "I contain multitudes (specifically, x86 CPU facts)". π¦
πΈ DESCRIPTION πΈ
CPUID provides an interface for querying information about the x86 CPU. that's it, that's the whole job, and honestly? iconic.
You do not read this thing like a normal file, bestie. You get to it by lseek(2) or pread(2)-ing your way to the right CPUID level and then reading in chunks of 16 bytes. Read bigger chunks and you're just doing multiple reads of consecutive levels β slay, bulk mode, whatever works for you.
Here's the part that's lowkey a flex: the lower 32 bits of the file position become the incoming %eax, and the upper 32 bits of the file position become the incoming %ecx. That %ecx one? It's meant for "counting" eax levels, the way eax=4 does. iykyk. π₯
The driver uses /dev/cpu/CPUNUM/cpuid, where CPUNUM is the minor number. On an SMP box it directs the access to CPU CPUNUM, exactly as that CPU is listed in /proc/cpuinfo. so you can literally pick your CPU like it's a starbucks order. π
and before you get any ideas β this file is protected. it can be read only by the user root, or by members of the group root. no random people peeking at your CPU's diary. π
π NOTES π
okay so yes, the CPUID instruction can be directly executed by a program using inline assembler. sure. but this device lets you conveniently access all CPUs without changing process affinity, which is the real main character energy right there. π
also, and I need you to hear me on this: most of the info in cpuid is already reported by the kernel in cooked form β either in /proc/cpuinfo or through subdirectories in /sys/devices/system/cpu. Direct CPUID access through this device should only be used in exceptional cases. like, it's the emergency snack drawer of CPU introspection, not the main course. π
big note: the cpuid driver is not auto-loaded. on modular kernels you might have to run this command to load it explicitly before you use it:
$ modprobe cpuid
there is no support for CPUID functions that require additional input registers. so if that's what you needed... it's not here, bestie. π
and the saddest one: early i486 CPUs do not support the CPUID instruction at all. opening this device for those CPUs fails with EIO. not me getting emotionally invested in an i486. π
π SEE ALSO π
cpuid(1)- Intel Corporation, Intel 64 and IA-32 Architectures Software Developer's Manual Volume 2A: Instruction Set Reference, A-M, 3-180 CPUID reference.
- Intel Corporation, Intel Processor Identification and the CPUID Instruction, Application note 485.
quick vibe check recap π« read in 16-byte chunks, lower 32 bits of the position =%eax, upper 32 bits =%ecx, path is/dev/cpu/CPUNUM/cpuid,CPUNUM= the minor number, root-only, cooked info lives in/proc/cpuinfoand/sys/devices/system/cpu, no extra input registers, i486 goesEIO. that's the whole tea. β
mwah π this gem is from Linux man-pages 6.20, dated 2026-02-08 β go forth and CPUID responsibly, you gorgeous nerd. π«Ά
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 2009, Intel Corp
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms