From patchwork Fri Jan 4 19:37:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 209528 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F3EB32C0085 for ; Sat, 5 Jan 2013 06:46:24 +1100 (EST) Received: from localhost ([::1]:46861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TrDDj-0006PB-5b for incoming@patchwork.ozlabs.org; Fri, 04 Jan 2013 14:46:23 -0500 Received: from eggs.gnu.org ([208.118.235.92]:60982) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TrDDc-0006Ot-3V for qemu-devel@nongnu.org; Fri, 04 Jan 2013 14:46:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TrDDb-0006Cb-01 for qemu-devel@nongnu.org; Fri, 04 Jan 2013 14:46:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:30424) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TrD6I-0004CJ-DY for qemu-devel@nongnu.org; Fri, 04 Jan 2013 14:38:42 -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 r04Jcfrj004592 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 4 Jan 2013 14:38:41 -0500 Received: from dell-pet610-01.lab.eng.brq.redhat.com (dell-pet610-01.lab.eng.brq.redhat.com [10.34.42.20]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r04JcdQT020045; Fri, 4 Jan 2013 14:38:40 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 4 Jan 2013 20:37:24 +0100 Message-Id: <1357328244-4410-1-git-send-email-imammedo@redhat.com> In-Reply-To: <20130104155013.GS18372@otherpad.lan.raisama.net> References: <20130104155013.GS18372@otherpad.lan.raisama.net> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: ehabkost@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH 09/20 v3] target-i386: add x86cpu_vendor_words2str() 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 Make for() cycle reusable for the next patch Signed-off-by: Igor Mammedov --- v3: fix/swap vendor2 and vendor3 order Spotted-By: Eduardo Habkost v2: place x86cpu_vendor_words2str() a bit earlier, before feature arrays to avoid compile error when vendor property is converted static property. --- target-i386/cpu.c | 21 ++++++++++++++------- 1 files changed, 14 insertions(+), 7 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index d6e4e71..e26e631 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -45,6 +45,18 @@ #include "hw/apic_internal.h" #endif +static void x86cpu_vendor_words2str(char *dst, uint32_t ebx, uint32_t ecx, + uint32_t edx) +{ + int i; + for (i = 0; i < 4; i++) { + dst[i] = ebx >> (8 * i); + dst[i + 4] = ecx >> (8 * i); + dst[i + 8] = edx >> (8 * i); + } + dst[CPUID_VENDOR_SZ] = '\0'; +} + /* feature flags taken from "Intel Processor Identification and the CPUID * Instruction" and AMD's "CPUID Specification". In cases of disagreement * between feature naming conventions, aliases may be added. @@ -1131,15 +1143,10 @@ static char *x86_cpuid_get_vendor(Object *obj, Error **errp) X86CPU *cpu = X86_CPU(obj); CPUX86State *env = &cpu->env; char *value; - int i; value = (char *)g_malloc(CPUID_VENDOR_SZ + 1); - for (i = 0; i < 4; i++) { - value[i ] = env->cpuid_vendor1 >> (8 * i); - value[i + 4] = env->cpuid_vendor2 >> (8 * i); - value[i + 8] = env->cpuid_vendor3 >> (8 * i); - } - value[CPUID_VENDOR_SZ] = '\0'; + x86cpu_vendor_words2str(value, env->cpuid_vendor1, env->cpuid_vendor2, + env->cpuid_vendor3); return value; }