From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [Qemu-devel] [PATCH] i386: derive '-cpu host' from KVM_GET_SUPPORTED_CPUID Date: Wed, 09 Nov 2011 11:56:20 -0600 Message-ID: <4EBABEC4.2080303@codemonkey.ws> References: <1320846276-19659-1-git-send-email-avi@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm@vger.kernel.org, qemu-devel@nongnu.org To: Avi Kivity Return-path: Received: from mail-gx0-f174.google.com ([209.85.161.174]:53921 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751975Ab1KIR4Y (ORCPT ); Wed, 9 Nov 2011 12:56:24 -0500 Received: by ggnb2 with SMTP id b2so1980175ggn.19 for ; Wed, 09 Nov 2011 09:56:23 -0800 (PST) In-Reply-To: <1320846276-19659-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 11/09/2011 07:44 AM, Avi Kivity wrote: > 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 This seems like a 1.0 candidate, yes? Regards, Anthony Liguori > --- > target-i386/cpuid.c | 27 ++++----------------------- > 1 files changed, 4 insertions(+), 23 deletions(-) > > diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c > index 1e8bcff..edac377 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 > } >