CPUID

CPUID是一条指令,在任何level都可执行。用来获取当前处理器的信息,比如它的功能等。

The CPUID instruction makes implicit use of the EAX, EBX, ECX, and EDX registers. Software loads a function code into EAX and, for some function codes, a sub-function code in ECX, executes the CPUID instruction, and then reads the associated processor-feature information in EAX, EBX, ECX, and EDX.

Some processor implementations may not support the CPUID instruction. Support for the CPUID instruction is determined by testing the RFLAGS.ID bit. If software can write this bit, then the CPUID instruction is supported by the processor implementation. Otherwise, execution of CPUID results in an invalid-opcode exception.

The CPUID instruction provides information about the processor implementation and its capabilities. Software operating at any privilege level can execute the CPUID instruction to collect this information. After the information is collected, software can select procedures that optimize performance for a particular hardware implementation.

Support for the CPUID instruction is implementation-dependent, as determined by software’s ability to write the RFLAGS.ID bit. After software has determined that the processor implementation supports the CPUID instruction, software can test for support for a specific feature by loading the appropriate function number into the EAX register and executing the CPUID instruction. Processor feature information is returned in the EAX, EBX, ECX, and EDX registers.

0000_xxxxh: standard function;
8000_xxxxh: extended function.

原文地址:https://www.cnblogs.com/yanli0302/p/11574975.html