From nobody Sat May 4 17:44:01 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 1499244726964440.3708871427158; Wed, 5 Jul 2017 01:52:06 -0700 (PDT) Received: from localhost ([::1]:44876 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSg2X-0001XT-NW for importer@patchew.org; Wed, 05 Jul 2017 04:52:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSg0f-0000fs-7a for qemu-devel@nongnu.org; Wed, 05 Jul 2017 04:50:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSg0c-00057z-6C for qemu-devel@nongnu.org; Wed, 05 Jul 2017 04:50:09 -0400 Received: from 5.mo4.mail-out.ovh.net ([188.165.44.50]:46991) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dSg0b-00057k-Vi for qemu-devel@nongnu.org; Wed, 05 Jul 2017 04:50:06 -0400 Received: from player159.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo4.mail-out.ovh.net (Postfix) with ESMTP id 107B582670 for ; Wed, 5 Jul 2017 10:50:04 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player159.ha.ovh.net (Postfix) with ESMTPA id 98DB6480092; Wed, 5 Jul 2017 10:49:59 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Wed, 05 Jul 2017 10:49:52 +0200 Message-ID: <149924459296.25523.6693809356627708668.stgit@bahia.lan> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 12122282824055560486 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrudeigddtjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 188.165.44.50 Subject: [Qemu-devel] [PATCH] ppc/kvm: have the "family" CPU alias to point to TYPE_HOST_POWERPC_CPU 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: Laurent Vivier , Thomas Huth , 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 When running KVM on POWER, we allow the user to pass "-cpu POWERx" instead of "-cpu host". This is achieved by patching the ppc_cpu_aliases[] array so that "POWERx" points to the CPU class with the same PVR as the host CPU. This causes CPUs to be instantiated from this CPU class instead of the TYPE_HOST_POWERPC_CPU class which is used with "-cpu host". These CPUs thus miss all the KVM specific tuning from kvmppc_host_cpu_class_init(). This currently causes QEMU with "-cpu POWER9" to fail when running KVM on a POWER9 DD1 host: qemu-system-ppc64: Register sync failed... If you're using kvm-hv.ko, only "-cpu host" is possible kvm_init_vcpu failed: Invalid argument Let's have the "POWERx" alias to point to TYPE_HOST_POWERPC_CPU directly, so that "-cpu POWERx" instantiates CPUs from the same class as "-cpu host". Signed-off-by: Greg Kurz Reviewed-by: Laurent Vivier Reviewed-by: Thomas Huth Tested-by: Laurent Vivier --- target/ppc/kvm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index f2f7c531bc7b..f7a7ea5858a3 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2445,6 +2445,7 @@ static int kvm_ppc_register_host_cpu_type(void) .class_init =3D kvmppc_host_cpu_class_init, }; PowerPCCPUClass *pvr_pcc; + ObjectClass *oc; DeviceClass *dc; int i; =20 @@ -2455,6 +2456,9 @@ 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 + oc =3D object_class_by_name(type_info.name); + g_assert(oc); + #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, @@ -2474,7 +2478,6 @@ static int kvm_ppc_register_host_cpu_type(void) 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; =20 ppc_cpu_aliases[i].model =3D g_strdup(object_class_get_name(oc= ));