From patchwork Mon Oct 22 15:03:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 193213 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8523D2C0176 for ; Tue, 23 Oct 2012 03:28:33 +1100 (EST) Received: from localhost ([::1]:36809 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQKrf-0007MV-Mi for incoming@patchwork.ozlabs.org; Mon, 22 Oct 2012 12:28:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQJZE-0003rS-2H for qemu-devel@nongnu.org; Mon, 22 Oct 2012 11:05:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TQJZ8-0001B4-Ok for qemu-devel@nongnu.org; Mon, 22 Oct 2012 11:05:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45150) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQJZ8-000189-GI for qemu-devel@nongnu.org; Mon, 22 Oct 2012 11:05:18 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9MF4v8g019571 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 22 Oct 2012 11:04:57 -0400 Received: from nial.brq.redhat.com (dhcp-1-247.brq.redhat.com [10.34.1.247]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9MF3OnU031350; Mon, 22 Oct 2012 11:04:55 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 22 Oct 2012 17:03:15 +0200 Message-Id: <1350918203-25198-30-git-send-email-imammedo@redhat.com> In-Reply-To: <1350918203-25198-1-git-send-email-imammedo@redhat.com> References: <1350918203-25198-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: aliguori@us.ibm.com, ehabkost@redhat.com, jan.kiszka@siemens.com, Don@CloudSwitch.com, mdroth@linux.vnet.ibm.com, blauwirbel@gmail.com, stefanha@redhat.com, pbonzini@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH 29/37] target-i386: convert "stepping" to static property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Igor Mammedov Reviewed-by: Don Slutz --- - in addition use error_setg() instead of error_set() --- target-i386/cpu.c | 85 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 39 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 6cbdde1..69c179a 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -441,6 +441,51 @@ PropertyInfo qdev_prop_model_id = { #define DEFINE_PROP_MODEL_ID(_n) \ DEFINE_ABSTRACT_PROP(_n, qdev_prop_model_id) +static void x86_cpuid_version_get_stepping(Object *obj, Visitor *v, + void *opaque, const char *name, + Error **errp) +{ + X86CPU *cpu = X86_CPU(obj); + CPUX86State *env = &cpu->env; + int64_t value; + + value = env->cpuid_version & 0xf; + visit_type_int(v, &value, name, errp); +} + +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_setg(errp, "Property %s.%s doesn't take value %" PRId64 " (min" + "imum: %" PRId64 ", maximum: %" PRId64, + object_get_typename(obj), name, value, min, max); + return; + } + + env->cpuid_version &= ~0xf; + env->cpuid_version |= value & 0xf; +} + +PropertyInfo qdev_prop_stepping = { + .name = "uint32", + .get = x86_cpuid_version_get_stepping, + .set = x86_cpuid_version_set_stepping, +}; +#define DEFINE_PROP_STEPPING(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_stepping, uint32_t) + static Property cpu_x86_properties[] = { DEFINE_PROP_BIT("f-fpu", X86CPU, env.cpuid_features, 0, false), DEFINE_PROP_BIT("f-vme", X86CPU, env.cpuid_features, 1, false), @@ -563,6 +608,7 @@ static Property cpu_x86_properties[] = { DEFINE_PROP_VENDOR("vendor", X86CPU, env.cpuid_vendor1), DEFINE_PROP_TSC_FREQ("tsc-frequency", X86CPU, env.tsc_khz), DEFINE_PROP_MODEL_ID("model-id"), + DEFINE_PROP_STEPPING("stepping", X86CPU, env.cpuid_version), DEFINE_PROP_END_OF_LIST(), }; @@ -1348,42 +1394,6 @@ 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_get_stepping(Object *obj, Visitor *v, - void *opaque, const char *name, - Error **errp) -{ - X86CPU *cpu = X86_CPU(obj); - CPUX86State *env = &cpu->env; - int64_t value; - - value = env->cpuid_version & 0xf; - visit_type_int(v, &value, name, errp); -} - -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 |= value & 0xf; -} - static void cpudef_2_x86_cpu(X86CPU *cpu, x86_def_t *def, Error **errp) { CPUX86State *env = &cpu->env; @@ -2254,9 +2264,6 @@ static void x86_cpu_initfn(Object *obj) object_property_add(obj, "model", "int", x86_cpuid_version_get_model, x86_cpuid_version_set_model, NULL, NULL, NULL); - object_property_add(obj, "stepping", "int", - x86_cpuid_version_get_stepping, - x86_cpuid_version_set_stepping, NULL, NULL, NULL); env->cpuid_apic_id = env->cpu_index;