From patchwork Wed Jun 29 20:51:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 9206207 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 10E7F60757 for ; Wed, 29 Jun 2016 21:00:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F391728673 for ; Wed, 29 Jun 2016 21:00:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E82F528679; Wed, 29 Jun 2016 21:00:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BEF9828673 for ; Wed, 29 Jun 2016 21:00:11 +0000 (UTC) Received: from localhost ([::1]:45767 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIMag-0000Ca-Ud for patchwork-qemu-devel@patchwork.kernel.org; Wed, 29 Jun 2016 17:00:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIMSh-0000dd-RS for qemu-devel@nongnu.org; Wed, 29 Jun 2016 16:52:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIMSc-0002JE-7H for qemu-devel@nongnu.org; Wed, 29 Jun 2016 16:51:54 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:48370) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIMSb-0002J4-UY for qemu-devel@nongnu.org; Wed, 29 Jun 2016 16:51:50 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u5TKhTI7025508 for ; Wed, 29 Jun 2016 16:51:49 -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 23usuauxu2-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 29 Jun 2016 16:51:49 -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, 29 Jun 2016 14:51:48 -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, 29 Jun 2016 14:51:45 -0600 X-IBM-Helo: d03dlp02.boulder.ibm.com X-IBM-MailFrom: groug@kaod.org Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 065583E40044; Wed, 29 Jun 2016 14:51:45 -0600 (MDT) Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u5TKpiG245744268; Wed, 29 Jun 2016 13:51:44 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D1BB7BE038; Wed, 29 Jun 2016 14:51:44 -0600 (MDT) Received: from bahia.lan (unknown [9.164.167.94]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP id B9881BE039; Wed, 29 Jun 2016 14:51:40 -0600 (MDT) From: Greg Kurz To: David Gibson Date: Wed, 29 Jun 2016 22:51:38 +0200 In-Reply-To: <146723340662.9665.6413150884317978000.stgit@bahia.lan> References: <146723340662.9665.6413150884317978000.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: 16062920-0008-0000-0000-000004F1C5FE X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16062920-0009-0000-0000-000038DFB351 Message-Id: <146723349880.9665.13394861227888249114.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-06-29_11:, , 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-1606290192 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 7/8] cpu: add initialization helper without realize 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: Peter Crosthwaite , qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Cedric Le Goater , bharata@linux.vnet.ibm.com, Scott Wood , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This will allow PowerPC machines to compute the device-tree cpu id between initialization and realization of the cpu. Signed-off-by: Greg Kurz --- include/qom/cpu.h | 12 ++++++++++++ qom/cpu.c | 19 ++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 63e77607f644..8b3adbbff060 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -557,8 +557,20 @@ ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model); */ CPUState *cpu_generic_init(const char *typename, const char *cpu_model); /** + * cpu_generic_init_no_realize: + * @typename: The CPU base type. + * @cpu_model: The model string including optional parameters. + * + * Instantiates a CPU, processes optional parameters. + * + * Returns: A #CPUState or %NULL if an error occurred. + */ +CPUState *cpu_generic_init_no_realize(const char *typename, + const char *cpu_model); + +/** * cpu_has_work: * @cpu: The vCPU to check. * * Checks whether the CPU has work to do. diff --git a/qom/cpu.c b/qom/cpu.c index 751e992de882..dfe3289991ab 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -42,9 +42,10 @@ bool cpu_exists(int64_t id) } return false; } -CPUState *cpu_generic_init(const char *typename, const char *cpu_model) +static CPUState *cpu_generic_init_common(const char *typename, + const char *cpu_model, bool realize) { char *str, *name, *featurestr; CPUState *cpu; ObjectClass *oc; @@ -69,10 +70,11 @@ CPUState *cpu_generic_init(const char *typename, const char *cpu_model) if (err != NULL) { goto out; } - object_property_set_bool(OBJECT(cpu), true, "realized", &err); - + if (realize) { + object_property_set_bool(OBJECT(cpu), true, "realized", &err); + } out: if (err != NULL) { error_report_err(err); object_unref(OBJECT(cpu)); @@ -81,8 +83,19 @@ out: return cpu; } +CPUState *cpu_generic_init(const char *typename, const char *cpu_model) +{ + return cpu_generic_init_common(typename, cpu_model, true); +} + +CPUState *cpu_generic_init_no_realize(const char *typename, + const char *cpu_model) +{ + return cpu_generic_init_common(typename, cpu_model, false); +} + bool cpu_paging_enabled(const CPUState *cpu) { CPUClass *cc = CPU_GET_CLASS(cpu);