How to modify the return value of CPUID of windows created by KVM

1.7k views Asked by At

I create a windows 7 x86 virtual machine by KVM.
When it executes the following instructions:

mov eax, 0x40000000
cpuid

It will return this:

eax=0x40000005
ebx=0x7263694d
ecx=0x666f736f
edx=0x76482074

That is "Microsoft Hv".

How to adjust KVM to return custom value?

1

There are 1 answers

1
ruthafjord On

If you mean QEMU/KVM, then you need to convince the hyperv enlightenments to have a different configuration.

  • For the QEMU cli, use hv-vendor-id=foobarbaz as a flag. See the docs for more.
  • For libvirt: add <vendor_id state='on' value='foobarbaz'/> between the <hyperv> </hyperv> tags.

One lazy alternative is to disable the enlightenments across the board (which will hide the hyperv cpuid leaf).

The following is probably not relevant, but it is a direct answer to this question. For a custom VMM that is directly using KVM, use the kvm_set_cpuid2 ioctl. Check out the documentation for more.