summaryrefslogtreecommitdiff
path: root/src/basic/virt.c
diff options
context:
space:
mode:
authorMike Gilbert <floppym@gentoo.org>2017-12-30 12:48:20 -0500
committerSven Eden <yamakuzure@gmx.net>2018-05-30 07:49:46 +0200
commit7b0acd5d3752492b8fb182c59976fd1a0ee61031 (patch)
treec72e14b2e3e0fc61882f3d016a8f496f503e50de /src/basic/virt.c
parent9a38bf7862a8a1117805163eeb0fb752b2a2b4d6 (diff)
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
Diffstat (limited to 'src/basic/virt.c')
-rw-r--r--src/basic/virt.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/basic/virt.c b/src/basic/virt.c
index 15dc860ad..21e11b698 100644
--- a/src/basic/virt.c
+++ b/src/basic/virt.c
@@ -79,8 +79,7 @@ static int detect_vm_cpuid(void) {
unsigned j;
/* There is a hypervisor, see what it is */
- if (__get_cpuid(0x40000000U, &eax, &ebx, &ecx, &edx) == 0)
- return VIRTUALIZATION_NONE;
+ __cpuid(0x40000000U, eax, ebx, ecx, edx);
sig.sig32[0] = ebx;
sig.sig32[1] = ecx;