From nobody Tue Feb 10 00:59:56 2026 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; dkim=fail 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 1498820715338605.5565295292149; Fri, 30 Jun 2017 04:05:15 -0700 (PDT) Received: from localhost ([::1]:43735 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQtja-0007tK-SY for importer@patchew.org; Fri, 30 Jun 2017 07:05:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQtRp-00006H-16 for qemu-devel@nongnu.org; Fri, 30 Jun 2017 06:46:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQtRm-0007zY-T8 for qemu-devel@nongnu.org; Fri, 30 Jun 2017 06:46:49 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:48965) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQtRm-0007wS-D5; Fri, 30 Jun 2017 06:46:46 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wzY9p2dtjz9t2K; Fri, 30 Jun 2017 20:46:37 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1498819598; bh=MMcYBhnkOhZTNa+qb8yileQCReyTnA2F9XQdppFFMp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KdJOEHKNcU1e+p6LoTWdANxod5gVqXkban9DSvV8UHu75K+fDpr1zTsMMARDDZEgI /BohV0u8y828u5rPP8ty3cOKcw3kB0AhZlmSGahUZOzQtJ7kWZhFho+J4lNM4Cq1Zn 2zZJmj/+V5/4lZcdCNHBBJL7AZJgzpqMEh7cxmI4= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 30 Jun 2017 20:46:23 +1000 Message-Id: <20170630104632.27942-13-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170630104632.27942-1-david@gibson.dropbear.id.au> References: <20170630104632.27942-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 12/21] 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: lvivier@redhat.com, thuth@redhat.com, qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.org, Bharata B Rao , sbobroff@redhat.com, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Bharata B Rao 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 Reviewed-by: Greg Kurz Signed-off-by: David Gibson --- 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 ee84044..783bf98 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.9.4