qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 06/15] target-i386: Add "stepping" property to X8


From: Andreas Färber
Subject: [Qemu-devel] [PATCH v2 06/15] target-i386: Add "stepping" property to X86CPU
Date: Tue, 24 Apr 2012 11:33:32 +0200

Signed-off-by: Andreas Färber <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
---
 target-i386/cpu.c |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 3a8141b..2f843be 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -649,10 +649,28 @@ static void x86_cpuid_version_set_model(Object *obj, 
Visitor *v, void *opaque,
     env->cpuid_version |= ((value & 0xf) << 4) | ((value >> 4) << 16);
 }
 
-static void x86_cpuid_version_set_stepping(CPUX86State *env, int stepping)
+static void x86_cpuid_version_set_stepping(Object *obj, Visitor *v,
+                                           void *opaque, const char *name,
+                                           Error **errp)
 {
+    X86CPU *cpu = X86_CPU(obj);
+    CPUX86State *env = &cpu->env;
+    const int64_t min = 0;
+    const int64_t max = 0xf;
+    int64_t value;
+
+    visit_type_int(v, &value, name, errp);
+    if (error_is_set(errp)) {
+        return;
+    }
+    if (value < min || value > max) {
+        error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
+                  name ? name : "null", value, min, max);
+        return;
+    }
+
     env->cpuid_version &= ~0xf;
-    env->cpuid_version |= stepping & 0xf;
+    env->cpuid_version |= value & 0xf;
 }
 
 static void x86_cpuid_set_model_id(CPUX86State *env, const char *model_id)
@@ -966,7 +984,7 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model)
     env->cpuid_level = def->level;
     object_property_set_int(OBJECT(cpu), def->family, "family", &error);
     object_property_set_int(OBJECT(cpu), def->model, "model", &error);
-    x86_cpuid_version_set_stepping(env, def->stepping);
+    object_property_set_int(OBJECT(cpu), def->stepping, "stepping", &error);
     env->cpuid_features = def->features;
     env->cpuid_ext_features = def->ext_features;
     env->cpuid_ext2_features = def->ext2_features;
@@ -1524,6 +1542,9 @@ static void x86_cpu_initfn(Object *obj)
     object_property_add(obj, "model", "int",
                         NULL,
                         x86_cpuid_version_set_model, NULL, NULL, NULL);
+    object_property_add(obj, "stepping", "int",
+                        NULL,
+                        x86_cpuid_version_set_stepping, NULL, NULL, NULL);
 
     env->cpuid_apic_id = env->cpu_index;
     mce_init(cpu);
-- 
1.7.7




reply via email to

[Prev in Thread] Current Thread [Next in Thread]