From patchwork Thu Sep 10 22:20:50 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 33392 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 480FBB7067 for ; Fri, 11 Sep 2009 08:30:45 +1000 (EST) Received: from localhost ([127.0.0.1]:55812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlsA3-0007e8-Jy for incoming@patchwork.ozlabs.org; Thu, 10 Sep 2009 18:30:39 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mls3z-0004e5-M8 for qemu-devel@nongnu.org; Thu, 10 Sep 2009 18:24:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mls3s-0004X5-TF for qemu-devel@nongnu.org; Thu, 10 Sep 2009 18:24:20 -0400 Received: from [199.232.76.173] (port=40031 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mls3r-0004Wg-MW for qemu-devel@nongnu.org; Thu, 10 Sep 2009 18:24:15 -0400 Received: from tx2ehsobe003.messaging.microsoft.com ([65.55.88.13]:1778 helo=TX2EHSOBE006.bigfish.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_MD5:16) (Exim 4.60) (envelope-from ) id 1Mls3r-0001Jq-BQ for qemu-devel@nongnu.org; Thu, 10 Sep 2009 18:24:15 -0400 Received: from mail16-tx2-R.bigfish.com (10.9.14.239) by TX2EHSOBE006.bigfish.com (10.9.40.26) with Microsoft SMTP Server id 8.1.340.0; Thu, 10 Sep 2009 22:24:14 +0000 Received: from mail16-tx2 (localhost.localdomain [127.0.0.1]) by mail16-tx2-R.bigfish.com (Postfix) with ESMTP id 72B141A8021C for ; Thu, 10 Sep 2009 22:24:14 +0000 (UTC) X-SpamScore: 1 X-BigFish: VPS1(zzzz1202hzzz32i203h62h) X-Spam-TCS-SCL: 1:0 X-FB-SS: 5, Received: by mail16-tx2 (MessageSwitch) id 1252621452952187_4716; Thu, 10 Sep 2009 22:24:12 +0000 (UCT) Received: from ausb3extmailp02.amd.com (ausb3extmailp02.amd.com [163.181.251.22]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail16-tx2.bigfish.com (Postfix) with ESMTP id AF4E6330051 for ; Thu, 10 Sep 2009 22:24:12 +0000 (UTC) Received: from ausb3twp01.amd.com (ausb3twp01.amd.com [163.181.250.37]) by ausb3extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id n8AMO8vR021751 for ; Thu, 10 Sep 2009 17:24:11 -0500 X-WSS-ID: 0KPS0W6-01-L79-02 X-M-MSG: Received: from sausexbh1.amd.com (sausexbh1.amd.com [163.181.22.101]) by ausb3twp01.amd.com (Tumbleweed MailGate 3.7.0) with ESMTP id 2F21E10284D7 for ; Thu, 10 Sep 2009 17:24:05 -0500 (CDT) Received: from sausexmb2.amd.com ([163.181.3.157]) by sausexbh1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 10 Sep 2009 17:24:06 -0500 Received: from SDRSEXMB1.amd.com ([172.20.3.116]) by sausexmb2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 10 Sep 2009 17:24:06 -0500 Received: from localhost.localdomain ([165.204.15.42]) by SDRSEXMB1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 11 Sep 2009 00:23:55 +0200 From: Andre Przywara To: qemu-devel@nongnu.org Date: Fri, 11 Sep 2009 00:20:50 +0200 Message-ID: <1252621257-26364-6-git-send-email-andre.przywara@amd.com> X-Mailer: git-send-email 1.6.1.3 In-Reply-To: <1252621257-26364-1-git-send-email-andre.przywara@amd.com> References: <1252621257-26364-1-git-send-email-andre.przywara@amd.com> X-OriginalArrivalTime: 10 Sep 2009 22:23:55.0527 (UTC) FILETIME=[62453970:01CA3265] MIME-Version: 1.0 X-detected-operating-system: by monty-python.gnu.org: Windows 2000 SP4, XP SP1+ Cc: Andre Przywara Subject: [Qemu-devel] [PATCH 05/12] cpuid: moved host_cpuid function and remove prototype X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org the host_cpuid function was located at the end of the file and had a prototype before it's first use. Move it up and remove the prototype. Signed-off-by: Andre Przywara --- target-i386/cpuid.c | 71 ++++++++++++++++++++++++-------------------------- 1 files changed, 34 insertions(+), 37 deletions(-) diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c index 7b69ff4..9ddf714 100644 --- a/target-i386/cpuid.c +++ b/target-i386/cpuid.c @@ -322,8 +322,40 @@ static x86_def_t x86_defs[] = { }, }; -static void host_cpuid(uint32_t function, uint32_t count, uint32_t *eax, - uint32_t *ebx, uint32_t *ecx, uint32_t *edx); +static 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]; + if (ebx) + *ebx = vec[1]; + if (ecx) + *ecx = vec[2]; + if (edx) + *edx = vec[3]; +#endif +} static int cpu_x86_fill_model_id(char *str) { @@ -555,41 +587,6 @@ int cpu_x86_register (CPUX86State *env, const char *cpu_model) return 0; } -static 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]; - if (ebx) - *ebx = vec[1]; - if (ecx) - *ecx = vec[2]; - if (edx) - *edx = vec[3]; -#endif -} - void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)