CPUID
CPUID
to determine processor type and whether features such as MMX/ SSE are implemented.
History
Prior to the general availability of theCPUID
instruction, programmers would write esoteric CPUID
instruction of any kind — certain specific instructions required elevated privileges. These could be used to tell various CPU family members apart. In the CPUID
instruction is specific to the x86 architecture, other architectures (like ARM) often provide on-chip registers which can be read in prescribed ways to obtain the same sorts of information provided by the x86 CPUID
instruction.
Calling CPUID
TheCPUID
opcode is 0F A2
.
In CPUID
instruction takes no parameters as CPUID
implicitly uses the EAX register to determine the main category of information returned. In Intel's more recent terminology, this is called the CPUID leaf. CPUID
should be called with EAX = 0
first, as this will store in the EAX register the highest EAX calling parameter (leaf) that the CPU implements.
To obtain extended function information CPUID
should be called with the most significant bit of EAX set. To determine the highest extended function calling parameter, call CPUID
with EAX = 80000000h
.
CPUID leaves greater than 3 but less than 80000000 are accessible only when the model-specific registers have IA32_MISC_ENABLE.BOOT_NT4 it 22= 0 (which is so by default). As the name suggests, Windows NT 4.0 until SP6 did not boot properly unless this bit was set, but later versions of Windows do not need it, so basic leaves greater than 4 can be assumed visible on current Windows systems. , basic valid leaves go up to 23h, but the information returned by some leaves are not disclosed in the publicly available documentation, i.e. they are "reserved".
Some of the more recently added leaves also have sub-leaves, which are selected via the ECX register before calling CPUID
.
EAX=0: Highest Function Parameter and Manufacturer ID
This returns the CPU's manufacturer ID stringa twelve-characterCPUID
) is returned in EAX.
Here is a list of processors and the highest function implemented.
The following are known processor manufacturer ID strings:
* "AuthenticAMD"
"CentaurHauls"
IDT WinChip/"CyrixInstead"
"GenuineIntel"
"GenuineIotel"
Intel (rare)
* "TransmetaCPU"
"GenuineTMx86"
"Geode by NSC"
"NexGenDriven"
"RiseRiseRise"
Rise
* "SiS SiS SiS "
SiS
* "UMC UMC UMC "
UMC
* "Vortex86 SoC"
DM&P Vortex86
* "Shanghai"
"HygonGenuine"
Hygon
* "GenuineRDC"
RDC Semiconductor Co. Ltd.
* "E2K MACHINE"
MCST Elbrussmxi"VIA VIA VIA "
VIA
* "AMD ISBETTER"
early engineering samples of "GenuineAO486"
ao486 CPU (old)
* "MiSTer AO486"
ao486 CPU (new)
* "GenuineIntel"
v586 core (this is identical to the Intel ID string)
The following are known ID strings from virtual machines:
* "MicrosoftXTA"
Microsoft x86-to-ARM
* "GenuineIntel"
Apple Rosetta 2
* "VirtualApple"
Newer versions of Apple Rosetta 2
* "PowerVM Lx86"
"Neko Project"
Neko Project II (GenuineIntel
processor, values returned in EBX is 0x756e6547
, EDX is 0x49656e69
and ECX is 0x6c65746e
. The following example code displays the vendor ID string as well as the highest calling parameter that the CPU implements.
WRMSR
instruction. This has been used on non-Intel processors to enable features and optimizations that have been disabled in software for CPUs that don't return the GenuineIntel
ID string. Processors that are known to possess such MSRs include:
EAX=1: Processor Info and Feature Bits
This returns the CPU's stepping, model, and family information in register EAX (also called the ''signature'' of a CPU), feature flags in registers EDX and ECX, and additional feature info in register EBX. * Stepping ID is a product revision number assigned due to fixedEAX=2: Cache and TLB Descriptor Information
This returns a list of descriptors indicating cache and TLB capabilities in EAX, EBX, ECX and EDX registers. On processors that support this leaf, callingCPUID
with EAX=2 will cause the bottom byte of EAX to be set to 01h
and the remaining 15 bytes of EAX/EBX/ECX/EDX to be filled with 15 descriptors, one byte each. These descriptors provide information about the processor's caches, TLBs and prefetch. This is typically one cache or TLB per descriptor, but some descriptor-values provide other information as well - in particular, 00h
is used for an empty descriptor, FFh
indicates that the leaf does not contain valid cache information and that leaf 4h should be used instead, and FEh
indicates that the leaf does not contain valid TLB information and that leaf 18h should be used instead. The descriptors may appear in any order.
For each of the four registers (EAX,EBX,ECX,EDX), if bit 31 is set, then the register should not be considered to contain valid descriptors (e.g. on Itanium in IA-32 mode, CPUID(EAX=2) returns 80000000h
in EDX - this should be interpreted to mean that EDX contains no valid information, not that it contains a descriptor for a 512K L2 cache.)
The table below provides, for known descriptor values, a condensed description of the cache or TLB indicated by that descriptor value (or other information, where that applies). The suffixes used in the table are:
* K,M,G : binary kilobyte, megabyte, gigabyte (capacity for caches, page-size for TLBs)
* E : entries (for TLBs; e.g. 64E = 64 entries)
* p : page-size (e.g. 4Kp for TLBs where each entry describes one 4 KB EAX=3: Processor Serial Number
This returns the processor's serial number. The processor serial number was introduced on IntelEAX=4 and EAX=8000'001Dh: Cache Hierarchy and Topology
These two leaves are used to provide information about theCPUID
instruction is run. Leaf 4
is used on Intel processors and leaf 8000'001Dh
is used on AMD processors - they both return data in EAX, EBX, ECX and EDX, using the same data format except that leaf 4
returns a few additional fields that are considered "reserved" for leaf 8000'001Dh
. They both provide CPU cache information in a series of sub-leaves selected by ECX - to get information about all the cache levels, it is necessary to invoke CPUID
repeatedly, with EAX=4
or 8000'001Dh
and ECX set to increasing values starting from 0 (0,1,2,...) until a sub-leaf not describing any caches (EAX :00) is found. The sub-leaves that do return cache information may appear in any order, but all of them will appear before the first sub-leaf not describing any caches.
In the below table, fields that are defined for leaf 4
but not for leaf 8000'001Dh
are highlighted with yellow cell coloring and a (#4) item.
For any caches that are valid and not fully-associative, the value returned in ECX is the number of sets in the cache minus 1. (For fully-associative caches, ECX should be treated as if it return the value 0.)
For any given cache described by a sub-leaf of CPUID
leaf 4
or 8000'001Dh
, the total cache size in bytes can be computed as:CacheSize = (EBX 1:01) * (EBX 1:121) * (EBX 1:221) * (ECX+1)
EBX=03C0F03F
and ECX=00001FFF
- this should be taken to mean that this cache has a cache line size of 64 bytes (EBX 1:01), has 16 cache lines per tag (EBX 1:121), is 16-way set-associative (EBX 1:221) with 8192 sets (ECX+1), for a total size of 64*16*16*8192=134217728 bytes, or 128 binary megabytes.
EAX=4 and EAX=Bh: Intel Thread/Core and Cache Topology
These two leaves are used for processor topology (thread, core, package) and cache hierarchy enumeration in Intel multi-core (and hyperthreaded) processors. AMD does not use these leaves but has alternate ways of doing the core enumeration. Unlike most other CPUID leaves, leaf Bh will return different values in EDX depending on which logical processor the CPUID instruction runs; the value returned in EDX is actually the x2APIC id of the logical processor. The x2APIC id space is not continuously mapped to logical processors, however; there can be gaps in the mapping, meaning that some intermediate x2APIC ids don't necessarily correspond to any logical processor. Additional information for mapping the x2APIC ids to cores is provided in the other registers. Although the leaf Bh has sub-leaves (selected by ECX as described further below), the value returned in EDX is only affected by the logical processor on which the instruction is running but not by the subleaf. The processor(s) topology exposed by leaf Bh is a hierarchical one, but with the strange caveat that the order of (logical) levels in this hierarchy doesn't necessarily correspond to the order in the physical hierarchy ( SMT/core/package). However, every logical level can be queried as an ECX subleaf (of the Bh leaf) for its correspondence to a "level type", which can be either SMT, core, or "invalid". The level id space starts at 0 and is continuous, meaning that if a level id is invalid, all higher level ids will also be invalid. The level type is returned in bits 15:08 of ECX, while the number of logical processors at the level queried is returned in EBX. Finally, the connection between these levels and x2APIC ids is returned in EAX :0as the number of bits that the x2APIC id must be shifted in order to obtain a unique id at the next level. As an example, a dual-core Westmere processor capable of hyperthreading (thus having two cores and four threads in total) could have x2APIC ids 0, 1, 4 and 5 for its four logical processors. Leaf Bh (=EAX), subleaf 0 (=ECX) of CPUID could for instance return 100h in ECX, meaning that level 0 describes the SMT (hyperthreading) layer, and return 2 in EBX because there are two logical processors (SMT units) per physical core. The value returned in EAX for this 0-subleaf should be 1 in this case, because shifting the aforementioned x2APIC ids to the right by one bit gives a unique core number (at the next level of the level id hierarchy) and erases the SMT id bit inside each core. A simpler way to interpret this information is that the last bit (bit number 0) of the x2APIC id identifies the SMT/hyperthreading unit inside each core in our example. Advancing to subleaf 1 (by making another call to CPUID with EAX=Bh and ECX=1) could for instance return 201h in ECX, meaning that this is a core-type level, and 4 in EBX because there are 4 logical processors in the package; EAX returned could be any value greater than 3, because it so happens that bit number 2 is used to identify the core in the x2APIC id. Note that bit number 1 of the x2APIC id is not used in this example. However, EAX returned at this level could well be 4 (and it happens to be so on a Clarkdale Core i3 5x0) because that also gives a unique id at the package level (=0 obviously) when shifting the x2APIC id by 4 bits. Finally, you may wonder what the EAX=4 leaf can tell us that we didn't find out already. In EAX 1:26it returns the APIC mask bits ''reserved'' for a package; that would be 111b in our example because bits 0 to 2 are used for identifying logical processors inside this package, but bit 1 is also reserved although not used as part of the logical processor identification scheme. In other words, APIC ids 0 to 7 are reserved for the package, even though half of these values don't map to a logical processor. The cache hierarchy of the processor is explored by looking at the sub-leaves of leaf 4. The APIC ids are also used in this hierarchy to convey information about how the different levels of cache are shared by the SMT units and cores. To continue our example, the L2 cache, which is shared by SMT units of the same core but not between physical cores on the Westmere is indicated by EAX 6:14being set to 1, while the information that the L3 cache is shared by the whole package is indicated by setting those bits to (at least) 111b. The cache details, including cache type, size, and associativity are communicated via the other registers on leaf 4. Beware that older versions of the Intel app note 485 contain some misleading information, particularly with respect to identifying and counting cores in a multi-core processor; errors from misinterpreting this information have even been incorporated in the Microsoft sample code for using CPUID, even for the 2013 edition of Visual Studio, and also in the sandpile.org page for CPUID, but the Intel code sample for identifying processor topology has the correct interpretation, and the current Intel Software Developer's Manual has a more clear language. The (open source) cross-platform production code from Wildfire Games also implements the correct interpretation of the Intel documentation. Topology detection examples involving older (pre-2010) Intel processors that lack x2APIC (thus don't implement the EAX=Bh leaf) are given in a 2010 Intel presentation. Beware that using that older detection method on 2010 and newer Intel processors may overestimate the number of cores and logical processors because the old detection method assumes there are no gaps in the APIC id space, and this assumption is violated by some newer processors (starting with the Core i3 5x0 series), but these newer processors also come with an x2APIC, so their topology can be correctly determined using the EAX=Bh leaf method.EAX=5: MONITOR/MWAIT Features
This returns feature information related to theMONITOR
and MWAIT
instructions in the EAX, EBX, ECX and EDX registers.
EAX=6: Thermal and Power Management
This returns feature bits in the EAX register and additional information in the EBX, ECX and EDX registers.EAX=7, ECX=0: Extended Features
This returns extended feature flags in EBX, ECX, and EDX. Returns the maximum ECX value for EAX=7 in EAX.EAX=7, ECX=1: Extended Features
This returns extended feature flags in all four registers.EAX=7, ECX=2: Extended Features
This returns extended feature flags in EDX. EAX, EBX and ECX are reserved.EAX=0Dh: XSAVE Features and State Components
This leaf is used to enumerate XSAVE features and state components. The XSAVE instruction set extension is designed to save/restore CPU extended state (typically for the purpose ofEAX=0Dh
CPUID leaf is used to provide information about which state-components the CPU supports and what their sizes/offsets are, so that the OS can reserve the proper amount of space and set the associated enable-bits.
The state-components can be subdivided into two groups: user-state (state-items that are visible to the application, e.g. XCR0
control register, while the supervisor-state items are enabled by setting their associated bits in the IA32_XSS
(0DA0h
) MSR - the indicated state items then become the state-components that can be saved and restored with the XSAVE
/XRSTOR
family of instructions.
The XSAVE mechanism can handle up to 63 state-components in this manner. State-components 0 and 1 ( x87 and SSE, respectively) have fixed offsets and sizes - for state-components 2 to 62, their sizes, offsets and a few additional flags can be queried by executing CPUID
with EAX=0Dh
and ECX
set to the index of the state-component. This will return the following items in EAX, EBX and ECX (with EDX being reserved):
Attempting to query an unsupported state-component in this manner results in EAX,EBX,ECX and EDX all being set to 0.
Sub-leaves 0 and 1 of CPUID
leaf 0Dh
are used to provide feature information:
As of July 2023, the XSAVE state-components that have been architecturally defined are:
EAX=12h: SGX Capabilities
This leaf provides information about the supported capabilities of the IntelENCLS CREATE/code> leaf function). The top 64 bits (given in EDX:ECX) are a bitmap of which bits can be set in the XFRM (X-feature request mask) - this mask is a bitmask of which CPU state-components (see leaf 0Dh) will be saved to the SSA in case of an AEX; this has the same layout as the XCR0
control register. The other bits are given in EAX and EBX, as follows:
Sub-leaves 2 and up are used to provide information about which physical memory regions are available for use as EPC (Enclave Page Cache) sections under SGX.
EAX=14h, ECX=0: Processor Trace
This sub-leaf provides feature information for Intel Processor Trace (also known as Real Time Instruction Trace).
The value returned in EAX is the index of the highest sub-leaf supported for CPUID with EAX=14h. EBX and ECX provide feature flags, EDX is reserved.
EAX=15h and EAX=16h: CPU, TSC, Bus and Core Crystal Clock Frequencies
These two leaves provide information about various frequencies in the CPU in EAX, EBX and ECX (EDX is reserved in both leaves).
If the returned values in EBX and ECX of leaf 15h are both nonzero, then the TSC ( Time Stamp Counter) frequency in Hz is given by TSCFreq = ECX*(EBX/EAX)
.
On some processors (e.g. Intel Skylake), CPUID_15h_ECX is zero but CPUID_16h_EAX is present and not zero. On all known processors where this is the case, the TSC frequency is equal to the Processor Base Frequency, and the Core Crystal Clock Frequency in Hz can be computed as CoreCrystalFreq = (CPUID_16h_EAX * 10000000) * (CPUID_15h_EAX/CPUID_15h_EBX)
.
On processors that enumerate the TSC/Core Crystal Clock ratio in CPUID leaf 15h, the APIC timer frequency will be the Core Crystal Clock frequency divided by the divisor specified by the APIC's Divide Configuration Register.
EAX=17h: SoC Vendor Attribute Enumeration
This leaf is present in systems where an x86 CPU IP core is implemented in an SoC ( System on chip) from another vendor - whereas the other leaves of CPUID
provide information about the x86 CPU core, this leaf provides information about the SoC. This leaf takes a sub-leaf index in ECX.
Sub-leaf 0 returns a maximum sub-leaf index in EAX (at least 3), and SoC identification information in EBX/ECX/EDX:
Sub-leaves 1 to 3 return a 48-byte SoC vendor brand string in UTF-8
UTF-8 is a character encoding standard used for electronic communication. Defined by the Unicode Standard, the name is derived from ''Unicode Transformation Format 8-bit''. Almost every webpage is transmitted as UTF-8.
UTF-8 supports all 1,112,0 ...
format. Sub-leaf 1 returns the first 16 bytes in EAX,EBX,ECX,EDX (in that order); sub-leaf 2 returns the next 16 bytes and sub-leaf 3 returns the last 16 bytes. The string is allowed but not required to be null-terminated.
EAX=19h: Intel Key Locker Features
This leaf provides feature information for Intel Key Locker in EAX, EBX and ECX. EDX is reserved.
EAX=1Dh: Tile Information
When ECX=0
, the highest supported "palette" subleaf is enumerated in EAX. When ECX≥1
, information on palette n is returned.
EAX=1Eh, ECX=0: TMUL
Information
This leaf returns information on the TMUL
(tile multiplier) unit.
EAX=1Eh, ECX=1: TMUL
Information
This leaf returns feature flags on the TMUL
(tile multiplier) unit.
EAX=21h: Reserved for TDX enumeration
When Intel TDX ( Trust Domain Extensions) is active, attempts to execute the CPUID
instruction by a TD (Trust Domain) guest will be intercepted by the TDX module.
This module will, when CPUID
is invoked with EAX=21h
and ECX=0
(leaf 21h
, sub-leaf 0), return the index of the highest supported sub-leaf for leaf 21h
in EAX
and a TDX module vendor ID string as a 12-byte ASCII string in EBX,EDX,ECX (in that order). Intel's own module implementation returns the vendor ID string "IntelTDX"
(with four trailing spaces) - for this module, additional feature information is not available through CPUID
and must instead be obtained through the TDX-specific TDCALL
instruction.
This leaf is reserved in hardware and will (on processors whose highest basic leaf is 21h
or higher) return 0 in EAX/EBX/ECX/EDX when run directly on the CPU.
EAX=24h, ECX=0: AVX10 Converged Vector ISA
This returns a maximum supported sub-leaf in EAX and AVX10 feature information in EBX. (ECX and EDX are reserved.)
EAX=24h, ECX=1: Discrete AVX10 Features
Subleaf 1 is reserved for AVX10 features not bound to a version.
EAX=2000'0000h: Highest Xeon Phi Function Implemented
The highest function is returned in EAX.
This leaf is only present on Xeon Phi processors.Intel
Intel Xeon Phi Coprocessor Instruction Set Architecture Reference Manual
Sep 2012, order no. 327364-001, appendix B.8, pages 677
Archived
on 4 Aug 2021.
EAX=2000'0001h: Xeon Phi Feature Bits
This function returns feature flags.
EAX=4000'0000h-4FFFF'FFFh: Reserved for
Hypervisor
A hypervisor, also known as a virtual machine monitor (VMM) or virtualizer, is a type of computer software, firmware or hardware that creates and runs virtual machines. A computer on which a hypervisor runs one or more virtual machines is called ...
s
When the CPUID
instruction is executed under Intel VT-x or AMD-v virtualization, it will be intercepted by the hypervisor, enabling the hypervisor to return CPUID
feature flags that differ from those of the underlying hardware. CPUID
leaves 40000000h
to 4FFFFFFFh
are not implemented in hardware, and are reserved for use by hypervisors to provide hypervisor-specific identification and feature information through this interception mechanism.
For leaf 40000000h
, the hypervisor is expected to return the index of the highest supported hypervisor CPUID leaf in EAX, and a 12-character hypervisor ID string in EBX,ECX,EDX (in that order). For leaf 40000001h
, the hypervisor may return an interface identification signature in EAX - e.g. hypervisors that wish to advertise that they are Hyper-V
Hyper-V is a native hypervisor developed by Microsoft; it can create virtual machines on x86-64 systems running Windows. It is included in Pro and Enterprise editions of Windows (since Windows 8) as an optional feature to be manually enabled. A ...
compatible may return 0x31237648
—"Hv#1"
in EAX. The formats of leaves 40000001h
and up to the highest supported leaf are otherwise hypervisor-specific. Hypervisors that implement these leaves will normally also set bit 31 of ECX for CPUID leaf 1 to indicate their presence.
Hypervisors that expose more than one hypervisor interface may provide additional sets of CPUID leaves for the additional interfaces, at a spacing of 100h
leaves per interface. For example, when QEMU
The Quick Emulator (QEMU) is a free and open-source emulator that uses dynamic binary translation to emulate a computer's processor; that is, it translates the emulated binary codes to an equivalent binary format which is executed by the mach ...
is configured to provide both Hyper-V
Hyper-V is a native hypervisor developed by Microsoft; it can create virtual machines on x86-64 systems running Windows. It is included in Pro and Enterprise editions of Windows (since Windows 8) as an optional feature to be manually enabled. A ...
and KVM interfaces, it will provide Hyper-V information starting from CPUID leaf 40000000h
and KVM information starting from leaf 40000100h
.
Some hypervisors that are known to return a hypervisor ID string in leaf 40000000h
include:
EAX=8000'0000h: Highest Extended Function Implemented
The highest calling parameter is returned in EAX.
EBX/ECX/EDX return the manufacturer ID string (same as EAX=0) on AMD but not Intel CPUs.
EAX=8000'0001h: Extended Processor Info and Feature Bits
This returns extended feature flags in EDX and ECX.
Many of the bits in EDX
(bits 0 through 9, 12 through 17, 23, and 24) are duplicates of EDX
from the EAX=1
leaf - these bits are highlighted in light yellow. (These duplicated bits are present on AMD but not Intel CPUs.)
AMD feature flags are as follows:
EAX=8000'0002h,8000'0003h,8000'0004h: Processor Brand String
These return the processor brand string in EAX, EBX, ECX and EDX. CPUID
must be issued with each parameter in sequence to get the entire 48-byte ASCII processor brand string. It is necessary to check whether the feature is present in the CPU by issuing CPUID
with EAX = 80000000h
first and checking if the returned value is not less than 80000004h
.
The string is specified in Intel/AMD documentation to be null-terminated, however this is not always the case (e.g. DM&P Vortex86DX3 and AMD Ryzen 7 6800HS are known to return non-null-terminated brand strings in leaves 80000002h
-80000004h
), and software should not rely on it.
#include
#include
#include
int main()
On AMD processors, from 180nm Athlon onwards (AuthenticAMD
Family 6 Model 2 and later), it is possible to modify the processor brand string returned by CPUID leaves 80000002h
-80000004h
by using the WRMSR
instruction to write a 48-byte replacement string to MSRs C0010030h
-C0010035h
. This can also be done on AMD Geode GX/LX, albeit using MSRs 300Ah
-300Fh
.
In some cases, determining the CPU vendor requires examining not just the Vendor ID in CPUID leaf 0 and the CPU signature in leaf 1, but also the Processor Brand String in leaves 80000002h
-80000004h
. Known cases include:
* Montage Jintide CPUs can be distinguished from the Intel Xeon CPU models they're based on by the presence of the substring Montage
in the brand string of the Montage CPUs (e.g. Montage Jintide C2460 and Intel Xeon Platinum 8160 - both of which identify themselves as GenuineIntel
Family 6 Model 55h Stepping 4 - can be distinguished in this manner.)
* CentaurHauls
Family 6 CPUs may be either VIA or Zhaoxin CPUs - these can be distinguished by the presence of the substring ZHAOXIN
in the brand string of the Zhaoxin CPUs (e.g. Zhaoxin KaiXian ZX-C+ C4580 and VIA Eden X4 C4250 - both of which identify themselves as CentaurHauls
Family 6 Model 0Fh Stepping 0Eh - can be distinguished in this manner.)
EAX=8000'0005h: L1 Cache and TLB Identifiers
This provides information about the processor's level-1 cache and TLB characteristics in EAX, EBX, ECX and EDX as follows:
* EAX: information about L1 hugepage TLBs (TLBs that hold entries corresponding to 2M/4M pages)
* EBX: information about L1 small-page TLBs (TLBs that hold entries corresponding to 4K pages)
* ECX: information about L1 data cache
* EDX: information about L1 instruction cache
EAX=8000'0006h: Extended L2 Cache Features
Returns details of the L2 cache in ECX, including the line size in bytes (Bits 07 - 00), type of associativity (encoded by a 4 bits field; Bits 15 - 12) and the cache size in KB (Bits 31 - 16).
#include
#include
int main()
EAX=8000'0007h: Processor Power Management Information and RAS Capabilities
This function provides information about power management, power reporting and RAS (Reliability, availability and serviceability
Reliability, availability and serviceability (RAS), also known as reliability, availability, and maintainability (RAM), is a computer hardware engineering term involving reliability engineering, high availability, and serviceability design. The p ...
) capabilities of the CPU.
EAX=8000'0008h: Virtual and Physical Address Sizes
EAX=8000'000Ah: SVM features
This leaf returns information about AMD SVM ( Secure Virtual Machine) features in EAX, EBX and EDX.
EAX=8000'001Fh: Encrypted Memory Capabilities
EAX=8000'0021h: Extended Feature Identification
EAX=8FFF'FFFFh: AMD Easter Egg
Several AMD CPU models will, for CPUID with EAX=8FFFFFFFh
, return an Easter Egg string in EAX, EBX, ECX and EDX. Known Easter Egg strings include:
EAX=C000'0000h: Highest
Centaur
A centaur ( ; ; ), occasionally hippocentaur, also called Ixionidae (), is a creature from Greek mythology with the upper body of a human and the lower body and legs of a horse that was said to live in the mountains of Thessaly. In one version o ...
Extended Function
Returns index of highest Centaur leaf in EAX. If the returned value in EAX is less than C0000001h
, then Centaur extended leaves are not supported.
Present in CPUs from VIA and Zhaoxin
Zhaoxin (Shanghai Zhaoxin Semiconductor Co., Ltd.; , ) is a fabless semiconductor company, created in 2013 as a joint venture between VIA Technologies and the Shanghai Municipal Government. The company manufactures x86-compatible desktop and ...
.
On IDT WinChip
The WinChip series is a discontinued CPU electrical consumption, low-power Socket 7-based x86 central processing unit, processor that was designed by Centaur Technology and marketed by its parent company Integrated Device Technology, IDT.
Overvie ...
CPUs (CentaurHauls
Family 5), the extended leaves C0000001h-C0000005h
do not encode any Centaur-specific functionality but are instead aliases of leaves 80000001h-80000005h
.
EAX=C000'0001h: Centaur Feature Information
This leaf returns Centaur feature information (mainly VIA/Zhaoxin PadLock) in EDX. (EAX, EBX and ECX are reserved.)
CPUID usage from high-level languages
Inline assembly
This information is easy to access from other languages as well. For instance, the C code for gcc below prints the first five values, returned by the cpuid:
#include
#include
int main()
In MSVC and Borland/Embarcadero C compilers (bcc32) flavored inline assembly, the clobbering information is implicit in the instructions:
#include
int main()
If either version was written in plain assembly language, the programmer must manually save the results of EAX, EBX, ECX, and EDX elsewhere if they want to keep using the values.
Wrapper functions
GCC also provides a header called <cpuid.h>
on systems that have CPUID. The __cpuid
is a macro expanding to inline assembly. Typical usage would be:
#include
#include
int main()
But if one requested an extended feature not present on this CPU, they would not notice and might get random, unexpected results. Safer version is also provided in <cpuid.h>
. It checks for extended features and does some more safety checks. The output values are not passed using reference-like macro parameters, but more conventional pointers.
#include
#include
int main()
Notice the ampersands in &a, &b, &c, &d
and the conditional statement. If the __get_cpuid
call receives a correct request, it will return a non-zero value, if it fails, zero.
Microsoft Visual C compiler has builtin function __cpuid()
so the cpuid instruction may be embedded without using inline assembly, which is handy since the x86-64 version of MSVC does not allow inline assembly at all. The same program for MSVC
Microsoft Visual C++ (MSVC) is a compiler for the C, C++, C++/CLI and C++/CX programming languages by Microsoft. MSVC is proprietary software; it was originally a standalone product but later became a part of Visual Studio and made available ...
would be:
#include
#ifdef _MSC_VER
#include
#endif
int main()
Many interpreted or compiled scripting languages are capable of using CPUID via an FFI library
One such implementation
shows usage of the Ruby FFI module to execute assembly language that includes the CPUID opcode.
.NET
The .NET platform (pronounced as "''dot net"'') is a free and open-source, managed code, managed computer software framework for Microsoft Windows, Windows, Linux, and macOS operating systems. The project is mainly developed by Microsoft emplo ...
5 and later versions provide the System.Runtime.Intrinsics.X86.X86base.CpuId
method. For instance, the C# code below prints the processor brand if it supports CPUID instruction:
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics.X86;
using System.Text;
namespace X86CPUID
CPU-specific information outside x86
Some of the non-x86 CPU architectures also provide certain forms of structured information about the processor's abilities, commonly as a set of special registers:
* ARM architecture
ARM (stylised in lowercase as arm, formerly an acronym for Advanced RISC Machines and originally Acorn RISC Machine) is a family of reduced instruction set computer, RISC instruction set architectures (ISAs) for central processing unit, com ...
s have a CPUID
coprocessor register which requires exception level EL1 or above to access.
* System/370
The IBM System/370 (S/370) is a range of IBM mainframe computers announced as the successors to the IBM System/360, System/360 family on June 30, 1970. The series mostly maintains backward compatibility with the S/360, allowing an easy migrati ...
through z/Architecture
z/Architecture, initially and briefly called ESA Modal Extensions (ESAME), is IBM's 64-bit complex instruction set computer (CISC) instruction set architecture, implemented by its mainframe computers. IBM introduced its first z/Architecture ...
IBM mainframe processors have a supervisor-mode-only ''Store CPU ID'' (STIDP
) instruction, which provides information that includes the CPU type.
* The z/Architecture mainframe processors also have a supervisor-mode-only ''Store Facilities List'' (STFL
) instruction, and a non-privileged ''Store Facilities List Extended'' (STFLE
) instruction, which list the installed hardware features.
* The MIPS32/64 architecture defines a mandatory ''Processor Identification'' (PrId
) and a series of daisy-chained ''Configuration Registers''.
* The PowerPC
PowerPC (with the backronym Performance Optimization With Enhanced RISC – Performance Computing, sometimes abbreviated as PPC) is a reduced instruction set computer (RISC) instruction set architecture (ISA) created by the 1991 Apple Inc., App ...
processor has the 32-bit read-only ''Processor Version Register'' (PVR
) identifying the processor model in use. The instruction requires supervisor access level.
* The RISC-V
RISC-V (pronounced "risk-five") is an open standard instruction set architecture (ISA) based on established reduced instruction set computer (RISC) principles. The project commenced in 2010 at the University of California, Berkeley. It transfer ...
architecture has an mcpuid
"read-only register containing information regarding the capabilities of the CPU implementation"
DSP and transputer
The transputer is a series of pioneering microprocessors from the 1980s, intended for parallel computing. To support this, each transputer had its own integrated memory and serial communication links to exchange data with other transputers. ...
-like chip families have not taken up the instruction in any noticeable way, in spite of having (in relative terms) as many variations in design. Alternate ways of silicon identification might be present; for example, DSPs from Texas Instruments
Texas Instruments Incorporated (TI) is an American multinational semiconductor company headquartered in Dallas, Texas. It is one of the top 10 semiconductor companies worldwide based on sales volume. The company's focus is on developing analog ...
contain a memory-based register set for each functional unit that starts with identifiers determining the unit type and model, its ASIC
An application-specific integrated circuit (ASIC ) is an integrated circuit (IC) chip customized for a particular use, rather than intended for general-purpose use, such as a chip designed to run in a digital voice recorder or a high-efficien ...
design revision and features selected at the design phase, and continues with unit-specific control and data registers. Access to these areas is performed by simply using the existing load and store instructions; thus, for such devices, there is no need for extending the register set for device identification purposes.
See also
x86-cpuid.org
a complete x86 architecture CPUID database plus related code generation tools, to be used by both the Linux Kernel
The Linux kernel is a Free and open-source software, free and open source Unix-like kernel (operating system), kernel that is used in many computer systems worldwide. The kernel was created by Linus Torvalds in 1991 and was soon adopted as the k ...
and the Xen hypervisor.
* CPU-Z
CPU-Z is a freeware system profiler, system profiling and system monitor, monitoring application for Microsoft Windows and Android (operating system), Android that detects the central processing unit, Random access memory, RAM, motherboard chipse ...
, a Windows utility that uses CPUID
to identify various system settings
CPU-X
an alternative of CPU-Z for Linux and FreeBSD
* Spectre (security vulnerability)
Spectre is one of the speculative execution CPU vulnerabilities which involve side-channel attacks. These affect modern microprocessors that perform branch prediction and other forms of speculative execution. On most processors, the specul ...
* Speculative Store Bypass (SSB)
* , a text file generated by certain systems containing some of the CPUID information
References
Further reading
*
External links
* Inte
Processor Identification and the CPUID Instruction
(Application Note 485), last published version. Said to be incorporated into th
Intel 64 and IA-32 Architectures Software Developer's Manualin 2013
but the manual still directs the reader to note 485.
** Contains some information that can be ''and was'' easily misinterpreted though, particularly with respect to processor topology identification.
** The big Intel manuals tend to lag behind the Intel ISA document, available at the top o
this page
which is updated even for processors not yet publicly available, and thus usually contains more CPUID bits. For example, as of this writing, the ISA book (at revision 19, dated May 2014) documents the CLFLUSHOPT bit in leaf 7, but the big manuals although apparently more up-to-date (at revision 51, dated June 2014) don't mention it.
AMD64 Architecture Programmer's Manual Volume 3: General-Purpose and System Instructions
command-line program for Linux
command-line programs for Windows
instlatx64
- collection of x86/x64 Instruction Latency, Memory Latency and CPUID dumps
{{DEFAULTSORT:Cpuid
X86 architecture
Machine code
X86 instructions