Received: from eggs.gnu.org ([208.118.235.92]:59066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tr9Vd-0003ap-7z for qemu-devel@nongnu.org; Fri, 04 Jan 2013 10:48:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tr9Vc-0007LW-70 for qemu-devel@nongnu.org; Fri, 04 Jan 2013 10:48:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58183) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tr9Vb-0007LH-UC for qemu-devel@nongnu.org; Fri, 04 Jan 2013 10:48:36 -0500 Date: Fri, 4 Jan 2013 13:50:13 -0200 From: Eduardo Habkost Message-ID: <20130104155013.GS18372@otherpad.lan.raisama.net> References: <1356724895-24118-10-git-send-email-imammedo@redhat.com> <1357309536-25711-1-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1357309536-25711-1-git-send-email-imammedo@redhat.com> Subject: Re: [Qemu-devel] [PATCH 09/20 v2] target-i386: add x86cpu_vendor_words2str() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: qemu-devel@nongnu.org, afaerber@suse.de On Fri, Jan 04, 2013 at 03:25:36PM +0100, Igor Mammedov wrote: > Make for() cycle reusable for the next patch > > Signed-off-by: Igor Mammedov > --- > v2: > place x86cpu_vendor_words2str() a bit earlier, before feature > arrays to avoid compile error when vendor property is converted > into 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..e58df4d 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] = edx >> (8 * i); > + dst[i + 8] = ecx >> (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); vendor2 is EDX, but you are passing vendor2 as the ECX value, here. I believe this will return "GenuintelineI" or "AuthcAMDenti" as the vendor string (I couldn't check it because the CPUs aren't on "info qtree" output yet as they don't have a bus). -- Eduardo