-
Notifications
You must be signed in to change notification settings - Fork 300
Description
The documentation for __get_cpuid_max
states:
If
cpuid
is supported, andleaf
is zero, then the first tuple argument
contains the highestleaf
value thatcpuid
supports. Forleaf
s
containing sub-leafs, the second tuple argument contains the
highest-supported sub-leaf value.
The second sentence is invalid. The function basically does CPUID(EAX=leaf
, ECX=0) and returns (EAX, EBX). I haven't found any leaf that behaves like described. Here are some variable subleaf CPUIDs, and how to determine which subleafs are valid (see Intel SDM, CPUID instruction):
0x0b
: repeat until you get ECX[15:08]=00x0d
: valid for every bit index set in EAX/EDX when ECX=00x12
: undefined, but practically until you get EAX[03:00]=0
So, none of these return “the highest-supported sub-leaf value” in EBX.
The GCC source code does have it and states:
Return highest supported input value for cpuid instruction. ext can
be either 0x0 or 0x80000000 to return highest supported value for
basic or extended cpuid information. Function returns 0 if cpuid
is not supported or whatever cpuid returns in eax register. If sig
pointer is non-null, then first four bytes of the signature
(as found in ebx register) are returned in location pointed by sig.
This does seem to accurately describe the function's behavior, but it's clearly not what Rust documents.
It's not entirely clear to me where this function comes from. It doesn't appear in the Intel Intrisics Guide or the Intel SDM. You practically need to read the documentation anyway to understand any CPUID output, so it's not clear why Rust includes this function which is just a different way to call __cpuid
.
cc @gnzlbg