From nobody Mon Apr 29 05:10:42 2024 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.zohomail.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 1502126818263853.3441212524232; Mon, 7 Aug 2017 10:26:58 -0700 (PDT) Received: from localhost ([::1]:38624 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1delns-0005m1-Iu for importer@patchew.org; Mon, 07 Aug 2017 13:26:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dells-00045H-Uh for qemu-devel@nongnu.org; Mon, 07 Aug 2017 13:24:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dello-0002DD-19 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 13:24:52 -0400 Received: from 2.mo4.mail-out.ovh.net ([46.105.72.36]:33993) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1delln-0002Cf-Rt for qemu-devel@nongnu.org; Mon, 07 Aug 2017 13:24:47 -0400 Received: from player694.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo4.mail-out.ovh.net (Postfix) with ESMTP id 73E828B487 for ; Mon, 7 Aug 2017 19:24:46 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player694.ha.ovh.net (Postfix) with ESMTPA id 16A0B2C0070; Mon, 7 Aug 2017 19:24:40 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Mon, 07 Aug 2017 19:24:39 +0200 Message-ID: <150212667952.12227.2933198220121691613.stgit@bahia> In-Reply-To: <150212666472.12227.5292551535430570753.stgit@bahia> References: <150212666472.12227.5292551535430570753.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 11699788882413459957 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrkedugdduudehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.72.36 Subject: [Qemu-devel] [for-2.10 PATCH 1/3] spapr_drc: abort if object_property_add_child() 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: Alexey Kardashevskiy , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 object_property_add_child() can only fail in two cases: - the child already has a parent, which shouldn't happen since the DRC was allocated a few lines above - the parent already has a child with the same name, which would mean the caller tries to create a DRC that already exists In both case, this is a QEMU bug and we should abort. Signed-off-by: Greg Kurz --- hw/ppc/spapr_drc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 47d94e782ac2..5260b5d363a0 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -541,7 +541,7 @@ sPAPRDRConnector *spapr_dr_connector_new(Object *owner,= const char *type, drc->owner =3D owner; prop_name =3D g_strdup_printf("dr-connector[%"PRIu32"]", spapr_drc_index(drc)); - object_property_add_child(owner, prop_name, OBJECT(drc), NULL); + object_property_add_child(owner, prop_name, OBJECT(drc), &error_abort); object_property_set_bool(OBJECT(drc), true, "realized", NULL); g_free(prop_name); =20 From nobody Mon Apr 29 05:10:42 2024 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.zohomail.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 1502126819169519.4571358002756; Mon, 7 Aug 2017 10:26:59 -0700 (PDT) Received: from localhost ([::1]:38625 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1delns-0005mB-LU for importer@patchew.org; Mon, 07 Aug 2017 13:26:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1delm4-0004Eh-M1 for qemu-devel@nongnu.org; Mon, 07 Aug 2017 13:25:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dellz-0002Hs-KL for qemu-devel@nongnu.org; Mon, 07 Aug 2017 13:25:04 -0400 Received: from 6.mo4.mail-out.ovh.net ([188.165.36.253]:60933) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dellz-0002HS-ET for qemu-devel@nongnu.org; Mon, 07 Aug 2017 13:24:59 -0400 Received: from player694.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo4.mail-out.ovh.net (Postfix) with ESMTP id 715CA8B4AA for ; Mon, 7 Aug 2017 19:24:58 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player694.ha.ovh.net (Postfix) with ESMTPA id 1411E2C006C; Mon, 7 Aug 2017 19:24:52 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Mon, 07 Aug 2017 19:24:51 +0200 Message-ID: <150212669147.12227.8408662555599046182.stgit@bahia> In-Reply-To: <150212666472.12227.5292551535430570753.stgit@bahia> References: <150212666472.12227.5292551535430570753.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 11703166583968668149 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrkedugdduudehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 188.165.36.253 Subject: [Qemu-devel] [for-2.10 PATCH 2/3] spapr_drc: add Error ** argument to spapr_dr_connector_new() 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: Alexey Kardashevskiy , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 This just allow spapr_dr_connector_new() to propagate errors to its callers. It doesn't change any functionality. Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 4 ++-- hw/ppc/spapr_drc.c | 4 ++-- hw/ppc/spapr_pci.c | 2 +- include/hw/ppc/spapr_drc.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index f7a19720dcdf..2bc3dbc25653 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2023,7 +2023,7 @@ static void spapr_create_lmb_dr_connectors(sPAPRMachi= neState *spapr) =20 addr =3D i * lmb_size + spapr->hotplug_memory.base; spapr_dr_connector_new(OBJECT(spapr), TYPE_SPAPR_DRC_LMB, - addr / lmb_size); + addr / lmb_size, NULL); } } =20 @@ -2118,7 +2118,7 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) =20 if (mc->has_hotpluggable_cpus) { spapr_dr_connector_new(OBJECT(spapr), TYPE_SPAPR_DRC_CPU, - (core_id / smp_threads) * smt); + (core_id / smp_threads) * smt, NULL); } =20 if (i < boot_cores_nr) { diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 5260b5d363a0..061fff41654a 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -532,7 +532,7 @@ static void unrealize(DeviceState *d, Error **errp) } =20 sPAPRDRConnector *spapr_dr_connector_new(Object *owner, const char *type, - uint32_t id) + uint32_t id, Error **errp) { sPAPRDRConnector *drc =3D SPAPR_DR_CONNECTOR(object_new(type)); char *prop_name; @@ -542,7 +542,7 @@ sPAPRDRConnector *spapr_dr_connector_new(Object *owner,= const char *type, prop_name =3D g_strdup_printf("dr-connector[%"PRIu32"]", spapr_drc_index(drc)); object_property_add_child(owner, prop_name, OBJECT(drc), &error_abort); - object_property_set_bool(OBJECT(drc), true, "realized", NULL); + object_property_set_bool(OBJECT(drc), true, "realized", errp); g_free(prop_name); =20 return drc; diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index d84abf1070a0..4b7882e3613d 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1733,7 +1733,7 @@ static void spapr_phb_realize(DeviceState *dev, Error= **errp) if (sphb->dr_enabled) { for (i =3D 0; i < PCI_SLOT_MAX * 8; i++) { spapr_dr_connector_new(OBJECT(phb), TYPE_SPAPR_DRC_PCI, - (sphb->index << 16) | i); + (sphb->index << 16) | i, NULL); } } =20 diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index a7958d0a8d14..8651af2ffae0 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -248,7 +248,7 @@ uint32_t spapr_drc_index(sPAPRDRConnector *drc); sPAPRDRConnectorType spapr_drc_type(sPAPRDRConnector *drc); =20 sPAPRDRConnector *spapr_dr_connector_new(Object *owner, const char *type, - uint32_t id); + uint32_t id, Error **errp); sPAPRDRConnector *spapr_drc_by_index(uint32_t index); sPAPRDRConnector *spapr_drc_by_id(const char *type, uint32_t id); int spapr_drc_populate_dt(void *fdt, int fdt_offset, Object *owner, From nobody Mon Apr 29 05:10:42 2024 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.zohomail.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 1502126957075554.0149512971603; Mon, 7 Aug 2017 10:29:17 -0700 (PDT) Received: from localhost ([::1]:38635 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1delq7-0007mz-Jp for importer@patchew.org; Mon, 07 Aug 2017 13:29:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1delmG-0004S1-Ry for qemu-devel@nongnu.org; Mon, 07 Aug 2017 13:25:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1delmB-0002Uf-Vf for qemu-devel@nongnu.org; Mon, 07 Aug 2017 13:25:16 -0400 Received: from 1.mo4.mail-out.ovh.net ([178.33.248.196]:33436) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1delmB-0002TA-Pg for qemu-devel@nongnu.org; Mon, 07 Aug 2017 13:25:11 -0400 Received: from player694.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo4.mail-out.ovh.net (Postfix) with ESMTP id 65A948B49E for ; Mon, 7 Aug 2017 19:25:10 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player694.ha.ovh.net (Postfix) with ESMTPA id 098782C0072; Mon, 7 Aug 2017 19:25:03 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Mon, 07 Aug 2017 19:25:03 +0200 Message-ID: <150212670348.12227.5534815630591997333.stgit@bahia> In-Reply-To: <150212666472.12227.5292551535430570753.stgit@bahia> References: <150212666472.12227.5292551535430570753.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 11706544284517767669 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrkedugdduudeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.248.196 Subject: [Qemu-devel] [for-2.10 PATCH 3/3] spapr: error out if PHB fails to setup PCI DRCs 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: Alexey Kardashevskiy , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 It is currently possible to start QEMU with two PHBs without using the index property: -device spapr-pci-host-bridge,id=3Dpci1,\ buid=3D0x800000020000001,\ liobn=3D0x80000100,\ liobn64=3D0x80000101,\ mem_win_addr=3D0x200100000000,\ mem64_win_addr=3D0x220000000000,\ io_win_addr=3D0x200000010000 \ -device spapr-pci-host-bridge,id=3Dpci2,\ buid=3D0x800000020000002,\ liobn=3D0x80000200,\ liobn64=3D0x80000201,\ mem_win_addr=3D0x200180000000,\ mem64_win_addr=3D0x230000000000,\ io_win_addr=3D0x200000020000 \ Each PHB has its index property equal to -1. As a consequence, each PHB will want to create PCI DRCs with the same ids: /* allocate connectors for child PCI devices */ if (sphb->dr_enabled) { for (i =3D 0; i < PCI_SLOT_MAX * 8; i++) { spapr_dr_connector_new(OBJECT(phb), TYPE_SPAPR_DRC_PCI, (sphb->index << 16) | i); } } When DRC objects are added to the composition tree, an alias using the DRC id is created in the "/dr-connector" path. But DRC ids are supposed to be globally unique and the alias creation fails, leaving the DRC object unrealized, which isn't expected by the rest of the DR logic. This has the effect of silently turning-off PCI hotplug support (ie, PCI hotplug no longer works on any PHB and no error message is printed). This bug always existed and would even cause a non-fatal error to be reported on the console (until recent commit bf26ae32a92a). This patch causes the error message to be printed again and QEMU to exit. Signed-off-by: Greg Kurz --- hw/ppc/spapr_pci.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 4b7882e3613d..4a1e6c5f697c 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1731,9 +1731,16 @@ static void spapr_phb_realize(DeviceState *dev, Erro= r **errp) =20 /* allocate connectors for child PCI devices */ if (sphb->dr_enabled) { + Error *local_err =3D NULL; + for (i =3D 0; i < PCI_SLOT_MAX * 8; i++) { spapr_dr_connector_new(OBJECT(phb), TYPE_SPAPR_DRC_PCI, - (sphb->index << 16) | i, NULL); + (sphb->index << 16) | i, &local_err); + if (local_err) { + error_propagate(errp, local_err); + error_prepend(errp, "Failed to create DRC: "); + return; + } } } =20