From patchwork Thu Jul 20 04:11:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharata B Rao X-Patchwork-Id: 9853737 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 1556F60392 for ; Thu, 20 Jul 2017 04:13:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0EB628704 for ; Thu, 20 Jul 2017 04:13:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E562C2874E; Thu, 20 Jul 2017 04:13:19 +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 6B49328704 for ; Thu, 20 Jul 2017 04:13:19 +0000 (UTC) Received: from localhost ([::1]:36000 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY2py-0004dL-2I for patchwork-qemu-devel@patchwork.kernel.org; Thu, 20 Jul 2017 00:13:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY2p6-0004XB-Pp for qemu-devel@nongnu.org; Thu, 20 Jul 2017 00:12:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dY2p1-0006Ti-Vz for qemu-devel@nongnu.org; Thu, 20 Jul 2017 00:12:24 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60599) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dY2p1-0006TB-MB for qemu-devel@nongnu.org; Thu, 20 Jul 2017 00:12:19 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6K48rMZ059671 for ; Thu, 20 Jul 2017 00:12:17 -0400 Received: from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140]) by mx0a-001b2d01.pphosted.com with ESMTP id 2btc8ft8q9-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 20 Jul 2017 00:12:17 -0400 Received: from localhost by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 20 Jul 2017 14:12:15 +1000 Received: from d23relay09.au.ibm.com (202.81.31.228) by e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 20 Jul 2017 14:12:13 +1000 Received: from d23av05.au.ibm.com (d23av05.au.ibm.com [9.190.234.119]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6K4C4WM31391826; Thu, 20 Jul 2017 14:12:12 +1000 Received: from d23av05.au.ibm.com (localhost [127.0.0.1]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v6K4BeHQ003194; Thu, 20 Jul 2017 14:11:40 +1000 Received: from bharata.in.ibm.com ([9.124.208.232]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v6K4Bc92002791; Thu, 20 Jul 2017 14:11:39 +1000 From: Bharata B Rao To: qemu-devel@nongnu.org Date: Thu, 20 Jul 2017 09:41:19 +0530 X-Mailer: git-send-email 2.7.4 X-TM-AS-MML: disable x-cbid: 17072004-0044-0000-0000-000002801D19 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17072004-0045-0000-0000-00000711210B Message-Id: <1500523879-23860-1-git-send-email-bharata@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-20_02:, , 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-1706020000 definitions=main-1707200067 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [FIX PATCH v1] spapr: Fix QEMU abort during memory unplug 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: danielhb@linux.vnet.ibm.com, 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 Commit 0cffce56 (hw/ppc/spapr.c: adding pending_dimm_unplugs to sPAPRMachineState) introduced a new way to track pending LMBs of DIMM device that is marked for removal. Since this commit we can hit the assert in spapr_pending_dimm_unplugs_add() in the following situation: - DIMM device removal fails as the guest doesn't allow the removal. - Subsequent attempt to remove the same DIMM would hit the assert as the corresponding sPAPRDIMMState is still part of the pending_dimm_unplugs list. Fix this by removing the assert and conditionally adding the sPAPRDIMMState to pending_dimm_unplugs list only when it is not already present. Fixes: 0cffce56ae3501c5783d779f97993ce478acf856 Signed-off-by: Bharata B Rao Reviewed-by: Daniel Barboza --- Changes in v1: - Added comment (David Gibson) - Ensured we free sPAPRDIMMState when corresonding entry already exists (Daniel Henrique Barboza) Daniel had shown another alternative, we can switch over to that if preferred. hw/ppc/spapr.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 1cb09e7..c6091e2 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2853,8 +2853,17 @@ static sPAPRDIMMState *spapr_pending_dimm_unplugs_find(sPAPRMachineState *s, static void spapr_pending_dimm_unplugs_add(sPAPRMachineState *spapr, sPAPRDIMMState *dimm_state) { - g_assert(!spapr_pending_dimm_unplugs_find(spapr, dimm_state->dimm)); - QTAILQ_INSERT_HEAD(&spapr->pending_dimm_unplugs, dimm_state, next); + /* + * If this request is for a DIMM whose removal had failed earlier + * (due to guest's refusal to remove the LMBs), we would have this + * dimm_state already in the pending_dimm_unplugs list. In that + * case don't add again. + */ + if (!spapr_pending_dimm_unplugs_find(spapr, dimm_state->dimm)) { + QTAILQ_INSERT_HEAD(&spapr->pending_dimm_unplugs, dimm_state, next); + } else { + g_free(dimm_state); + } } static void spapr_pending_dimm_unplugs_remove(sPAPRMachineState *spapr,