From patchwork Wed Jul 6 17:49:30 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: 9216779 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 6B2186048B for ; Wed, 6 Jul 2016 17:50:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F5C12818B for ; Wed, 6 Jul 2016 17:50:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DFAB28179; Wed, 6 Jul 2016 17:50:12 +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 AF51928179 for ; Wed, 6 Jul 2016 17:50:10 +0000 (UTC) Received: from localhost ([::1]:35119 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKqxd-0006UB-KY for patchwork-qemu-devel@patchwork.kernel.org; Wed, 06 Jul 2016 13:50:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKqxH-0006TQ-DL for qemu-devel@nongnu.org; Wed, 06 Jul 2016 13:49:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKqxC-0004yr-RA for qemu-devel@nongnu.org; Wed, 06 Jul 2016 13:49:47 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:24770) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKqxC-0004yg-Hn for qemu-devel@nongnu.org; Wed, 06 Jul 2016 13:49:42 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u66HflqD118617 for ; Wed, 6 Jul 2016 13:49:40 -0400 Received: from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140]) by mx0a-001b2d01.pphosted.com with ESMTP id 2415xjstt3-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 06 Jul 2016 13:49:40 -0400 Received: from localhost by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 7 Jul 2016 03:49:38 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 7 Jul 2016 03:49:36 +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 d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 4E1FB2CE8057; Thu, 7 Jul 2016 03:49:36 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u66HnaLG60948612; Thu, 7 Jul 2016 03:49:36 +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 u66HnZqq027759; Thu, 7 Jul 2016 03:49:36 +1000 Received: from bharata.in.ibm.com ([9.79.190.110]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u66HnX0h027744; Thu, 7 Jul 2016 03:49:34 +1000 From: Bharata B Rao To: qemu-devel@nongnu.org Date: Wed, 6 Jul 2016 23:19:30 +0530 X-Mailer: git-send-email 2.7.4 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16070617-0044-0000-0000-000001BE25A1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16070617-0045-0000-0000-000005125202 Message-Id: <1467827370-8808-1-git-send-email-bharata@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-07-06_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1607060152 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v0] spapr: Error out when CPU hotplug is attempted on older pseries machines 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: Bharata B Rao , qemu-ppc@nongnu.org, 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 CPU hotplug and coldplug aren't supported prior to pseries-2.7. query-hotpluggable-cpus and coldplug on older pseries machines are crashing the QEMU. Fix this. - Let query_hotpluggable_cpus return NULL for pseries < 2.7 - spapr_core_pre_plug() should fail hot/cold plug attempts for pseries < 2.7 - spapr_core_plug() should never be called for pseries < 2.7, hence use an assert. Signed-off-by: Bharata B Rao --- Applies on ppc-for-2.7 branch of David's tree. hw/ppc/spapr.c | 5 +++++ hw/ppc/spapr_cpu_core.c | 19 ++++++------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 7f33a1b..e3a7912 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2368,9 +2368,14 @@ static HotpluggableCPUList *spapr_query_hotpluggable_cpus(MachineState *machine) int i; HotpluggableCPUList *head = NULL; sPAPRMachineState *spapr = SPAPR_MACHINE(machine); + sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine); int spapr_max_cores = max_cpus / smp_threads; int smt = kvmppc_smt_threads(); + if (!smc->dr_cpu_enabled) { + return NULL; + } + for (i = 0; i < spapr_max_cores; i++) { HotpluggableCPUList *list_item = g_new0(typeof(*list_item), 1); HotpluggableCPU *cpu_item = g_new0(typeof(*cpu_item), 1); diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 70b6b0b..273207c 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -162,19 +162,12 @@ void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev, int index; int smt = kvmppc_smt_threads(); + g_assert(smc->dr_cpu_enabled); + drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, cc->core_id); index = cc->core_id / smt; spapr->cores[index] = OBJECT(dev); - if (!smc->dr_cpu_enabled) { - /* - * This is a cold plugged CPU core but the machine doesn't support - * DR. So skip the hotplug path ensuring that the core is brought - * up online with out an associated DR connector. - */ - return; - } - g_assert(drc); /* @@ -223,13 +216,13 @@ void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, char *base_core_type = spapr_get_cpu_core_type(machine->cpu_model); const char *type = object_get_typename(OBJECT(dev)); - if (strcmp(base_core_type, type)) { - error_setg(&local_err, "CPU core type should be %s", base_core_type); + if (!smc->dr_cpu_enabled) { + error_setg(&local_err, "CPU hotplug not supported for this machine"); goto out; } - if (!smc->dr_cpu_enabled && dev->hotplugged) { - error_setg(&local_err, "CPU hotplug not supported for this machine"); + if (strcmp(base_core_type, type)) { + error_setg(&local_err, "CPU core type should be %s", base_core_type); goto out; }