Setting the CPUID of a XEN guest
After some reading around I've discovered it is possible to configure the CPU vendor and model information that a XEN guest sees.
Most Linux sysadmins will be familiar with
cat /proc/cpuinfo
to get
information about the systems processors. This gives information about the CPU
vendor, model and features. For example my desktop gives:
[cellis@cedesktop ~]$ cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 15
model : 67
model name : AMD Athlon(tm) 64 X2 Dual Core Processor 5200+
- snip -
This information is actually exposed via
cpuid instruction
. This instruction takes
a command in the
EAX
register and populates the
EAX
,
EBX
,
ECX
and
EDX
registers
with the requested data.
If
EAX
is set to zero, the CPU vendor string is returned. This is a 12 byte
ASCII string. Which is stored in the
EBX
,
EDX
,
ECX
(that is certainly logical,
I suspect a hangup from the circuit complexity).
The CPU model string is a little more complex, it is a 48 byte ASCII string.
This string is obtained by executing the
cpuid
instruction 3 times, with
EAX
set to:
0x80000002
,
0x80000003
and
0x80000004
.
XEN has the
cpuid config option
, which
defines the values of
EAX
,
EBX
,
ECX
and
EDX
for specific values of
EAX
.
Lets take the following XEN config:
cpuid=['0:eax=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,ebx=01110010011101000110111001001001,
ecx=00000000000000000000000000000000,edx=00000000011110100110100101100010']
This causes the XEN guest to see the CPU vendor string 'Intrbiz', by providing the cpuid register values when EAX = 0.
As such, my XEN VM now reports:
xenvm1:~ # cat /proc/cpuinfo
processor : 0
vendor_id : Intrbiz
cpu family : 0
model : 0
model name : Intrbiz XEN virtual CPU
stepping : 0
The hard part of setting this, is working out the values of the registers. It takes time to convert the text to binary and get the orderings correct.
Instead, you can generate the XEN config right here:
Simply enter your desired CPU vendor and model string and the XEN config will be generated
CPU Vendor: Model: