From patchwork Fri Jul 1 22:41:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 643318 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 3rhBV672dSz9ssP for ; Sat, 2 Jul 2016 08:51:26 +1000 (AEST) Received: from localhost ([::1]:36077 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ7HQ-0004hE-Vr for incoming@patchwork.ozlabs.org; Fri, 01 Jul 2016 18:51:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44099) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ78N-0002K4-5W for qemu-devel@nongnu.org; Fri, 01 Jul 2016 18:42:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bJ78I-0003U4-0q for qemu-devel@nongnu.org; Fri, 01 Jul 2016 18:42:02 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:20867 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ78H-0003U0-R8 for qemu-devel@nongnu.org; Fri, 01 Jul 2016 18:41:57 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u61Mce2J018062 for ; Fri, 1 Jul 2016 18:41:57 -0400 Received: from e19.ny.us.ibm.com (e19.ny.us.ibm.com [129.33.205.209]) by mx0b-001b2d01.pphosted.com with ESMTP id 23wa3mjj97-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 01 Jul 2016 18:41:57 -0400 Received: from localhost by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 1 Jul 2016 18:41:56 -0400 Received: from d01dlp01.pok.ibm.com (9.56.250.166) by e19.ny.us.ibm.com (146.89.104.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 1 Jul 2016 18:41:52 -0400 X-IBM-Helo: d01dlp01.pok.ibm.com X-IBM-MailFrom: groug@kaod.org Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id A135F38C803B; Fri, 1 Jul 2016 18:41:51 -0400 (EDT) Received: from b01ledav03.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u61MfsvW56819814; Fri, 1 Jul 2016 22:41:54 GMT Received: from b01ledav03.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7CB3AB2050; Fri, 1 Jul 2016 18:41:51 -0400 (EDT) Received: from bahia.lan (unknown [9.164.136.204]) by b01ledav03.gho.pok.ibm.com (Postfix) with ESMTP id DF56DB204E; Fri, 1 Jul 2016 18:41:49 -0400 (EDT) From: Greg Kurz To: David Gibson Date: Sat, 02 Jul 2016 00:41:48 +0200 In-Reply-To: <146741287399.948.15988269239450224065.stgit@bahia.lan> References: <146741287399.948.15988269239450224065.stgit@bahia.lan> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16070122-0056-0000-0000-000000AE2589 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16070122-0057-0000-0000-000004C81F09 Message-Id: <146741290890.948.9125710372347515263.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-07-01_07:, , 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-1607010225 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v2 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: qemu-devel@nongnu.org, Alexander Graf , 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. It borrows some lines from previous work from Bharata to handle the feature parsing. Signed-off-by: Greg Kurz --- hw/ppc/ppc.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index dc3d214009c5..57f4ddd073d0 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 "hw/loader.h" #include "sysemu/kvm.h" @@ -1353,5 +1354,41 @@ 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; + CPUClass *cc; + 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]); + return NULL; + } + + cpu = POWERPC_CPU(object_new(object_class_get_name(oc))); + + cc = CPU_CLASS(oc); + cc->parse_features(CPU(cpu), model_pieces[1], &err); + g_strfreev(model_pieces); + if (err != NULL) { + goto out; + } + + object_property_set_bool(OBJECT(cpu), true, "realized", &err); + +out: + if (err != NULL) { + error_report_err(err); + object_unref(OBJECT(cpu)); + return NULL; + } + + return cpu; }