Commit 9b72d3b0 authored by Gleb Natapov's avatar Gleb Natapov Committed by Avi Kivity

KVM guest: make kvm_para_available() check hypervisor bit reading cpuid leaf

This cpuid range does not exist on real HW and Intel spec says that
"Information returned for highest basic information leaf" will be
returned. Not very well defined.
Signed-off-by: default avatarGleb Natapov <gleb@redhat.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent 57c22e5f
...@@ -178,14 +178,16 @@ static inline int kvm_para_available(void) ...@@ -178,14 +178,16 @@ static inline int kvm_para_available(void)
unsigned int eax, ebx, ecx, edx; unsigned int eax, ebx, ecx, edx;
char signature[13]; char signature[13];
cpuid(KVM_CPUID_SIGNATURE, &eax, &ebx, &ecx, &edx); if (cpu_has_hypervisor) {
memcpy(signature + 0, &ebx, 4); cpuid(KVM_CPUID_SIGNATURE, &eax, &ebx, &ecx, &edx);
memcpy(signature + 4, &ecx, 4); memcpy(signature + 0, &ebx, 4);
memcpy(signature + 8, &edx, 4); memcpy(signature + 4, &ecx, 4);
signature[12] = 0; memcpy(signature + 8, &edx, 4);
signature[12] = 0;
if (strcmp(signature, "KVMKVMKVM") == 0)
return 1; if (strcmp(signature, "KVMKVMKVM") == 0)
return 1;
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment