The CPUID Guide
By
Lawrence Curwood
of Paradice Software
Last Updated 25 November 2003

  1. What is the CPUID instruction?
  2. What processors support CPUID?
  3. How to call the CPUID instruction.
  4. Making sense of what CPUID returns.
  5. Identifying CPU manufacturer through CPUID.
  6. Identifying CPU features through CPUID.
  7. A table of family/model values for CPUs.

An index to all of the supplementary notes used in this guide.

.

  1. What is the CPUID instruction?

In the earlier days of x86 computing (when the 486 was supreme), there was a vast amount of different hardware inside PCs, much as there is today, but back in those days "compatibility" was an unknown concept between manufacturers - all their hardware behaved differently, and the poor programmer had to write mountains of code merely to identify the hardware the program was running on, yet alone take full advantage of it's unique features. The CPU was one area where, despite continual advancements by Intel, AMD and others, programs were generally not using any optimisation based on the user's CPU, because it was difficult to know which CPU was being used!

When Intel released MMX, however, it decided that it needed to make it easy for programs to recognise it's new CPUs, and utilise the instructions provided to increase the performance of the programs when running under a new CPU (which was good for Intel too - people saw how much faster it was, and they bought the new CPUs). So, they developed the CPUID instruction. This simple assembler instruction gave instant access for the programmer to a lot of information: who manufactured this CPU (e.g. Intel, AMD, Cyrix, etc), what "extra features" it supports (e.g. an FPU, MMX, 3DNow, etc), and other information (see Chapters #5 ,#6 & #7 for how to obtain this information).

.

  2. What processors support CPUID?

Generally speaking, virtually all Pentium CPUs support the CPUID (opcode 0Fh-A2h) instruction. Also, genuine Intel 486-based CPUs and many 486 clones support it. The Pentium Pro, PentiumII, Pentium III and Pentium IV all support it. All AMD's CPUs support it, and the Cyrix MediaGX, 6x86, 6x86MX and mII (although not without troubles). Anything newer than the above will support it. A simple guideline is that all CPUs available today support CPUID, and Chapter #7 has a complete list of CPUs that support CPUID.

Unfortunately, there is a small problem with just calling CPUID to find the CPU information, and that is: If the CPU you are running on does not support CPUID, it will crash (or, as the OS likes to call it, an "Invalid Instruction Exception"). There is a method of "checking" the CPU to see if it supports CPUID, but (of course) the check only works on 486+ class CPUs. Relax, though, because the process (and appropriate source code) to find out as much information as possible from any given CPU type is here, in flow-chart form (this assumes you are using at least a 386, which is a moot point as any compiler you'll find nowadays will require at least a 386 processor)

Here are the code snippets you'll need (assembler with some Pascal wrappings):

  3. How to call the CPUID instruction.

The CPUID instruction is very easy to call from any language that supports in-line assembler. Here is a complete <CPUID vendor program> written for FreePascal. It is a trivial matter to convert to C/C++ or other languages, provided that their in-line assemblers recognise CPUID.

CPUID doesn't have any parameters, instead the value of eax is set before calling. This value determines which CPUID function you want to call. Always call eax=$0 first, because this returns the vendor and highest eax value, then you can call the higher functions if necessary & available.

.

  4. Making sense of what CPUID returns.

The tables below show what values of eax return what information. Take note of the "highest eax value" field, because this is the highest value of eax that you can call CPUID with on that processor. Note that all processors handle eax=$0 the same way (i.e. highest eax, then vendor string), but after that different manufacturers return different information. All CPUs also respond to the 'CPU Features' correctly, and all respond to 'CPU Signature' correctly.

CPUID Function results
EAX value EAX EBX ECX EDX
$0000_0000 Highest eax Mfg string Mfg string Mfg string
$0000_0001 Signature Brand ID/APIC/Misc MSRs/Misc Features
$0000_0002 Config Config Config Config
$0000_0003 reserved reserved (Serial on Transmeta) Serial Serial
>$0000_0003 (Intel) reserved reserved reserved reserved

For values of eax=$2 and higher, different CPUs return different information. The table shows information returned by GenuineIntel processors (as they have the official documentation). Others, such as the Cyrix MediaGX enhanced, for example, return cache information in eax=$2. You can of course click any of the above entries for notes about it.

.

  5. Identifying CPU manufacturer through CPUID.

Identifying the manufacturer of the target CPU using CPUID is one of the simplest tasks available. It has already been demonstrated with the vendor program from Chapter #3, which returns the vendor string. It is simple to turn this string into the actual manufacturer. The table below shows the vendor strings and the manufacturers that use them. Note: The vendor string is also handy when looking at the stepping/model/family table, as it allows you to determine the exact CPU that your program is running on.

CPU Vendor String Manufacturer Name
GenuineIntel Intel
AuthenticAMD AMD
CyrixInstead Cyrix
CentaurHauls Centaur
NexGenDriven NexGen
GenuineTMx86 Transmeta
RiseRiseRise Rise
UMC UMC UMC UMC
SiS SiS SiS SiS
Geode by NSC National Semiconductor

Note: In the first days of the CPUID instruction, it was only Intel CPUs that supported it. Some applications made the mistake of checking CPUID and then looking for the "GenuineIntel" string. Because such software would have problems with all non-Intel CPUID enabled CPUs, some CPUs have the capability to change the vendor string, to GenuineIntel or to anything else. Thus you cannot always rely 100% on the above information being returned by your CPU.

.

  6. Identifying CPU features through CPUID.

CPUID function eax=$1, if available (check highest eax value first) returns CPU information and also "supported features" a.k.a. "standard feature flags" of that CPU.

Standard CPUID Feature flags
Flag (bit) Feature Description
0 fpu Floating Point Unit
1 vme Virtual Mode Extensions
2 de Debugging Extensions
3 pse Page Size Extensions
4 tsc Time stamp counter
5 msr Model-specific registers
6 pae Physical Address Extensions
7 mce Machine Check Exceptions
8 cxchg8 Compare and exchange 8-byte
9 apic On-chip APIC
10 n/a Reserved
11 sep Fast System Calls
12 mtrr Memory Type Range Registers
13 pge Page Global Enable
14 mca Machine Check Architecture
15 cmov Conditional move instruction
16 pat Page Attribute Table
17 pse36 36-bit Page Size Extensions
18 psn Processor Serial Number
19 clfl CLFLUSH, Description pending
20 n/a Reserved
21 dtes Debug Trace and EMON Store MSRs
22 acpi Thermal Control MSR
23 mmx MMX instruction set
24 fxsr Fast floating point save/restore
25 sse SSE (Streaming SIMD Extensions)
26 sse2 SSE2 (Streaming SIMD Extensions - #2)
27 ss Selfsnoop
28 htt Hyper-Threading Technology
29 tm1 Thermal Interrupt & Status MSRs.
30 ia-64 IA-64 (64-bit Intel CPU)
31 pbe Pending Break Event


Because the different CPU manufacturers were developing new (and unique) features for their CPUs at the same time, the non-Intel vendors (AMD, Cyrix etc) created an "Extended" CPU function, called with eax=$8000_0001, so that they could define their own feature flags and not sacrifice compatibility with software expecting the standard values. (Note: to identify support for the extended values, you must first call eax=$8000_0000, which returns the maximum supported extended levels in eax.) For most bits, their meanings are identical to the standard flags, but where they differ, the values and meanings are listed below:


Extended CPUID Feature Flags
Flag Feature Description
10 n/a Reserved
AMD K6 (model 6) CPU: Fast System Calls.
Model 7 or newer CPU: Use bit 11 instead (as per Standard)
16 fcmov or pat Cyrix, AMD K6 CPUs: Floating-point Conditional Move
AMD K7 CPUs: Page Attribute Table (as per Standard)
18 n/a Reserved
19 mp MP (Multi Processor) Capable
20..21 n/a Reserved
22 mmx+ AMD CPUs: MMX+ (AMD MMX Extensions)
24 cxmmx or fxsr Cyrix CPUs: Extended MMX instructions
AMD K7 CPUs: Fast floating point save/restore (as per Standard)
25..28 n/a Reserved
29 lm AA-64 (AMD 64-bit CPU)
30 3dnowext 3DNow! extended instructions
31 3dnow 3DNow! instructions


That that although earlier processors may not support CPUID, they still may have some of the features in the table above. Many 386 processors have in-built FPUs and MMUs, so use alternative detection methods in your program before deciding not to use those features.

.

  7. A table of model & family values for CPUs.

The "CPU signature" function (eax=$1, returned in eax) returns stepping, model and family information in the format of the table below:

Bits Description
0..3 Stepping
4..7 Model
8..11 Family
12..13 Processor type
16..19 Extended Model
20..27 Extended Family

These family and model numbers, in conjunction with the CPU vendor information from Chapter #5, can tell you the exact CPU your system is running on. Following are tables for each CPU manufacturer, with the family and model numbers for each released CPU. Note: the Stepping values are specific to each CPU, change with great frequency, and are poorly documentated by the manufacturers. As such, it is not possible to list them here.

AMD CPU signatures - Standard
Family Model Name *Family
4 3 486 DX/2 n/a
  7 486 DX/2-WB n/a
  8 486 DX/4 n/a
  9 486 DX/4-WB n/a
  14 Am5x86-WT n/a
  15 Am5x86-WB n/a
5 0 K5/SSA5 n/a
  1..3 K5 5
  6,7 K6 6
  8 K6-2 6
  9 K6-3 6
  13 K6-2+ or K6-III+ 6
6 0..1 Athlon (25 µm) 7
  2 Athlon (18 µm) 7
  3 Duron 7
  4 Athlon (Thunderbird) 7
  6 Athlon (Palamino) 7
  7 Duron (Morgan) 7
  8 Athlon (Thoroughbred) 7
  10 Athlon (Barton) 7
15 .. Use Extended family table

AMD CPU signatures - Extended Family
Ext. Family Model Name
0 4 Athlon 64
0 5 Athlon 64 FX
Opteron

Intel CPU signatures - Standard
Family Model Name
4 0 486 DX-25/33
  1 486 DX-50
  2 486 SX
  3 486 DX/2
  4 486 SL
  5 486 SX/2
  7 486 DX/2-WB
  8 486 DX/4
  9 486 DX/4-WB
5 0 Pentium 60/66 A-step
  1 Pentium 60/66
  2 Pentium 75 - 200
  3 OverDrive PODP5V83
  4 Pentium MMX
  7 Mobile Pentium 75 - 200
  8 Mobile Pentium MMX
6 0 Pentium Pro A-step
  1 Pentium Pro
  3 Pentium II (Klamath)
  5 Pentium II (Deschutes), Celeron (Covington), Mobile Pentium II (Dixon)
  6 Mobile Pentium II, Celeron (Mendocino)
  7 Pentium III (Katmai)
  8 Pentium III (Coppermine)
  9 Mobile Pentium III
  10 Pentium III (0.18 µm)
  11 Pentium III (0.13 µm)
7 .. Itanium (IA-64)
15 .. Use Extended family table

Intel CPU signatures - Extended Family
Ext. Family Model Name
0 0,1 Pentium IV (0.18 µm)
0 2 Pentium IV (0.13 µm)
0 3 Pentium IV (0.09 µm)
1 .. Itanium 2 (IA-64)

Cyrix CPU signatures
Family Model Name
4 4 MediaGX
5 2 6x86 / 6x86L (Identifying the difference)
  4 MediaGX MMX Enhanced
6 0 m II (6x86MX)
  5 VIA Cyrix M2 core
  6 WinChip C5A
  7 WinChip C5B ,WinChip C5C
  8 WinChip C5N
  9 WinChip C5XL, WinChip C5P

UMC CPU signatures
Family Model Name
4 1 U5D
  2 U5S

NexGen CPU signatures
Family Model Name
5 0 Nx586

Rise CPU signatures
Family Model Name
5 0,1 mP6

SiS CPU signatures
Family Model Name
5 0 55x

Transmeta CPU signatures
Family Model Name
5 4 Crusoe TM3x00 and TM5x00

Centaur CPU signatures
Family Model Name
5 4 C6
  8 C2
  9 C3

National Semiconductor CPU signatures
Family Model Name
5 4 GX1, GXLV, GXm
5 5 GX2
 

Finally, please be sure to email me comments, and visit the Paradice Software page

(c) 2000-2003 by Lawrence Curwood, Paradice Software. I assume no responsibilty for the accuracy any of the above information or your usage of it. This includes any possible damage to your system, either direct or indirect. If you are in doubts as to the accuracy of any of the above information, or require guaranteed accuracy for any specific purpose, check with your CPU vendor directly! This information mostly obtained from www.sandpile.org. All Trademarks are copyright their respective owners.