CPUCTL(4)
π CPUCTL(4) β the cpuctl pseudo device, explained by your favorite Unix bestie
okay so this is from the Kernel Interfaces Manual, and it's about cpuctl β yes the little pseudo device that lets you poke at your CPU's guts. buckle up π
β¨ NAME β¨
cpuctl β the cpuctl pseudo device. that's it, that's the name. iconic. π
πΈ SYNOPSIS πΈ
so if you wanna compile this driver into the kernel, you drop these lines in your kernel configuration file:
device cpuctl
or, bestie alternative β¨ β load it as a module at boot time by putting this in loader.conf(5):
cpuctl_load="YES"
either way, you're getting cpuctl. no cap. π«Ά
π¦ DESCRIPTION π¦
The special device /dev/cpuctl is basically a little interface to your system CPU. it gives you the power to grab CPUID info, read and write machine specific registers (MSR), and do CPU firmware updates. main character energy fr fr π
for every CPU present in the system, a special device /dev/cpuctl%d gets created with the appropriate index. and for multicore CPUs? yes queen, one of these special devices gets created for each core. π
currently, only i386 and amd64 processors are supported. periodt.
π₯ IOCTL INTERFACE π₯
all the supported operations get invoked using the ioctl(2) system call. currently, the following ioctls are defined:
CPUCTL_RDMSRcpuctl_msr_args_t *argsCPUCTL_WRMSRcpuctl_msr_args_t *args
read/write CPU machine specific register. the cpuctl_msr_args_t structure is defined in <sys/cpuctl.h> as:
typedef struct {
int msr; /* MSR to read */
uint64_t data;
} cpuctl_msr_args_t;
CPUCTL_MSRSBITcpuctl_msr_args_t *argsCPUCTL_MSRCBITcpuctl_msr_args_t *args
set/clear MSR bits according to the mask given in the data field. slay π
CPUCTL_CPUIDcpuctl_cpuid_args_t *args
retrieve CPUID information. arguments are supplied in the following structure:
typedef struct {
int level; /* CPUID level */
uint32_t data[4];
} cpuctl_cpuid_args_t;
it's equivalent to the CPUCTL_CPUID_COUNT request with level_type set to 0. iykyk β¨
CPUCTL_CPUID_COUNTcpuctl_cpuid_count_args_t *args
retrieve CPUID information. arguments are supplied in the following structure:
typedef struct {
int level; /* CPUID level */
int level_type; /* CPUID level type */
uint32_t data[4];
} cpuctl_cpuid_count_args_t;
the level field indicates the CPUID level to retrieve, and it gets loaded into the %eax register before the CPUID instruction is executed. the level_type field indicates the CPUID level type to retrieve, and it gets loaded into the %ecx register.
the data field is used to store the received CPUID data. that is, data[0] contains the value of the %eax register after the CPUID instruction is executed, data[1] is for %ebx, data[2] for %ecx, and data[3] for %edx. literally all four, accounted for π
CPUCTL_UPDATEcpuctl_update_args_t *args
update CPU firmware (microcode). the structure is defined in <sys/cpuctl.h> as:
typedef struct {
void *data;
size_t size;
} cpuctl_update_args_t;
the data field should point to the firmware image of size size. π§
for additional information refer to cpuctl.h. go off, header file. π
π FILES π
/dev/cpuctl
π ERRORS π
[ENXIO]β the operation requested is not supported by the device (e.g., unsupported architecture or the CPU is disabled). sad but valid π[EINVAL]β incorrect request was supplied, or microcode image is not correct.[ENOMEM]β no physical memory was available to complete the request.[EFAULT]β the firmware image address points outside the process address space. rude. π
β SEE ALSO β
π HISTORY π
The cpuctl driver first appeared in FreeBSD 7.2. a legend was born β¨
π AUTHORS π
The cpuctl module and this manual page were written by Stanislav Sedov <stas@FreeBSD.org>. we stan. π«Ά
π BUGS π
yes, probably, report if any. that's the whole section. i'm obsessed with the honesty ngl π
lowkey a whole vibe check: onlyi386andamd64, so don't come for this driver with anything else bestie π
and that's the tea π΅ β this page is from the Debian build, dated June 20, 2014, bestie. oldie but a goodie. mwah π πΈ
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- π the page's license: BSD-2-Clause
- Copyright (c) 2006-2008 Stanislav Sedov <stas@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms