From patchwork Fri Jul 1 22:41:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 9210567 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 12F0F60752 for ; Fri, 1 Jul 2016 22:47:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03513286C0 for ; Fri, 1 Jul 2016 22:47:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB2F8286CD; Fri, 1 Jul 2016 22:47:42 +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 1D32B286C0 for ; Fri, 1 Jul 2016 22:47:41 +0000 (UTC) Received: from localhost ([::1]:36058 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ7Do-00006r-IQ for patchwork-qemu-devel@patchwork.kernel.org; Fri, 01 Jul 2016 18:47:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ78F-0002EN-5C for qemu-devel@nongnu.org; Fri, 01 Jul 2016 18:41:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bJ78B-0003Sq-62 for qemu-devel@nongnu.org; Fri, 01 Jul 2016 18:41:55 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51150) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ78A-0003Se-Tu for qemu-devel@nongnu.org; Fri, 01 Jul 2016 18:41:51 -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 u61McmUP018790 for ; Fri, 1 Jul 2016 18:41:50 -0400 Received: from e19.ny.us.ibm.com (e19.ny.us.ibm.com [129.33.205.209]) by mx0a-001b2d01.pphosted.com with ESMTP id 23w62ybyuj-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 01 Jul 2016 18:41:50 -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:48 -0400 Received: from d01dlp02.pok.ibm.com (9.56.250.167) 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:44 -0400 X-IBM-Helo: d01dlp02.pok.ibm.com X-IBM-MailFrom: groug@kaod.org Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 5AE006E803F; Fri, 1 Jul 2016 18:41:25 -0400 (EDT) Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u61MfheP57212964; Fri, 1 Jul 2016 22:41:43 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A9D08124049; Fri, 1 Jul 2016 18:41:43 -0400 (EDT) Received: from bahia.lan (unknown [9.164.136.204]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id B2313124037; Fri, 1 Jul 2016 18:41:41 -0400 (EDT) From: Greg Kurz To: David Gibson Date: Sat, 02 Jul 2016 00:41:40 +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-000000AE2583 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16070122-0057-0000-0000-000004C81F04 Message-Id: <146741290050.948.9173344298826435779.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=2 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.156.1 Subject: [Qemu-devel] [PATCH v2 3/7] ppc: different creation paths for cpus in system and user mode 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The machine code currently uses the same cpu_ppc_init() function to create cpus as the user mode. This function also triggers the cpu realization. It is okay for user mode but with system mode we may want to do other things between initialization and realization, like generating cpu ids for the DT for example. With this patch, each mode has its own creation helper: - ppc_cpu_init() is for system mode only - cpu_init() is for user mode only Suggested-by: Igor Mammedov Signed-off-by: Greg Kurz --- hw/ppc/e500.c | 2 +- hw/ppc/mac_newworld.c | 2 +- hw/ppc/mac_oldworld.c | 2 +- hw/ppc/ppc.c | 5 +++++ hw/ppc/ppc440_bamboo.c | 2 +- hw/ppc/ppc4xx_devs.c | 2 +- hw/ppc/prep.c | 2 +- hw/ppc/spapr.c | 2 +- hw/ppc/virtex_ml507.c | 2 +- include/hw/ppc/ppc.h | 1 + target-ppc/cpu.h | 5 +++-- target-ppc/translate_init.c | 5 ----- 12 files changed, 17 insertions(+), 15 deletions(-) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 0cd534df55f8..ff5d92e48dd9 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -821,7 +821,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params) CPUState *cs; qemu_irq *input; - cpu = cpu_ppc_init(machine->cpu_model); + cpu = ppc_cpu_init(machine->cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to initialize CPU!\n"); exit(1); diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 32e88b378687..6ab675c498d0 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -193,7 +193,7 @@ static void ppc_core99_init(MachineState *machine) #endif } for (i = 0; i < smp_cpus; i++) { - cpu = cpu_ppc_init(machine->cpu_model); + cpu = ppc_cpu_init(machine->cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 447948746b1a..77fbdfffd4e2 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -113,7 +113,7 @@ static void ppc_heathrow_init(MachineState *machine) if (machine->cpu_model == NULL) machine->cpu_model = "G3"; for (i = 0; i < smp_cpus; i++) { - cpu = cpu_ppc_init(machine->cpu_model); + cpu = ppc_cpu_init(machine->cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index e4252528a69d..dc3d214009c5 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -1350,3 +1350,8 @@ PowerPCCPU *ppc_get_vcpu_by_dt_id(int cpu_dt_id) return NULL; } + +PowerPCCPU *ppc_cpu_init(const char *cpu_model) +{ + return POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, cpu_model)); +} diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c index 5c535b18a20d..7f22433c8e91 100644 --- a/hw/ppc/ppc440_bamboo.c +++ b/hw/ppc/ppc440_bamboo.c @@ -186,7 +186,7 @@ static void bamboo_init(MachineState *machine) if (machine->cpu_model == NULL) { machine->cpu_model = "440EP"; } - cpu = cpu_ppc_init(machine->cpu_model); + cpu = ppc_cpu_init(machine->cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to initialize CPU!\n"); exit(1); diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c index e7f413e49d08..94a24243af70 100644 --- a/hw/ppc/ppc4xx_devs.c +++ b/hw/ppc/ppc4xx_devs.c @@ -56,7 +56,7 @@ PowerPCCPU *ppc4xx_init(const char *cpu_model, CPUPPCState *env; /* init CPUs */ - cpu = cpu_ppc_init(cpu_model); + cpu = ppc_cpu_init(cpu_model, 0); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC %s CPU definition\n", cpu_model); diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index 054af1e8b481..e62fe643f492 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -509,7 +509,7 @@ static void ppc_prep_init(MachineState *machine) if (machine->cpu_model == NULL) machine->cpu_model = "602"; for (i = 0; i < smp_cpus; i++) { - cpu = cpu_ppc_init(machine->cpu_model); + cpu = ppc_cpu_init(machine->cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 78ebd9ee38ce..690ee486aa07 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1828,7 +1828,7 @@ static void ppc_spapr_init(MachineState *machine) g_free(type); } else { for (i = 0; i < smp_cpus; i++) { - PowerPCCPU *cpu = cpu_ppc_init(machine->cpu_model); + PowerPCCPU *cpu = ppc_cpu_init(machine->cpu_model); if (cpu == NULL) { error_report("Unable to find PowerPC CPU definition"); exit(1); diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index b97d96685cf1..8d350fb98b2c 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -96,7 +96,7 @@ static PowerPCCPU *ppc440_init_xilinx(ram_addr_t *ram_size, CPUPPCState *env; qemu_irq *irqs; - cpu = cpu_ppc_init(cpu_model); + cpu = ppc_cpu_init(cpu_model, 0); if (cpu == NULL) { fprintf(stderr, "Unable to initialize CPU!\n"); exit(1); diff --git a/include/hw/ppc/ppc.h b/include/hw/ppc/ppc.h index 5617dc4a2c04..a4db1db82e1b 100644 --- a/include/hw/ppc/ppc.h +++ b/include/hw/ppc/ppc.h @@ -106,4 +106,5 @@ enum { /* ppc_booke.c */ void ppc_booke_timers_init(PowerPCCPU *cpu, uint32_t freq, uint32_t flags); +PowerPCCPU *ppc_cpu_init(const char *cpu_model); #endif diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h index af73bced9f70..440309a68006 100644 --- a/target-ppc/cpu.h +++ b/target-ppc/cpu.h @@ -1196,7 +1196,6 @@ extern const struct VMStateDescription vmstate_ppc_cpu; #endif /*****************************************************************************/ -PowerPCCPU *cpu_ppc_init(const char *cpu_model); void ppc_translate_init(void); void gen_update_current_nip(void *opaque); /* you can call this signal handler from your SIGBUS and SIGSEGV @@ -1275,7 +1274,9 @@ static inline uint64_t ppc_dump_gpr(CPUPPCState *env, int gprn) int ppc_dcr_read (ppc_dcr_t *dcr_env, int dcrn, uint32_t *valp); int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, uint32_t val); -#define cpu_init(cpu_model) CPU(cpu_ppc_init(cpu_model)) +#if defined(CONFIG_USER_ONLY) +#define cpu_init(cpu_model) cpu_generic_init(TYPE_POWERPC_CPU, cpu_model) +#endif #define cpu_signal_handler cpu_ppc_signal_handler #define cpu_list ppc_cpu_list diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index a06bf50b65d4..6706787b41a1 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -10000,11 +10000,6 @@ static ObjectClass *ppc_cpu_class_by_name(const char *name) return NULL; } -PowerPCCPU *cpu_ppc_init(const char *cpu_model) -{ - return POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, cpu_model)); -} - /* Sort by PVR, ordering special case "host" last. */ static gint ppc_cpu_list_compare(gconstpointer a, gconstpointer b) {