From patchwork Mon Jun 27 08:40:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharata B Rao X-Patchwork-Id: 9200017 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 645AC6075F for ; Mon, 27 Jun 2016 08:41:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BFFB28575 for ; Mon, 27 Jun 2016 08:41:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40BB928581; Mon, 27 Jun 2016 08:41:28 +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 EE18628575 for ; Mon, 27 Jun 2016 08:41:26 +0000 (UTC) Received: from localhost ([::1]:57180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHS6f-0000Jb-AE for patchwork-qemu-devel@patchwork.kernel.org; Mon, 27 Jun 2016 04:41:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHS6J-0000JD-MF for qemu-devel@nongnu.org; Mon, 27 Jun 2016 04:41:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHS6F-0000vg-Df for qemu-devel@nongnu.org; Mon, 27 Jun 2016 04:41:02 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:24919) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHS6F-0000vV-5h for qemu-devel@nongnu.org; Mon, 27 Jun 2016 04:40:59 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u5R8cv9C080556 for ; Mon, 27 Jun 2016 04:40:58 -0400 Received: from e23smtp01.au.ibm.com (e23smtp01.au.ibm.com [202.81.31.143]) by mx0a-001b2d01.pphosted.com with ESMTP id 23sp40us6w-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 27 Jun 2016 04:40:57 -0400 Received: from localhost by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 27 Jun 2016 18:40:55 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 27 Jun 2016 18:40:53 +1000 X-IBM-Helo: d23dlp01.au.ibm.com X-IBM-MailFrom: bharata@linux.vnet.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org;qemu-ppc@nongnu.org Received: from d23relay07.au.ibm.com (d23relay07.au.ibm.com [9.190.26.37]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 1C4B22CE8054; Mon, 27 Jun 2016 18:40:53 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u5R8erLT9568728; Mon, 27 Jun 2016 18:40:53 +1000 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u5R8eqiW021868; Mon, 27 Jun 2016 18:40:52 +1000 Received: from in.ibm.com ([9.124.35.80]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u5R8emvp021782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Mon, 27 Jun 2016 18:40:50 +1000 Date: Mon, 27 Jun 2016 14:10:48 +0530 From: Bharata B Rao To: David Gibson References: <1467008386-21995-1-git-send-email-bharata@linux.vnet.ibm.com> <20160627065134.GR4242@voom.fritz.box> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160627065134.GR4242@voom.fritz.box> User-Agent: Mutt/1.5.23 (2014-03-12) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16062708-1617-0000-0000-00000131E825 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16062708-1618-0000-0000-000046278C77 Message-Id: <20160627084047.GE27296@in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-06-27_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-1606270099 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 Subject: Re: [Qemu-devel] [PATCH v2 1/1] spapr: Set compat type for CPUs of a core 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: , Reply-To: bharata@linux.vnet.ibm.com Cc: imammedo@redhat.com, thuth@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, ehabkost@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Jun 27, 2016 at 04:51:34PM +1000, David Gibson wrote: > On Mon, Jun 27, 2016 at 11:49:46AM +0530, Bharata B Rao wrote: > > Compat CPU type is typically specified on -cpu cmdline option like: > > -cpu host,compat=power7 or -cpu POWER8E,compat=power7 etc. When > > compat is specified on -cpu cmdline, apply the same to all the > > CPUs that get created as part of CPU core devices. > > > > This patch takes care of compat property that is specified with > > -cpu cmdline option only. The other way to specify this property > > is via -global cmdline option and that usage isn't addressed by > > this patch because -global is already broken for some CPU class > > in PowerPC. There are two issues with using -global on CPU class. > > > > - We specify alias names for CPUs commonly and use of alias names > > won't work with -global seamlessly. For eg, When "-cpu host" is > > specified, the actual CPU type that gets created > > is host-powerpc64-cpu. Hence specifying -global host.compat=power7 > > will not work, so it has to be -global host-powerpc64-cpu.compat=power7. > > > > - PowerPC class names have . (dot) and opts parsing doesn't like it. > > Specifying -global POWER8E_v2.1-powerpc64-cpu.compat=power7 will not > > work as the driver name gets extracted as POWER8E_v2 and hence setting > > of global property fails. > > > > The above two aspects could be considered/fixed separately from this > > patch as this patch allows existing uses of -cpu cpuname,compat= to > > work correctly after the introducton of sPAPR CPU cores. > > > > Signed-off-by: Bharata B Rao > > --- > > Changes in v2: > > - No need for a separate property named compat for cores. > > - Simplified spapr_get_cpu_compat_type() based on David's review. > > I'm still not seeing why this is actually necessary. If the compat > property is specified with -global, it will automatically be > propagated to all threads without core intervention, yes? > > So shouldn't we just make the -cpu fallback effectively set the same > -global property, rather than bouncing it through the core object? Yes and the below patch against Igor's cpu_parse_into_global_props_V2 branch exactly does that for sPAPR. =========== So essentially this uses cc->parse_features() to parse the cpu feature string even before any CPU is initialized and cpu_common_parse_features() will ensure that compat= and any other properties that are part of -cpu will be set globally only once. I am following what Igor did for x86 here. Igor's tree doesn't yet contain PowerPC hotplug patches, hence I couldn't verify this with spapr cpu cores, but I believe that this is all that is required (on top of Igor's cpu features work) to ensure that compat= is applied automatically to all the created CPU threads. However as I note in the patch description of the original patch in this mail, -global is broken for certain cpu type names. -cpu host -global host-powerpc64-cpu.compat=power7 -cpu POWER8 -global POWER8-powerpc64-cpu.compat=power7 work, but -cpu POWER8E -global POWER8E_v2.1-powerpc64-cpu.compat=power7 doesn't since cpu typename has . (dot) and this needs to be fixed. Regards, Bharata. =========== spapr: Parse CPU feature only once From: Bharata B Rao Signed-off-by: Bharata B Rao --- hw/ppc/spapr.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 0636642..be24a37 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1727,6 +1727,10 @@ static void ppc_spapr_init(MachineState *machine) long load_limit, fw_size; bool kernel_le = false; char *filename; + CPUClass *cc; + ObjectClass *oc; + const char *typename; + gchar **model_pieces; msi_nonbroken = true; @@ -1785,6 +1789,24 @@ static void ppc_spapr_init(MachineState *machine) if (machine->cpu_model == NULL) { machine->cpu_model = kvm_enabled() ? "host" : "POWER7"; } + + model_pieces = g_strsplit(machine->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); + for (i = 0; i < smp_cpus; i++) { cpu = cpu_ppc_init(machine->cpu_model); if (cpu == NULL) {