[cpuid] Allow input %ecx value to be specified

For some CPUID leaves (e.g. %eax=0x00000004), the result depends on
the input value of %ecx.  Allow this subfunction number to be
specified as a parameter to the cpuid() wrapper.

The subfunction number is exposed via the ${cpuid/...} settings
mechanism using the syntax

  ${cpuid/<subfunction>.0x40.<register>.<function>}

e.g.

  ${cpuid/0.0x40.0.0x0000000b}
  ${cpuid/1.0x40.0.0x0000000b}

to retrieve the CPU topology information.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2017-06-16 01:17:48 +01:00
parent c8cb867d65
commit a6a5825f8d
6 changed files with 57 additions and 45 deletions
+3 -3
View File
@@ -66,12 +66,12 @@ static int hvm_cpuid_base ( struct hvm_device *hvm ) {
/* Scan for magic signature */
for ( base = HVM_CPUID_MIN ; base <= HVM_CPUID_MAX ;
base += HVM_CPUID_STEP ) {
cpuid ( base, &discard_eax, &signature.ebx, &signature.ecx,
cpuid ( base, 0, &discard_eax, &signature.ebx, &signature.ecx,
&signature.edx );
if ( memcmp ( &signature, HVM_CPUID_MAGIC,
sizeof ( signature ) ) == 0 ) {
hvm->cpuid_base = base;
cpuid ( ( base + HVM_CPUID_VERSION ), &version,
cpuid ( ( base + HVM_CPUID_VERSION ), 0, &version,
&discard_ebx, &discard_ecx, &discard_edx );
DBGC2 ( hvm, "HVM using CPUID base %#08x (v%d.%d)\n",
base, ( version >> 16 ), ( version & 0xffff ) );
@@ -101,7 +101,7 @@ static int hvm_map_hypercall ( struct hvm_device *hvm ) {
int rc;
/* Get number of hypercall pages and MSR to use */
cpuid ( ( hvm->cpuid_base + HVM_CPUID_PAGES ), &pages, &msr,
cpuid ( ( hvm->cpuid_base + HVM_CPUID_PAGES ), 0, &pages, &msr,
&discard_ecx, &discard_edx );
/* Allocate pages */