Received: from eggs.gnu.org ([2001:4830:134:3::10]:37712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UwxDp-0002IU-8S for qemu-devel@nongnu.org; Wed, 10 Jul 2013 12:26:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UwxDl-000801-Mx for qemu-devel@nongnu.org; Wed, 10 Jul 2013 12:26:29 -0400 Received: from cantor2.suse.de ([195.135.220.15]:37919 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UwxDl-0007zo-Fc for qemu-devel@nongnu.org; Wed, 10 Jul 2013 12:26:25 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 10 Jul 2013 18:26:17 +0200 Message-Id: <1373473577-1088-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH] linux-user: Use X86CPU property to retrieve CPUID family List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Riku Voipio , =?UTF-8?q?Andreas=20F=C3=A4rber?= Avoids duplicating the calculation. Signed-off-by: Andreas F=C3=A4rber --- Have this lying around for a while already, apparently not sent out yet. linux-user/cpu-uname.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/linux-user/cpu-uname.c b/linux-user/cpu-uname.c index 59cd647..cc713e6 100644 --- a/linux-user/cpu-uname.c +++ b/linux-user/cpu-uname.c @@ -55,12 +55,14 @@ const char *cpu_to_uname_machine(void *cpu_env) return "x86-64"; #elif defined(TARGET_I386) /* see arch/x86/kernel/cpu/bugs.c: check_bugs(), 386, 486, 586, 686 = */ - uint32_t cpuid_version =3D ((CPUX86State *)cpu_env)->cpuid_version; - int family =3D ((cpuid_version >> 8) & 0x0f) + ((cpuid_version >> 20= ) & 0xff); - if (family =3D=3D 4) + CPUState *cpu =3D ENV_GET_CPU((CPUX86State *)cpu_env); + int family =3D object_property_get_int(OBJECT(cpu), "family", NULL); + if (family =3D=3D 4) { return "i486"; - if (family =3D=3D 5) + } + if (family =3D=3D 5) { return "i586"; + } return "i686"; #else /* default is #define-d in each arch/ subdir */ --=20 1.8.1.4