Skip to contentSkip to conversation

linux-user: Use X86CPU property to retrieve CPUID family

PATCH In review Andreas Färber 2 participants 3 messages Jul 10, 2013 – Jul 22, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: Use X86CPU property to retrieve CPUID family

Avoids duplicating the calculation.

---
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(-)
linux-user/cpu-uname.c +6 -4
index 59cd647..cc713e6 100644
@@ -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 = ((CPUX86State *)cpu_env)->cpuid_version;
-    int family = ((cpuid_version >> 8) & 0x0f) + ((cpuid_version >> 20) & 0xff);
-    if (family == 4)
+    CPUState *cpu = ENV_GET_CPU((CPUX86State *)cpu_env);
+    int family = object_property_get_int(OBJECT(cpu), "family", NULL);
+    if (family == 4) {
         return "i486";
-    if (family == 5)
+    }
+    if (family == 5) {
         return "i586";
+    }
     return "i686";
 #else
     /* default is #define-d in each arch/ subdir */
Signature · 1 line
1.8.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 22 lines · On Wed, 10 Jul 2013 18:26:17 +0200 Andreas Färber <[email protected]> wrote:

Avoids duplicating the calculation.

---
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(-)
linux-user/cpu-uname.c +2 -3
index 59cd647..cc713e6 100644
@@ -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 = ((CPUX86State *)cpu_env)->cpuid_version;
-    int family = ((cpuid_version >> 8) & 0x0f) + ((cpuid_version >> 20) & 0xff);
-    if (family == 4)
+    CPUState *cpu = ENV_GET_CPU((CPUX86State *)cpu_env);
+    int family = object_property_get_int(OBJECT(cpu), "family", NULL);

linux-user/cpu-uname.c const char *cpu_to_uname_machine(void *cpu_env) · line 68

Quoted 10 lines
linux-user/cpu-uname.c +4 -1
+    if (family == 4) {
         return "i486";
-    if (family == 5)
+    }
+    if (family == 5) {
         return "i586";
+    }
     return "i686";
 #else
     /* default is #define-d in each arch/ subdir */
author Applied
#2 lore raw

Am 11.07.2013 07:35, schrieb Igor Mammedov:

Quoted 11 lines
Quoted 8 lines · On Wed, 10 Jul 2013 18:26:17 +0200 Andreas Färber <[email protected]> wrote:

Avoids duplicating the calculation.

---
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(-)

[...]

Quoted 1 line

Thanks, applied to qom-cpu:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg