Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

cpuid(4) [linux man page]

CPUID(4)						     Linux Programmer's Manual							  CPUID(4)

cpuid - x86 CPUID access device DESCRIPTION
CPUID provides an interface for querying information about the x86 CPU. This device is accessed by lseek (2) or pread (2) to the appropriate CPUID level and reading in chunks of 16 bytes. A larger read size means multiple reads of consecutive levels. The lower 32 bits of the file position is used as the incoming %eax, and the upper 32 bits of the file position as the incoming %ecx, the latter intended for "counting" eax levels like eax=4. This driver uses /dev/cpu/CPUNUM/cpuid, where CPUNUM is the minor number, and on an SMP box will direct the access to CPU CPUNUM as listed in /proc/cpuinfo. This file is protected so that it can only be read by the user root, or members of the group root. NOTES
The CPUID instruction can be directly executed by a program using inline assembler. However this device allows convenient access to all CPUs without changing process affinity. Most of the information in cpuid is 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. The cpuid driver is not auto-loaded. On modular kernels you might need to use the following command to load it explicitly before use: $ modprobe cpuid There is no support for CPUID functions that require additional input registers. Very old x86 CPUs don't support CPUID. SEE ALSO
Intel Corporation, Intel 64 and IA-32 Architectures Software Developer's Manual Volume 2A: Instruction Set Reference, A-M, 3-180 CPUID ref- erence. Intel Corporation, Intel Processor Identification and the CPUID Instruction, Application note 485. COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at Linux 2009-03-31 CPUID(4)

Check Out this Related Man Page

cpuid(7D)							      Devices								 cpuid(7D)

cpuid - CPU identification driver SYNOPSIS
/dev/cpu/self/cpuid DESCRIPTION
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 occassional 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. EXAMPLE
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"; /*ARGSUSED*/ int main(int argc, char *argv[]) { struct { uint32_t r_eax, r_ebx, r_ecx, r_edx; } _r, *rp = &_r; int d; char *s; if ((d = open(devname, O_RDONLY)) == -1) { perror(devname); return(1); } if (pread(d, rp, sizeof (*rp), 0) != sizeof (*rp)) { perror(devname); 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 "); return(0); } } fail: (void) close(d); return(1); } ERRORS
ENXIO Results from attempting to read data from the device on a system that does not support the CPU identification interfaces EINVAL Results from reading from an offset larger than UINT_MAX, or attempting to read with a size that is not multiple of 16 bytes. FILES
/dev/cpu/self/cpuid Provides access to CPU identification data. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWckr | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
psrinfo(1M), prtconf(1M), pread(2), read(2), attributes(5) SunOS 5.11 16 Sep 2004 cpuid(7D)
Man Page

Featured Tech Videos