From nobody Tue Feb 10 17:08:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14998767432187.4229286205176095; Wed, 12 Jul 2017 09:25:43 -0700 (PDT) Received: from localhost ([::1]:54616 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVKSK-0005v8-Bg for importer@patchew.org; Wed, 12 Jul 2017 12:25:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVKNu-0001x3-24 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 12:21:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVKNs-0004DH-C0 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 12:21:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55248) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVKNs-0004D6-2Z for qemu-devel@nongnu.org; Wed, 12 Jul 2017 12:21:04 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1A4881A09B; Wed, 12 Jul 2017 16:21:03 +0000 (UTC) Received: from localhost (ovpn-116-74.gru2.redhat.com [10.97.116.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 923DC60BEC; Wed, 12 Jul 2017 16:21:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1A4881A09B Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1A4881A09B From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Wed, 12 Jul 2017 13:20:55 -0300 Message-Id: <20170712162058.10538-2-ehabkost@redhat.com> In-Reply-To: <20170712162058.10538-1-ehabkost@redhat.com> References: <20170712162058.10538-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 12 Jul 2017 16:21:03 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/4] target/i386: Use simple static property for "model-id" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Jiri Denemark , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Instead of storing the raw CPUID data in CPUX86State and having to convert the data back and forth on the QOM getter/setter, use a simple static string property, and calculate CPUID data inside cpu_x86_cpuid(). Signed-off-by: Eduardo Habkost --- target/i386/cpu.h | 2 +- target/i386/cpu.c | 62 ++++++++++++++++-----------------------------------= ---- 2 files changed, 19 insertions(+), 45 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 7a228af..f56a3ea 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1151,7 +1151,7 @@ typedef struct CPUX86State { FeatureWordArray features; /* Features that were explicitly enabled/disabled */ FeatureWordArray user_features; - uint32_t cpuid_model[12]; + char *model_id; =20 /* MTRRs */ uint64_t mtrr_fixed[11]; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index c571772..30b704c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1828,43 +1828,6 @@ static void x86_cpuid_set_vendor(Object *obj, const = char *value, } } =20 -static char *x86_cpuid_get_model_id(Object *obj, Error **errp) -{ - X86CPU *cpu =3D X86_CPU(obj); - CPUX86State *env =3D &cpu->env; - char *value; - int i; - - value =3D g_malloc(48 + 1); - for (i =3D 0; i < 48; i++) { - value[i] =3D env->cpuid_model[i >> 2] >> (8 * (i & 3)); - } - value[48] =3D '\0'; - return value; -} - -static void x86_cpuid_set_model_id(Object *obj, const char *model_id, - Error **errp) -{ - X86CPU *cpu =3D X86_CPU(obj); - CPUX86State *env =3D &cpu->env; - int c, len, i; - - if (model_id =3D=3D NULL) { - model_id =3D ""; - } - len =3D strlen(model_id); - memset(env->cpuid_model, 0, 48); - for (i =3D 0; i < 48; i++) { - if (i >=3D len) { - c =3D '\0'; - } else { - c =3D (uint8_t)model_id[i]; - } - env->cpuid_model[i >> 2] |=3D c << (8 * (i & 3)); - } -} - static void x86_cpuid_get_tsc_freq(Object *obj, Visitor *v, const char *na= me, void *opaque, Error **errp) { @@ -2899,10 +2862,23 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, case 0x80000002: case 0x80000003: case 0x80000004: - *eax =3D env->cpuid_model[(index - 0x80000002) * 4 + 0]; - *ebx =3D env->cpuid_model[(index - 0x80000002) * 4 + 1]; - *ecx =3D env->cpuid_model[(index - 0x80000002) * 4 + 2]; - *edx =3D env->cpuid_model[(index - 0x80000002) * 4 + 3]; + { + int i; + int len =3D strlen(env->model_id); + uint32_t model[4] =3D { 0, 0, 0, 0 }; + + for (i =3D 0; i < 16; i++) { + int p =3D (index - 0x80000002) * 16 + i; + if (p >=3D len) { + continue; + } + model[i >> 2] |=3D ((uint8_t)env->model_id[p]) << (8 * (i = & 3)); + } + *eax =3D model[0]; + *ebx =3D model[1]; + *ecx =3D model[2]; + *edx =3D model[3]; + } break; case 0x80000005: /* cache info (L1 cache) */ @@ -3868,9 +3844,6 @@ static void x86_cpu_initfn(Object *obj) object_property_add_str(obj, "vendor", x86_cpuid_get_vendor, x86_cpuid_set_vendor, NULL); - object_property_add_str(obj, "model-id", - x86_cpuid_get_model_id, - x86_cpuid_set_model_id, NULL); object_property_add(obj, "tsc-frequency", "int", x86_cpuid_get_tsc_freq, x86_cpuid_set_tsc_freq, NULL, NULL, NULL); @@ -4004,6 +3977,7 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_UINT32("phys-bits", X86CPU, phys_bits, 0), DEFINE_PROP_BOOL("host-phys-bits", X86CPU, host_phys_bits, false), DEFINE_PROP_BOOL("fill-mtrr-mask", X86CPU, fill_mtrr_mask, true), + DEFINE_PROP_STRING("model-id", X86CPU, env.model_id), DEFINE_PROP_UINT32("level", X86CPU, env.cpuid_level, UINT32_MAX), DEFINE_PROP_UINT32("xlevel", X86CPU, env.cpuid_xlevel, UINT32_MAX), DEFINE_PROP_UINT32("xlevel2", X86CPU, env.cpuid_xlevel2, UINT32_MAX), --=20 2.9.4