From nobody Fri May 3 02:18:21 2024 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 From nobody Fri May 3 02:18:21 2024 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 1499876894904227.6779789872644; Wed, 12 Jul 2017 09:28:14 -0700 (PDT) Received: from localhost ([::1]:54627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVKUm-0008Qb-EM for importer@patchew.org; Wed, 12 Jul 2017 12:28:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVKNu-0001xy-WE 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 1dVKNu-0004Ev-86 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 12:21:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42892) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVKNu-0004De-1f for qemu-devel@nongnu.org; Wed, 12 Jul 2017 12:21:06 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 08AFA7F3E5; Wed, 12 Jul 2017 16:21:05 +0000 (UTC) Received: from localhost (ovpn-116-74.gru2.redhat.com [10.97.116.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8ADEA5D9C8; Wed, 12 Jul 2017 16:21:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 08AFA7F3E5 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 08AFA7F3E5 From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Wed, 12 Jul 2017 13:20:56 -0300 Message-Id: <20170712162058.10538-3-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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 12 Jul 2017 16:21:05 +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 2/4] target/i386: Use host_vendor_fms() in max_x86_cpu_initfn() 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" The existing code duplicated the logic in host_vendor_fms(), so reuse the helper function instead. Signed-off-by: Eduardo Habkost Reviewed-by: Igor Mammedov --- target/i386/cpu.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 30b704c..a667d5d 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1588,13 +1588,8 @@ static void max_x86_cpu_initfn(Object *obj) X86CPUDefinition host_cpudef =3D { }; uint32_t eax =3D 0, ebx =3D 0, ecx =3D 0, edx =3D 0; =20 - host_cpuid(0x0, 0, &eax, &ebx, &ecx, &edx); - x86_cpu_vendor_words2str(host_cpudef.vendor, ebx, edx, ecx); - - host_cpuid(0x1, 0, &eax, &ebx, &ecx, &edx); - host_cpudef.family =3D ((eax >> 8) & 0x0F) + ((eax >> 20) & 0xFF); - host_cpudef.model =3D ((eax >> 4) & 0x0F) | ((eax & 0xF0000) >> 12= ); - host_cpudef.stepping =3D eax & 0x0F; + host_vendor_fms(host_cpudef.vendor, &host_cpudef.family, + &host_cpudef.model, &host_cpudef.stepping); =20 cpu_x86_fill_model_id(host_cpudef.model_id); =20 --=20 2.9.4 From nobody Fri May 3 02:18:21 2024 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 149987691749126.59928067326348; Wed, 12 Jul 2017 09:28:37 -0700 (PDT) Received: from localhost ([::1]:54633 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVKV9-0000LU-9L for importer@patchew.org; Wed, 12 Jul 2017 12:28:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42366) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVKNz-00022K-C7 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 12:21:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVKNy-0004KK-Jm for qemu-devel@nongnu.org; Wed, 12 Jul 2017 12:21:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55482) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVKNy-0004It-Dc for qemu-devel@nongnu.org; Wed, 12 Jul 2017 12:21:10 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F8E451144; Wed, 12 Jul 2017 16:21:09 +0000 (UTC) Received: from localhost (ovpn-116-74.gru2.redhat.com [10.97.116.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18B6C703B0; Wed, 12 Jul 2017 16:21:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6F8E451144 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 6F8E451144 From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Wed, 12 Jul 2017 13:20:57 -0300 Message-Id: <20170712162058.10538-4-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.15 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:09 +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 3/4] target/i386: Define CPUID_MODEL_ID_SZ macro 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" Document cpu_x86_fill_model_id() and define CPUID_MODEL_ID_SZ to help callers use the right buffer size. Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index a667d5d..e2cd157 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1537,6 +1537,17 @@ static bool lmce_supported(void) return !!(mce_cap & MCG_LMCE_P); } =20 +#define CPUID_MODEL_ID_SZ 48 + +/** + * cpu_x86_fill_model_id: + * Get CPUID model ID string from host CPU. + * + * @str should have at least CPUID_MODEL_ID_SZ bytes + * + * The function does NOT add a null terminator to the string + * automatically. + */ static int cpu_x86_fill_model_id(char *str) { uint32_t eax =3D 0, ebx =3D 0, ecx =3D 0, edx =3D 0; --=20 2.9.4 From nobody Fri May 3 02:18:21 2024 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 1499877015227339.4281149239074; Wed, 12 Jul 2017 09:30:15 -0700 (PDT) Received: from localhost ([::1]:54640 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVKWj-00027C-Vc for importer@patchew.org; Wed, 12 Jul 2017 12:30:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42393) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVKO2-000245-Jw for qemu-devel@nongnu.org; Wed, 12 Jul 2017 12:21:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVKO0-0004Lj-Hl for qemu-devel@nongnu.org; Wed, 12 Jul 2017 12:21:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41564) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVKO0-0004LH-8w for qemu-devel@nongnu.org; Wed, 12 Jul 2017 12:21:12 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4DF618B13D; Wed, 12 Jul 2017 16:21:11 +0000 (UTC) Received: from localhost (ovpn-116-74.gru2.redhat.com [10.97.116.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF01F4D757; Wed, 12 Jul 2017 16:21:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4DF618B13D Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4DF618B13D From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Wed, 12 Jul 2017 13:20:58 -0300 Message-Id: <20170712162058.10538-5-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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 12 Jul 2017 16:21:11 +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 4/4] target/i386: Don't use x86_cpu_load_def() on "max" CPU model 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" When commit 0bacd8b3046f ('i386: Don't set CPUClass::cpu_def on "max" model') removed the CPUClass::cpu_def field, we kept using the x86_cpu_load_def() helper directly in max_x86_cpu_initfn(), emulating the previous behavior when CPUClass::cpu_def was set. However, x86_cpu_load_def() is intended to help initialization of CPU models from the builtin_x86_defs table, and does lots of other steps that are not necessary for "max". One of the things x86_cpu_load_def() do is to set the properties listed at tcg_default_props/kvm_default_props. We must not do that on the "max" CPU model, otherwise under KVM we will incorrectly report all KVM features as always available, and the "svm" feature as always unavailable. The latter caused the bug reported at: https://bugzilla.redhat.com/show_bug.cgi?id=3D1467599 ("Unable to start domain: the CPU is incompatible with host CPU: Host CPU does not provide required features: svm") Replace x86_cpu_load_def() with simple object_property_set*() calls. In addition to fixing the above bug, this makes the KVM branch in max_x86_cpu_initfn() very similar to the existing TCG branch. Signed-off-by: Eduardo Habkost Reviewed-by: Igor Mammedov --- target/i386/cpu.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index e2cd157..62d8021 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1596,15 +1596,21 @@ static void max_x86_cpu_initfn(Object *obj) cpu->max_features =3D true; =20 if (kvm_enabled()) { - X86CPUDefinition host_cpudef =3D { }; - uint32_t eax =3D 0, ebx =3D 0, ecx =3D 0, edx =3D 0; + char vendor[CPUID_VENDOR_SZ + 1] =3D { 0 }; + char model_id[CPUID_MODEL_ID_SZ + 1] =3D { 0 }; + int family, model, stepping; =20 - host_vendor_fms(host_cpudef.vendor, &host_cpudef.family, - &host_cpudef.model, &host_cpudef.stepping); + host_vendor_fms(vendor, &family, &model, &stepping); =20 - cpu_x86_fill_model_id(host_cpudef.model_id); + cpu_x86_fill_model_id(model_id); =20 - x86_cpu_load_def(cpu, &host_cpudef, &error_abort); + object_property_set_str(OBJECT(cpu), vendor, "vendor", &error_abor= t); + object_property_set_int(OBJECT(cpu), family, "family", &error_abor= t); + object_property_set_int(OBJECT(cpu), model, "model", &error_abort); + object_property_set_int(OBJECT(cpu), stepping, "stepping", + &error_abort); + object_property_set_str(OBJECT(cpu), model_id, "model-id", + &error_abort); =20 env->cpuid_min_level =3D kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX); --=20 2.9.4