User Tools

Site Tools




cpuid - CPU identification driver




SPARC and x86 system
This device provides implementation-private information via ioctls about various aspects of the implementation to Solaris libraries and utilities.

x86 systems only
This device also provides a file-like view of the namespace and return values of the x86 cpuid instruction. The cpuid instruction takes a single 32-bit integer function code, and returns four 32-bit integer values corresponding to the input value that describe various aspects of the capabilities and configuration of the processor.

The API for the character device consists of using the seek offset to set the function code value, and using a read(2) or pread(2) of 16 bytes to fetch the four 32-bit return values of the instruction in the order %eax, %ebx, %ecx and %edx.

No data can be written to the device. Like the cpuid instruction, no special privileges are required to use the device.

The device is useful to enable low-level configuration information to be extracted from the CPU without having to write any assembler code to invoke the cpuid instruction directly. It also allows the kernel to attempt to correct any erroneous data returned by the instruction (prompted by occasional errors in the information exported by various processor implementations over the years).

See the processor manufacturers documentation for further information about the syntax and semantics of the wide variety of information available from this instruction.


This example allows you to determine if the current x86 processor supports “long mode,” which is a necessary (but not sufficient) condition for running the 64-bit Solaris kernel on the processor.


#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>

static const char devname[] = “/dev/cpu/self/cpuid”;

main(int argc, char *argv[])
struct {
uint32_t r_eax, r_ebx, r_ecx, r_edx;
} _r, *rp = &_r;
int d;
char *s;

if 1) == -1) {
return (1);

if (pread(d, rp, sizeof (*rp), 0) != sizeof (*rp)) {
goto fail;

s = (char *)&rp→r_ebx;
if (strncmp(s, “Auth” “cAMD” “enti”, 12) != 0 &&
strncmp(s, “Genu” “ntel” “ineI”, 12) != 0)
goto fail;

if (pread(d, rp, sizeof (*rp), 0x80000001) == sizeof (*rp)) {
* Read extended feature word; check bit 29
(void) close(d);
if ((rp→r_edx » 29) & 1) {
(void) printf(“processor supports long mode\n”);
return (0);
(void) close(d);
return (1);



Results from attempting to read data from the device on a system that does not support the CPU identification interfaces


Results from reading from an offset larger than UINT_MAX, or attempting to read with a size that is not multiple of 16 bytes.



Provides access to CPU identification data.


See attributes(7) for descriptions of the following attributes:


d = open(devname, O_RDONLY
solaris/cpuid.4d.txt · Last modified: 2023/07/19 08:57 by A User Not Logged in