From nobody Fri May 17 17:02:20 2024 Delivered-To: importer@patchew.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=1597078533; cv=none; d=zohomail.com; s=zohoarc; b=fZ6WdbUaOtYjswMBBj7tNHtsNS/Jy64bfKzW19mAsye0TE4XIGeRHm1JUfxLpIKHcQPIKKAqy0+EyyWqP4/LMFESIdVrzcrKjjvlD8h2ng4qWG6Tl03Ga2qlveeGuSrJfSd6vcbIV9/cemyHxUWagFz39AjcgkL/zkNYN28qg8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597078533; 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=0l0SWC7lzDtM+abbvOy1z3dwMFGzq91vNvTqgdD7dgQ=; b=ApNsHGl+3ziGaZ4yJM4QaWJajVQiRd7upuuJQjaGtqVR0QdzbqhboKL0Qn2JHBq6uqVfBJE4t816m5IDlIy7KbAu7AE7I9soRqsH0NKE/cPEPxhQ1YeSgxBGE3wgwyA3oGPVDFgX2/JISZwtKzRQdmKGJE8RgXbwfBzQ7w7yL5E= 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 1597078533659261.66155584954436; Mon, 10 Aug 2020 09:55:33 -0700 (PDT) Received: from localhost ([::1]:48616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5B59-0006P4-9J for importer@patchew.org; Mon, 10 Aug 2020 12:55:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5B3q-0004vF-50 for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:54:10 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:48180 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k5B3n-0000fu-Kj for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:54:09 -0400 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-39-G7oybxA9NOmzDGmOx9D3Sg-1; Mon, 10 Aug 2020 12:54:01 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 41F99106B243; Mon, 10 Aug 2020 16:54:00 +0000 (UTC) Received: from bahia.lan (ovpn-112-38.ams2.redhat.com [10.36.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 698C25D9CD; Mon, 10 Aug 2020 16:53:59 +0000 (UTC) X-MC-Unique: G7oybxA9NOmzDGmOx9D3Sg-1 Subject: [PATCH 01/14] spapr: Simplify error handling in spapr_phb_realize() From: Greg Kurz To: David Gibson Date: Mon, 10 Aug 2020 18:53:58 +0200 Message-ID: <159707843851.1489912.6108405733810934642.stgit@bahia.lan> In-Reply-To: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> References: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> User-Agent: StGit/0.21 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=groug@kaod.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable 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; Received-SPF: softfail client-ip=207.211.31.120; envelope-from=groug@kaod.org; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/10 03:31:01 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action 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, =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The spapr_phb_realize() function has a local_err variable which is used to: 1) check failures of spapr_irq_findone() and spapr_irq_claim() 2) prepend extra information to the error message Recent work from Markus Armbruster highlighted we get better code when testing the return value of a function, rather than setting up all the local_err boiler plate. For similar reasons, it is now preferred to use ERRP_GUARD() and error_prepend() rather than error_propagate_prepend(). Since spapr_irq_findone() and spapr_irq_claim() return negative values in case of failure, do both changes. This is just cleanup, no functional impact. Signed-off-by: Greg Kurz Reviewed-by: Markus Armbruster Reviewed-by: David Gibson --- hw/ppc/spapr_pci.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 363cdb3f7b8d..0a418f1e6711 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1796,6 +1796,7 @@ static void spapr_phb_destroy_msi(gpointer opaque) =20 static void spapr_phb_realize(DeviceState *dev, Error **errp) { + ERRP_GUARD(); /* We don't use SPAPR_MACHINE() in order to exit gracefully if the user * tries to add a sPAPR PHB to a non-pseries machine. */ @@ -1813,7 +1814,6 @@ static void spapr_phb_realize(DeviceState *dev, Error= **errp) uint64_t msi_window_size =3D 4096; SpaprTceTable *tcet; const unsigned windows_supported =3D spapr_phb_windows_supported(sphb); - Error *local_err =3D NULL; =20 if (!spapr) { error_setg(errp, TYPE_SPAPR_PCI_HOST_BRIDGE " needs a pseries mach= ine"); @@ -1964,13 +1964,12 @@ static void spapr_phb_realize(DeviceState *dev, Err= or **errp) =20 /* Initialize the LSI table */ for (i =3D 0; i < PCI_NUM_PINS; i++) { - uint32_t irq =3D SPAPR_IRQ_PCI_LSI + sphb->index * PCI_NUM_PINS + = i; + int irq =3D SPAPR_IRQ_PCI_LSI + sphb->index * PCI_NUM_PINS + i; =20 if (smc->legacy_irq_allocation) { - irq =3D spapr_irq_findone(spapr, &local_err); - if (local_err) { - error_propagate_prepend(errp, local_err, - "can't allocate LSIs: "); + irq =3D spapr_irq_findone(spapr, errp); + if (irq < 0) { + error_prepend(errp, "can't allocate LSIs: "); /* * Older machines will never support PHB hotplug, ie, this= is an * init only path and QEMU will terminate. No need to roll= back. @@ -1979,9 +1978,8 @@ static void spapr_phb_realize(DeviceState *dev, Error= **errp) } } =20 - spapr_irq_claim(spapr, irq, true, &local_err); - if (local_err) { - error_propagate_prepend(errp, local_err, "can't allocate LSIs:= "); + if (spapr_irq_claim(spapr, irq, true, errp) < 0) { + error_prepend(errp, "can't allocate LSIs: "); goto unrealize; } =20 From nobody Fri May 17 17:02:20 2024 Delivered-To: importer@patchew.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=1597078619; cv=none; d=zohomail.com; s=zohoarc; b=mqsjJnZIbjeMbyrW3lr71+nAUtRjCv14dWlKBkoORIi5P2flWkpZgUumq6Ob/ehBPhe5LTCPQ7bjXoaOoc0H5MC+4xnvjQikOiv+KMNfypgvLqiizwD88Y+2YI7FTP9VHkHp6TfPjo/sJzQTUYaGZjCGhWfbv4+Vd1dlhH7yOks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597078619; 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=6Yv1iKESneVxmMpPGoVh58LVSw36k1KcPDiwGT2WXwA=; b=h9p890G06k7dY8Hm97u1ytHBzT4qJuKY/jqdYXsmcNlToSkgKIFClzR4LRiOysRIj98TsLbOQ/t77Y5wlvOLXY2mtfTkjl+g6XTNbzVw4Vg8GVwbxdoKkw1p9PTJQeSX3hYqkcRiedtl4HInb9AI0g7fLyWiCsmxfA2fcMv/tAA= 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 1597078619900754.7328276138811; Mon, 10 Aug 2020 09:56:59 -0700 (PDT) Received: from localhost ([::1]:57176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5B6Y-0001Y4-Jt for importer@patchew.org; Mon, 10 Aug 2020 12:56:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5B3t-00051F-Ak for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:54:13 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:54985 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k5B3r-0000gn-SA for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:54:13 -0400 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-202-dZcfky0SNGCuR5CMkki5tQ-1; Mon, 10 Aug 2020 12:54:08 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3955E80046C; Mon, 10 Aug 2020 16:54:07 +0000 (UTC) Received: from bahia.lan (ovpn-112-38.ams2.redhat.com [10.36.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6260519C4F; Mon, 10 Aug 2020 16:54:06 +0000 (UTC) X-MC-Unique: dZcfky0SNGCuR5CMkki5tQ-1 Subject: [PATCH 02/14] spapr/xive: Rework error handling of kvmppc_xive_cpu_connect() From: Greg Kurz To: David Gibson Date: Mon, 10 Aug 2020 18:54:05 +0200 Message-ID: <159707844549.1489912.4862921680328017645.stgit@bahia.lan> In-Reply-To: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> References: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> User-Agent: StGit/0.21 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable 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; Received-SPF: softfail client-ip=205.139.110.120; envelope-from=groug@kaod.org; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/10 11:00:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action 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, =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Use error_setg_errno() instead of error_setg(strerror()). While here, use -ret instead of errno since kvm_vcpu_enable_cap() returns a negative errno on failure. Use ERRP_GUARD() to ensure that errp can be passed to error_append_hint(), and get rid of the local_err boilerplate. Propagate the return value so that callers may use it as well to check failures. Signed-off-by: Greg Kurz --- hw/intc/spapr_xive_kvm.c | 21 ++++++++++----------- include/hw/ppc/xive.h | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index 82a6f99f022d..aa1a2f915363 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -144,8 +144,9 @@ void kvmppc_xive_cpu_synchronize_state(XiveTCTX *tctx, = Error **errp) } } =20 -void kvmppc_xive_cpu_connect(XiveTCTX *tctx, Error **errp) +int kvmppc_xive_cpu_connect(XiveTCTX *tctx, Error **errp) { + ERRP_GUARD(); SpaprXive *xive =3D SPAPR_XIVE(tctx->xptr); unsigned long vcpu_id; int ret; @@ -154,7 +155,7 @@ void kvmppc_xive_cpu_connect(XiveTCTX *tctx, Error **er= rp) =20 /* Check if CPU was hot unplugged and replugged. */ if (kvm_cpu_is_enabled(tctx->cs)) { - return; + return 0; } =20 vcpu_id =3D kvm_arch_vcpu_id(tctx->cs); @@ -162,20 +163,18 @@ void kvmppc_xive_cpu_connect(XiveTCTX *tctx, Error **= errp) ret =3D kvm_vcpu_enable_cap(tctx->cs, KVM_CAP_PPC_IRQ_XIVE, 0, xive->f= d, vcpu_id, 0); if (ret < 0) { - Error *local_err =3D NULL; - - error_setg(&local_err, - "XIVE: unable to connect CPU%ld to KVM device: %s", - vcpu_id, strerror(errno)); - if (errno =3D=3D ENOSPC) { - error_append_hint(&local_err, "Try -smp maxcpus=3DN with N < %= u\n", + error_setg_errno(errp, -ret, + "XIVE: unable to connect CPU%ld to KVM device", + vcpu_id); + if (ret =3D=3D -ENOSPC) { + error_append_hint(errp, "Try -smp maxcpus=3DN with N < %u\n", MACHINE(qdev_get_machine())->smp.max_cpus); } - error_propagate(errp, local_err); - return; + return ret; } =20 kvm_cpu_enable(tctx->cs); + return 0; } =20 /* diff --git a/include/hw/ppc/xive.h b/include/hw/ppc/xive.h index 2f3c5af810bb..2d87ed43728a 100644 --- a/include/hw/ppc/xive.h +++ b/include/hw/ppc/xive.h @@ -487,7 +487,7 @@ void xive_tctx_ipb_update(XiveTCTX *tctx, uint8_t ring,= uint8_t ipb); =20 int kvmppc_xive_source_reset_one(XiveSource *xsrc, int srcno, Error **errp= ); void kvmppc_xive_source_set_irq(void *opaque, int srcno, int val); -void kvmppc_xive_cpu_connect(XiveTCTX *tctx, Error **errp); +int kvmppc_xive_cpu_connect(XiveTCTX *tctx, Error **errp); void kvmppc_xive_cpu_synchronize_state(XiveTCTX *tctx, Error **errp); void kvmppc_xive_cpu_get_state(XiveTCTX *tctx, Error **errp); void kvmppc_xive_cpu_set_state(XiveTCTX *tctx, Error **errp); From nobody Fri May 17 17:02:20 2024 Delivered-To: importer@patchew.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=1597078549; cv=none; d=zohomail.com; s=zohoarc; b=Z7PGG0sxhvDm7+KPhfYE4VUB3HwIc2u7EDX2mbFZPsl5BlMZnmdUz3icCVvUKf6N+fhHe4vOpKPCWOLw2SztvVQMONov5L6+F3OSfh1skQu7jtNwfThoSGHsv2uVBNkv7hxwjIeUhC0ubY0aauyNmAYeSHEwpVIZeUsjXHZRyDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597078549; 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=buB7oKbW1bOcT2v/kM4eDS0g0J7xWue893Pky63mhYI=; b=Q9oi+nzHgY+1OEdXR1jI5PTLgZClwmrQ9raoXKa16Vynv527eSZrZ/+3EM5/p341gRjLMGtboQrI65JY09NfM8ReHVUtesfAbPuJQRqjtEBm4R3FNx6YagpuCJx5QNWpYsR/2Wu38BO5kaI1M+nQ63LcMIyh2Cw/9dlmY/J0Eoc= 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 1597078549055341.51096248279134; Mon, 10 Aug 2020 09:55:49 -0700 (PDT) Received: from localhost ([::1]:50166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5B5P-00073J-Pz for importer@patchew.org; Mon, 10 Aug 2020 12:55:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5B42-0005Ib-B1 for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:54:22 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:53156 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k5B3z-0000hS-TJ for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:54:21 -0400 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-441-5ZahJmd7NiGx9KDWL06zWQ-1; Mon, 10 Aug 2020 12:54:15 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 79A408015FB; Mon, 10 Aug 2020 16:54:14 +0000 (UTC) Received: from bahia.lan (ovpn-112-38.ams2.redhat.com [10.36.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 506276F12D; Mon, 10 Aug 2020 16:54:13 +0000 (UTC) X-MC-Unique: 5ZahJmd7NiGx9KDWL06zWQ-1 Subject: [PATCH 03/14] spapr/xive: Rework error handling of kvmppc_xive_source_reset() From: Greg Kurz To: David Gibson Date: Mon, 10 Aug 2020 18:54:12 +0200 Message-ID: <159707845245.1489912.9151822670764690034.stgit@bahia.lan> In-Reply-To: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> References: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> User-Agent: StGit/0.21 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=groug@kaod.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable 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; Received-SPF: softfail client-ip=207.211.31.81; envelope-from=groug@kaod.org; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/10 04:13:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action 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, =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Since kvmppc_xive_source_reset_one() has a return value, convert kvmppc_xive_source_reset() to use it for error checking. This allows to get rid of the local_err boiler plate. Propagate the return value so that callers may use it as well to check failures. Signed-off-by: Greg Kurz --- hw/intc/spapr_xive_kvm.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index aa1a2f915363..d801bf5cd11c 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -248,24 +248,25 @@ int kvmppc_xive_source_reset_one(XiveSource *xsrc, in= t srcno, Error **errp) true, errp); } =20 -static void kvmppc_xive_source_reset(XiveSource *xsrc, Error **errp) +static int kvmppc_xive_source_reset(XiveSource *xsrc, Error **errp) { SpaprXive *xive =3D SPAPR_XIVE(xsrc->xive); int i; =20 for (i =3D 0; i < xsrc->nr_irqs; i++) { - Error *local_err =3D NULL; + int ret; =20 if (!xive_eas_is_valid(&xive->eat[i])) { continue; } =20 - kvmppc_xive_source_reset_one(xsrc, i, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; + ret =3D kvmppc_xive_source_reset_one(xsrc, i, errp); + if (ret < 0) { + return ret; } } + + return 0; } =20 /* From nobody Fri May 17 17:02:20 2024 Delivered-To: importer@patchew.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=1597078560; cv=none; d=zohomail.com; s=zohoarc; b=V7xCtgqAj5fQZHVvjopLA6PNOYkO4m/Ys4S2HYyqCt86EhbYa8ueOxdjmubJIzpgo+DlrBIfbsm+vVgO3jM1BcmiC1qid9om3JgVpzj3EnlMrclRfb7ihD7ViFk7NLN1KvgF0bSEXLlymgJ20qJtqQCJ0wU5dCdE58URJd3R5Cc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597078560; 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=xBomt8mkzlegesTGNUTGRDRwID9uD0hPLVtRsl2usF0=; b=mrh7VChT8QajC122uEtEQhshR8s223F/w8Y5lPl27vo5gv3yHtfj3CxHqx5Wo/neNOSxSDY0ryiLuCxjLDno8rinHx4fRKsjHX61jSModYPT0dVi+4p+a++MLqwGWSqU/gQYWSJtufs1PRwR/7G/2ZsToXCHisI/saPEkhH/wLA= 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 1597078560456677.8424302328245; Mon, 10 Aug 2020 09:56:00 -0700 (PDT) Received: from localhost ([::1]:51158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5B5b-0007Ty-6p for importer@patchew.org; Mon, 10 Aug 2020 12:55:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5B49-0005YH-Os for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:54:29 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:34670 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k5B48-0000iR-3n for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:54:29 -0400 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-398-1eOYZTHxNnyVaKWenPKo_A-1; Mon, 10 Aug 2020 12:54:22 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 68BA5106B249; Mon, 10 Aug 2020 16:54:21 +0000 (UTC) Received: from bahia.lan (ovpn-112-38.ams2.redhat.com [10.36.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 919C02DE64; Mon, 10 Aug 2020 16:54:20 +0000 (UTC) X-MC-Unique: 1eOYZTHxNnyVaKWenPKo_A-1 Subject: [PATCH 04/14] spapr/xive: Rework error handling of kvmppc_xive_mmap() From: Greg Kurz To: David Gibson Date: Mon, 10 Aug 2020 18:54:19 +0200 Message-ID: <159707845972.1489912.719896767746375765.stgit@bahia.lan> In-Reply-To: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> References: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> User-Agent: StGit/0.21 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=groug@kaod.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable 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; Received-SPF: softfail client-ip=205.139.110.120; envelope-from=groug@kaod.org; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/10 11:00:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action 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, =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Callers currently check failures of kvmppc_xive_mmap() through the @errp argument, which isn't a recommanded practice. It is preferred to use a return value when possible. Since NULL isn't an invalid address in theory, it seems better to return MAP_FAILED and to teach callers to handle it. Signed-off-by: Greg Kurz --- hw/intc/spapr_xive_kvm.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index d801bf5cd11c..b2a36fd59dae 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -698,6 +698,7 @@ int kvmppc_xive_post_load(SpaprXive *xive, int version_= id) return 0; } =20 +/* Returns MAP_FAILED on error and sets errno */ static void *kvmppc_xive_mmap(SpaprXive *xive, int pgoff, size_t len, Error **errp) { @@ -708,7 +709,6 @@ static void *kvmppc_xive_mmap(SpaprXive *xive, int pgof= f, size_t len, pgoff << page_shift); if (addr =3D=3D MAP_FAILED) { error_setg_errno(errp, errno, "XIVE: unable to set memory mapping"= ); - return NULL; } =20 return addr; @@ -728,6 +728,7 @@ int kvmppc_xive_connect(SpaprInterruptController *intc,= uint32_t nr_servers, size_t tima_len =3D 4ull << TM_SHIFT; CPUState *cs; int fd; + void *addr; =20 /* * The KVM XIVE device already in use. This is the case when @@ -763,11 +764,12 @@ int kvmppc_xive_connect(SpaprInterruptController *int= c, uint32_t nr_servers, /* * 1. Source ESB pages - KVM mapping */ - xsrc->esb_mmap =3D kvmppc_xive_mmap(xive, KVM_XIVE_ESB_PAGE_OFFSET, es= b_len, - &local_err); - if (local_err) { + addr =3D kvmppc_xive_mmap(xive, KVM_XIVE_ESB_PAGE_OFFSET, esb_len, + &local_err); + if (addr =3D=3D MAP_FAILED) { goto fail; } + xsrc->esb_mmap =3D addr; =20 memory_region_init_ram_device_ptr(&xsrc->esb_mmio_kvm, OBJECT(xsrc), "xive.esb-kvm", esb_len, xsrc->esb_m= map); @@ -781,11 +783,13 @@ int kvmppc_xive_connect(SpaprInterruptController *int= c, uint32_t nr_servers, /* * 3. TIMA pages - KVM mapping */ - xive->tm_mmap =3D kvmppc_xive_mmap(xive, KVM_XIVE_TIMA_PAGE_OFFSET, ti= ma_len, - &local_err); - if (local_err) { + addr =3D kvmppc_xive_mmap(xive, KVM_XIVE_TIMA_PAGE_OFFSET, tima_len, + &local_err); + if (addr =3D=3D MAP_FAILED) { goto fail; } + xive->tm_mmap =3D addr; + memory_region_init_ram_device_ptr(&xive->tm_mmio_kvm, OBJECT(xive), "xive.tima", tima_len, xive->tm_mmap= ); memory_region_add_subregion_overlap(&xive->tm_mmio, 0, From nobody Fri May 17 17:02:20 2024 Delivered-To: importer@patchew.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=1597078718; cv=none; d=zohomail.com; s=zohoarc; b=mtYQQBfOdqgQeACkd+gLP5uuNWtQRt2484Kx+Buh0IZUGjm+9+1jVdZMeG/JC20phirfjWK/ge5aEDpLRK8CM0igRvfrZ8d1vaIV1oTit2ZDlnEnknMd7eRduliusbI9Bb38UaEZ3VvyZWCp8EluwmKcD1i5EC0urNV0xslPKzE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597078718; 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=TYzQzVAXbZi2Fhs9u1RqMKHVYwP5oM3MeI3H3IMkjZ0=; b=hAfUZH76wutnKt85JODEFcX7WivpAUesiV5wo4rkVe5lPqqIIIfRV5EgLWEOj45E7vzp/37EUiAd4+cPHVaBSzSQreAdL2k9yJCl2SM34+KZgD2KzWnXCWYIVnf8SJsrhsntDGPboo7zUL2WqWUKPTcJz/sUPD7iJtKxKeFXrXo= 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 1597078718468445.84223405217494; Mon, 10 Aug 2020 09:58:38 -0700 (PDT) Received: from localhost ([::1]:37340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5B88-0004xq-I1 for importer@patchew.org; Mon, 10 Aug 2020 12:58:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5B4H-0005sW-N5 for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:54:37 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:26947 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k5B4G-0000kL-1v for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:54:37 -0400 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-164-7zJVZ1EKMGmWCtcPIlqtng-1; Mon, 10 Aug 2020 12:54:29 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 575778005B0; Mon, 10 Aug 2020 16:54:28 +0000 (UTC) Received: from bahia.lan (ovpn-112-38.ams2.redhat.com [10.36.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 825F35F1E4; Mon, 10 Aug 2020 16:54:27 +0000 (UTC) X-MC-Unique: 7zJVZ1EKMGmWCtcPIlqtng-1 Subject: [PATCH 05/14] spapr/xive: Rework error handling of kvmppc_xive_cpu_[gs]et_state() From: Greg Kurz To: David Gibson Date: Mon, 10 Aug 2020 18:54:26 +0200 Message-ID: <159707846665.1489912.14267225652103441921.stgit@bahia.lan> In-Reply-To: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> References: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> User-Agent: StGit/0.21 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=groug@kaod.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable 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; Received-SPF: softfail client-ip=205.139.110.61; envelope-from=groug@kaod.org; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/10 03:29:25 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=ham autolearn_force=no X-Spam_action: no action 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, =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" kvm_set_one_reg() returns a negative errno on failure, use that instead of errno. Also propagate it to callers so they can use it to check for failures and hopefully get rid of their local_err boilerplate. Signed-off-by: Greg Kurz --- hw/intc/spapr_xive_kvm.c | 15 ++++++++++----- include/hw/ppc/xive.h | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index b2a36fd59dae..5e088ccbf885 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -73,7 +73,7 @@ static void kvm_cpu_disable_all(void) * XIVE Thread Interrupt Management context (KVM) */ =20 -void kvmppc_xive_cpu_set_state(XiveTCTX *tctx, Error **errp) +int kvmppc_xive_cpu_set_state(XiveTCTX *tctx, Error **errp) { SpaprXive *xive =3D SPAPR_XIVE(tctx->xptr); uint64_t state[2]; @@ -86,13 +86,16 @@ void kvmppc_xive_cpu_set_state(XiveTCTX *tctx, Error **= errp) =20 ret =3D kvm_set_one_reg(tctx->cs, KVM_REG_PPC_VP_STATE, state); if (ret !=3D 0) { - error_setg_errno(errp, errno, + error_setg_errno(errp, -ret, "XIVE: could not restore KVM state of CPU %ld", kvm_arch_vcpu_id(tctx->cs)); + return ret; } + + return 0; } =20 -void kvmppc_xive_cpu_get_state(XiveTCTX *tctx, Error **errp) +int kvmppc_xive_cpu_get_state(XiveTCTX *tctx, Error **errp) { SpaprXive *xive =3D SPAPR_XIVE(tctx->xptr); uint64_t state[2] =3D { 0 }; @@ -102,14 +105,16 @@ void kvmppc_xive_cpu_get_state(XiveTCTX *tctx, Error = **errp) =20 ret =3D kvm_get_one_reg(tctx->cs, KVM_REG_PPC_VP_STATE, state); if (ret !=3D 0) { - error_setg_errno(errp, errno, + error_setg_errno(errp, -ret, "XIVE: could not capture KVM state of CPU %ld", kvm_arch_vcpu_id(tctx->cs)); - return; + return ret; } =20 /* word0 and word1 of the OS ring. */ *((uint64_t *) &tctx->regs[TM_QW1_OS]) =3D state[0]; + + return 0; } =20 typedef struct { diff --git a/include/hw/ppc/xive.h b/include/hw/ppc/xive.h index 2d87ed43728a..785c905357dc 100644 --- a/include/hw/ppc/xive.h +++ b/include/hw/ppc/xive.h @@ -489,7 +489,7 @@ int kvmppc_xive_source_reset_one(XiveSource *xsrc, int = srcno, Error **errp); void kvmppc_xive_source_set_irq(void *opaque, int srcno, int val); int kvmppc_xive_cpu_connect(XiveTCTX *tctx, Error **errp); void kvmppc_xive_cpu_synchronize_state(XiveTCTX *tctx, Error **errp); -void kvmppc_xive_cpu_get_state(XiveTCTX *tctx, Error **errp); -void kvmppc_xive_cpu_set_state(XiveTCTX *tctx, Error **errp); +int kvmppc_xive_cpu_get_state(XiveTCTX *tctx, Error **errp); +int kvmppc_xive_cpu_set_state(XiveTCTX *tctx, Error **errp); =20 #endif /* PPC_XIVE_H */ From nobody Fri May 17 17:02:20 2024 Delivered-To: importer@patchew.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=1597078812; cv=none; d=zohomail.com; s=zohoarc; b=fSNnrmwX6xCnYzpbRRqBToVJ9b5CSp/KbmVr0/naBhUyhXpf5FvI53deQ+PIKkRpXzPeNnLjpHfY32rAEAnMbcUOJZlXXrZg131/9yldpctdSWmCrDe2aXR5KVJso/V01BckfW5tafDD+bS81oNKKY9jz94H8glvcp1Et5yRsnY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597078812; 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=UO78w4rIbBOjM4dvA7A5scAV2br5hNNOb1JnomNV9lM=; b=Osl4LyZKnRNCVr/VhkWaFPys2u2i3P62XbMYvkAE+3FkM8YarRTE1AEmlIKXK7TqrZ/0Ig+2R/xzksEAiA7b0cVpszA7RDrROXeLVRLU0ss+751U4z7KAzc/k+bTHX2Vq34YK8PyRhqiOJ52d5h5YN/+Fw7/gXLCFxTMMnxTxjs= 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 1597078812356739.715745603124; Mon, 10 Aug 2020 10:00:12 -0700 (PDT) Received: from localhost ([::1]:44340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5B9e-0007op-IV for importer@patchew.org; Mon, 10 Aug 2020 13:00:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5B4K-0005ug-ML for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:54:40 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:24326 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k5B4J-0000ka-8S for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:54:40 -0400 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-44-e8ME-aKsNkmNoXOx_d1P0g-1; Mon, 10 Aug 2020 12:54:36 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 734C357; Mon, 10 Aug 2020 16:54:35 +0000 (UTC) Received: from bahia.lan (ovpn-112-38.ams2.redhat.com [10.36.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7636F69318; Mon, 10 Aug 2020 16:54:34 +0000 (UTC) X-MC-Unique: e8ME-aKsNkmNoXOx_d1P0g-1 Subject: [PATCH 06/14] spapr/xive: Rework error handling of kvmppc_xive_[gs]et_queue_config() From: Greg Kurz To: David Gibson Date: Mon, 10 Aug 2020 18:54:33 +0200 Message-ID: <159707847357.1489912.2032291280645236480.stgit@bahia.lan> In-Reply-To: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> References: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> User-Agent: StGit/0.21 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=groug@kaod.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable 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; Received-SPF: softfail client-ip=205.139.110.120; envelope-from=groug@kaod.org; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/10 11:00:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action 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, =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Since kvm_device_access() returns a negative errno on failure, convert kvmppc_xive_get_queue_config() and kvmppc_xive_set_queue_config() to use it for error checking. This allows to get rid of the local_err boilerplate. Propagate the return value so that callers may use it as well to check failures. Signed-off-by: Greg Kurz --- hw/intc/spapr_xive_kvm.c | 35 ++++++++++++++++------------------- include/hw/ppc/spapr_xive.h | 4 ++-- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index 5e088ccbf885..696623f717b7 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -374,15 +374,15 @@ void kvmppc_xive_source_set_irq(void *opaque, int src= no, int val) /* * sPAPR XIVE interrupt controller (KVM) */ -void kvmppc_xive_get_queue_config(SpaprXive *xive, uint8_t end_blk, - uint32_t end_idx, XiveEND *end, - Error **errp) +int kvmppc_xive_get_queue_config(SpaprXive *xive, uint8_t end_blk, + uint32_t end_idx, XiveEND *end, + Error **errp) { struct kvm_ppc_xive_eq kvm_eq =3D { 0 }; uint64_t kvm_eq_idx; uint8_t priority; uint32_t server; - Error *local_err =3D NULL; + int ret; =20 assert(xive_end_is_valid(end)); =20 @@ -394,11 +394,10 @@ void kvmppc_xive_get_queue_config(SpaprXive *xive, ui= nt8_t end_blk, kvm_eq_idx |=3D server << KVM_XIVE_EQ_SERVER_SHIFT & KVM_XIVE_EQ_SERVER_MASK; =20 - kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_EQ_CONFIG, kvm_eq_idx, - &kvm_eq, false, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; + ret =3D kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_EQ_CONFIG, kvm_eq= _idx, + &kvm_eq, false, errp); + if (ret < 0) { + return ret; } =20 /* @@ -408,17 +407,18 @@ void kvmppc_xive_get_queue_config(SpaprXive *xive, ui= nt8_t end_blk, */ end->w1 =3D xive_set_field32(END_W1_GENERATION, 0ul, kvm_eq.qtoggle) | xive_set_field32(END_W1_PAGE_OFF, 0ul, kvm_eq.qindex); + + return 0; } =20 -void kvmppc_xive_set_queue_config(SpaprXive *xive, uint8_t end_blk, - uint32_t end_idx, XiveEND *end, - Error **errp) +int kvmppc_xive_set_queue_config(SpaprXive *xive, uint8_t end_blk, + uint32_t end_idx, XiveEND *end, + Error **errp) { struct kvm_ppc_xive_eq kvm_eq =3D { 0 }; uint64_t kvm_eq_idx; uint8_t priority; uint32_t server; - Error *local_err =3D NULL; =20 /* * Build the KVM state from the local END structure. @@ -456,12 +456,9 @@ void kvmppc_xive_set_queue_config(SpaprXive *xive, uin= t8_t end_blk, kvm_eq_idx |=3D server << KVM_XIVE_EQ_SERVER_SHIFT & KVM_XIVE_EQ_SERVER_MASK; =20 - kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_EQ_CONFIG, kvm_eq_idx, - &kvm_eq, true, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } + return + kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_EQ_CONFIG, kvm_eq_idx, + &kvm_eq, true, errp); } =20 void kvmppc_xive_reset(SpaprXive *xive, Error **errp) diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h index 93d09d68deb7..d0a08b618f79 100644 --- a/include/hw/ppc/spapr_xive.h +++ b/include/hw/ppc/spapr_xive.h @@ -85,10 +85,10 @@ void kvmppc_xive_set_source_config(SpaprXive *xive, uin= t32_t lisn, XiveEAS *eas, void kvmppc_xive_sync_source(SpaprXive *xive, uint32_t lisn, Error **errp); uint64_t kvmppc_xive_esb_rw(XiveSource *xsrc, int srcno, uint32_t offset, uint64_t data, bool write); -void kvmppc_xive_set_queue_config(SpaprXive *xive, uint8_t end_blk, +int kvmppc_xive_set_queue_config(SpaprXive *xive, uint8_t end_blk, uint32_t end_idx, XiveEND *end, Error **errp); -void kvmppc_xive_get_queue_config(SpaprXive *xive, uint8_t end_blk, +int kvmppc_xive_get_queue_config(SpaprXive *xive, uint8_t end_blk, uint32_t end_idx, XiveEND *end, Error **errp); void kvmppc_xive_synchronize_state(SpaprXive *xive, Error **errp); From nobody Fri May 17 17:02:20 2024 Delivered-To: importer@patchew.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=1597078960; cv=none; d=zohomail.com; s=zohoarc; b=BoObhmlb9Yvjl2y3wheGn1mrevh5WiRKtuR/3z2c0+/HXCn8stbVZ44AoSz9prwuS0m/v3wqjqgzuTWg55SAnIO9VvHeG7bbpfZcf3msHBi32IxWCW4WLJwXF5rw7CQRlsdp44FDH8QHRTwVBqesVL6oC9PwbUczIA5Ca2WrVZ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597078960; 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=FgzRdKvrZvTNaQ3sqp2NfZoA/vPe+Bi1BwgPA3UTr0s=; b=F6nVlNBWSaXavicXRLcQTxyMk+yQX9sJQ3bln5EckdoPv5FZ+bj57suCyAxTELCIZMYCrmZKpKBfUnUv3X4OX1w8ceUb6g3G3STf4QqqWVJMkceOLQlKwLiIcZfUl8otO9jY/WNYZylDKzhHtBc0VzxxuGWLSr5j3iOqsDqx3L4= 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 1597078960014102.10510366949438; Mon, 10 Aug 2020 10:02:40 -0700 (PDT) Received: from localhost ([::1]:50828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5BC2-0002FI-Lm for importer@patchew.org; Mon, 10 Aug 2020 13:02:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5B4R-00062j-8S for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:54:47 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:32701 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k5B4P-0000kw-PS for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:54:46 -0400 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-330-JOSmJhokPP6m_LtDr_G4Iw-1; Mon, 10 Aug 2020 12:54:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 660761005504; Mon, 10 Aug 2020 16:54:42 +0000 (UTC) Received: from bahia.lan (ovpn-112-38.ams2.redhat.com [10.36.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91BEB5F1E4; Mon, 10 Aug 2020 16:54:41 +0000 (UTC) X-MC-Unique: JOSmJhokPP6m_LtDr_G4Iw-1 Subject: [PATCH 07/14] spapr/xive: Rework error handling in kvmppc_xive_get_queues() From: Greg Kurz To: David Gibson Date: Mon, 10 Aug 2020 18:54:40 +0200 Message-ID: <159707848069.1489912.14879208798696134531.stgit@bahia.lan> In-Reply-To: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> References: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> User-Agent: StGit/0.21 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=groug@kaod.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable 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; Received-SPF: softfail client-ip=205.139.110.120; envelope-from=groug@kaod.org; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/10 11:00:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action 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, =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Since kvmppc_xive_get_queue_config() has a return value, convert kvmppc_xive_get_queues() to use it for error checking. This allows to get rid of the local_err boiler plate. Propagate the return value so that callers may use it as well to check failures. Signed-off-by: Greg Kurz --- hw/intc/spapr_xive_kvm.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index 696623f717b7..4142aaffff47 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -467,23 +467,24 @@ void kvmppc_xive_reset(SpaprXive *xive, Error **errp) NULL, true, errp); } =20 -static void kvmppc_xive_get_queues(SpaprXive *xive, Error **errp) +static int kvmppc_xive_get_queues(SpaprXive *xive, Error **errp) { - Error *local_err =3D NULL; int i; + int ret; =20 for (i =3D 0; i < xive->nr_ends; i++) { if (!xive_end_is_valid(&xive->endt[i])) { continue; } =20 - kvmppc_xive_get_queue_config(xive, SPAPR_XIVE_BLOCK_ID, i, - &xive->endt[i], &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; + ret =3D kvmppc_xive_get_queue_config(xive, SPAPR_XIVE_BLOCK_ID, i, + &xive->endt[i], errp); + if (ret < 0) { + return ret; } } + + return 0; } =20 /* From nobody Fri May 17 17:02:20 2024 Delivered-To: importer@patchew.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=1597079029; cv=none; d=zohomail.com; s=zohoarc; b=Kev+hEDQqBJZukNIRU6RB9ETnvtR0JGycOawiXQnhK47o8QoXJemOjEmVULppF95YsiTX+D39wINSFHdbfuDFdh9JFG2NZMyBbWV95DMLojmLO2roigbHnQay8top4wWB2vh8nFhqKgG2Cp52CxO8Z6oD6or+vzjlAw6uaGMwZk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597079029; 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=rkWI09AXIMTHGMRTLRWY7NOegO1vrsSmcEVhldtBsJ4=; b=GMQNOiEo0TGUxBhW0QRQRx1SYl9Q4ux0lkF/+r79h55JmG8wdsiyt0MKlD602Cz2C+4wGgFtpM9xFXZmV/RrDX+vSprK17FnXSueLqJ4Pa24DIa8jbFQgFoPNMqzRRZVC2+rv18Po/34OXyAbO4g9KiHe0XRUptwDVXJVGWDno8= 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 1597079029324886.0452674404887; Mon, 10 Aug 2020 10:03:49 -0700 (PDT) Received: from localhost ([::1]:53800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5BD9-0003U1-H4 for importer@patchew.org; Mon, 10 Aug 2020 13:03:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5B4a-0006KQ-PX for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:54:56 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:35909 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k5B4Z-0000lW-4h for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:54:56 -0400 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-222--vVCfanuPgqVF4GDBI32Xw-1; Mon, 10 Aug 2020 12:54:50 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 51F668005B0; Mon, 10 Aug 2020 16:54:49 +0000 (UTC) Received: from bahia.lan (ovpn-112-38.ams2.redhat.com [10.36.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7CDF31001901; Mon, 10 Aug 2020 16:54:48 +0000 (UTC) X-MC-Unique: -vVCfanuPgqVF4GDBI32Xw-1 Subject: [PATCH 08/14] spapr/xive: Rework error handling of kvmppc_xive_set_source_config() From: Greg Kurz To: David Gibson Date: Mon, 10 Aug 2020 18:54:47 +0200 Message-ID: <159707848764.1489912.17078842252160674523.stgit@bahia.lan> In-Reply-To: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> References: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> User-Agent: StGit/0.21 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=groug@kaod.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable 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; Received-SPF: softfail client-ip=205.139.110.120; envelope-from=groug@kaod.org; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/10 11:00:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action 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, =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Since kvm_device_access() returns a negative errno on failure, convert kvmppc_xive_set_source_config() to use it for error checking. This allows to get rid of the local_err boilerplate. Propagate the return value so that callers may use it as well to check failures. Signed-off-by: Greg Kurz --- hw/intc/spapr_xive_kvm.c | 13 ++++--------- include/hw/ppc/spapr_xive.h | 4 ++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index 4142aaffff47..f2dda692183b 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -186,8 +186,8 @@ int kvmppc_xive_cpu_connect(XiveTCTX *tctx, Error **err= p) * XIVE Interrupt Source (KVM) */ =20 -void kvmppc_xive_set_source_config(SpaprXive *xive, uint32_t lisn, XiveEAS= *eas, - Error **errp) +int kvmppc_xive_set_source_config(SpaprXive *xive, uint32_t lisn, XiveEAS = *eas, + Error **errp) { uint32_t end_idx; uint32_t end_blk; @@ -196,7 +196,6 @@ void kvmppc_xive_set_source_config(SpaprXive *xive, uin= t32_t lisn, XiveEAS *eas, bool masked; uint32_t eisn; uint64_t kvm_src; - Error *local_err =3D NULL; =20 assert(xive_eas_is_valid(eas)); =20 @@ -216,12 +215,8 @@ void kvmppc_xive_set_source_config(SpaprXive *xive, ui= nt32_t lisn, XiveEAS *eas, kvm_src |=3D ((uint64_t)eisn << KVM_XIVE_SOURCE_EISN_SHIFT) & KVM_XIVE_SOURCE_EISN_MASK; =20 - kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_SOURCE_CONFIG, lisn, - &kvm_src, true, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } + return kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_SOURCE_CONFIG, lis= n, + &kvm_src, true, errp); } =20 void kvmppc_xive_sync_source(SpaprXive *xive, uint32_t lisn, Error **errp) diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h index d0a08b618f79..0ffbe0be0280 100644 --- a/include/hw/ppc/spapr_xive.h +++ b/include/hw/ppc/spapr_xive.h @@ -80,8 +80,8 @@ int kvmppc_xive_connect(SpaprInterruptController *intc, u= int32_t nr_servers, Error **errp); void kvmppc_xive_disconnect(SpaprInterruptController *intc); void kvmppc_xive_reset(SpaprXive *xive, Error **errp); -void kvmppc_xive_set_source_config(SpaprXive *xive, uint32_t lisn, XiveEAS= *eas, - Error **errp); +int kvmppc_xive_set_source_config(SpaprXive *xive, uint32_t lisn, XiveEAS = *eas, + Error **errp); void kvmppc_xive_sync_source(SpaprXive *xive, uint32_t lisn, Error **errp); uint64_t kvmppc_xive_esb_rw(XiveSource *xsrc, int srcno, uint32_t offset, uint64_t data, bool write); From nobody Fri May 17 17:02:20 2024 Delivered-To: importer@patchew.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=1597078655; cv=none; d=zohomail.com; s=zohoarc; b=IBhLo8iCc2NWqBesFKdhJU9CqC9xhNXnXh2cuS/8pkSrMdZu1F7OLKllLgZZLyzjsUbn6gBy3mRap1Ws2vkHf06sRWbjHGcBI8bK8oNdddohFJEJUGJPga/o0C8FOSg34Q2gGFJCJPMGKrODMgFP7CdsNF187lXiSbHJ6Qnpzws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597078655; 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=naCbeXvRbKndb2E2zAKH7fG7q6MSVtmZ+sUtw/+PoLo=; b=jVuxFdNIFtdVL1hesjML8STI0t9iIGoDo1bCrtzlNzLLTehC/CCPGMN5u+YmtYgKNXC20F1wRR27O6aE73prnv5iM9PQzHbztIBtJ8amWzEqqkpFnCN0PcQCYeNtkCjAugkO2luU2C93C01fKGLtmPIlIVI29XLsM+Vsf9FFVR8= 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 1597078655729914.9783910234323; Mon, 10 Aug 2020 09:57:35 -0700 (PDT) Received: from localhost ([::1]:60754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5B78-00030U-4q for importer@patchew.org; Mon, 10 Aug 2020 12:57:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5B4j-0006Z5-1K for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:55:05 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:32762 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k5B4h-0000mM-H1 for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:55:04 -0400 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-299-LCdmqLOIMqCu9VZVTHotdA-1; Mon, 10 Aug 2020 12:54:57 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 40779106B246; Mon, 10 Aug 2020 16:54:56 +0000 (UTC) Received: from bahia.lan (ovpn-112-38.ams2.redhat.com [10.36.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 693977010B; Mon, 10 Aug 2020 16:54:55 +0000 (UTC) X-MC-Unique: LCdmqLOIMqCu9VZVTHotdA-1 Subject: [PATCH 09/14] spapr/kvm: Fix error handling in kvmppc_xive_pre_save() From: Greg Kurz To: David Gibson Date: Mon, 10 Aug 2020 18:54:54 +0200 Message-ID: <159707849455.1489912.6034461176847728064.stgit@bahia.lan> In-Reply-To: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> References: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> User-Agent: StGit/0.21 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=groug@kaod.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable 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; Received-SPF: softfail client-ip=207.211.31.81; envelope-from=groug@kaod.org; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/10 04:13:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action 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, =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Now that kvmppc_xive_get_queues() returns a negative errno on failure, check with that because it is preferred to local_err. And most of all, propagate it because vmstate expects negative errnos. Signed-off-by: Greg Kurz --- hw/intc/spapr_xive_kvm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index f2dda692183b..1686b036eb2d 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -604,16 +604,17 @@ void kvmppc_xive_synchronize_state(SpaprXive *xive, E= rror **errp) int kvmppc_xive_pre_save(SpaprXive *xive) { Error *local_err =3D NULL; + int ret; =20 assert(xive->fd !=3D -1); =20 /* EAT: there is no extra state to query from KVM */ =20 /* ENDT */ - kvmppc_xive_get_queues(xive, &local_err); - if (local_err) { + ret =3D kvmppc_xive_get_queues(xive, &local_err); + if (ret < 0) { error_report_err(local_err); - return -1; + return ret; } =20 return 0; From nobody Fri May 17 17:02:20 2024 Delivered-To: importer@patchew.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=1597078653; cv=none; d=zohomail.com; s=zohoarc; b=hYeBjXD4C6H/7GNQmeIb21BuUMawkMOUkpCxEwV8NKZ/uu3Vb+mpyEmoAh+xWF/DE6Pisup6mmRaZIIzAjLNa87HCcuG4kjyjIk77MSIA94OPJrN5KAaqYoTobo6LMAZPD1GVSHTHJJyDc0KIyW/2IX1L7EWD8NtrH3+5OWg/kI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597078653; 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=jX/bDYHk1UEYCndrEwGw3VO93mNJ+bFNWbr0Id5pr8M=; b=cfmubGewWTcLRu7mEq6kcyRXl0Z5pr21C3OGVsNltxOqXOl4b2uby09mst4a1FH7yH2tV6wqDSZtmYszGZWK/6xyRpFoVUiijytzeEhPV1aEa9Ve1NrHEZh6cHT4VuIQWoXy/pKzBluhvwFppJm0QSNdMGyvnLszrKnaBXwD+9E= 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 1597078653104931.0914795351429; Mon, 10 Aug 2020 09:57:33 -0700 (PDT) Received: from localhost ([::1]:60558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5B75-0002vj-SU for importer@patchew.org; Mon, 10 Aug 2020 12:57:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5B4o-0006mG-Fw for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:55:10 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:57021 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k5B4m-0000mt-TT for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:55:10 -0400 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-386-f9Y9hy54M0O6kAR2OcFVgg-1; Mon, 10 Aug 2020 12:55:04 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2DE991940920; Mon, 10 Aug 2020 16:55:03 +0000 (UTC) Received: from bahia.lan (ovpn-112-38.ams2.redhat.com [10.36.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 585656F129; Mon, 10 Aug 2020 16:55:02 +0000 (UTC) X-MC-Unique: f9Y9hy54M0O6kAR2OcFVgg-1 Subject: [PATCH 10/14] spapr/xive: Fix error handling in kvmppc_xive_post_load() From: Greg Kurz To: David Gibson Date: Mon, 10 Aug 2020 18:55:01 +0200 Message-ID: <159707850148.1489912.18355118622296682631.stgit@bahia.lan> In-Reply-To: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> References: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> User-Agent: StGit/0.21 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable 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; Received-SPF: softfail client-ip=205.139.110.120; envelope-from=groug@kaod.org; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/10 11:00:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action 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, =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Now that all these functions return a negative errno on failure, check that because it is preferred to local_err. And most of all, propagate it because vmstate expects negative errnos. Signed-off-by: Greg Kurz --- hw/intc/spapr_xive_kvm.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index 1686b036eb2d..005729ebffed 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -631,6 +631,7 @@ int kvmppc_xive_post_load(SpaprXive *xive, int version_= id) Error *local_err =3D NULL; CPUState *cs; int i; + int ret; =20 /* The KVM XIVE device should be in use */ assert(xive->fd !=3D -1); @@ -641,11 +642,10 @@ int kvmppc_xive_post_load(SpaprXive *xive, int versio= n_id) continue; } =20 - kvmppc_xive_set_queue_config(xive, SPAPR_XIVE_BLOCK_ID, i, - &xive->endt[i], &local_err); - if (local_err) { - error_report_err(local_err); - return -1; + ret =3D kvmppc_xive_set_queue_config(xive, SPAPR_XIVE_BLOCK_ID, i, + &xive->endt[i], &local_err); + if (ret < 0) { + goto fail; } } =20 @@ -660,16 +660,14 @@ int kvmppc_xive_post_load(SpaprXive *xive, int versio= n_id) * previously set in KVM. Since we don't do that for all interrupts * at reset time anymore, let's do it now. */ - kvmppc_xive_source_reset_one(&xive->source, i, &local_err); - if (local_err) { - error_report_err(local_err); - return -1; + ret =3D kvmppc_xive_source_reset_one(&xive->source, i, &local_err); + if (ret < 0) { + goto fail; } =20 - kvmppc_xive_set_source_config(xive, i, &xive->eat[i], &local_err); - if (local_err) { - error_report_err(local_err); - return -1; + ret =3D kvmppc_xive_set_source_config(xive, i, &xive->eat[i], &loc= al_err); + if (ret < 0) { + goto fail; } } =20 @@ -686,15 +684,18 @@ int kvmppc_xive_post_load(SpaprXive *xive, int versio= n_id) CPU_FOREACH(cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); =20 - kvmppc_xive_cpu_set_state(spapr_cpu_state(cpu)->tctx, &local_err); - if (local_err) { - error_report_err(local_err); - return -1; + ret =3D kvmppc_xive_cpu_set_state(spapr_cpu_state(cpu)->tctx, &loc= al_err); + if (ret < 0) { + goto fail; } } =20 /* The source states will be restored when the machine starts running = */ return 0; + +fail: + error_report_err(local_err); + return ret; } =20 /* Returns MAP_FAILED on error and sets errno */ From nobody Fri May 17 17:02:20 2024 Delivered-To: importer@patchew.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=1597078652; cv=none; d=zohomail.com; s=zohoarc; b=mAHqe3tymS70DXeJ4etchazhFIJ/6KjRtLiCTiKzJTzUiXyUrMcy9xWfs/i7UAAJS0t6FUpUkFo3ViudQH/nUjvVdQLI0QVWVFDFZ1gbMEPaEo3Pa+g3geXQm7rJiyULgClBRWMepNs66nyTHcFQx1TF3z+Fq/T3Vwoh9Yk55q4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597078652; 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=86s8mwUhFPLFWWxDZAJzrsRh9fuTfCsO+gGYu1vUdDg=; b=TmX9Fc33Wy1W7cVk4Coum24AXft6oUqPVQh4BxS/qScW1/EW6DSgvHK5gWHbwADwcT97L6HEdaRRs4QGr8ov93ONLd8BYlFmXE/jEXH7Trfcuqqj8jyB5iuAOkrCVztE+UJctDDaeqPL4tG8MRn2kmMPtwv0vf+ipVKzXScTwPs= 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 1597078652370292.6715018579922; Mon, 10 Aug 2020 09:57:32 -0700 (PDT) Received: from localhost ([::1]:60426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5B75-0002sT-67 for importer@patchew.org; Mon, 10 Aug 2020 12:57:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5B4u-0006yT-KZ for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:55:16 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:46625 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k5B4r-0000nk-PT for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:55:16 -0400 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-557-Kk3b-ToDNXS291tDU34NoA-1; Mon, 10 Aug 2020 12:55:11 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24C771005504; Mon, 10 Aug 2020 16:55:10 +0000 (UTC) Received: from bahia.lan (ovpn-112-38.ams2.redhat.com [10.36.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F5226111F; Mon, 10 Aug 2020 16:55:09 +0000 (UTC) X-MC-Unique: Kk3b-ToDNXS291tDU34NoA-1 Subject: [PATCH 11/14] ppc/xive: Fix error handling in vmstate_xive_tctx_*() callbacks From: Greg Kurz To: David Gibson Date: Mon, 10 Aug 2020 18:55:08 +0200 Message-ID: <159707850840.1489912.14912810818646455474.stgit@bahia.lan> In-Reply-To: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> References: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> User-Agent: StGit/0.21 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=groug@kaod.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable 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; Received-SPF: softfail client-ip=207.211.31.120; envelope-from=groug@kaod.org; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/10 03:31:01 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action 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, =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Now that kvmppc_xive_cpu_get_state() and kvmppc_xive_cpu_set_state() return negative errnos on failures, use that instead local_err because it is the recommended practice. Also return that instead of -1 since vmstate expects negative errnos. Signed-off-by: Greg Kurz --- hw/intc/xive.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/intc/xive.c b/hw/intc/xive.c index a453e8f4dcbe..17ca5a1916b4 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -695,12 +695,13 @@ static int vmstate_xive_tctx_pre_save(void *opaque) { XiveTCTX *tctx =3D XIVE_TCTX(opaque); Error *local_err =3D NULL; + int ret; =20 if (xive_in_kernel(tctx->xptr)) { - kvmppc_xive_cpu_get_state(tctx, &local_err); - if (local_err) { + ret =3D kvmppc_xive_cpu_get_state(tctx, &local_err); + if (ret < 0) { error_report_err(local_err); - return -1; + return ret; } } =20 @@ -711,16 +712,17 @@ static int vmstate_xive_tctx_post_load(void *opaque, = int version_id) { XiveTCTX *tctx =3D XIVE_TCTX(opaque); Error *local_err =3D NULL; + int ret; =20 if (xive_in_kernel(tctx->xptr)) { /* * Required for hotplugged CPU, for which the state comes * after all states of the machine. */ - kvmppc_xive_cpu_set_state(tctx, &local_err); - if (local_err) { + ret =3D kvmppc_xive_cpu_set_state(tctx, &local_err); + if (ret < 0) { error_report_err(local_err); - return -1; + return ret; } } =20 From nobody Fri May 17 17:02:20 2024 Delivered-To: importer@patchew.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=1597078747; cv=none; d=zohomail.com; s=zohoarc; b=UsSYv/MNu/6VfJghEV8RcSFvgtdyXSF0nHUoOtCXwvW9CEW6Zw42TAkNj7IxiPIAOJCJHDdA2h8eUPFDlbiErWd0ygBpfyPgQzr2yvjboaYJAny5zbnaKUAhmoIxVhKgPcHP0IGuf9DORDN3CbhDm1ju6FRF54Z/iaIKY9UOZFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597078747; 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=3HoIYfHuA+uB9pB6Cf7A8egLaAGigh+ASaEFO+JrLow=; b=cdCyzRr9/DW5YMDt3wxv2r1SCNwRoQctAI7qHAfkg70Poi0XP7fdTm8PzRPwiNRJHnxrjBKcMALBkpG/qHO/l0Pw23EkC5KgsPEzJvCKnFUWbgSTMQeDbSR0SnGRlSXMMgs93B0PSVV6jhYztDcaUSqcuEQDTScSO2MsnhWJtCo= 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 1597078747142804.2491449105328; Mon, 10 Aug 2020 09:59:07 -0700 (PDT) Received: from localhost ([::1]:39700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5B8b-0005ua-Vs for importer@patchew.org; Mon, 10 Aug 2020 12:59:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41088) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5B53-00074X-Cd for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:55:25 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:39044 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k5B50-0000tn-Ug for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:55:25 -0400 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-65-QTaOuewSOO2MZ5k5NF254A-1; Mon, 10 Aug 2020 12:55:18 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1DEA78005B0; Mon, 10 Aug 2020 16:55:17 +0000 (UTC) Received: from bahia.lan (ovpn-112-38.ams2.redhat.com [10.36.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4692A6111F; Mon, 10 Aug 2020 16:55:16 +0000 (UTC) X-MC-Unique: QTaOuewSOO2MZ5k5NF254A-1 Subject: [PATCH 12/14] spapr/xive: Simplify error handling in kvmppc_xive_connect() From: Greg Kurz To: David Gibson Date: Mon, 10 Aug 2020 18:55:15 +0200 Message-ID: <159707851537.1489912.1030839306195472651.stgit@bahia.lan> In-Reply-To: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> References: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> User-Agent: StGit/0.21 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable 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; Received-SPF: softfail client-ip=207.211.31.81; envelope-from=groug@kaod.org; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/10 04:13:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action 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, =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Now that all these functions return a negative errno on failure, check that and get rid of the local_err boilerplate. Signed-off-by: Greg Kurz --- hw/intc/spapr_xive_kvm.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index 005729ebffed..e9a36115bed6 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -723,12 +723,12 @@ int kvmppc_xive_connect(SpaprInterruptController *int= c, uint32_t nr_servers, { SpaprXive *xive =3D SPAPR_XIVE(intc); XiveSource *xsrc =3D &xive->source; - Error *local_err =3D NULL; size_t esb_len =3D xive_source_esb_len(xsrc); size_t tima_len =3D 4ull << TM_SHIFT; CPUState *cs; int fd; void *addr; + int ret; =20 /* * The KVM XIVE device already in use. This is the case when @@ -754,9 +754,10 @@ int kvmppc_xive_connect(SpaprInterruptController *intc= , uint32_t nr_servers, /* Tell KVM about the # of VCPUs we may have */ if (kvm_device_check_attr(xive->fd, KVM_DEV_XIVE_GRP_CTRL, KVM_DEV_XIVE_NR_SERVERS)) { - if (kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_CTRL, - KVM_DEV_XIVE_NR_SERVERS, &nr_servers, true, - &local_err)) { + ret =3D kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_CTRL, + KVM_DEV_XIVE_NR_SERVERS, &nr_servers, true, + errp); + if (ret < 0) { goto fail; } } @@ -764,8 +765,7 @@ int kvmppc_xive_connect(SpaprInterruptController *intc,= uint32_t nr_servers, /* * 1. Source ESB pages - KVM mapping */ - addr =3D kvmppc_xive_mmap(xive, KVM_XIVE_ESB_PAGE_OFFSET, esb_len, - &local_err); + addr =3D kvmppc_xive_mmap(xive, KVM_XIVE_ESB_PAGE_OFFSET, esb_len, err= p); if (addr =3D=3D MAP_FAILED) { goto fail; } @@ -783,8 +783,7 @@ int kvmppc_xive_connect(SpaprInterruptController *intc,= uint32_t nr_servers, /* * 3. TIMA pages - KVM mapping */ - addr =3D kvmppc_xive_mmap(xive, KVM_XIVE_TIMA_PAGE_OFFSET, tima_len, - &local_err); + addr =3D kvmppc_xive_mmap(xive, KVM_XIVE_TIMA_PAGE_OFFSET, tima_len, e= rrp); if (addr =3D=3D MAP_FAILED) { goto fail; } @@ -802,15 +801,15 @@ int kvmppc_xive_connect(SpaprInterruptController *int= c, uint32_t nr_servers, CPU_FOREACH(cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); =20 - kvmppc_xive_cpu_connect(spapr_cpu_state(cpu)->tctx, &local_err); - if (local_err) { + ret =3D kvmppc_xive_cpu_connect(spapr_cpu_state(cpu)->tctx, errp); + if (ret < 0) { goto fail; } } =20 /* Update the KVM sources */ - kvmppc_xive_source_reset(xsrc, &local_err); - if (local_err) { + ret =3D kvmppc_xive_source_reset(xsrc, errp); + if (ret < 0) { goto fail; } =20 @@ -820,7 +819,6 @@ int kvmppc_xive_connect(SpaprInterruptController *intc,= uint32_t nr_servers, return 0; =20 fail: - error_propagate(errp, local_err); kvmppc_xive_disconnect(intc); return -1; } From nobody Fri May 17 17:02:20 2024 Delivered-To: importer@patchew.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=1597078898; cv=none; d=zohomail.com; s=zohoarc; b=nlKPZaO+S3tgGbcHIGHKa8eSby6nT+qnDA+oPkPdLDiKjlJlUjshuZevF5KW4V2M0giMtdYionDjzBc3AW6Eueq3JQ56RnkOghSimOZevC07IWZbJzP2PFrpBT1EHdPPZZBm9yU/SwZ4jHKZv8C/BQ5qA0UgPI8ZzbMrkb/m0yo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597078898; 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=5ntiG/cBUWES765tqDIUQbN8u39U2Wcv219gLwuMEys=; b=DdJnrvf7G1TXYp8FKt6shS0StTXjohQRMVNMV1oI/CX7F6jpPjBE4G42jrR/6VUX3yZeTWhqkTTARwEOLRNoxOJfHqxMnuBe6vlMZQHnzfDNQDGC4sv0Z72wS1HvDHEWbQdiwq/fHRbfFBbLRMK23MVu0G5oGdpuWh6vl9fgd5A= 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 1597078898371374.0078399408811; Mon, 10 Aug 2020 10:01:38 -0700 (PDT) Received: from localhost ([::1]:47430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5BB3-0000o6-05 for importer@patchew.org; Mon, 10 Aug 2020 13:01:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5B5A-0007CO-DH for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:55:32 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:60020 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k5B57-0000ur-DC for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:55:32 -0400 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-94-2M_Cz48CMNuw0Rch-kwwig-1; Mon, 10 Aug 2020 12:55:25 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E59EE59; Mon, 10 Aug 2020 16:55:23 +0000 (UTC) Received: from bahia.lan (ovpn-112-38.ams2.redhat.com [10.36.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BD155D9CD; Mon, 10 Aug 2020 16:55:22 +0000 (UTC) X-MC-Unique: 2M_Cz48CMNuw0Rch-kwwig-1 Subject: [PATCH 13/14] ppc/xive: Simplify error handling in xive_tctx_realize() From: Greg Kurz To: David Gibson Date: Mon, 10 Aug 2020 18:55:22 +0200 Message-ID: <159707852234.1489912.16410314514265848075.stgit@bahia.lan> In-Reply-To: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> References: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> User-Agent: StGit/0.21 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=groug@kaod.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable 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; Received-SPF: softfail client-ip=205.139.110.61; envelope-from=groug@kaod.org; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/10 03:29:25 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=unavailable autolearn_force=no X-Spam_action: no action 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, =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Now that kvmppc_xive_cpu_connect() returns a negative errno on failure, use that and get rid of the local_err boilerplate. Signed-off-by: Greg Kurz --- hw/intc/xive.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hw/intc/xive.c b/hw/intc/xive.c index 17ca5a1916b4..489e6256ef70 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -662,7 +662,6 @@ static void xive_tctx_realize(DeviceState *dev, Error *= *errp) XiveTCTX *tctx =3D XIVE_TCTX(dev); PowerPCCPU *cpu; CPUPPCState *env; - Error *local_err =3D NULL; =20 assert(tctx->cs); assert(tctx->xptr); @@ -683,9 +682,7 @@ static void xive_tctx_realize(DeviceState *dev, Error *= *errp) =20 /* Connect the presenter to the VCPU (required for CPU hotplug) */ if (xive_in_kernel(tctx->xptr)) { - kvmppc_xive_cpu_connect(tctx, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (kvmppc_xive_cpu_connect(tctx, errp) < 0) { return; } } From nobody Fri May 17 17:02:20 2024 Delivered-To: importer@patchew.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=1597078754; cv=none; d=zohomail.com; s=zohoarc; b=MgM3ob29GAGyctYCCMGff+Kpw5y1fI7WFSTesHkiAszSBZS2PI9Pw1yO5/Yo0GmCxoH62pNOn6gEKVXgz1f14egJlX2YnrWqd9AHwbvM1n324f0/hnXl/ObVNQ+nuuly2EFn8jGNEllxUFQ9f41Cr8EicUTZ99tSk5r6hL2oW5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597078754; 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=PZiWoPoV2/ZHxpl37XWTiVBwZtD8QZDni4Yka3V2uTs=; b=Vo38wCXLw9uzpaootTlxD0L60Fx5Slm48JZncAO1NXRCS+pwdXVRpuTtwxtZQi+gVcfxlpWn/j2CeRSN+iO9rx2CesxIzgDp8QwLNyhe1Wz4BBYV5maRLCUJHA41M+fcjqiOaaCxA2ztJcr4ojzIQuZdjtM0K1SfMC4D//05LG0= 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 1597078754864428.47218330404576; Mon, 10 Aug 2020 09:59:14 -0700 (PDT) Received: from localhost ([::1]:39976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5B8j-00062i-Lq for importer@patchew.org; Mon, 10 Aug 2020 12:59:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5B5F-0007P1-QI for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:55:37 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:29796 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k5B5E-0000wV-5I for qemu-devel@nongnu.org; Mon, 10 Aug 2020 12:55:37 -0400 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-202-KjOy7M5_NbC-bVCsfgcv1Q-1; Mon, 10 Aug 2020 12:55:31 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D283C57; Mon, 10 Aug 2020 16:55:30 +0000 (UTC) Received: from bahia.lan (ovpn-112-38.ams2.redhat.com [10.36.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 088A96F120; Mon, 10 Aug 2020 16:55:29 +0000 (UTC) X-MC-Unique: KjOy7M5_NbC-bVCsfgcv1Q-1 Subject: [PATCH 14/14] spapr/xive: Simplify error handling of kvmppc_xive_cpu_synchronize_state() From: Greg Kurz To: David Gibson Date: Mon, 10 Aug 2020 18:55:29 +0200 Message-ID: <159707852916.1489912.8376334685349668124.stgit@bahia.lan> In-Reply-To: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> References: <159707843034.1489912.1082061742626355958.stgit@bahia.lan> User-Agent: StGit/0.21 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=groug@kaod.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable 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; Received-SPF: softfail client-ip=205.139.110.120; envelope-from=groug@kaod.org; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/10 11:00:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action 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, =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Now that kvmppc_xive_cpu_get_state() returns negative on error, use that and get rid of the temporary Error object and error_propagate(). Signed-off-by: Greg Kurz --- hw/intc/spapr_xive_kvm.c | 14 ++++++-------- include/hw/ppc/xive.h | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index e9a36115bed6..d871bb1a0016 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -119,7 +119,8 @@ int kvmppc_xive_cpu_get_state(XiveTCTX *tctx, Error **e= rrp) =20 typedef struct { XiveTCTX *tctx; - Error *err; + Error **errp; + int ret; } XiveCpuGetState; =20 static void kvmppc_xive_cpu_do_synchronize_state(CPUState *cpu, @@ -127,14 +128,14 @@ static void kvmppc_xive_cpu_do_synchronize_state(CPUS= tate *cpu, { XiveCpuGetState *s =3D arg.host_ptr; =20 - kvmppc_xive_cpu_get_state(s->tctx, &s->err); + s->ret =3D kvmppc_xive_cpu_get_state(s->tctx, s->errp); } =20 -void kvmppc_xive_cpu_synchronize_state(XiveTCTX *tctx, Error **errp) +int kvmppc_xive_cpu_synchronize_state(XiveTCTX *tctx, Error **errp) { XiveCpuGetState s =3D { .tctx =3D tctx, - .err =3D NULL, + .errp =3D errp, }; =20 /* @@ -143,10 +144,7 @@ void kvmppc_xive_cpu_synchronize_state(XiveTCTX *tctx,= Error **errp) run_on_cpu(tctx->cs, kvmppc_xive_cpu_do_synchronize_state, RUN_ON_CPU_HOST_PTR(&s)); =20 - if (s.err) { - error_propagate(errp, s.err); - return; - } + return s.ret; } =20 int kvmppc_xive_cpu_connect(XiveTCTX *tctx, Error **errp) diff --git a/include/hw/ppc/xive.h b/include/hw/ppc/xive.h index 785c905357dc..2c42ae92d287 100644 --- a/include/hw/ppc/xive.h +++ b/include/hw/ppc/xive.h @@ -488,7 +488,7 @@ void xive_tctx_ipb_update(XiveTCTX *tctx, uint8_t ring,= uint8_t ipb); int kvmppc_xive_source_reset_one(XiveSource *xsrc, int srcno, Error **errp= ); void kvmppc_xive_source_set_irq(void *opaque, int srcno, int val); int kvmppc_xive_cpu_connect(XiveTCTX *tctx, Error **errp); -void kvmppc_xive_cpu_synchronize_state(XiveTCTX *tctx, Error **errp); +int kvmppc_xive_cpu_synchronize_state(XiveTCTX *tctx, Error **errp); int kvmppc_xive_cpu_get_state(XiveTCTX *tctx, Error **errp); int kvmppc_xive_cpu_set_state(XiveTCTX *tctx, Error **errp); =20