From nobody Wed Nov 5 09:24:05 2025 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; dkim=fail; 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 149974855296826.8462800499168; Mon, 10 Jul 2017 21:49:12 -0700 (PDT) Received: from localhost ([::1]:44158 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUn6l-0002Tg-Hx for importer@patchew.org; Tue, 11 Jul 2017 00:49:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUmxV-0002U9-K0 for qemu-devel@nongnu.org; Tue, 11 Jul 2017 00:39:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUmxU-0007Zt-Jr for qemu-devel@nongnu.org; Tue, 11 Jul 2017 00:39:37 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:59029) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dUmxU-0007Xz-7p; Tue, 11 Jul 2017 00:39:36 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3x68Vz2gK8z9t2s; Tue, 11 Jul 2017 14:39:22 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1499747963; bh=yPspgvxDGMfBYYE6xzvpp9Lu+DalUmiuZzkFWFJS6d8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P65sdEq+4uRbq5LHBYEymGhfMV5C9pfKAAV9M4HvmhkyBHjbxWexogKJNj8eLrUiS /aqXsMQjEQFBZQOdB3mPp+RBinWy4Fg8jl9I4h3i87kV4zurJ++rGzDjlCGGbkCmjO 0tqmufOSv96CyLwTvrypOJnAr+2nsWWN2jU2xhYc= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 11 Jul 2017 14:39:15 +1000 Message-Id: <20170711043917.1757-16-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170711043917.1757-1-david@gibson.dropbear.id.au> References: <20170711043917.1757-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 15/17] 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: lvivier@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, surajjs@au1.ibm.com, aik@ozlabs.ru, sbobroff@au1.ibm.com, groug@kaod.org, agraf@suse.de, qemu-ppc@nongnu.org, bharata@linux.vnet.ibm.com, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz 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 Tested-by: Laurent Vivier Reviewed-by: Laurent Vivier Reviewed-by: Thomas Huth Signed-off-by: David Gibson --- 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 f2f7c53..f7a7ea5 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= )); --=20 2.9.4