From nobody Thu Jan 1 03:24:12 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.zoho.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 1486020627369637.6491076623837; Wed, 1 Feb 2017 23:30:27 -0800 (PST) Received: from localhost ([::1]:55042 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZBqb-0005Ih-Ew for importer@patchew.org; Thu, 02 Feb 2017 02:30:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53031) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZ9kO-000871-O5 for qemu-devel@nongnu.org; Thu, 02 Feb 2017 00:15:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZ9kG-0004QL-04 for qemu-devel@nongnu.org; Thu, 02 Feb 2017 00:15:52 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:51503) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZ9kF-0004Lk-F6; Thu, 02 Feb 2017 00:15:43 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vDSqc50gxz9sNM; Thu, 2 Feb 2017 16:15:04 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1486012508; bh=tL6PPAgo8lesu153s2H9BXBQGnq9xy/d499042X1sgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lKphy6uUf2c0fsZFPBXOFl0lC4R6louDAStLp4pJ3NeCe1slM6klC5x3GTTzk+gMW c/Ovt5NQu+dPr68dGQe0Esc3FfAmj/xCXasu5SLjJBzgx19caZk5UgHo52DcUT9ApF PPWPopvKTqhfmgHWqugnYHIaGnlk8vCiT28vGwvs= From: David Gibson To: peter.maydell@linaro.org Date: Thu, 2 Feb 2017 16:14:44 +1100 Message-Id: <20170202051445.5735-107-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170202051445.5735-1-david@gibson.dropbear.id.au> References: <20170202051445.5735-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 106/107] ppc/kvm: Handle the "family" CPU via alias instead of registering new types 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: lvivier@redhat.com, thuth@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, qemu-ppc@nongnu.org, David Gibson 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" From: Thomas Huth When running with KVM on POWER, we are registering a "family" CPU type for the host CPU that we are running on. For example, on all POWER8-compatible hosts, we register a "POWER8" CPU type, so that you can always start QEMU with "-cpu POWER8" there, without the need to know whether you are running on a POWER8, POWER8E or POWER8NVL host machine. However, we also have a "POWER8" CPU alias in the ppc_cpu_aliases list (that is mainly useful for TCG). This leads to two cosmetical drawbacks: If the user runs QEMU with "-cpu ?", we always claim that POWER8 is an "alias for POWER8_v2.0" - which is simply not true when running with KVM on POWER. And when using the 'query-cpu-definitions' QMP call, there are currently two entries for "POWER8", one for the alias, and one for the additional registered type. To solve the two problems, we should rather update the "family" alias instead of registering a new types. We then only have one "POWER8" CPU definition around, an alias, which also points to the right destination. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D1396536 Signed-off-by: Thomas Huth Signed-off-by: David Gibson --- target/ppc/kvm.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index e69fca8..663d2e7 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -24,6 +24,7 @@ #include "qemu-common.h" #include "qemu/error-report.h" #include "cpu.h" +#include "cpu-models.h" #include "qemu/timer.h" #include "sysemu/sysemu.h" #include "sysemu/hw_accel.h" @@ -2412,6 +2413,7 @@ static int kvm_ppc_register_host_cpu_type(void) }; PowerPCCPUClass *pvr_pcc; DeviceClass *dc; + int i; =20 pvr_pcc =3D kvm_ppc_get_host_cpu_class(); if (pvr_pcc =3D=3D NULL) { @@ -2420,13 +2422,6 @@ static int kvm_ppc_register_host_cpu_type(void) type_info.parent =3D object_class_get_name(OBJECT_CLASS(pvr_pcc)); type_register(&type_info); =20 - /* Register generic family CPU class for a family */ - pvr_pcc =3D ppc_cpu_get_family_class(pvr_pcc); - dc =3D DEVICE_CLASS(pvr_pcc); - type_info.parent =3D object_class_get_name(OBJECT_CLASS(pvr_pcc)); - type_info.name =3D g_strdup_printf("%s-"TYPE_POWERPC_CPU, dc->desc); - type_register(&type_info); - #if defined(TARGET_PPC64) type_info.name =3D g_strdup_printf("%s-"TYPE_SPAPR_CPU_CORE, "host"); type_info.parent =3D TYPE_SPAPR_CPU_CORE, @@ -2436,14 +2431,29 @@ static int kvm_ppc_register_host_cpu_type(void) type_info.class_data =3D (void *) "host"; type_register(&type_info); g_free((void *)type_info.name); - - /* Register generic spapr CPU family class for current host CPU type */ - type_info.name =3D g_strdup_printf("%s-"TYPE_SPAPR_CPU_CORE, dc->desc); - type_info.class_data =3D (void *) dc->desc; - type_register(&type_info); - g_free((void *)type_info.name); #endif =20 + /* + * Update generic CPU family class alias (e.g. on a POWER8NVL host, + * we want "POWER8" to be a "family" alias that points to the current + * host CPU type, too) + */ + dc =3D DEVICE_CLASS(ppc_cpu_get_family_class(pvr_pcc)); + for (i =3D 0; ppc_cpu_aliases[i].alias !=3D NULL; i++) { + if (strcmp(ppc_cpu_aliases[i].alias, dc->desc) =3D=3D 0) { + ObjectClass *oc =3D OBJECT_CLASS(pvr_pcc); + char *suffix; + + ppc_cpu_aliases[i].model =3D g_strdup(object_class_get_name(oc= )); + suffix =3D strstr(ppc_cpu_aliases[i].model, "-"TYPE_POWERPC_CP= U); + if (suffix) { + *suffix =3D 0; + } + ppc_cpu_aliases[i].oc =3D oc; + break; + } + } + return 0; } =20 --=20 2.9.3