From nobody Tue Nov 11 03:22:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560779820; cv=none; d=zoho.com; s=zohoarc; b=QxOG10ghBpX8rrj94dyPS+3B0rxxeEjP+rlNHulQFx9eliTH4I8TceJNYFOSnkMgtWAh3FUokKiLFMd/BtnaMhKYylcE7ed737CmklTRotmeHcQaDz4sC2NeXdBrYEpjblu1/SG1alCkp2w0LG71VdJMQVN0jqxyZHWO2eQSVDY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560779820; 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:ARC-Authentication-Results; bh=Q44z6YegoN7gahjTILwUKwoyWqawuFTdJYTP0rb68p8=; b=dyDrqde6diAlaQLW4yN4qTioqsxcjnPtZvlxGjUCcewcf3/ad3K2/PhRiTyobsMMUr07RNzOu2ABFk9ng1iBr7wurxxfabKzcIjD4JzLaUrrcOIDkt/c13Kep1y0/0A/wuE8WpOV7m8xl+zDRIpPJXcksAhmz1Zbv8QvOzwh4BQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560779820443292.93188607951106; Mon, 17 Jun 2019 06:57:00 -0700 (PDT) Received: from localhost ([::1]:47726 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcs83-000516-84 for importer@patchew.org; Mon, 17 Jun 2019 09:56:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33075) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcrye-0004Pg-PM for qemu-devel@nongnu.org; Mon, 17 Jun 2019 09:47:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcryY-0000qc-Rq for qemu-devel@nongnu.org; Mon, 17 Jun 2019 09:47:14 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55418) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcryU-0000lN-VG for qemu-devel@nongnu.org; Mon, 17 Jun 2019 09:47:08 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5HDdUmi056952 for ; Mon, 17 Jun 2019 09:47:03 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2t6bmh143x-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 17 Jun 2019 09:47:02 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 17 Jun 2019 14:47:00 +0100 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.194) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 17 Jun 2019 14:46:59 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x5HDkw5439977374 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 13:46:58 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2EDD44C044; Mon, 17 Jun 2019 13:46:58 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F36FE4C040; Mon, 17 Jun 2019 13:46:57 +0000 (GMT) Received: from bahia.lan (unknown [9.145.14.35]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 17 Jun 2019 13:46:57 +0000 (GMT) From: Greg Kurz To: David Gibson Date: Mon, 17 Jun 2019 15:46:57 +0200 In-Reply-To: <156077918969.433243.1416211899441569578.stgit@bahia.lan> References: <156077918969.433243.1416211899441569578.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19061713-0008-0000-0000-000002F47BC6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19061713-0009-0000-0000-000022618DE3 Message-Id: <156077921763.433243.4614327010172954196.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-06-17_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=818 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906170126 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 5/6] xics/kvm: Add error propagation to ic*_set_kvm_state() functions 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" This allows errors happening there to be propagated up to spapr_irq, just like XIVE already does. Signed-off-by: Greg Kurz Reviewed-by: C=C3=A9dric Le Goater --- hw/intc/xics.c | 39 ++++++++++++++++++++++++++++++++++----- hw/intc/xics_kvm.c | 37 ++++++++++++++++++++++--------------- include/hw/ppc/xics.h | 6 +++--- 3 files changed, 59 insertions(+), 23 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 1dc3a0f12280..69152e3d9ff6 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -267,7 +267,14 @@ static int icp_post_load(void *opaque, int version_id) ICPState *icp =3D opaque; =20 if (kvm_irqchip_in_kernel()) { - return icp_set_kvm_state(icp); + Error *local_err =3D NULL; + int ret; + + ret =3D icp_set_kvm_state(icp, &local_err); + if (ret < 0) { + error_report_err(local_err); + return ret; + } } =20 return 0; @@ -300,7 +307,12 @@ static void icp_reset_handler(void *dev) qemu_set_irq(icp->output, 0); =20 if (kvm_irqchip_in_kernel()) { - icp_set_kvm_state(ICP(dev)); + Error *local_err =3D NULL; + + icp_set_kvm_state(ICP(dev), &local_err); + if (local_err) { + error_report_err(local_err); + } } } =20 @@ -555,7 +567,12 @@ static void ics_simple_reset(DeviceState *dev) icsc->parent_reset(dev); =20 if (kvm_irqchip_in_kernel()) { - ics_set_kvm_state(ICS_BASE(dev)); + Error *local_err =3D NULL; + + ics_set_kvm_state(ICS_BASE(dev), &local_err); + if (local_err) { + error_report_err(local_err); + } } } =20 @@ -671,7 +688,14 @@ static int ics_base_post_load(void *opaque, int versio= n_id) ICSState *ics =3D opaque; =20 if (kvm_irqchip_in_kernel()) { - return ics_set_kvm_state(ics); + Error *local_err =3D NULL; + int ret; + + ret =3D ics_set_kvm_state(ics, &local_err); + if (ret < 0) { + error_report_err(local_err); + return ret; + } } =20 return 0; @@ -757,8 +781,13 @@ void ics_set_irq_type(ICSState *ics, int srcno, bool l= si) lsi ? XICS_FLAGS_IRQ_LSI : XICS_FLAGS_IRQ_MSI; =20 if (kvm_irqchip_in_kernel()) { + Error *local_err =3D NULL; + ics_reset_irq(ics->irqs + srcno); - ics_set_kvm_state_one(ics, srcno); + ics_set_kvm_state_one(ics, srcno, &local_err); + if (local_err) { + error_report_err(local_err); + } } } =20 diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index c9e25fb051bb..4bfbe1a84092 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -106,7 +106,7 @@ void icp_synchronize_state(ICPState *icp) } } =20 -int icp_set_kvm_state(ICPState *icp) +int icp_set_kvm_state(ICPState *icp, Error **errp) { uint64_t state; int ret; @@ -126,10 +126,11 @@ int icp_set_kvm_state(ICPState *icp) | ((uint64_t)icp->pending_priority << KVM_REG_PPC_ICP_PPRI_SHIFT); =20 ret =3D kvm_set_one_reg(icp->cs, KVM_REG_PPC_ICP_STATE, &state); - if (ret !=3D 0) { - error_report("Unable to restore KVM interrupt controller state (0x= %" - PRIx64 ") for CPU %ld: %s", state, kvm_arch_vcpu_id(icp->c= s), - strerror(errno)); + if (ret < 0) { + error_setg_errno(errp, -ret, + "Unable to restore KVM interrupt controller state= (0x%" + PRIx64 ") for CPU %ld", state, + kvm_arch_vcpu_id(icp->cs)); return ret; } =20 @@ -240,10 +241,9 @@ void ics_synchronize_state(ICSState *ics) ics_get_kvm_state(ics); } =20 -int ics_set_kvm_state_one(ICSState *ics, int srcno) +int ics_set_kvm_state_one(ICSState *ics, int srcno, Error **errp) { uint64_t state; - Error *local_err =3D NULL; ICSIRQState *irq =3D &ics->irqs[srcno]; int ret; =20 @@ -278,16 +278,15 @@ int ics_set_kvm_state_one(ICSState *ics, int srcno) } =20 ret =3D kvm_device_access(kernel_xics_fd, KVM_DEV_XICS_GRP_SOURCES, - srcno + ics->offset, &state, true, &local_err); - if (local_err) { - error_report_err(local_err); + srcno + ics->offset, &state, true, errp); + if (ret < 0) { return ret; } =20 return 0; } =20 -int ics_set_kvm_state(ICSState *ics) +int ics_set_kvm_state(ICSState *ics, Error **errp) { int i; =20 @@ -297,10 +296,12 @@ int ics_set_kvm_state(ICSState *ics) } =20 for (i =3D 0; i < ics->nr_irqs; i++) { + Error *local_err =3D NULL; int ret; =20 - ret =3D ics_set_kvm_state_one(ics, i); - if (ret) { + ret =3D ics_set_kvm_state_one(ics, i, &local_err); + if (ret < 0) { + error_propagate(errp, local_err); return ret; } } @@ -402,12 +403,18 @@ int xics_kvm_connect(SpaprMachineState *spapr, Error = **errp) } =20 /* Update the KVM sources */ - ics_set_kvm_state(spapr->ics); + ics_set_kvm_state(spapr->ics, &local_err); + if (local_err) { + goto fail; + } =20 /* Connect the presenters to the initial VCPUs of the machine */ CPU_FOREACH(cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); - icp_set_kvm_state(spapr_cpu_state(cpu)->icp); + icp_set_kvm_state(spapr_cpu_state(cpu)->icp, &local_err); + if (local_err) { + goto fail; + } } =20 return 0; diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index eb65ad7e43b7..1eb7b5cd6847 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -190,13 +190,13 @@ Object *icp_create(Object *cpu, const char *type, XIC= SFabric *xi, =20 /* KVM */ void icp_get_kvm_state(ICPState *icp); -int icp_set_kvm_state(ICPState *icp); +int icp_set_kvm_state(ICPState *icp, Error **errp); void icp_synchronize_state(ICPState *icp); void icp_kvm_realize(DeviceState *dev, Error **errp); =20 void ics_get_kvm_state(ICSState *ics); -int ics_set_kvm_state_one(ICSState *ics, int srcno); -int ics_set_kvm_state(ICSState *ics); +int ics_set_kvm_state_one(ICSState *ics, int srcno, Error **errp); +int ics_set_kvm_state(ICSState *ics, Error **errp); void ics_synchronize_state(ICSState *ics); void ics_kvm_set_irq(ICSState *ics, int srcno, int val); =20