From patchwork Wed Aug 10 19:08:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 657857 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 3s8gs92NkZz9ttq for ; Thu, 11 Aug 2016 05:17:48 +1000 (AEST) Received: from localhost ([::1]:43394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXZ0b-0007KE-Q9 for incoming@patchwork.ozlabs.org; Wed, 10 Aug 2016 15:17:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXYre-0005v2-1W for qemu-devel@nongnu.org; Wed, 10 Aug 2016 15:08:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXYrY-0001cA-15 for qemu-devel@nongnu.org; Wed, 10 Aug 2016 15:08:28 -0400 Received: from 10.mo173.mail-out.ovh.net ([46.105.74.148]:53575) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXYrX-0001bt-Ma for qemu-devel@nongnu.org; Wed, 10 Aug 2016 15:08:23 -0400 Received: from player157.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo173.mail-out.ovh.net (Postfix) with ESMTP id BC95DFFCCB1 for ; Wed, 10 Aug 2016 21:08:22 +0200 (CEST) Received: from localhost.localdomain (ARennes-257-1-180-252.w2-13.abo.wanadoo.fr [2.13.187.252]) (Authenticated sender: clg@kaod.org) by player157.ha.ovh.net (Postfix) with ESMTPSA id BBDCA50007E; Wed, 10 Aug 2016 21:08:13 +0200 (CEST) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org Date: Wed, 10 Aug 2016 21:08:01 +0200 Message-Id: <1470856081-28168-1-git-send-email-clg@kaod.org> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Ovh-Tracer-Id: 8909808916985645907 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeluddrtdehgdegjeculddtuddrfeeltddrtddtmdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 46.105.74.148 Subject: [Qemu-devel] [PATCH for 2.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 , Greg Kurz , qemu-devel@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bharata B Rao , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Greg Kurz 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 [clg: only kept the fix for the spapr platform. support for other platform will be added in 2.8 ] Signed-off-by: Cédric Le Goater Tested-by: Bharata B Rao Reviewed-by: Eduardo Habkost --- This is a standalone version of patch 2 from my latest series: https://lists.nongnu.org/archive/html/qemu-devel/2016-07/msg02433.html The only changes are trivial conflict fixes caused by the introduction of ppc_cpu_init by patch 1. --- hw/ppc/ppc.c | 26 ++++++++++++++++++++++++++ hw/ppc/spapr.c | 2 ++ include/hw/ppc/ppc.h | 1 + 3 files changed, 29 insertions(+) Index: qemu-dgibson-for-2.8.git/hw/ppc/ppc.c =================================================================== --- qemu-dgibson-for-2.8.git.orig/hw/ppc/ppc.c +++ qemu-dgibson-for-2.8.git/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" @@ -1350,3 +1351,28 @@ PowerPCCPU *ppc_get_vcpu_by_dt_id(int cp return NULL; } + +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); +} Index: qemu-dgibson-for-2.8.git/hw/ppc/spapr.c =================================================================== --- qemu-dgibson-for-2.8.git.orig/hw/ppc/spapr.c +++ qemu-dgibson-for-2.8.git/hw/ppc/spapr.c @@ -1769,6 +1769,8 @@ static void ppc_spapr_init(MachineState machine->cpu_model = kvm_enabled() ? "host" : "POWER7"; } + ppc_cpu_parse_features(machine->cpu_model); + if (mc->query_hotpluggable_cpus) { char *type = spapr_get_cpu_core_type(machine->cpu_model); Index: qemu-dgibson-for-2.8.git/include/hw/ppc/ppc.h =================================================================== --- qemu-dgibson-for-2.8.git.orig/include/hw/ppc/ppc.h +++ qemu-dgibson-for-2.8.git/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); +void ppc_cpu_parse_features(const char *cpu_model); #endif