summaryrefslogtreecommitdiffstats
path: root/target-i386
diff options
context:
space:
mode:
authorAvi Kivity2011-11-09 14:44:36 +0100
committerAnthony Liguori2011-11-09 19:06:20 +0100
commit66e3dd9282141b5ae75637c9676002cf3ceeb988 (patch)
tree2969dfbd9358905cc0de86a422e5b3098710fd98 /target-i386
parentconfigure: fix detection for xattr.h on modern distributions (diff)
downloadqemu-66e3dd9282141b5ae75637c9676002cf3ceeb988.tar.gz
qemu-66e3dd9282141b5ae75637c9676002cf3ceeb988.tar.xz
qemu-66e3dd9282141b5ae75637c9676002cf3ceeb988.zip
i386: derive '-cpu host' from KVM_GET_SUPPORTED_CPUID
The fact that a host cpu supports a feature doesn't mean that QEMU and KVM will also support it, yet -cpuid host brings host features wholesale. We need to whitelist each feature separately to make sure we support it. This patch adds KVM whitelisting (by simply using KVM_GET_SUPPORTED_CPUID instead of the CPUID instruction). Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'target-i386')
-rw-r--r--target-i386/cpuid.c27
1 files changed, 4 insertions, 23 deletions
diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 1e8bcff65d..edac377a02 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -107,33 +107,14 @@ void host_cpuid(uint32_t function, uint32_t count,
uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
{
#if defined(CONFIG_KVM)
- uint32_t vec[4];
-
-#ifdef __x86_64__
- asm volatile("cpuid"
- : "=a"(vec[0]), "=b"(vec[1]),
- "=c"(vec[2]), "=d"(vec[3])
- : "0"(function), "c"(count) : "cc");
-#else
- asm volatile("pusha \n\t"
- "cpuid \n\t"
- "mov %%eax, 0(%2) \n\t"
- "mov %%ebx, 4(%2) \n\t"
- "mov %%ecx, 8(%2) \n\t"
- "mov %%edx, 12(%2) \n\t"
- "popa"
- : : "a"(function), "c"(count), "S"(vec)
- : "memory", "cc");
-#endif
-
if (eax)
- *eax = vec[0];
+ *eax = kvm_arch_get_supported_cpuid(kvm_state, function, count, R_EAX);
if (ebx)
- *ebx = vec[1];
+ *ebx = kvm_arch_get_supported_cpuid(kvm_state, function, count, R_EBX);
if (ecx)
- *ecx = vec[2];
+ *ecx = kvm_arch_get_supported_cpuid(kvm_state, function, count, R_ECX);
if (edx)
- *edx = vec[3];
+ *edx = kvm_arch_get_supported_cpuid(kvm_state, function, count, R_EDX);
#endif
}