aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorGleb Natapov <gleb@redhat.com>2012-04-30 07:45:49 -0400
committerAvi Kivity <avi@redhat.com>2012-05-06 08:59:49 -0400
commit9b72d3b07dd99ac8ab2b84de5004a295af460536 (patch)
tree1142d76d9688772df00f1ce78faaf0075493448f /arch/x86
parent57c22e5f35aa4b9b2fe11f73f3e62bbf9ef36190 (diff)
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: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/include/asm/kvm_para.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h
index 99c4bbe0cca2..a7a7a94b94ce 100644
--- a/arch/x86/include/asm/kvm_para.h
+++ b/arch/x86/include/asm/kvm_para.h
@@ -178,14 +178,16 @@ static inline int kvm_para_available(void)
178 unsigned int eax, ebx, ecx, edx; 178 unsigned int eax, ebx, ecx, edx;
179 char signature[13]; 179 char signature[13];
180 180
181 cpuid(KVM_CPUID_SIGNATURE, &eax, &ebx, &ecx, &edx); 181 if (cpu_has_hypervisor) {
182 memcpy(signature + 0, &ebx, 4); 182 cpuid(KVM_CPUID_SIGNATURE, &eax, &ebx, &ecx, &edx);
183 memcpy(signature + 4, &ecx, 4); 183 memcpy(signature + 0, &ebx, 4);
184 memcpy(signature + 8, &edx, 4); 184 memcpy(signature + 4, &ecx, 4);
185 signature[12] = 0; 185 memcpy(signature + 8, &edx, 4);
186 186 signature[12] = 0;
187 if (strcmp(signature, "KVMKVMKVM") == 0) 187
188 return 1; 188 if (strcmp(signature, "KVMKVMKVM") == 0)
189 return 1;
190 }
189 191
190 return 0; 192 return 0;
191} 193}