aboutsummaryrefslogtreecommitdiff
path: root/target-i386/cpu.c
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2012-04-17 12:16:39 +0200
committerAndreas Färber <afaerber@suse.de>2012-04-25 10:51:35 +0200
commitc5291a4f2d87310c5650064ab870251600b68c14 (patch)
tree72446335ad087b30c44526fe84f644abac128ffb /target-i386/cpu.c
parent71ad61d37e612119cca6967484f5feb165a169a4 (diff)
target-i386: Add "model" property to X86CPU
Signed-off-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Diffstat (limited to 'target-i386/cpu.c')
-rw-r--r--target-i386/cpu.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 9eb5738e35..ebee9914cc 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -626,10 +626,27 @@ static void x86_cpuid_version_set_family(Object *obj, Visitor *v, void *opaque,
}
}
-static void x86_cpuid_version_set_model(CPUX86State *env, int model)
+static void x86_cpuid_version_set_model(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 = 0xff;
+ 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 &= ~0xf00f0;
- env->cpuid_version |= ((model & 0xf) << 4) | ((model >> 4) << 16);
+ env->cpuid_version |= ((value & 0xf) << 4) | ((value >> 4) << 16);
}
static void x86_cpuid_version_set_stepping(CPUX86State *env, int stepping)
@@ -946,7 +963,7 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model)
env->cpuid_vendor_override = def->vendor_override;
env->cpuid_level = def->level;
object_property_set_int(OBJECT(cpu), def->family, "family", &error);
- x86_cpuid_version_set_model(env, def->model);
+ object_property_set_int(OBJECT(cpu), def->model, "model", &error);
x86_cpuid_version_set_stepping(env, def->stepping);
env->cpuid_features = def->features;
env->cpuid_ext_features = def->ext_features;
@@ -1502,6 +1519,9 @@ static void x86_cpu_initfn(Object *obj)
object_property_add(obj, "family", "int",
NULL,
x86_cpuid_version_set_family, NULL, NULL, NULL);
+ object_property_add(obj, "model", "int",
+ NULL,
+ x86_cpuid_version_set_model, NULL, NULL, NULL);
env->cpuid_apic_id = env->cpu_index;
mce_init(cpu);