From patchwork Wed Nov 9 13:44:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 124554 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 619591007D9 for ; Thu, 10 Nov 2011 00:45:07 +1100 (EST) Received: from localhost ([::1]:39535 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RO8Se-0004jL-Ln for incoming@patchwork.ozlabs.org; Wed, 09 Nov 2011 08:45:04 -0500 Received: from eggs.gnu.org ([140.186.70.92]:49280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RO8ST-0004ip-L1 for qemu-devel@nongnu.org; Wed, 09 Nov 2011 08:44:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RO8SP-0001DV-4l for qemu-devel@nongnu.org; Wed, 09 Nov 2011 08:44:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:19504) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RO8SO-0001DN-Si for qemu-devel@nongnu.org; Wed, 09 Nov 2011 08:44:49 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pA9DilQD007894 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 9 Nov 2011 08:44:47 -0500 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pA9DikmD018781; Wed, 9 Nov 2011 08:44:46 -0500 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id D94D8250B98; Wed, 9 Nov 2011 15:44:42 +0200 (IST) From: Avi Kivity To: Marcelo Tosatti , Anthony Liguori , kvm@vger.kernel.org, qemu-devel@nongnu.org Date: Wed, 9 Nov 2011 15:44:36 +0200 Message-Id: <1320846276-19659-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] i386: derive '-cpu host' from KVM_GET_SUPPORTED_CPUID X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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 }