Search code examples
assemblyx86x86-64cpuid

How to interpret System-On-Chip cpu vendor string?


Intel Manual defines the cpuid leaf 0x17 to be responsible for cpu vendor string. The output depends on the value in ecx. So according to the note:

Leaf 17H output depends on the initial value in ECX. SOC Vendor Brand String is a UTF-8 encoded string padded with trailing bytes of 00H.The complete SOC Vendor Brand String is constructed by concatenating in ascending order of EAX:EBX:ECX:EDX and from the sub-leaf 1 fragment towards sub-leaf 3.

I wrote the following assembly and expected to get some sensible string:

;Set the System-On-Chip value to eax
mov eax, 0x17

;Set the first subleaf in ecx
mov ecx, 0x01

cpuid

The result of the cpuid instruction is the following:

(gdb) p/x $eax
$8 = 0x7d0
(gdb) p/x $ebx
$9 = 0xfa0
(gdb) p/x $ecx
$10 = 0x64
(gdb) p/x $edx
$11 = 0x0

Simply concatenating the register content (throwing away trailing 0x00 bytes) does not result in something readable:

$1 = 0x7fffffffdea0 "d\240\017\320\a"

QUESTION: How to interpret SOC vendor string?


Solution

  • Your processor doesn't support cpuid leaf 0x17. Use cpuid leaf 0 to find out the maximum supported cpuid leaf (returned in eax). For example, on my system, the maximum cpuid leaf is 0x0f. When cpuid is used with a leaf value greater than the maximum supported value, the processor returns results from the maximum supported value, which is why you are getting what appear to be garbage values. (If you try cpuid leaf 0x16, you will see that you get the exact same return values as you do with 0x17.)