chiark / gitweb /
basic: detect_vm_cpuid: fix hypervisor detection
authorMike Gilbert <floppym@gentoo.org>
Sat, 30 Dec 2017 17:48:20 +0000 (12:48 -0500)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:49:46 +0000 (07:49 +0200)
commit7b0acd5d3752492b8fb182c59976fd1a0ee61031
treec72e14b2e3e0fc61882f3d016a8f496f503e50de
parent9a38bf7862a8a1117805163eeb0fb752b2a2b4d6
basic: detect_vm_cpuid: fix hypervisor detection

The __get_cpuid() function only calls __cpuid() if __get_cpuid_max()
returns a value that is less than or equal to the leaf value.

In QEMU/KVM, I found that the special hypervisor leaf value (0x40000000U)
is always larger than the value retured by __get_cpuid_max().

Avoid this problem by calling the __cpuid() macro directly once we have
checked the hypervisor bit from leaf 1.

Fixes: d31b0033b7743393562a2e9d3c1e74afea981c13
src/basic/virt.c