From patchwork Wed Jul 6 12:14:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 645249 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rl0Gy0BBkz9sBl for ; Wed, 6 Jul 2016 22:21:30 +1000 (AEST) Received: from localhost ([::1]:33279 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKlpX-0007OA-Sm for incoming@patchwork.ozlabs.org; Wed, 06 Jul 2016 08:21:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKlix-0006au-CM for qemu-devel@nongnu.org; Wed, 06 Jul 2016 08:14:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKlis-0002l5-Gg for qemu-devel@nongnu.org; Wed, 06 Jul 2016 08:14:39 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:45861) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKlis-0002ks-7W for qemu-devel@nongnu.org; Wed, 06 Jul 2016 08:14:34 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u66CEAEw052262 for ; Wed, 6 Jul 2016 08:14:33 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 240nf25dmn-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 06 Jul 2016 08:14:33 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 6 Jul 2016 06:14:32 -0600 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 6 Jul 2016 06:14:28 -0600 X-IBM-Helo: d03dlp02.boulder.ibm.com X-IBM-MailFrom: groug@kaod.org Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id EDB153E40044; Wed, 6 Jul 2016 06:14:27 -0600 (MDT) Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u66CERwG64684216; Wed, 6 Jul 2016 05:14:27 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B91936A03F; Wed, 6 Jul 2016 06:14:27 -0600 (MDT) Received: from bahia.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.41]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id 170336A03C; Wed, 6 Jul 2016 06:14:25 -0600 (MDT) From: Greg Kurz To: David Gibson Date: Wed, 06 Jul 2016 14:14:25 +0200 In-Reply-To: <146780713904.26232.12351310667258006783.stgit@bahia.lab.toulouse-stg.fr.ibm.com> References: <146780713904.26232.12351310667258006783.stgit@bahia.lab.toulouse-stg.fr.ibm.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16070612-0008-0000-0000-000004FD4FB5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16070612-0009-0000-0000-0000390F2AEF Message-Id: <146780723427.26232.10779748351110554240.stgit@bahia.lab.toulouse-stg.fr.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-07-06_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1607060109 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v3 4/7] ppc: open code cpu creation for machine 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: Eduardo Habkost , Alexander Graf , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, Cedric Le Goater , Bharata B Rao , Scott Wood , Igor Mammedov Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" If we want to generate cpu_dt_id in the machine code, this must occur before the cpu gets realized. We must open code the cpu creation to be able to do this. This patch just does that. Signed-off-by: Greg Kurz Reviewed-by: David Gibson --- v3: don't parse cpu features as it is done in a previous patch --- hw/ppc/ppc.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index 313b3f0b9a51..0df32a9b3965 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -32,6 +32,7 @@ #include "sysemu/cpus.h" #include "hw/timer/m48t59.h" #include "qemu/log.h" +#include "qapi/error.h" #include "qemu/error-report.h" #include "qapi/error.h" #include "hw/loader.h" @@ -1354,7 +1355,36 @@ PowerPCCPU *ppc_get_vcpu_by_dt_id(int cpu_dt_id) PowerPCCPU *ppc_cpu_init(const char *cpu_model) { - return POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, cpu_model)); + PowerPCCPU *cpu; + ObjectClass *oc; + gchar **model_pieces; + Error *err = NULL; + + model_pieces = g_strsplit(cpu_model, ",", 2); + if (!model_pieces[0]) { + error_report("Invalid/empty CPU model name"); + return NULL; + } + + oc = cpu_class_by_name(TYPE_POWERPC_CPU, model_pieces[0]); + if (oc == NULL) { + error_report("Unable to find CPU definition: %s", model_pieces[0]); + goto out; + } + + cpu = POWERPC_CPU(object_new(object_class_get_name(oc))); + object_property_set_bool(OBJECT(cpu), true, "realized", &err); + +out: + g_strfreev(model_pieces); + + if (err != NULL) { + error_report_err(err); + object_unref(OBJECT(cpu)); + return NULL; + } + + return cpu; } void ppc_cpu_parse_features(const char *cpu_model)