问题
What does the below comment mean in Intel Processor data sheet? How can I check that in my driver's code in Linux?
If CPUID.06H:EAX.[7] = 1
I come across this type of statements in the SW developer's manual for Intel Processors in the comments column in register description table..
Ref: https://software.intel.com/sites/default/files/managed/22/0d/335592-sdm-vol-4.pdf
Please help me to understand the processor descriptions.
Thanks.
回答1:
CPUID.06H:EAX.[7] enables the discovery of the HWP (HARDWARE-CONTROLLED PERFORMANCE STATES) support in an Intel processor.
If that feature-bit isn't set, the feature does not exist. Accessing the HWP MSRs will result in #GP exception. For other feature-bits, the result may be worse: no fault but causing hard-to-debug problems later way.
It means that you should check a bit in the eax
register (specifically eax & (1<<7)
) after running the cpuid instruction with eax=0x6
before the instruction.
To discover the CPUID value in Linux kernel you can use one of the cpuid functions, with op=6:
#include <asm/processor.h> // defines the following:
void cpuid(unsigned int op,
unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx);
void cpuid_count(unsigned int op, int count,
unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx);
Or for cases where you only want one register result:
unsigned int cpuid_eax(unsigned int op);
And mask the EAX returned value.
One small note: when quoting the SDM it is better to specify a section - it is a big book after all...
回答2:
Question 1
What does the below comment mean in Intel Processor data sheet?
If CPUID.06H:EAX.[7] = 1
The cpuid
is a special processor instruction used to discover details of the processor (check the availability of some uncommon features for eg). It implicitly uses the EAX register as parameter and returns the result in EAX, EBX, ECX, EDX.
In Intel manual, the general format is:
CPUID.EAX_VALUE:RETURN_REGISTER.[BIT_NUMBER] = 1
: means that If you execute CPUID
instruction with EAX register = EAX_VALUE, you will get the result in RETURN_REGISTER. If the bit number BIT_NUMBER is set, so it has some special mean you can find in the manuals.
CPUID.06H:EAX.[7]=1
means that If you execute CPUID
instruction with register EAX = 06H (6 in hexadecimal) as input, you will get the result in EAX. If the bit number 7 of the result is 1, so it has some special mean you can find in the manuals. For eg. I read this in the manual:
Availability of HWP baseline resource and capability, CPUID.06H:EAX[bit 7]: If this bit is set (that is if
CPUID.06H:EAX.[7]=1
), HWP provides several new architectural MSRs: IA32_PM_ENABLE, IA32_HWP_CAPABILITIES, IA32_HWP_REQUEST,IA32_HWP_STATUS.
Question 2
How can I check that in my driver's code in Linux?
if(cpuid_eax(0x06) & (1<<7)){
// Good news :features availlable, do your job
}else{
// Bad luck ::
return;
}
来源:https://stackoverflow.com/questions/45883852/intel-processor-if-cpuid-06heax-7-1-meaning