From patchwork Wed Jul 6 12:13:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 9216267 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 1A04A60752 for ; Wed, 6 Jul 2016 12:14:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09EFF2887A for ; Wed, 6 Jul 2016 12:14:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F226D28880; Wed, 6 Jul 2016 12:14:29 +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 476C12887A for ; Wed, 6 Jul 2016 12:14:29 +0000 (UTC) Received: from localhost ([::1]:33230 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKlim-00066F-GD for patchwork-qemu-devel@patchwork.kernel.org; Wed, 06 Jul 2016 08:14:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKliJ-00063J-8I for qemu-devel@nongnu.org; Wed, 06 Jul 2016 08:14:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKliE-0002bX-BX for qemu-devel@nongnu.org; Wed, 06 Jul 2016 08:13:59 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:16027 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKliE-0002bM-6m for qemu-devel@nongnu.org; Wed, 06 Jul 2016 08:13:54 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u66C9aH5051285 for ; Wed, 6 Jul 2016 08:13:53 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0b-001b2d01.pphosted.com with ESMTP id 240nbywef0-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 06 Jul 2016 08:13:53 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 6 Jul 2016 06:13:52 -0600 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 6 Jul 2016 06:13:49 -0600 X-IBM-Helo: d03dlp03.boulder.ibm.com X-IBM-MailFrom: groug@kaod.org Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 5EB5C19D8047; Wed, 6 Jul 2016 06:13:26 -0600 (MDT) Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u66CDn9853870712; Wed, 6 Jul 2016 05:13:49 -0700 Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0734A13603C; Wed, 6 Jul 2016 06:13:49 -0600 (MDT) Received: from bahia.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.41]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP id 3859F13603A; Wed, 6 Jul 2016 06:13:47 -0600 (MDT) From: Greg Kurz To: David Gibson Date: Wed, 06 Jul 2016 14:13:46 +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-0024-0000-0000-0000140BC7E0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16070612-0025-0000-0000-00004270ED0B Message-Id: <146780721838.26232.17447546364308576256.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-1607060108 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v3 3/7] ppc: parse cpu features once 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Considering that features are converted to global properties and global properties are automatically applied to every new instance of created CPU (at object_new() time), there is no point in parsing cpu_model string every time a CPU created. So move parsing outside CPU creation loop and do it only once. Parsing also should be done before any CPU is created so that features would affect the first CPU a well. This patch does that for all PowerPC machine types. It is based on previous work from Bharata: https://lists.nongnu.org/archive/html/qemu-devel/2016-06/msg07564.html Signed-off-by: Greg Kurz --- hw/ppc/e500.c | 2 ++ hw/ppc/mac_newworld.c | 1 + hw/ppc/mac_oldworld.c | 1 + hw/ppc/ppc.c | 26 ++++++++++++++++++++++++++ hw/ppc/ppc440_bamboo.c | 1 + hw/ppc/ppc4xx_devs.c | 1 + hw/ppc/prep.c | 1 + hw/ppc/spapr.c | 2 ++ hw/ppc/virtex_ml507.c | 1 + include/hw/ppc/ppc.h | 1 + 10 files changed, 37 insertions(+) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index ff5d92e48dd9..b9221cc2c14a 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -814,6 +814,8 @@ void ppce500_init(MachineState *machine, PPCE500Params *params) machine->cpu_model = "e500v2_v30"; } + ppc_cpu_parse_features(machine->cpu_model); + irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *)); irqs[0] = g_malloc0(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB); for (i = 0; i < smp_cpus; i++) { diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index ecd40914be45..366089085844 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -192,6 +192,7 @@ static void ppc_core99_init(MachineState *machine) machine->cpu_model = "G4"; #endif } + ppc_cpu_parse_features(machine->cpu_model); for (i = 0; i < smp_cpus; i++) { cpu = ppc_cpu_init(machine->cpu_model); if (cpu == NULL) { diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 77fbdfffd4e2..5c2dc53cb584 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -112,6 +112,7 @@ static void ppc_heathrow_init(MachineState *machine) /* init CPUs */ if (machine->cpu_model == NULL) machine->cpu_model = "G3"; + ppc_cpu_parse_features(machine->cpu_model); for (i = 0; i < smp_cpus; i++) { cpu = ppc_cpu_init(machine->cpu_model); if (cpu == NULL) { diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index dc3d214009c5..313b3f0b9a51 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -33,6 +33,7 @@ #include "hw/timer/m48t59.h" #include "qemu/log.h" #include "qemu/error-report.h" +#include "qapi/error.h" #include "hw/loader.h" #include "sysemu/kvm.h" #include "kvm_ppc.h" @@ -1355,3 +1356,28 @@ PowerPCCPU *ppc_cpu_init(const char *cpu_model) { return POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, cpu_model)); } + +void ppc_cpu_parse_features(const char *cpu_model) +{ + CPUClass *cc; + ObjectClass *oc; + const char *typename; + gchar **model_pieces; + + model_pieces = g_strsplit(cpu_model, ",", 2); + if (!model_pieces[0]) { + error_report("Invalid/empty CPU model name"); + exit(1); + } + + 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]); + exit(1); + } + + typename = object_class_get_name(oc); + cc = CPU_CLASS(oc); + cc->parse_features(typename, model_pieces[1], &error_fatal); + g_strfreev(model_pieces); +} diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c index 7f22433c8e91..709a779cba7e 100644 --- a/hw/ppc/ppc440_bamboo.c +++ b/hw/ppc/ppc440_bamboo.c @@ -186,6 +186,7 @@ static void bamboo_init(MachineState *machine) if (machine->cpu_model == NULL) { machine->cpu_model = "440EP"; } + ppc_cpu_parse_features(machine->cpu_model); cpu = ppc_cpu_init(machine->cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to initialize CPU!\n"); diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c index d48b61f04910..8cbe50361e86 100644 --- a/hw/ppc/ppc4xx_devs.c +++ b/hw/ppc/ppc4xx_devs.c @@ -56,6 +56,7 @@ PowerPCCPU *ppc4xx_init(const char *cpu_model, CPUPPCState *env; /* init CPUs */ + ppc_cpu_parse_features(cpu_model); cpu = ppc_cpu_init(cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC %s CPU definition\n", diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index e62fe643f492..99409a09f0ef 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -508,6 +508,7 @@ static void ppc_prep_init(MachineState *machine) /* init CPUs */ if (machine->cpu_model == NULL) machine->cpu_model = "602"; + ppc_cpu_parse_features(machine->cpu_model); for (i = 0; i < smp_cpus; i++) { cpu = ppc_cpu_init(machine->cpu_model); if (cpu == NULL) { diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 09600fee19b2..8ca80812f16a 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1815,6 +1815,8 @@ static void ppc_spapr_init(MachineState *machine) machine->cpu_model = kvm_enabled() ? "host" : "POWER7"; } + ppc_cpu_parse_features(machine->cpu_model); + if (smc->dr_cpu_enabled) { char *type = spapr_get_cpu_core_type(machine->cpu_model); diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index 7e4445b6879a..a19dd17addda 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -96,6 +96,7 @@ static PowerPCCPU *ppc440_init_xilinx(ram_addr_t *ram_size, CPUPPCState *env; qemu_irq *irqs; + ppc_cpu_parse_features(cpu_model); cpu = ppc_cpu_init(cpu_model); if (cpu == NULL) { fprintf(stderr, "Unable to initialize CPU!\n"); diff --git a/include/hw/ppc/ppc.h b/include/hw/ppc/ppc.h index a4db1db82e1b..2ed063e09bec 100644 --- a/include/hw/ppc/ppc.h +++ b/include/hw/ppc/ppc.h @@ -107,4 +107,5 @@ enum { void ppc_booke_timers_init(PowerPCCPU *cpu, uint32_t freq, uint32_t flags); PowerPCCPU *ppc_cpu_init(const char *cpu_model); +void ppc_cpu_parse_features(const char *cpu_model); #endif