From nobody Tue Apr 30 19:33:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1576860796; cv=none; d=zohomail.com; s=zohoarc; b=gdX33fzqyS5ipNt9Pi/WYJ3eRYkyiDErfTqHdfxJcYyCHn4gzclox8AAZpCLbOmKimrCTGc8GRJemX7jdS8dJLLRWUzzOJs9GJ+mcSG2ILJFIwXH1j0iY8+R9jhyrYRtDMbBss887rPOqs2vNaxcMWlltPMYPchQLxz9A6aQiIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576860796; 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=PLF4+MAabFJgFVn9j4eVEYqTxB6aZX3LvhPMApvWzIU=; b=QAl3dKMoK60Ikk2HeJUHvNjT+ARl0zfJeL8+0//4dVqLtB+Jhtgt29WO9SmNlpFt7GO6dTA+DsAxMpb9T95YMLBY4AvPKvR68GyMg4tDxTatyyc7zQAbtmDb2FyKpt3a8KdXFWyGsZhroX1zZQ411TYbqaJQQ4qF+kdmECXwr6Y= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576860796833259.3040594479644; Fri, 20 Dec 2019 08:53:16 -0800 (PST) Received: from localhost ([::1]:59004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiLWc-0006t5-Up for importer@patchew.org; Fri, 20 Dec 2019 11:53:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60274) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiLVH-0005Zr-0n for qemu-devel@nongnu.org; Fri, 20 Dec 2019 11:51:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiLVF-0005Ls-V8 for qemu-devel@nongnu.org; Fri, 20 Dec 2019 11:51:50 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:63328 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 1iiLVF-0005L7-Nc for qemu-devel@nongnu.org; Fri, 20 Dec 2019 11:51:49 -0500 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xBKGRgV2069204 for ; Fri, 20 Dec 2019 11:51:49 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2x0xcdrmpj-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 20 Dec 2019 11:51:49 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Dec 2019 16:51:47 -0000 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.194) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 20 Dec 2019 16:51:44 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xBKGphLs45547956 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Dec 2019 16:51:43 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 269C65204E; Fri, 20 Dec 2019 16:51:43 +0000 (GMT) Received: from bahia.lan (unknown [9.145.169.241]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id E938C52051; Fri, 20 Dec 2019 16:51:42 +0000 (GMT) Subject: [PATCH 1/2] ppc/pnv: Exit gracefully if CPU topology doesn't match the machine capacities From: Greg Kurz To: David Gibson , =?utf-8?q?C=C3=A9dric?= Le Goater Date: Fri, 20 Dec 2019 17:51:42 +0100 In-Reply-To: <157686069624.97184.12603452056634667288.stgit@bahia.lan> References: <157686069624.97184.12603452056634667288.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19122016-0008-0000-0000-00000342FD0C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19122016-0009-0000-0000-00004A631B52 Message-Id: <157686070223.97184.882725559353545017.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-12-20_04:2019-12-17,2019-12-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 spamscore=0 clxscore=1034 bulkscore=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 mlxscore=0 suspectscore=0 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1912200127 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 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: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" QEMU crashes when started with: -machine powernv,num-chips=3D2 -smp cores=3D2 -accel tcg,thread=3Dmulti ERROR: tcg/tcg.c:789:tcg_register_thread: assertion failed: (n < ms->smp.max_cpus) Aborted (core dumped) This happens because the powernv machine creates num-chips * smp.cores CPUs, which might exceed the maximum number of CPUs of the CPU topology as computed by smp_parse(). Check the CPU topology in pnv_set_num_chips(). Signed-off-by: Greg Kurz --- hw/ppc/pnv.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index f77e7ca84ede..f8cf2b6d760f 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1706,7 +1706,8 @@ static void pnv_set_num_chips(Object *obj, Visitor *v= , const char *name, void *opaque, Error **errp) { PnvMachineState *pnv =3D PNV_MACHINE(obj); - uint32_t num_chips; + MachineState *ms =3D MACHINE(pnv); + uint32_t num_chips, num_cpus; Error *local_err =3D NULL; =20 visit_type_uint32(v, name, &num_chips, &local_err); @@ -1724,6 +1725,13 @@ static void pnv_set_num_chips(Object *obj, Visitor *= v, const char *name, return; } =20 + num_cpus =3D num_chips * ms->smp.cores * ms->smp.threads; + if (num_cpus > ms->smp.max_cpus) { + error_setg(errp, "%d chips don't fit in the CPU topology", num_chi= ps); + error_append_hint(errp, "Try -smp sockets=3D%d.\n", num_chips); + return; + } + pnv->num_chips =3D num_chips; } =20 From nobody Tue Apr 30 19:33:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1576860905; cv=none; d=zohomail.com; s=zohoarc; b=gSjfFP3lUzxwPlY5Iw5ohFlS1eMtnxBZK4JgNy5lTcHzKHGpOGN7NPFamDRgEb3Edn3W9tiZpHV6lC3BPeTylYGYsmLv6oRAyD2ZvkeiKfV8e6WlZ4XsoBzrPoZltLchOz90JYjc2rd6FQvsnrGjewxuaqY7DSDsZWeIQU6SFZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576860905; 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=eLA4EDd84Xe7wRm7YFdeSNSu5mlAkiUv6SQcI5deWWE=; b=KBkIoZQp1UZsg6QXHFDFpMK5XTRwjg0V6jeBqB6IH23RrRfIUdOvjEzaieYWYazTm2iLd3Y+iRGa6jvOliIEzBmGDX2DW9rFPBxz43ygGvlD88SHCtVik9Z2s53HfvcJiyvzZz/KsM4y4hCjAtp60M1SI8W3mmV73ZAzIuCGOz0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576860905238959.5974447433357; Fri, 20 Dec 2019 08:55:05 -0800 (PST) Received: from localhost ([::1]:59032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiLYO-00010s-5s for importer@patchew.org; Fri, 20 Dec 2019 11:55:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60587) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiLVL-0005fy-E5 for qemu-devel@nongnu.org; Fri, 20 Dec 2019 11:51:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiLVK-0005RN-A3 for qemu-devel@nongnu.org; Fri, 20 Dec 2019 11:51:55 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:61004 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 1iiLVK-0005Qh-4O for qemu-devel@nongnu.org; Fri, 20 Dec 2019 11:51:54 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xBKGRtK8101801 for ; Fri, 20 Dec 2019 11:51:53 -0500 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2x0ksq7370-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 20 Dec 2019 11:51:53 -0500 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Dec 2019 16:51:51 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 20 Dec 2019 16:51:50 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xBKGpnMq54132760 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Dec 2019 16:51:49 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1E8D64C052; Fri, 20 Dec 2019 16:51:49 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E2DA14C04E; Fri, 20 Dec 2019 16:51:48 +0000 (GMT) Received: from bahia.lan (unknown [9.145.169.241]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 20 Dec 2019 16:51:48 +0000 (GMT) Subject: [PATCH 2/2] ppc/pnv: Use the CPU topology to compute the default number of chips From: Greg Kurz To: David Gibson , =?utf-8?q?C=C3=A9dric?= Le Goater Date: Fri, 20 Dec 2019 17:51:48 +0100 In-Reply-To: <157686069624.97184.12603452056634667288.stgit@bahia.lan> References: <157686069624.97184.12603452056634667288.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19122016-0020-0000-0000-0000039A4E99 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19122016-0021-0000-0000-000021F17D9C Message-Id: <157686070815.97184.16561911770080665569.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-12-20_04:2019-12-17,2019-12-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 spamscore=0 mlxscore=0 malwarescore=0 clxscore=1034 phishscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 adultscore=0 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1912200127 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 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: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Multi TCG mandates the CPU topology to be dimensioned to the actual number of CPUs, depending on the number of chips the user asked for. That is, '-machine num-chips=3DN' should always have a '-smp' companion with a topology that meats the resulting number of CPUs, typically '-smp sockets=3DN'. Simplify the command line for these setups by computing the default number of chips based on the CPU topology, ie. no need to explicitely set "num-chips" anymore. This must be done at machine init because smp_parse() is called after instance init. Signed-off-by: Greg Kurz --- hw/ppc/pnv.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index f8cf2b6d760f..9b777b7084a0 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -768,6 +768,19 @@ static void pnv_init(MachineState *machine) exit(1); } =20 + if (!pnv->num_chips) { + uint32_t num_chips =3D + machine->smp.max_cpus / (machine->smp.cores * machine->smp.thr= eads); + Error *local_err =3D NULL; + + object_property_set_uint(OBJECT(pnv), num_chips, "num-chips", + &local_err); + if (local_err) { + error_report_err(local_err); + exit(1); + } + } + pnv->chips =3D g_new0(PnvChip *, pnv->num_chips); for (i =3D 0; i < pnv->num_chips; i++) { char chip_name[32]; @@ -1722,6 +1735,9 @@ static void pnv_set_num_chips(Object *obj, Visitor *v= , const char *name, */ if (!is_power_of_2(num_chips) || num_chips > 4) { error_setg(errp, "invalid number of chips: '%d'", num_chips); + error_append_hint(errp, + "Set 'num-chips' implicitely with '-smp sockets= =3DN'. " + "Valid values are : 1, 2 or 4.\n"); return; } =20 @@ -1735,12 +1751,6 @@ static void pnv_set_num_chips(Object *obj, Visitor *= v, const char *name, pnv->num_chips =3D num_chips; } =20 -static void pnv_machine_instance_init(Object *obj) -{ - PnvMachineState *pnv =3D PNV_MACHINE(obj); - pnv->num_chips =3D 1; -} - static void pnv_machine_class_props_init(ObjectClass *oc) { object_class_property_add(oc, "num-chips", "uint32", @@ -1874,7 +1884,6 @@ static const TypeInfo types[] =3D { .parent =3D TYPE_MACHINE, .abstract =3D true, .instance_size =3D sizeof(PnvMachineState), - .instance_init =3D pnv_machine_instance_init, .class_init =3D pnv_machine_class_init, .class_size =3D sizeof(PnvMachineClass), .interfaces =3D (InterfaceInfo[]) {