From nobody Wed Nov 5 13:19:04 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1497505544394908.5135085547248; Wed, 14 Jun 2017 22:45:44 -0700 (PDT) Received: from localhost ([::1]:52058 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLNbC-0007Am-3P for importer@patchew.org; Thu, 15 Jun 2017 01:45:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLNaI-0006kR-MQ for qemu-devel@nongnu.org; Thu, 15 Jun 2017 01:44:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dLNaG-00075Z-Vh for qemu-devel@nongnu.org; Thu, 15 Jun 2017 01:44:46 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38478 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dLNaG-00075V-Px for qemu-devel@nongnu.org; Thu, 15 Jun 2017 01:44:44 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v5F5ho05074691 for ; Thu, 15 Jun 2017 01:44:44 -0400 Received: from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148]) by mx0b-001b2d01.pphosted.com with ESMTP id 2b3ep5cj92-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 15 Jun 2017 01:44:43 -0400 Received: from localhost by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Jun 2017 15:44:39 +1000 Received: from d23relay07.au.ibm.com (202.81.31.226) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 15 Jun 2017 15:44:36 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v5F5iadX6684964; Thu, 15 Jun 2017 15:44:36 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v5F5iSf1020643; Thu, 15 Jun 2017 15:44:28 +1000 Received: from bharata.in.ibm.com ([9.124.35.210]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v5F5iQUr020581; Thu, 15 Jun 2017 15:44:27 +1000 From: Bharata B Rao To: qemu-devel@nongnu.org Date: Thu, 15 Jun 2017 11:14:24 +0530 X-Mailer: git-send-email 2.7.4 X-TM-AS-MML: disable x-cbid: 17061505-0040-0000-0000-0000032E97D2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17061505-0041-0000-0000-00000CA8CEC1 Message-Id: <1497505464-12796-1-git-send-email-bharata@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-06-15_02:, , 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-1703280000 definitions=main-1706150099 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [FIX PATCH] target/ppc: Proper cleanup when ppc_cpu_realizefn fails 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If ppc_cpu_realizefn() fails after cpu_exec_realizefn() has been called, we will have to undo whatever cpu_exec_realizefn() did by explicitly calling cpu_exec_unrealizeffn() which is currently missing. Failure to do this proper cleanup will result in CPU which was never fully realized to linger on the cpus list causing SIGSEGV later (for eg when running "info cpus"). Signed-off-by: Bharata B Rao --- target/ppc/translate_init.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index e837cd2..53aff5a 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -9825,14 +9825,14 @@ static void ppc_cpu_realizefn(DeviceState *dev, Err= or **errp) error_append_hint(errp, "Adjust the number of cpus to %d " "or try to raise the number of threads per core\= n", cpu->cpu_dt_id * smp_threads / max_smt); - return; + goto unrealize; } #endif =20 if (tcg_enabled()) { if (ppc_fixup_cpu(cpu) !=3D 0) { error_setg(errp, "Unable to emulate selected CPU with TCG"); - return; + goto unrealize; } } =20 @@ -9841,14 +9841,14 @@ static void ppc_cpu_realizefn(DeviceState *dev, Err= or **errp) error_setg(errp, "CPU does not possess a BookE or 4xx MMU. " "Please use qemu-system-ppc or qemu-system-ppc64 instea= d " "or choose another CPU model."); - return; + goto unrealize; } #endif =20 create_ppc_opcodes(cpu, &local_err); if (local_err !=3D NULL) { error_propagate(errp, local_err); - return; + goto unrealize; } init_ppc_proc(cpu); =20 @@ -10033,6 +10033,10 @@ static void ppc_cpu_realizefn(DeviceState *dev, Er= ror **errp) fflush(stdout); } #endif + return; + +unrealize: + cpu_exec_unrealizefn(cs); } =20 static void ppc_cpu_unrealizefn(DeviceState *dev, Error **errp) --=20 2.7.4