CPUID 指令
简介
CPUID 指令根据传递给 EAX 寄存器的值,将对应的信息返回给 EAX、EBX、ECX 及 EDX 寄存器。从 Intel 手册上看,早期有的 CPU 是不支持 CPUID 指令的,但现在的处理器应该都支持了。通过 EFLAGS 寄存器可以知晓。该寄存器 bit 21(ID) 标志表示了处理器对 CPUID 指令的支持。coreboot 中,使用 cpuid 函数进行 CPUID 指令的操作,传入参数实际上即是手册中出现的 EAX 的值。
EAX = 0:vendor id
执行 CPUID 后,返回值寄存器依次为 EBX、EDX、ECX,其中EBX为 “Genu”,EDX 为 “ineI”,ECX 为 “ntel”。手册解释如下:
EBX <- 756e6547h (* “Genu”, with G in the low eight bits of BL )
EDX <- 49656e69h ( “ineI”, with i in the low eight bits of DL )
ECX <- 6c65746eh ( “ntel”, with n in the low eight bits of CL *)
这些寄存器组合起来,就是 “GenuineIntel”。
下面是一些已知的 CPU ID 字符串:
值 | 解释 |
---|---|
AMDisbetter! | early engineering samples of AMD K5 processor |
AuthenticAMD | AMD |
CentaurHauls | Centaur (Including some VIA CPU) |
CyrixInstead | Cyrix |
GenuineIntel | Intel |
TransmetaCPU | Transmeta |
GenuineTMx86 | Transmeta |
Geode by NSC | National Semiconductor |
NexGenDriven | NexGen |
RiseRiseRise | Rise |
SiS SiS SiS | SiS |
UMC UMC UMC | UMC |
VIA VIA VIA | VIA |
Vortex86 SoC | Vortex |
下面是虚拟机的 CPU ID 字符串:
值 | 解释 |
---|---|
KVMKVMKVM | KVM |
Microsoft Hv | Microsoft Hyper -V or Windows Virtual PC |
lrpepyh vr | Parallels (it possibly should be prl hyperv, but it is encoded as lrpepyh vr) |
VMwareVMware | VMware |
XenVMMXenVMM | Xen HVM |
EAX = 0x01:Model、Family、Stepping 信息
执行 CPUID 后,返回的 EAX 寄存器包含 Model、Family、Stepping 信息。各个字段解释如下图所示:
EAX = 80000002h、80000003h、80000004h:处理器品牌(brand)字符串
比如 Atom 的一款 CPU 的品牌信息为:”Intel(R) Atom(TM) CPU E3815 @ 1.46GHz.”。
80000002h:” Intel(R)” 80000003h:” Atom(TM) CPU E” 80000004h:”3815 @ 1.46GHz.”
字符串的低位对应寄存器的逻辑低位
EAX = 80000008h:虚拟地址和物理地址大小
物理地址的大小在 EAX 的 bit[7:0] 返回,虚拟地址的大小在 EAX 的 bit[15:8]。
参考资料