From nobody Sat May 4 20:25:25 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.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 1494848607734938.538672164823; Mon, 15 May 2017 04:43:27 -0700 (PDT) Received: from localhost ([::1]:36112 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAEPO-000714-B1 for importer@patchew.org; Mon, 15 May 2017 07:43:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41533) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAELW-0003rw-W8 for qemu-devel@nongnu.org; Mon, 15 May 2017 07:39:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dAELT-00024d-1a for qemu-devel@nongnu.org; Mon, 15 May 2017 07:39:27 -0400 Received: from 8.mo69.mail-out.ovh.net ([46.105.56.233]:38823) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dAELS-00023W-Rd for qemu-devel@nongnu.org; Mon, 15 May 2017 07:39:22 -0400 Received: from player699.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo69.mail-out.ovh.net (Postfix) with ESMTP id 7487C1FC57 for ; Mon, 15 May 2017 13:39:21 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player699.ha.ovh.net (Postfix) with ESMTPA id 2C5CA240076; Mon, 15 May 2017 13:39:17 +0200 (CEST) From: Greg Kurz To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Date: Mon, 15 May 2017 13:39:16 +0200 Message-ID: <149484835694.20089.2114938170632779266.stgit@bahia.lan> In-Reply-To: <149484833874.20089.4164801378197848306.stgit@bahia.lan> References: <149484833874.20089.4164801378197848306.stgit@bahia.lan> 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: 10622021199451625867 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeljedrudefgdegfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.56.233 Subject: [Qemu-devel] [PATCH 1/6] ppc/xics: simplify prototype of xics_spapr_init() 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: David Gibson , Cedric Le Goater , Bharata B Rao Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 This function only does hypercall and RTAS-call registration, and thus never returns an error. This patch adapt the prototype to reflect that. Signed-off-by: Greg Kurz Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/intc/xics_spapr.c | 3 +-- hw/ppc/spapr.c | 2 +- include/hw/ppc/xics.h | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index f05308b897f2..d98ea8b13068 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -229,7 +229,7 @@ static void rtas_int_on(PowerPCCPU *cpu, sPAPRMachineSt= ate *spapr, rtas_st(rets, 0, RTAS_OUT_SUCCESS); } =20 -int xics_spapr_init(sPAPRMachineState *spapr, Error **errp) +void xics_spapr_init(sPAPRMachineState *spapr) { /* Registration of global state belongs into realize */ spapr_rtas_register(RTAS_IBM_SET_XIVE, "ibm,set-xive", rtas_set_xive); @@ -243,7 +243,6 @@ int xics_spapr_init(sPAPRMachineState *spapr, Error **e= rrp) spapr_register_hypercall(H_XIRR_X, h_xirr_x); spapr_register_hypercall(H_EOI, h_eoi); spapr_register_hypercall(H_IPOLL, h_ipoll); - return 0; } =20 #define ICS_IRQ_FREE(ics, srcno) \ diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 1b7cadab0cdf..abfb99b71b7d 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -139,7 +139,7 @@ static void xics_system_init(MachineState *machine, int= nr_irqs, Error **errp) } =20 if (!spapr->ics) { - xics_spapr_init(spapr, errp); + xics_spapr_init(spapr); spapr->icp_type =3D TYPE_ICP; spapr->ics =3D spapr_ics_create(spapr, TYPE_ICS_SIMPLE, nr_irqs, e= rrp); } diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 05e6acbb3533..d6cb51f3ad5d 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -206,6 +206,6 @@ void icp_resend(ICPState *ss); typedef struct sPAPRMachineState sPAPRMachineState; =20 int xics_kvm_init(sPAPRMachineState *spapr, Error **errp); -int xics_spapr_init(sPAPRMachineState *spapr, Error **errp); +void xics_spapr_init(sPAPRMachineState *spapr); =20 #endif /* XICS_H */ From nobody Sat May 4 20:25:25 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.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 1494848487739266.57750156649763; Mon, 15 May 2017 04:41:27 -0700 (PDT) Received: from localhost ([::1]:36105 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAENQ-0005Cb-L0 for importer@patchew.org; Mon, 15 May 2017 07:41:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAELg-00040h-Je for qemu-devel@nongnu.org; Mon, 15 May 2017 07:39:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dAELc-0002Bj-LP for qemu-devel@nongnu.org; Mon, 15 May 2017 07:39:36 -0400 Received: from 5.mo69.mail-out.ovh.net ([46.105.43.105]:42279) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dAELc-0002BB-Cx for qemu-devel@nongnu.org; Mon, 15 May 2017 07:39:32 -0400 Received: from player699.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo69.mail-out.ovh.net (Postfix) with ESMTP id 036001FB35 for ; Mon, 15 May 2017 13:39:30 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player699.ha.ovh.net (Postfix) with ESMTPA id B0EBA240091; Mon, 15 May 2017 13:39:26 +0200 (CEST) From: Greg Kurz To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Date: Mon, 15 May 2017 13:39:26 +0200 Message-ID: <149484836649.20089.8174753739169885859.stgit@bahia.lan> In-Reply-To: <149484833874.20089.4164801378197848306.stgit@bahia.lan> References: <149484833874.20089.4164801378197848306.stgit@bahia.lan> 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: 10624554471451105675 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeljedrudefgdegfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.43.105 Subject: [Qemu-devel] [PATCH 2/6] spapr: fix error path of required kernel-irqchip 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: David Gibson , Cedric Le Goater , Bharata B Rao Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 QEMU should exit if the user explicitely asked for kernel-irqchip support and "xics-kvm" initialization fails. The changelog of commit 34f2af3d3edf ("spapr: Clean up misuse of qdev_init() in xics-kvm creation") reads: While there, improve the error message when we can't satisfy an explicit user request for "xics-kvm", and exit(1) instead of abort(). Simplify the abort when we can't create "xics". This patch adds the missing call to exit(). Signed-off-by: Greg Kurz Reviewed-by: C=C3=A9dric Le Goater --- hw/ppc/spapr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index abfb99b71b7d..f477d7b8a210 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -133,6 +133,7 @@ static void xics_system_init(MachineState *machine, int= nr_irqs, Error **errp) if (machine_kernel_irqchip_required(machine) && !spapr->ics) { error_reportf_err(err, "kernel_irqchip requested but unavailable: "= ); + exit(EXIT_FAILURE); } else { error_free(err); } From nobody Sat May 4 20:25:25 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.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 1494848694185609.7288467394225; Mon, 15 May 2017 04:44:54 -0700 (PDT) Received: from localhost ([::1]:36124 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAEQn-0008J3-1q for importer@patchew.org; Mon, 15 May 2017 07:44:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41644) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAELp-00047r-MT for qemu-devel@nongnu.org; Mon, 15 May 2017 07:39:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dAELl-0002Km-RU for qemu-devel@nongnu.org; Mon, 15 May 2017 07:39:45 -0400 Received: from 7.mo69.mail-out.ovh.net ([46.105.50.32]:42137) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dAELl-0002Ju-K4 for qemu-devel@nongnu.org; Mon, 15 May 2017 07:39:41 -0400 Received: from player699.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo69.mail-out.ovh.net (Postfix) with ESMTP id 8A7EF1FBBB for ; Mon, 15 May 2017 13:39:40 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player699.ha.ovh.net (Postfix) with ESMTPA id 40835240078; Mon, 15 May 2017 13:39:36 +0200 (CEST) From: Greg Kurz To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Date: Mon, 15 May 2017 13:39:36 +0200 Message-ID: <149484837602.20089.6188552126304330653.stgit@bahia.lan> In-Reply-To: <149484833874.20089.4164801378197848306.stgit@bahia.lan> References: <149484833874.20089.4164801378197848306.stgit@bahia.lan> 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: 10627369222850976139 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeljedrudefgdegfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.50.32 Subject: [Qemu-devel] [PATCH 3/6] spapr: fix error reporting in xics_system_init() 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: David Gibson , Cedric Le Goater , Bharata B Rao Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 The xics_system_init() function passes its errp argument to xics_kvm_init(). If the call fails and the user requested in-kernel irqchip, it then ends up passing a NULL Error * to error_reportf_err() and the error message is silently dropped. Passing an errp argument is generally wrong, unless you really just need to convey an error to the caller. This patch converts xics_system_init() to *only* pass a pointer to its own Error * and then to propagate it with error_propagate(), as recommended in error.h. The local_err name is used for consistency with the rest of the code. Signed-off-by: Greg Kurz Reviewed-by: C=C3=A9dric Le Goater --- hw/ppc/spapr.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index f477d7b8a210..44f7dc7f40e9 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -121,29 +121,32 @@ static ICSState *spapr_ics_create(sPAPRMachineState *= spapr, static void xics_system_init(MachineState *machine, int nr_irqs, Error **e= rrp) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(machine); + Error *local_err =3D NULL; =20 if (kvm_enabled()) { - Error *err =3D NULL; - if (machine_kernel_irqchip_allowed(machine) && - !xics_kvm_init(spapr, errp)) { + !xics_kvm_init(spapr, &local_err)) { spapr->icp_type =3D TYPE_KVM_ICP; - spapr->ics =3D spapr_ics_create(spapr, TYPE_ICS_KVM, nr_irqs, = &err); + spapr->ics =3D spapr_ics_create(spapr, TYPE_ICS_KVM, nr_irqs, + &local_err); } if (machine_kernel_irqchip_required(machine) && !spapr->ics) { - error_reportf_err(err, + error_reportf_err(local_err, "kernel_irqchip requested but unavailable: "= ); exit(EXIT_FAILURE); } else { - error_free(err); + error_free(local_err); } } =20 if (!spapr->ics) { xics_spapr_init(spapr); spapr->icp_type =3D TYPE_ICP; - spapr->ics =3D spapr_ics_create(spapr, TYPE_ICS_SIMPLE, nr_irqs, e= rrp); + spapr->ics =3D spapr_ics_create(spapr, TYPE_ICS_SIMPLE, nr_irqs, + &local_err); } + + error_propagate(errp, local_err); } =20 static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu, From nobody Sat May 4 20:25:25 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.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 1494848510235601.3194655406559; Mon, 15 May 2017 04:41:50 -0700 (PDT) Received: from localhost ([::1]:36107 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAENm-0005Td-Vv for importer@patchew.org; Mon, 15 May 2017 07:41:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41715) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAELz-0004Ef-7Y for qemu-devel@nongnu.org; Mon, 15 May 2017 07:39:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dAELv-0002Px-A6 for qemu-devel@nongnu.org; Mon, 15 May 2017 07:39:55 -0400 Received: from 6.mo69.mail-out.ovh.net ([46.105.50.107]:53750) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dAELv-0002PO-3j for qemu-devel@nongnu.org; Mon, 15 May 2017 07:39:51 -0400 Received: from player699.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo69.mail-out.ovh.net (Postfix) with ESMTP id 1C5EA1FBF7 for ; Mon, 15 May 2017 13:39:50 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player699.ha.ovh.net (Postfix) with ESMTPA id C5F96240076; Mon, 15 May 2017 13:39:45 +0200 (CEST) From: Greg Kurz To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Date: Mon, 15 May 2017 13:39:45 +0200 Message-ID: <149484838558.20089.5029926585755792842.stgit@bahia.lan> In-Reply-To: <149484833874.20089.4164801378197848306.stgit@bahia.lan> References: <149484833874.20089.4164801378197848306.stgit@bahia.lan> 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: 10630183971462879627 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeljedrudefgdegfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.50.107 Subject: [Qemu-devel] [PATCH 4/6] spapr: sanitize error handling in spapr_ics_create() 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: David Gibson , Cedric Le Goater , Bharata B Rao Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 The spapr_ics_create() function handles errors in a rather convoluted way, with two local Error * variables. Moreover, failing to parent the ICS object to the machine should be considered as a bug but it is currently ignored. This patch addresses both issues. Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 44f7dc7f40e9..c53989bb10b1 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -101,21 +101,26 @@ static ICSState *spapr_ics_create(sPAPRMachineState *= spapr, const char *type_ics, int nr_irqs, Error **errp) { - Error *err =3D NULL, *local_err =3D NULL; + Error *local_err =3D NULL; Object *obj; =20 obj =3D object_new(type_ics); - object_property_add_child(OBJECT(spapr), "ics", obj, NULL); + object_property_add_child(OBJECT(spapr), "ics", obj, &error_abort); object_property_add_const_link(obj, "xics", OBJECT(spapr), &error_abor= t); - object_property_set_int(obj, nr_irqs, "nr-irqs", &err); + object_property_set_int(obj, nr_irqs, "nr-irqs", &local_err); + if (local_err) { + goto error; + } object_property_set_bool(obj, true, "realized", &local_err); - error_propagate(&err, local_err); - if (err) { - error_propagate(errp, err); - return NULL; + if (local_err) { + goto error; } =20 return ICS_SIMPLE(obj); + +error: + error_propagate(errp, local_err); + return NULL; } =20 static void xics_system_init(MachineState *machine, int nr_irqs, Error **e= rrp) From nobody Sat May 4 20:25:25 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.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 1494848782330191.6937262493334; Mon, 15 May 2017 04:46:22 -0700 (PDT) Received: from localhost ([::1]:36134 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAESD-0000hH-5s for importer@patchew.org; Mon, 15 May 2017 07:46:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41775) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAEM9-0004Ms-2k for qemu-devel@nongnu.org; Mon, 15 May 2017 07:40:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dAEM5-0002SJ-5U for qemu-devel@nongnu.org; Mon, 15 May 2017 07:40:05 -0400 Received: from 9.mo69.mail-out.ovh.net ([46.105.56.78]:46799) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dAEM4-0002S2-VB for qemu-devel@nongnu.org; Mon, 15 May 2017 07:40:01 -0400 Received: from player699.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo69.mail-out.ovh.net (Postfix) with ESMTP id 9CC7D1FC04 for ; Mon, 15 May 2017 13:39:59 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player699.ha.ovh.net (Postfix) with ESMTPA id 5716624006C; Mon, 15 May 2017 13:39:55 +0200 (CEST) From: Greg Kurz To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Date: Mon, 15 May 2017 13:39:55 +0200 Message-ID: <149484839512.20089.2730407279712230463.stgit@bahia.lan> In-Reply-To: <149484833874.20089.4164801378197848306.stgit@bahia.lan> References: <149484833874.20089.4164801378197848306.stgit@bahia.lan> 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: 10632717245560166795 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeljedrudefgdegfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.56.78 Subject: [Qemu-devel] [PATCH 5/6] spapr-cpu-core: release ICP object when realization 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: David Gibson , Cedric Le Goater , Bharata B Rao Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 While here we introduce a single error path to avoid code duplication. Signed-off-by: Greg Kurz --- hw/ppc/spapr_cpu_core.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 4389ef4c2aef..63d160f7e010 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -147,25 +147,25 @@ static void spapr_cpu_core_realize_child(Object *chil= d, Error **errp) object_property_add_const_link(obj, "xics", OBJECT(spapr), &error_abor= t); object_property_set_bool(obj, true, "realized", &local_err); if (local_err) { - error_propagate(errp, local_err); - return; + goto error; } =20 object_property_set_bool(child, true, "realized", &local_err); if (local_err) { - object_unparent(obj); - error_propagate(errp, local_err); - return; + goto error; } =20 spapr_cpu_init(spapr, cpu, &local_err); if (local_err) { - object_unparent(obj); - error_propagate(errp, local_err); - return; + goto error; } =20 xics_cpu_setup(XICS_FABRIC(spapr), cpu, ICP(obj)); + return; + +error: + object_unparent(obj); + error_propagate(errp, local_err); } =20 static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) From nobody Sat May 4 20:25:25 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.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 1494848568938596.5508343571178; Mon, 15 May 2017 04:42:48 -0700 (PDT) Received: from localhost ([::1]:36110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAEOl-0006NL-90 for importer@patchew.org; Mon, 15 May 2017 07:42:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAEMF-0004Xo-JJ for qemu-devel@nongnu.org; Mon, 15 May 2017 07:40:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dAEME-0002aP-Im for qemu-devel@nongnu.org; Mon, 15 May 2017 07:40:11 -0400 Received: from 10.mo69.mail-out.ovh.net ([46.105.73.241]:43950) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dAEME-0002Zk-9T for qemu-devel@nongnu.org; Mon, 15 May 2017 07:40:10 -0400 Received: from player699.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo69.mail-out.ovh.net (Postfix) with ESMTP id 3B3601FC04 for ; Mon, 15 May 2017 13:40:09 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player699.ha.ovh.net (Postfix) with ESMTPA id DEDC5240084; Mon, 15 May 2017 13:40:04 +0200 (CEST) From: Greg Kurz To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Date: Mon, 15 May 2017 13:40:04 +0200 Message-ID: <149484840466.20089.893964776019028654.stgit@bahia.lan> In-Reply-To: <149484833874.20089.4164801378197848306.stgit@bahia.lan> References: <149484833874.20089.4164801378197848306.stgit@bahia.lan> 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: 10635531996790102411 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeljedrudefgdegfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.73.241 Subject: [Qemu-devel] [PATCH 6/6] spapr: fix migration of ICP objects from/to older QEMU 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: David Gibson , Cedric Le Goater , Bharata B Rao Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Commit 5bc8d26de20c ("spapr: allocate the ICPState object from under sPAPRCPUCore") moved ICP objects from the machine to CPU cores. This is an improvement since we no longer allocate ICP objects that will never be used. But it has the side-effect of breaking migration of older machine types from older QEMU versions. This patch introduces a compat flag in the sPAPR machine class so that all pseries machine up to 2.9 go on with the previous behavior of pre-allocating ICP objects. While here, we also ensure that object_property_add_child() errors cause QEMU to abort for newer machines. Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 36 ++++++++++++++++++++++++++++++++++++ hw/ppc/spapr_cpu_core.c | 28 ++++++++++++++++++++-------- include/hw/ppc/spapr.h | 2 ++ 3 files changed, 58 insertions(+), 8 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index c53989bb10b1..ab3683bcd677 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -126,6 +126,7 @@ error: static void xics_system_init(MachineState *machine, int nr_irqs, Error **e= rrp) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(machine); + sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); Error *local_err =3D NULL; =20 if (kvm_enabled()) { @@ -151,6 +152,38 @@ static void xics_system_init(MachineState *machine, in= t nr_irqs, Error **errp) &local_err); } =20 + if (!spapr->ics) { + goto out; + } + + if (smc->must_pre_allocate_icps) { + int smt =3D kvmppc_smt_threads(); + int nr_servers =3D DIV_ROUND_UP(max_cpus * smt, smp_threads); + int i; + + spapr->legacy_icps =3D g_malloc0(nr_servers * sizeof(ICPState)); + + for (i =3D 0; i < nr_servers; i++) { + void* obj =3D &spapr->legacy_icps[i]; + + object_initialize(obj, sizeof(ICPState), spapr->icp_type); + object_property_add_child(OBJECT(spapr), "icp[*]", obj, + &error_abort); + object_unref(obj); + object_property_add_const_link(obj, "xics", OBJECT(spapr), + &error_abort); + object_property_set_bool(obj, true, "realized", &local_err); + if (local_err) { + while (i--) { + object_unparent(obj); + } + g_free(spapr->legacy_icps); + break; + } + } + } + +out: error_propagate(errp, local_err); } =20 @@ -3256,8 +3289,11 @@ static void spapr_machine_2_9_instance_options(Machi= neState *machine) =20 static void spapr_machine_2_9_class_options(MachineClass *mc) { + sPAPRMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); + spapr_machine_2_10_class_options(mc); SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_9); + smc->must_pre_allocate_icps =3D true; } =20 DEFINE_SPAPR_MACHINE(2_9, "2.9", false); diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 63d160f7e010..5476647efa06 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -119,6 +119,7 @@ static void spapr_cpu_core_unrealizefn(DeviceState *dev= , Error **errp) size_t size =3D object_type_get_instance_size(typename); CPUCore *cc =3D CPU_CORE(dev); int i; + sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); =20 for (i =3D 0; i < cc->nr_threads; i++) { void *obj =3D sc->threads + i * size; @@ -127,7 +128,9 @@ static void spapr_cpu_core_unrealizefn(DeviceState *dev= , Error **errp) PowerPCCPU *cpu =3D POWERPC_CPU(cs); =20 spapr_cpu_destroy(cpu); - object_unparent(cpu->intc); + if (!spapr->legacy_icps) { + object_unparent(cpu->intc); + } cpu_remove_sync(cs); object_unparent(obj); } @@ -142,12 +145,19 @@ static void spapr_cpu_core_realize_child(Object *chil= d, Error **errp) PowerPCCPU *cpu =3D POWERPC_CPU(cs); Object *obj; =20 - obj =3D object_new(spapr->icp_type); - object_property_add_child(OBJECT(cpu), "icp", obj, NULL); - object_property_add_const_link(obj, "xics", OBJECT(spapr), &error_abor= t); - object_property_set_bool(obj, true, "realized", &local_err); - if (local_err) { - goto error; + if (spapr->legacy_icps) { + int index =3D cpu->parent_obj.cpu_index; + + obj =3D OBJECT(&spapr->legacy_icps[index]); + } else { + obj =3D object_new(spapr->icp_type); + object_property_add_child(OBJECT(cpu), "icp", obj, &error_abort); + object_property_add_const_link(obj, "xics", OBJECT(spapr), + &error_abort); + object_property_set_bool(obj, true, "realized", &local_err); + if (local_err) { + goto error; + } } =20 object_property_set_bool(child, true, "realized", &local_err); @@ -164,7 +174,9 @@ static void spapr_cpu_core_realize_child(Object *child,= Error **errp) return; =20 error: - object_unparent(obj); + if (!spapr->legacy_icps) { + object_unparent(obj); + } error_propagate(errp, local_err); } =20 diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 5802f888c39d..72cd5af2679b 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -53,6 +53,7 @@ struct sPAPRMachineClass { bool dr_lmb_enabled; /* enable dynamic-reconfig/hotplug of LMBs = */ bool use_ohci_by_default; /* use USB-OHCI instead of XHCI */ const char *tcg_default_cpu; /* which (TCG) CPU to simulate by default= */ + bool must_pre_allocate_icps; /* only for pseries-2.9 and older */ void (*phb_placement)(sPAPRMachineState *spapr, uint32_t index, uint64_t *buid, hwaddr *pio,=20 hwaddr *mmio32, hwaddr *mmio64, @@ -109,6 +110,7 @@ struct sPAPRMachineState { MemoryHotplugState hotplug_memory; =20 const char *icp_type; + ICPState *legacy_icps; }; =20 #define H_SUCCESS 0