From nobody Mon Feb 9 19:08:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1574074522; cv=none; d=zoho.com; s=zohoarc; b=BFnSqUUK9deShq9wc+GCpf+bHih5tFQgKOAqC+juKYSQVP1IxN+h7wQrah9yYLVmw1AtAZimDnlTvfTMzQAgBSPgQlhRJH4C3wl0dYljUpK5txDJwDzpnoau0FZplKhEdj2LmiK6dddfjP0xeaNtxWorOdWUihZIuWdrV7RIO6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574074522; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=152F3VsBW27j1IFKoVLVwCYJGK5KIGmsJlQ2TDMp0a8=; b=lIyMtDe2VAQuYVa5nmNxV+bMt2vFiNFQt+FMQ1u7+dUiUYUqA2VA8EO7Ox3a/9KSBph4HqjIJs9VjJLvweuc21VfFkZ5barVJSdMCzMLTQIimCrcciExfVMh5VmIe5klc8Y4D6XWtlQxqkPdaWdnbFUUTN7070GBPedwFc4X8CI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574074522851647.1488642543397; Mon, 18 Nov 2019 02:55:22 -0800 (PST) Received: from localhost ([::1]:60478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iWegg-00038c-IC for importer@patchew.org; Mon, 18 Nov 2019 05:55:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42403) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iWef3-0001X0-Lb for qemu-devel@nongnu.org; Mon, 18 Nov 2019 05:53:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iWef2-0004Qg-Ks for qemu-devel@nongnu.org; Mon, 18 Nov 2019 05:53:37 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:39296 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iWef2-0004QS-Gk for qemu-devel@nongnu.org; Mon, 18 Nov 2019 05:53:36 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-46-D9zpYNcJPm-cycoKrSRBNA-1; Mon, 18 Nov 2019 05:53:31 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 84CC7802688; Mon, 18 Nov 2019 10:53:30 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-117-32.ams2.redhat.com [10.36.117.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6D5660856; Mon, 18 Nov 2019 10:53:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574074416; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=152F3VsBW27j1IFKoVLVwCYJGK5KIGmsJlQ2TDMp0a8=; b=dxIWL68QRqTdmH+cc9oQHXjwniL4a7MCLomyLAnstO35kRNXtDMJILui9eMKsTRqivdkDa 1P+Wf1zxgqKWw+mxLWIdZ2QvqU0P7pWiya7nfB9NfVgL1qoSY+EaKc+6hxLbQ7TW/dHwFl EtBwmvKoD4lHRPaomQWh2mUQuu14+eE= From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL v2 3/6] ppc: Skip partially initialized vCPUs in 'info pic' Date: Mon, 18 Nov 2019 11:53:16 +0100 Message-Id: <20191118105319.7658-4-lvivier@redhat.com> In-Reply-To: <20191118105319.7658-1-lvivier@redhat.com> References: <20191118105319.7658-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: D9zpYNcJPm-cycoKrSRBNA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Mark Cave-Ayland , Greg Kurz , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz CPU_FOREACH() can race with vCPU hotplug/unplug on sPAPR machines, ie. we may try to print out info about a vCPU with a NULL presenter pointer. Check that in order to prevent QEMU from crashing. Signed-off-by: Greg Kurz Message-Id: <157192725327.3146912.12047076483178652551.stgit@bahia.lan> Signed-off-by: David Gibson Signed-off-by: Laurent Vivier --- hw/intc/xics.c | 11 ++++++++++- hw/intc/xive.c | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 5f746079be46..e7ac9ba618fa 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -44,7 +44,16 @@ =20 void icp_pic_print_info(ICPState *icp, Monitor *mon) { - int cpu_index =3D icp->cs ? icp->cs->cpu_index : -1; + int cpu_index; + + /* Skip partially initialized vCPUs. This can happen on sPAPR when vCP= Us + * are hot plugged or unplugged. + */ + if (!icp) { + return; + } + + cpu_index =3D icp->cs ? icp->cs->cpu_index : -1; =20 if (!icp->output) { return; diff --git a/hw/intc/xive.c b/hw/intc/xive.c index 952a461d5329..75dce82fb205 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -523,9 +523,18 @@ static const char * const xive_tctx_ring_names[] =3D { =20 void xive_tctx_pic_print_info(XiveTCTX *tctx, Monitor *mon) { - int cpu_index =3D tctx->cs ? tctx->cs->cpu_index : -1; + int cpu_index; int i; =20 + /* Skip partially initialized vCPUs. This can happen on sPAPR when vCP= Us + * are hot plugged or unplugged. + */ + if (!tctx) { + return; + } + + cpu_index =3D tctx->cs ? tctx->cs->cpu_index : -1; + if (kvm_irqchip_in_kernel()) { Error *local_err =3D NULL; =20 --=20 2.23.0