From patchwork Mon Jun 27 06:19:46 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: 9199923 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 6BD7260757 for ; Mon, 27 Jun 2016 06:20:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A77A28336 for ; Mon, 27 Jun 2016 06:20:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EA3E2853C; Mon, 27 Jun 2016 06:20:35 +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 83E8928336 for ; Mon, 27 Jun 2016 06:20:34 +0000 (UTC) Received: from localhost ([::1]:56679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHPuK-00058E-M4 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 27 Jun 2016 02:20:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHPtu-000567-7t for qemu-devel@nongnu.org; Mon, 27 Jun 2016 02:20:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHPtp-0006uq-U5 for qemu-devel@nongnu.org; Mon, 27 Jun 2016 02:20:05 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:36872) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHPtp-0006ud-MI for qemu-devel@nongnu.org; Mon, 27 Jun 2016 02:20:01 -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 u5R6DexZ085166 for ; Mon, 27 Jun 2016 02:20:00 -0400 Received: from e23smtp02.au.ibm.com (e23smtp02.au.ibm.com [202.81.31.144]) by mx0a-001b2d01.pphosted.com with ESMTP id 23sjufusx4-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 27 Jun 2016 02:20:00 -0400 Received: from localhost by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 27 Jun 2016 16:19:57 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp02.au.ibm.com (202.81.31.208) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 27 Jun 2016 16:19:56 +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 d23relay09.au.ibm.com (d23relay09.au.ibm.com [9.185.63.181]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id B98F32CE8059; Mon, 27 Jun 2016 16:19:55 +1000 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u5R6JtMF20840552; Mon, 27 Jun 2016 16:19:55 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u5R6JtCE016116; Mon, 27 Jun 2016 16:19:55 +1000 Received: from bharata.in.ibm.com ([9.124.35.80]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u5R6Jqe0016018; Mon, 27 Jun 2016 16:19:53 +1000 From: Bharata B Rao To: qemu-devel@nongnu.org Date: Mon, 27 Jun 2016 11:49:46 +0530 X-Mailer: git-send-email 2.1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16062706-0004-0000-0000-0000017347AF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16062706-0005-0000-0000-0000082730ED Message-Id: <1467008386-21995-1-git-send-email-bharata@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-06-27_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1606270071 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 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: , Cc: thuth@redhat.com, ehabkost@redhat.com, qemu-ppc@nongnu.org, Bharata B Rao , imammedo@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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. v1: https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg06279.html hw/ppc/spapr_cpu_core.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 3a5da09..e8873fd 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -96,6 +96,28 @@ char *spapr_get_cpu_core_type(const char *model) return core_type; } +/* + * Returns the CPU compat type specified in -cpu @model. + */ +static char *spapr_get_cpu_compat_type(const char *model) +{ + char *model_str = g_strdup(model); + char *featurestr, *compat = NULL; + + featurestr = model_str ? strtok(model_str, ",") : NULL; + while (featurestr) { + if (!strncmp(featurestr, "compat=", 7)) { + compat = g_strdup(featurestr + 7); + goto out; + } + featurestr = strtok(NULL, ","); + } + +out: + g_free(model_str); + return compat; +} + static void spapr_core_release(DeviceState *dev, void *opaque) { sPAPRCPUCore *sc = SPAPR_CPU_CORE(OBJECT(dev)); @@ -285,6 +307,8 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) CPUCore *cc = CPU_CORE(OBJECT(dev)); const char *typename = object_class_get_name(sc->cpu_class); size_t size = object_type_get_instance_size(typename); + MachineState *machine = MACHINE(qdev_get_machine()); + char *compat = spapr_get_cpu_compat_type(machine->cpu_model); Error *local_err = NULL; Object *obj; int i; @@ -300,11 +324,18 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) if (local_err) { goto err; } + if (compat) { + object_property_set_str(obj, compat, "compat", &local_err); + if (local_err) { + goto err; + } + } } object_child_foreach(OBJECT(dev), spapr_cpu_core_realize_child, &local_err); if (local_err) { goto err; } else { + g_free(compat); return; } @@ -315,6 +346,7 @@ err: i--; } g_free(sc->threads); + g_free(compat); error_propagate(errp, local_err); }