From nobody Wed Nov 5 05:42:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504111094497948.8931159290945; Wed, 30 Aug 2017 09:38:14 -0700 (PDT) Received: from localhost ([::1]:51544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn60J-00086S-6r for importer@patchew.org; Wed, 30 Aug 2017 12:38:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50120) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn5yg-0007Ff-3J for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dn5yc-0006GG-Vl for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:30 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54920 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dn5yc-0006Fp-Px for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:26 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7UGTBMS138568 for ; Wed, 30 Aug 2017 12:36:24 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cnx0xp95j-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 30 Aug 2017 12:36:24 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 30 Aug 2017 17:36:22 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 30 Aug 2017 17:36:21 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7UGaLNF19267738; Wed, 30 Aug 2017 16:36:21 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0849352041; Wed, 30 Aug 2017 16:31:48 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id CECC95203F; Wed, 30 Aug 2017 16:31:47 +0100 (BST) From: Halil Pasic To: Cornelia Huck Date: Wed, 30 Aug 2017 18:36:01 +0200 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170830163609.50260-1-pasic@linux.vnet.ibm.com> References: <20170830163609.50260-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17083016-0040-0000-0000-000003D471AC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17083016-0041-0000-0000-000025D4E31C Message-Id: <20170830163609.50260-2-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-30_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708300251 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 1/9] s390x/css: fix cc handling for XSCH X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Jia Shi , Halil Pasic , Pierre Morel , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The function ioinst_handle_xsch is presenting cc 2 when it's supposed to present cc 1 and the other way around, because css_do_xsch has the error codes mixed up. Fixing the error codes also fixes the priority. Let us fix this. Signed-off-by: Halil Pasic Reported-by: Pierre Morel --- hw/s390x/css.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 1880b1a0ff..a50fb0727e 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -1281,12 +1281,12 @@ int css_do_xsch(SubchDev *sch) (!(s->ctrl & (SCSW_ACTL_RESUME_PEND | SCSW_ACTL_START_PEND | SCSW_ACTL_SUSP)= )) || (s->ctrl & SCSW_ACTL_SUBCH_ACTIVE)) { - ret =3D -EINPROGRESS; + ret =3D -EBUSY; goto out; } =20 if (s->ctrl & SCSW_CTRL_MASK_STCTL) { - ret =3D -EBUSY; + ret =3D -EINPROGRESS; goto out; } =20 --=20 2.13.5 From nobody Wed Nov 5 05:42:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504111094513154.876952691444; Wed, 30 Aug 2017 09:38:14 -0700 (PDT) Received: from localhost ([::1]:51545 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn60J-000874-T0 for importer@patchew.org; Wed, 30 Aug 2017 12:38:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn5yh-0007Fk-8C for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dn5ye-0006Gv-5F for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:31 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59494 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dn5yd-0006Gn-VL for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:28 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7UGWMlh123925 for ; Wed, 30 Aug 2017 12:36:27 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cnx1vp5je-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 30 Aug 2017 12:36:27 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 30 Aug 2017 17:36:25 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 30 Aug 2017 17:36:22 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7UGaMQh19005628; Wed, 30 Aug 2017 16:36:22 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36B0052043; Wed, 30 Aug 2017 16:31:49 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 089A152041; Wed, 30 Aug 2017 16:31:49 +0100 (BST) From: Halil Pasic To: Cornelia Huck Date: Wed, 30 Aug 2017 18:36:02 +0200 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170830163609.50260-1-pasic@linux.vnet.ibm.com> References: <20170830163609.50260-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17083016-0040-0000-0000-000003F46E7F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17083016-0041-0000-0000-00002094D2E6 Message-Id: <20170830163609.50260-3-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-30_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708300251 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 2/9] s390x: fix invalid use of cc 1 for SSCH X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Jia Shi , Halil Pasic , Pierre Morel , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" According to the POP a start subchannel instruction (SSCH) returning with cc 1 implies that the subchannel was status pending when SSCH executed. Due to a somewhat confusing error handling, where error codes are mapped to cc value, sane looking error codes result in non AR compliant behavior. Let's fix this! Instead of cc 1 we use cc 3 which means device not operational, and is much closer to the truth in the given cases. Signed-off-by: Halil Pasic Acked-by: Pierre Morel --- This patch turned out quite controversial. We did not reach a consensus during the internal review. The most of the discussion revolved around the ORB flag which architecturally must be supported, but are currently not supported by vfio-ccw (not yet, or can't be). The idea showing the most promise for consensus was to handle this via device status (along the lines better a strange acting device than a non-conform machine) but since it's a radical change we decided to first discuss upstream and then do whatever needs to be done. --- hw/s390x/css.c | 15 ++++++--------- hw/s390x/s390-ccw.c | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index a50fb0727e..0822538cde 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -1034,7 +1034,7 @@ static int sch_handle_start_func_passthrough(SubchDev= *sch) */ if (!(orb->ctrl0 & ORB_CTRL0_MASK_PFCH) || !(orb->ctrl0 & ORB_CTRL0_MASK_C64)) { - return -EINVAL; + return -ENODEV; } =20 ret =3D s390_ccw_cmd_request(orb, s, sch->driver_data); @@ -1046,16 +1046,13 @@ static int sch_handle_start_func_passthrough(SubchD= ev *sch) break; case -ENODEV: break; + case -EFAULT: + break; case -EACCES: /* Let's reflect an inaccessible host device by cc 3. */ - ret =3D -ENODEV; - break; default: - /* - * All other return codes will trigger a program check, - * or set cc to 1. - */ - break; + /* Let's make all other return codes map to cc 3. */ + ret =3D -ENODEV; }; =20 return ret; @@ -1115,7 +1112,7 @@ static int do_subchannel_work(SubchDev *sch) if (sch->do_subchannel_work) { return sch->do_subchannel_work(sch); } else { - return -EINVAL; + return -ENODEV; } } =20 diff --git a/hw/s390x/s390-ccw.c b/hw/s390x/s390-ccw.c index 8614dda6f8..2b0741741c 100644 --- a/hw/s390x/s390-ccw.c +++ b/hw/s390x/s390-ccw.c @@ -25,7 +25,7 @@ int s390_ccw_cmd_request(ORB *orb, SCSW *scsw, void *data) if (cdc->handle_request) { return cdc->handle_request(orb, scsw, data); } else { - return -ENOSYS; + return -ENODEV; } } =20 --=20 2.13.5 From nobody Wed Nov 5 05:42:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504111337276163.4258316417305; Wed, 30 Aug 2017 09:42:17 -0700 (PDT) Received: from localhost ([::1]:51563 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn64E-0003LI-DS for importer@patchew.org; Wed, 30 Aug 2017 12:42:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn5yj-0007G6-II for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dn5yg-0006I4-FM for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:33 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:36456) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dn5yg-0006HN-5o for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:30 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7UGYFin061836 for ; Wed, 30 Aug 2017 12:36:28 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cnyf4p67p-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 30 Aug 2017 12:36:28 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 30 Aug 2017 17:36:26 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 30 Aug 2017 17:36:24 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7UGaNkI16777376; Wed, 30 Aug 2017 16:36:23 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 64D8D52043; Wed, 30 Aug 2017 16:31:50 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 3703A5203F; Wed, 30 Aug 2017 16:31:50 +0100 (BST) From: Halil Pasic To: Cornelia Huck Date: Wed, 30 Aug 2017 18:36:03 +0200 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170830163609.50260-1-pasic@linux.vnet.ibm.com> References: <20170830163609.50260-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17083016-0020-0000-0000-000003B26EAD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17083016-0021-0000-0000-00004242C0A4 Message-Id: <20170830163609.50260-4-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-30_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708300251 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 3/9] s390x/css: be more consistent if broken beyond repair X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Jia Shi , Halil Pasic , Pierre Morel , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If we detect that the internally manged state of the subchannel is broken beyond repair while in do_subchannel_work in case of virtual we just abort the operation and pretend all went well, while in case of pass-through we honor the situation with -ENODEV which results in cc 3 for the instruction whose handler triggered the call. Let's be consistent on this and do the -ENODEV also for virtual subchannels. Signed-off-by: Halil Pasic Acked-by: Pierre Morel --- hw/s390x/css.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 0822538cde..bc47bf5b20 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -1078,7 +1078,7 @@ int do_subchannel_work_virtual(SubchDev *sch) sch_handle_start_func_virtual(sch); } else { /* Cannot happen. */ - return 0; + return -ENODEV; } css_inject_io_interrupt(sch); return 0; --=20 2.13.5 From nobody Wed Nov 5 05:42:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504111228543994.0590120862598; Wed, 30 Aug 2017 09:40:28 -0700 (PDT) Received: from localhost ([::1]:51551 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn62U-0001pK-2e for importer@patchew.org; Wed, 30 Aug 2017 12:40:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn5yl-0007Hz-7Y for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dn5yi-0006J5-P3 for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:35 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50007) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dn5yi-0006Ij-H5 for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:32 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7UGa36d083450 for ; Wed, 30 Aug 2017 12:36:29 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cnur1hj5k-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 30 Aug 2017 12:36:29 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 30 Aug 2017 17:36:26 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 30 Aug 2017 17:36:25 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7UGaOAh22413364; Wed, 30 Aug 2017 16:36:24 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9CDF252049; Wed, 30 Aug 2017 16:31:51 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 6582452043; Wed, 30 Aug 2017 16:31:51 +0100 (BST) From: Halil Pasic To: Cornelia Huck Date: Wed, 30 Aug 2017 18:36:04 +0200 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170830163609.50260-1-pasic@linux.vnet.ibm.com> References: <20170830163609.50260-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17083016-0008-0000-0000-000004917045 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17083016-0009-0000-0000-00001E21C2D6 Message-Id: <20170830163609.50260-5-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-30_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708300251 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 4/9] s390x: refactor error handling for SSCH and RSCH X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Jia Shi , Halil Pasic , Pierre Morel , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Simplify the error handling of the SSCH and RSCH handler avoiding arbitrary and cryptic error codes being mapped to what a subchannel is supposed to do. Let the code detecting the condition tell how it's to be handled in a less ambiguous way. It's best to handle SSCH and RSCH in one go as the emulation of the two shares a lot of code. Signed-off-by: Halil Pasic Acked-by: Pierre Morel --- Notes: Funny, we had a different swich-case for SSCH and RSCH. For virtual it did not matter, but for passtrough it could. In practice -EINVAL from the kernel would have been mapped to cc 2 in case of RSCH and to cc 1 in case of SSHC which is absurd. Same goes for -EBUSY from kernel which is correctly mapped to cc 2 in case of SSCH, but for RSCH it gets mapped to cc 1 which is also absurd. --- hw/s390x/css.c | 86 ++++++++++++++---------------------------= ---- hw/s390x/s390-ccw.c | 8 ++--- hw/vfio/ccw.c | 32 +++++++++++++---- include/hw/s390x/css.h | 30 ++++++++++++---- include/hw/s390x/s390-ccw.h | 2 +- target/s390x/ioinst.c | 61 +++++++++----------------------- 6 files changed, 97 insertions(+), 122 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index bc47bf5b20..1102642c10 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -1015,12 +1015,11 @@ static void sch_handle_start_func_virtual(SubchDev = *sch) =20 } =20 -static int sch_handle_start_func_passthrough(SubchDev *sch) +static void sch_handle_start_func_passthrough(SubchDev *sch) { =20 PMCW *p =3D &sch->curr_status.pmcw; SCSW *s =3D &sch->curr_status.scsw; - int ret; =20 ORB *orb =3D &sch->orb; if (!(s->ctrl & SCSW_ACTL_SUSP)) { @@ -1034,28 +1033,10 @@ static int sch_handle_start_func_passthrough(SubchD= ev *sch) */ if (!(orb->ctrl0 & ORB_CTRL0_MASK_PFCH) || !(orb->ctrl0 & ORB_CTRL0_MASK_C64)) { - return -ENODEV; + sch->iret.cc =3D 3; } =20 - ret =3D s390_ccw_cmd_request(orb, s, sch->driver_data); - switch (ret) { - /* Currently we don't update control block and just return the cc code= . */ - case 0: - break; - case -EBUSY: - break; - case -ENODEV: - break; - case -EFAULT: - break; - case -EACCES: - /* Let's reflect an inaccessible host device by cc 3. */ - default: - /* Let's make all other return codes map to cc 3. */ - ret =3D -ENODEV; - }; - - return ret; + s390_ccw_cmd_request(sch); } =20 /* @@ -1064,7 +1045,7 @@ static int sch_handle_start_func_passthrough(SubchDev= *sch) * read/writes) asynchronous later on if we start supporting more than * our current very simple devices. */ -int do_subchannel_work_virtual(SubchDev *sch) +void do_subchannel_work_virtual(SubchDev *sch) { =20 SCSW *s =3D &sch->curr_status.scsw; @@ -1078,41 +1059,35 @@ int do_subchannel_work_virtual(SubchDev *sch) sch_handle_start_func_virtual(sch); } else { /* Cannot happen. */ - return -ENODEV; + sch->iret.cc =3D 3; } css_inject_io_interrupt(sch); - return 0; } =20 -int do_subchannel_work_passthrough(SubchDev *sch) +void do_subchannel_work_passthrough(SubchDev *sch) { - int ret; SCSW *s =3D &sch->curr_status.scsw; =20 if (s->ctrl & SCSW_FCTL_CLEAR_FUNC) { /* TODO: Clear handling */ sch_handle_clear_func(sch); - ret =3D 0; } else if (s->ctrl & SCSW_FCTL_HALT_FUNC) { /* TODO: Halt handling */ sch_handle_halt_func(sch); - ret =3D 0; } else if (s->ctrl & SCSW_FCTL_START_FUNC) { - ret =3D sch_handle_start_func_passthrough(sch); + sch_handle_start_func_passthrough(sch); } else { /* Cannot happen. */ - return -ENODEV; + sch->iret.cc =3D 3; } - - return ret; } =20 -static int do_subchannel_work(SubchDev *sch) +static void do_subchannel_work(SubchDev *sch) { if (sch->do_subchannel_work) { - return sch->do_subchannel_work(sch); + sch->do_subchannel_work(sch); } else { - return -ENODEV; + sch->iret.cc =3D 3; } } =20 @@ -1400,27 +1375,26 @@ static void css_update_chnmon(SubchDev *sch) } } =20 -int css_do_ssch(SubchDev *sch, ORB *orb) +void css_do_ssch(SubchDev *sch, ORB *orb) { SCSW *s =3D &sch->curr_status.scsw; PMCW *p =3D &sch->curr_status.pmcw; - int ret; =20 if (~(p->flags) & (PMCW_FLAGS_MASK_DNV | PMCW_FLAGS_MASK_ENA)) { - ret =3D -ENODEV; - goto out; + sch->iret.cc =3D 3; + return; } =20 if (s->ctrl & SCSW_STCTL_STATUS_PEND) { - ret =3D -EINPROGRESS; - goto out; + sch->iret.cc =3D 1; + return; } =20 if (s->ctrl & (SCSW_FCTL_START_FUNC | SCSW_FCTL_HALT_FUNC | SCSW_FCTL_CLEAR_FUNC)) { - ret =3D -EBUSY; - goto out; + sch->iret.cc =3D 2; + return; } =20 /* If monitoring is active, update counter. */ @@ -1433,10 +1407,7 @@ int css_do_ssch(SubchDev *sch, ORB *orb) s->ctrl |=3D (SCSW_FCTL_START_FUNC | SCSW_ACTL_START_PEND); s->flags &=3D ~SCSW_FLAGS_MASK_PNO; =20 - ret =3D do_subchannel_work(sch); - -out: - return ret; + do_subchannel_work(sch); } =20 static void copy_irb_to_guest(IRB *dest, const IRB *src, PMCW *pmcw, @@ -1683,27 +1654,26 @@ void css_do_schm(uint8_t mbk, int update, int dct, = uint64_t mbo) } } =20 -int css_do_rsch(SubchDev *sch) +void css_do_rsch(SubchDev *sch) { SCSW *s =3D &sch->curr_status.scsw; PMCW *p =3D &sch->curr_status.pmcw; - int ret; =20 if (~(p->flags) & (PMCW_FLAGS_MASK_DNV | PMCW_FLAGS_MASK_ENA)) { - ret =3D -ENODEV; - goto out; + sch->iret.cc =3D 3; + return; } =20 if (s->ctrl & SCSW_STCTL_STATUS_PEND) { - ret =3D -EINPROGRESS; - goto out; + sch->iret.cc =3D 1; + return; } =20 if (((s->ctrl & SCSW_CTRL_MASK_FCTL) !=3D SCSW_FCTL_START_FUNC) || (s->ctrl & SCSW_ACTL_RESUME_PEND) || (!(s->ctrl & SCSW_ACTL_SUSP))) { - ret =3D -EINVAL; - goto out; + sch->iret.cc =3D 2; + return; } =20 /* If monitoring is active, update counter. */ @@ -1713,10 +1683,6 @@ int css_do_rsch(SubchDev *sch) =20 s->ctrl |=3D SCSW_ACTL_RESUME_PEND; do_subchannel_work(sch); - ret =3D 0; - -out: - return ret; } =20 int css_do_rchp(uint8_t cssid, uint8_t chpid) diff --git a/hw/s390x/s390-ccw.c b/hw/s390x/s390-ccw.c index 2b0741741c..fa0947894d 100644 --- a/hw/s390x/s390-ccw.c +++ b/hw/s390x/s390-ccw.c @@ -18,14 +18,14 @@ #include "hw/s390x/css-bridge.h" #include "hw/s390x/s390-ccw.h" =20 -int s390_ccw_cmd_request(ORB *orb, SCSW *scsw, void *data) +void s390_ccw_cmd_request(SubchDev *sch) { - S390CCWDeviceClass *cdc =3D S390_CCW_DEVICE_GET_CLASS(data); + S390CCWDeviceClass *cdc =3D S390_CCW_DEVICE_GET_CLASS(sch->driver_data= ); =20 if (cdc->handle_request) { - return cdc->handle_request(orb, scsw, data); + cdc->handle_request(sch); } else { - return -ENODEV; + sch->iret.cc =3D 3; } } =20 diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index a8baadf57a..b2827ce987 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -23,6 +23,7 @@ #include "hw/s390x/s390-ccw.h" #include "hw/s390x/ccw-device.h" #include "qemu/error-report.h" +#include "cpu.h" =20 #define TYPE_VFIO_CCW "vfio-ccw" typedef struct VFIOCCWDevice { @@ -47,9 +48,9 @@ struct VFIODeviceOps vfio_ccw_ops =3D { .vfio_compute_needs_reset =3D vfio_ccw_compute_needs_reset, }; =20 -static int vfio_ccw_handle_request(ORB *orb, SCSW *scsw, void *data) +static void vfio_ccw_handle_request(SubchDev *sch) { - S390CCWDevice *cdev =3D data; + S390CCWDevice *cdev =3D sch->driver_data; VFIOCCWDevice *vcdev =3D DO_UPCAST(VFIOCCWDevice, cdev, cdev); struct ccw_io_region *region =3D vcdev->io_region; int ret; @@ -60,8 +61,8 @@ static int vfio_ccw_handle_request(ORB *orb, SCSW *scsw, = void *data) =20 memset(region, 0, sizeof(*region)); =20 - memcpy(region->orb_area, orb, sizeof(ORB)); - memcpy(region->scsw_area, scsw, sizeof(SCSW)); + memcpy(region->orb_area, &sch->orb, sizeof(ORB)); + memcpy(region->scsw_area, &sch->curr_status.scsw, sizeof(SCSW)); =20 again: ret =3D pwrite(vcdev->vdev.fd, region, @@ -71,10 +72,27 @@ again: goto again; } error_report("vfio-ccw: wirte I/O region failed with errno=3D%d", = errno); - return -errno; + ret =3D -errno; + } else { + ret =3D region->ret_code; + } + switch (-ret) { + /* Currently we don't update control block and just return the cc code= . */ + case 0: + sch->iret.cc =3D 0; + break; + case EBUSY: + sch->iret.cc =3D 2; + break; + case EFAULT: + sch->iret.pgm_chk =3D true; + sch->iret.irq_code =3D PGM_ADDRESSING; + break; + case ENODEV: + case EACCES: + default: + sch->iret.cc =3D 3; } - - return region->ret_code; } =20 static void vfio_ccw_reset(DeviceState *dev) diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index 5c5fe6b202..d093181a9e 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -94,13 +94,31 @@ struct SubchDev { /* transport-provided data: */ int (*ccw_cb) (SubchDev *, CCW1); void (*disable_cb)(SubchDev *); - int (*do_subchannel_work) (SubchDev *); + void (*do_subchannel_work) (SubchDev *); SenseId id; void *driver_data; + /* io instructions conclude according to iret */ + struct { + /* + * General semantic of cc codes of IO instructions is (brief): + * 0 -- produced expected result + * 1 -- produced alternate result + * 2 -- ineffective, because busy with previously initiated functi= on + * 3 -- ineffective, not operational + */ + uint32_t cc:4; + bool pgm_chk:1; + uint32_t irq_code; + } iret; }; =20 extern const VMStateDescription vmstate_subch_dev; =20 +static inline void css_subch_clear_iret(SubchDev *sch) +{ + memset(&sch->iret, 0, sizeof(sch->iret)); +} + /* * Identify a device within the channel subsystem. * Note that this can be used to identify either the subchannel or @@ -156,9 +174,9 @@ void css_generate_sch_crws(uint8_t cssid, uint8_t ssid,= uint16_t schid, void css_generate_chp_crws(uint8_t cssid, uint8_t chpid); void css_generate_css_crws(uint8_t cssid); void css_clear_sei_pending(void); -int s390_ccw_cmd_request(ORB *orb, SCSW *scsw, void *data); -int do_subchannel_work_virtual(SubchDev *sub); -int do_subchannel_work_passthrough(SubchDev *sub); +void s390_ccw_cmd_request(SubchDev *sch); +void do_subchannel_work_virtual(SubchDev *sub); +void do_subchannel_work_passthrough(SubchDev *sub); =20 typedef enum { CSS_IO_ADAPTER_VIRTIO =3D 0, @@ -189,7 +207,7 @@ int css_do_msch(SubchDev *sch, const SCHIB *schib); int css_do_xsch(SubchDev *sch); int css_do_csch(SubchDev *sch); int css_do_hsch(SubchDev *sch); -int css_do_ssch(SubchDev *sch, ORB *orb); +void css_do_ssch(SubchDev *sch, ORB *orb); int css_do_tsch_get_irb(SubchDev *sch, IRB *irb, int *irb_len); void css_do_tsch_update_subch(SubchDev *sch); int css_do_stcrw(CRW *crw); @@ -200,7 +218,7 @@ int css_collect_chp_desc(int m, uint8_t cssid, uint8_t = f_chpid, uint8_t l_chpid, void css_do_schm(uint8_t mbk, int update, int dct, uint64_t mbo); int css_enable_mcsse(void); int css_enable_mss(void); -int css_do_rsch(SubchDev *sch); +void css_do_rsch(SubchDev *sch); int css_do_rchp(uint8_t cssid, uint8_t chpid); bool css_present(uint8_t cssid); #endif diff --git a/include/hw/s390x/s390-ccw.h b/include/hw/s390x/s390-ccw.h index 9f45cf1347..d2159c9ed7 100644 --- a/include/hw/s390x/s390-ccw.h +++ b/include/hw/s390x/s390-ccw.h @@ -33,7 +33,7 @@ typedef struct S390CCWDeviceClass { CCWDeviceClass parent_class; void (*realize)(S390CCWDevice *dev, char *sysfsdev, Error **errp); void (*unrealize)(S390CCWDevice *dev, Error **errp); - int (*handle_request) (ORB *, SCSW *, void *); + void (*handle_request) (SubchDev *sch); } S390CCWDeviceClass; =20 #endif diff --git a/target/s390x/ioinst.c b/target/s390x/ioinst.c index 51fbea620d..e8044068c2 100644 --- a/target/s390x/ioinst.c +++ b/target/s390x/ioinst.c @@ -217,8 +217,6 @@ void ioinst_handle_ssch(S390CPU *cpu, uint64_t reg1, ui= nt32_t ipb) SubchDev *sch; ORB orig_orb, orb; uint64_t addr; - int ret =3D -ENODEV; - int cc; CPUS390XState *env =3D &cpu->env; uint8_t ar; =20 @@ -238,33 +236,17 @@ void ioinst_handle_ssch(S390CPU *cpu, uint64_t reg1, = uint32_t ipb) } trace_ioinst_sch_id("ssch", cssid, ssid, schid); sch =3D css_find_subch(m, cssid, ssid, schid); - if (sch && css_subch_visible(sch)) { - ret =3D css_do_ssch(sch, &orb); + if (!sch || !css_subch_visible(sch)) { + setcc(cpu, 3); + return; } - switch (ret) { - case -ENODEV: - cc =3D 3; - break; - case -EBUSY: - cc =3D 2; - break; - case -EFAULT: - /* - * TODO: - * I'm wondering whether there is something better - * to do for us here (like setting some device or - * subchannel status). - */ - program_interrupt(env, PGM_ADDRESSING, 4); + css_subch_clear_iret(sch); + css_do_ssch(sch, &orb); + if (sch->iret.pgm_chk) { + program_interrupt(env, sch->iret.irq_code, 4); return; - case 0: - cc =3D 0; - break; - default: - cc =3D 1; - break; } - setcc(cpu, cc); + setcc(cpu, sch->iret.cc); } =20 void ioinst_handle_stcrw(S390CPU *cpu, uint32_t ipb) @@ -767,8 +749,6 @@ void ioinst_handle_rsch(S390CPU *cpu, uint64_t reg1) { int cssid, ssid, schid, m; SubchDev *sch; - int ret =3D -ENODEV; - int cc; =20 if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { program_interrupt(&cpu->env, PGM_OPERAND, 4); @@ -776,24 +756,17 @@ void ioinst_handle_rsch(S390CPU *cpu, uint64_t reg1) } trace_ioinst_sch_id("rsch", cssid, ssid, schid); sch =3D css_find_subch(m, cssid, ssid, schid); - if (sch && css_subch_visible(sch)) { - ret =3D css_do_rsch(sch); + if (!sch || !css_subch_visible(sch)) { + setcc(cpu, 3); + return; } - switch (ret) { - case -ENODEV: - cc =3D 3; - break; - case -EINVAL: - cc =3D 2; - break; - case 0: - cc =3D 0; - break; - default: - cc =3D 1; - break; + css_subch_clear_iret(sch); + css_do_rsch(sch); + if (sch->iret.pgm_chk) { + program_interrupt(&cpu->env, sch->iret.irq_code, 4); + return; } - setcc(cpu, cc); + setcc(cpu, sch->iret.cc); } =20 #define RCHP_REG1_RES(_reg) (_reg & 0x00000000ff00ff00) --=20 2.13.5 From nobody Wed Nov 5 05:42:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504111533813679.8691675279613; Wed, 30 Aug 2017 09:45:33 -0700 (PDT) Received: from localhost ([::1]:51581 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn67P-0005o9-HV for importer@patchew.org; Wed, 30 Aug 2017 12:45:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50204) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn5ym-0007I3-AG for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dn5yj-0006JJ-4n for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:36 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:36591) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dn5yi-0006Io-SN for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:33 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7UGYBjx061708 for ; Wed, 30 Aug 2017 12:36:31 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cnyf4p6a9-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 30 Aug 2017 12:36:31 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 30 Aug 2017 17:36:28 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 30 Aug 2017 17:36:26 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7UGaQ1f21037306; Wed, 30 Aug 2017 16:36:26 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CB40E5203F; Wed, 30 Aug 2017 16:31:52 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 9D87E52043; Wed, 30 Aug 2017 16:31:52 +0100 (BST) From: Halil Pasic To: Cornelia Huck Date: Wed, 30 Aug 2017 18:36:05 +0200 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170830163609.50260-1-pasic@linux.vnet.ibm.com> References: <20170830163609.50260-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17083016-0040-0000-0000-000003F46E80 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17083016-0041-0000-0000-00002094D2E7 Message-Id: <20170830163609.50260-6-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-30_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708300251 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 5/9] s390x: refactor error handling for XSCH handler X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Jia Shi , Halil Pasic , Pierre Morel , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Simplify the error handling of the XSCH handler avoiding arbitrary and cryptic error codes being mapped to what a subchannel is supposed to do. Let the code detecting the condition tell how it's to be handled in a less ambiguous way. Signed-off-by: Halil Pasic Acked-by: Pierre Morel --- hw/s390x/css.c | 19 +++++++------------ include/hw/s390x/css.h | 2 +- target/s390x/ioinst.c | 27 +++++++++------------------ 3 files changed, 17 insertions(+), 31 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 1102642c10..7880c2c025 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -1237,15 +1237,14 @@ out: return ret; } =20 -int css_do_xsch(SubchDev *sch) +void css_do_xsch(SubchDev *sch) { SCSW *s =3D &sch->curr_status.scsw; PMCW *p =3D &sch->curr_status.pmcw; - int ret; =20 if (~(p->flags) & (PMCW_FLAGS_MASK_DNV | PMCW_FLAGS_MASK_ENA)) { - ret =3D -ENODEV; - goto out; + sch->iret.cc =3D 3; + return; } =20 if (!(s->ctrl & SCSW_CTRL_MASK_FCTL) || @@ -1253,13 +1252,13 @@ int css_do_xsch(SubchDev *sch) (!(s->ctrl & (SCSW_ACTL_RESUME_PEND | SCSW_ACTL_START_PEND | SCSW_ACTL_SUSP)= )) || (s->ctrl & SCSW_ACTL_SUBCH_ACTIVE)) { - ret =3D -EBUSY; - goto out; + sch->iret.cc =3D 2; + return; } =20 if (s->ctrl & SCSW_CTRL_MASK_STCTL) { - ret =3D -EINPROGRESS; - goto out; + sch->iret.cc =3D 1; + return; } =20 /* Cancel the current operation. */ @@ -1271,10 +1270,6 @@ int css_do_xsch(SubchDev *sch) sch->last_cmd_valid =3D false; s->dstat =3D 0; s->cstat =3D 0; - ret =3D 0; - -out: - return ret; } =20 int css_do_csch(SubchDev *sch) diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index d093181a9e..d78ee5714b 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -204,7 +204,7 @@ void css_conditional_io_interrupt(SubchDev *sch); int css_do_stsch(SubchDev *sch, SCHIB *schib); bool css_schid_final(int m, uint8_t cssid, uint8_t ssid, uint16_t schid); int css_do_msch(SubchDev *sch, const SCHIB *schib); -int css_do_xsch(SubchDev *sch); +void css_do_xsch(SubchDev *sch); int css_do_csch(SubchDev *sch); int css_do_hsch(SubchDev *sch); void css_do_ssch(SubchDev *sch, ORB *orb); diff --git a/target/s390x/ioinst.c b/target/s390x/ioinst.c index e8044068c2..f8e038fac7 100644 --- a/target/s390x/ioinst.c +++ b/target/s390x/ioinst.c @@ -41,8 +41,6 @@ void ioinst_handle_xsch(S390CPU *cpu, uint64_t reg1) { int cssid, ssid, schid, m; SubchDev *sch; - int ret =3D -ENODEV; - int cc; =20 if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { program_interrupt(&cpu->env, PGM_OPERAND, 4); @@ -50,24 +48,17 @@ void ioinst_handle_xsch(S390CPU *cpu, uint64_t reg1) } trace_ioinst_sch_id("xsch", cssid, ssid, schid); sch =3D css_find_subch(m, cssid, ssid, schid); - if (sch && css_subch_visible(sch)) { - ret =3D css_do_xsch(sch); + if (!sch || !css_subch_visible(sch)) { + setcc(cpu, 3); + return; } - switch (ret) { - case -ENODEV: - cc =3D 3; - break; - case -EBUSY: - cc =3D 2; - break; - case 0: - cc =3D 0; - break; - default: - cc =3D 1; - break; + css_subch_clear_iret(sch); + css_do_xsch(sch); + if (sch->iret.pgm_chk) { + program_interrupt(&cpu->env, sch->iret.irq_code, 4); + return; } - setcc(cpu, cc); + setcc(cpu, sch->iret.cc); } =20 void ioinst_handle_csch(S390CPU *cpu, uint64_t reg1) --=20 2.13.5 From nobody Wed Nov 5 05:42:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504111102497916.7701855072153; Wed, 30 Aug 2017 09:38:22 -0700 (PDT) Received: from localhost ([::1]:51546 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn60S-0008Am-Kc for importer@patchew.org; Wed, 30 Aug 2017 12:38:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50181) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn5yl-0007Hw-6O for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dn5yj-0006JS-9s for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:35 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59888 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dn5yj-0006J9-4F for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:33 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7UGTBKp111808 for ; Wed, 30 Aug 2017 12:36:32 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cnx1vp5pc-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 30 Aug 2017 12:36:32 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 30 Aug 2017 17:36:30 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 30 Aug 2017 17:36:27 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7UGaR6i29687854; Wed, 30 Aug 2017 16:36:27 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1198352041; Wed, 30 Aug 2017 16:31:54 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id D039C5203F; Wed, 30 Aug 2017 16:31:53 +0100 (BST) From: Halil Pasic To: Cornelia Huck Date: Wed, 30 Aug 2017 18:36:06 +0200 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170830163609.50260-1-pasic@linux.vnet.ibm.com> References: <20170830163609.50260-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17083016-0020-0000-0000-000003B26EAE X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17083016-0021-0000-0000-00004242C0A5 Message-Id: <20170830163609.50260-7-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-30_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708300251 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 6/9] s390x: refactor error handling for CSCH handler X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Jia Shi , Halil Pasic , Pierre Morel , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Simplify the error handling of the CSCH handler avoiding arbitrary and cryptic error codes being mapped to what a subchannel is supposed to do. Let the code detecting the condition tell how it's to be handled in a less ambiguous way. Signed-off-by: Halil Pasic Reviewed-by: Pierre Morel --- hw/s390x/css.c | 11 +++-------- include/hw/s390x/css.h | 2 +- target/s390x/ioinst.c | 18 +++++++++--------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 7880c2c025..e661a87387 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -1272,15 +1272,14 @@ void css_do_xsch(SubchDev *sch) s->cstat =3D 0; } =20 -int css_do_csch(SubchDev *sch) +void css_do_csch(SubchDev *sch) { SCSW *s =3D &sch->curr_status.scsw; PMCW *p =3D &sch->curr_status.pmcw; - int ret; =20 if (~(p->flags) & (PMCW_FLAGS_MASK_DNV | PMCW_FLAGS_MASK_ENA)) { - ret =3D -ENODEV; - goto out; + sch->iret.cc =3D 3; + return; } =20 /* Trigger the clear function. */ @@ -1288,10 +1287,6 @@ int css_do_csch(SubchDev *sch) s->ctrl |=3D SCSW_FCTL_CLEAR_FUNC | SCSW_ACTL_CLEAR_PEND; =20 do_subchannel_work(sch); - ret =3D 0; - -out: - return ret; } =20 int css_do_hsch(SubchDev *sch) diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index d78ee5714b..d5a7e460ec 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -205,7 +205,7 @@ int css_do_stsch(SubchDev *sch, SCHIB *schib); bool css_schid_final(int m, uint8_t cssid, uint8_t ssid, uint16_t schid); int css_do_msch(SubchDev *sch, const SCHIB *schib); void css_do_xsch(SubchDev *sch); -int css_do_csch(SubchDev *sch); +void css_do_csch(SubchDev *sch); int css_do_hsch(SubchDev *sch); void css_do_ssch(SubchDev *sch, ORB *orb); int css_do_tsch_get_irb(SubchDev *sch, IRB *irb, int *irb_len); diff --git a/target/s390x/ioinst.c b/target/s390x/ioinst.c index f8e038fac7..501f3135ad 100644 --- a/target/s390x/ioinst.c +++ b/target/s390x/ioinst.c @@ -65,8 +65,6 @@ void ioinst_handle_csch(S390CPU *cpu, uint64_t reg1) { int cssid, ssid, schid, m; SubchDev *sch; - int ret =3D -ENODEV; - int cc; =20 if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { program_interrupt(&cpu->env, PGM_OPERAND, 4); @@ -74,15 +72,17 @@ void ioinst_handle_csch(S390CPU *cpu, uint64_t reg1) } trace_ioinst_sch_id("csch", cssid, ssid, schid); sch =3D css_find_subch(m, cssid, ssid, schid); - if (sch && css_subch_visible(sch)) { - ret =3D css_do_csch(sch); + if (!sch || !css_subch_visible(sch)) { + setcc(cpu, 3); + return; } - if (ret =3D=3D -ENODEV) { - cc =3D 3; - } else { - cc =3D 0; + css_subch_clear_iret(sch); + css_do_csch(sch); + if (sch->iret.pgm_chk) { + program_interrupt(&cpu->env, sch->iret.irq_code, 4); + return; } - setcc(cpu, cc); + setcc(cpu, sch->iret.cc); } =20 void ioinst_handle_hsch(S390CPU *cpu, uint64_t reg1) --=20 2.13.5 From nobody Wed Nov 5 05:42:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504111440198611.5039686010418; Wed, 30 Aug 2017 09:44:00 -0700 (PDT) Received: from localhost ([::1]:51569 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn65t-0004TM-QJ for importer@patchew.org; Wed, 30 Aug 2017 12:43:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn5ym-0007I2-70 for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dn5yj-0006JD-1H for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:36 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44875 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dn5yi-0006It-SF for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:32 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7UGT9OY033495 for ; Wed, 30 Aug 2017 12:36:32 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cnxcqv6jp-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 30 Aug 2017 12:36:31 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 30 Aug 2017 17:36:30 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 30 Aug 2017 17:36:29 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7UGaSkj27066592; Wed, 30 Aug 2017 16:36:28 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4783052041; Wed, 30 Aug 2017 16:31:55 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 122A85203F; Wed, 30 Aug 2017 16:31:55 +0100 (BST) From: Halil Pasic To: Cornelia Huck Date: Wed, 30 Aug 2017 18:36:07 +0200 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170830163609.50260-1-pasic@linux.vnet.ibm.com> References: <20170830163609.50260-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17083016-0012-0000-0000-000005737A46 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17083016-0013-0000-0000-000018EB9D25 Message-Id: <20170830163609.50260-8-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-30_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708300251 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 7/9] s390x: refactor error handling for HSCH handler X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Jia Shi , Halil Pasic , Pierre Morel , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Simplify the error handling of the HSCH handler avoiding arbitrary and cryptic error codes being mapped to what a subchannel is supposed to do. Let the code detecting the condition tell how it's to be handled in a less ambiguous way. Signed-off-by: Halil Pasic Reviewed-by: Pierre Morel --- hw/s390x/css.c | 19 +++++++------------ include/hw/s390x/css.h | 2 +- target/s390x/ioinst.c | 27 +++++++++------------------ 3 files changed, 17 insertions(+), 31 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index e661a87387..eff1b91a8c 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -1289,28 +1289,27 @@ void css_do_csch(SubchDev *sch) do_subchannel_work(sch); } =20 -int css_do_hsch(SubchDev *sch) +void css_do_hsch(SubchDev *sch) { SCSW *s =3D &sch->curr_status.scsw; PMCW *p =3D &sch->curr_status.pmcw; - int ret; =20 if (~(p->flags) & (PMCW_FLAGS_MASK_DNV | PMCW_FLAGS_MASK_ENA)) { - ret =3D -ENODEV; - goto out; + sch->iret.cc =3D 3; + return; } =20 if (((s->ctrl & SCSW_CTRL_MASK_STCTL) =3D=3D SCSW_STCTL_STATUS_PEND) || (s->ctrl & (SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY | SCSW_STCTL_ALERT))) { - ret =3D -EINPROGRESS; - goto out; + sch->iret.cc =3D 1; + return; } =20 if (s->ctrl & (SCSW_FCTL_HALT_FUNC | SCSW_FCTL_CLEAR_FUNC)) { - ret =3D -EBUSY; - goto out; + sch->iret.cc =3D 2; + return; } =20 /* Trigger the halt function. */ @@ -1324,10 +1323,6 @@ int css_do_hsch(SubchDev *sch) s->ctrl |=3D SCSW_ACTL_HALT_PEND; =20 do_subchannel_work(sch); - ret =3D 0; - -out: - return ret; } =20 static void css_update_chnmon(SubchDev *sch) diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index d5a7e460ec..d8d949da4f 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -206,7 +206,7 @@ bool css_schid_final(int m, uint8_t cssid, uint8_t ssid= , uint16_t schid); int css_do_msch(SubchDev *sch, const SCHIB *schib); void css_do_xsch(SubchDev *sch); void css_do_csch(SubchDev *sch); -int css_do_hsch(SubchDev *sch); +void css_do_hsch(SubchDev *sch); void css_do_ssch(SubchDev *sch, ORB *orb); int css_do_tsch_get_irb(SubchDev *sch, IRB *irb, int *irb_len); void css_do_tsch_update_subch(SubchDev *sch); diff --git a/target/s390x/ioinst.c b/target/s390x/ioinst.c index 501f3135ad..e91788d586 100644 --- a/target/s390x/ioinst.c +++ b/target/s390x/ioinst.c @@ -89,8 +89,6 @@ void ioinst_handle_hsch(S390CPU *cpu, uint64_t reg1) { int cssid, ssid, schid, m; SubchDev *sch; - int ret =3D -ENODEV; - int cc; =20 if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { program_interrupt(&cpu->env, PGM_OPERAND, 4); @@ -98,24 +96,17 @@ void ioinst_handle_hsch(S390CPU *cpu, uint64_t reg1) } trace_ioinst_sch_id("hsch", cssid, ssid, schid); sch =3D css_find_subch(m, cssid, ssid, schid); - if (sch && css_subch_visible(sch)) { - ret =3D css_do_hsch(sch); + if (!sch || !css_subch_visible(sch)) { + setcc(cpu, 3); + return; } - switch (ret) { - case -ENODEV: - cc =3D 3; - break; - case -EBUSY: - cc =3D 2; - break; - case 0: - cc =3D 0; - break; - default: - cc =3D 1; - break; + css_subch_clear_iret(sch); + css_do_hsch(sch); + if (sch->iret.pgm_chk) { + program_interrupt(&cpu->env, sch->iret.irq_code, 4); + return; } - setcc(cpu, cc); + setcc(cpu, sch->iret.cc); } =20 static int ioinst_schib_valid(SCHIB *schib) --=20 2.13.5 From nobody Wed Nov 5 05:42:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504111340241218.00216447770845; Wed, 30 Aug 2017 09:42:20 -0700 (PDT) Received: from localhost ([::1]:51564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn64I-0003Ni-Ar for importer@patchew.org; Wed, 30 Aug 2017 12:42:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50197) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn5ym-0007I1-51 for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dn5yl-0006KT-20 for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:36 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59972 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dn5yk-0006K7-Rp for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:34 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7UGTAGC111723 for ; Wed, 30 Aug 2017 12:36:34 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cnx1vp5qh-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 30 Aug 2017 12:36:34 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 30 Aug 2017 17:36:32 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 30 Aug 2017 17:36:30 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7UGaTLn9044152; Wed, 30 Aug 2017 16:36:29 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 758C45203F; Wed, 30 Aug 2017 16:31:56 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 47DC452041; Wed, 30 Aug 2017 16:31:56 +0100 (BST) From: Halil Pasic To: Cornelia Huck Date: Wed, 30 Aug 2017 18:36:08 +0200 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170830163609.50260-1-pasic@linux.vnet.ibm.com> References: <20170830163609.50260-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17083016-0020-0000-0000-000003B26EAF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17083016-0021-0000-0000-00004242C0A6 Message-Id: <20170830163609.50260-9-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-30_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708300251 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 8/9] s390x: refactor error handling for MSCH handler X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Jia Shi , Halil Pasic , Pierre Morel , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Simplify the error handling of the MSCH handler avoiding arbitrary and cryptic error codes being mapped to what a subchannel is supposed to do. Let the code detecting the condition tell how it's to be handled in a less ambiguous way. Signed-off-by: Halil Pasic Reviewed-by: Pierre Morel --- hw/s390x/css.c | 20 +++++++------------- include/hw/s390x/css.h | 2 +- target/s390x/ioinst.c | 27 +++++++++------------------ 3 files changed, 17 insertions(+), 32 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index eff1b91a8c..931a097d6a 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -1182,28 +1182,27 @@ static void copy_schib_from_guest(SCHIB *dest, cons= t SCHIB *src) } } =20 -int css_do_msch(SubchDev *sch, const SCHIB *orig_schib) +void css_do_msch(SubchDev *sch, const SCHIB *orig_schib) { SCSW *s =3D &sch->curr_status.scsw; PMCW *p =3D &sch->curr_status.pmcw; uint16_t oldflags; - int ret; SCHIB schib; =20 if (!(sch->curr_status.pmcw.flags & PMCW_FLAGS_MASK_DNV)) { - ret =3D 0; - goto out; + sch->iret.cc =3D 0; + return; } =20 if (s->ctrl & SCSW_STCTL_STATUS_PEND) { - ret =3D -EINPROGRESS; - goto out; + sch->iret.cc =3D 1; + return; } =20 if (s->ctrl & (SCSW_FCTL_START_FUNC|SCSW_FCTL_HALT_FUNC|SCSW_FCTL_CLEAR_FUNC)) { - ret =3D -EBUSY; - goto out; + sch->iret.cc =3D 2; + return; } =20 copy_schib_from_guest(&schib, orig_schib); @@ -1230,11 +1229,6 @@ int css_do_msch(SubchDev *sch, const SCHIB *orig_sch= ib) && (p->flags & PMCW_FLAGS_MASK_ENA) =3D=3D 0) { sch->disable_cb(sch); } - - ret =3D 0; - -out: - return ret; } =20 void css_do_xsch(SubchDev *sch) diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index d8d949da4f..37ac36b014 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -203,7 +203,7 @@ bool css_subch_visible(SubchDev *sch); void css_conditional_io_interrupt(SubchDev *sch); int css_do_stsch(SubchDev *sch, SCHIB *schib); bool css_schid_final(int m, uint8_t cssid, uint8_t ssid, uint16_t schid); -int css_do_msch(SubchDev *sch, const SCHIB *schib); +void css_do_msch(SubchDev *sch, const SCHIB *schib); void css_do_xsch(SubchDev *sch); void css_do_csch(SubchDev *sch); void css_do_hsch(SubchDev *sch); diff --git a/target/s390x/ioinst.c b/target/s390x/ioinst.c index e91788d586..a286495219 100644 --- a/target/s390x/ioinst.c +++ b/target/s390x/ioinst.c @@ -128,8 +128,6 @@ void ioinst_handle_msch(S390CPU *cpu, uint64_t reg1, ui= nt32_t ipb) SubchDev *sch; SCHIB schib; uint64_t addr; - int ret =3D -ENODEV; - int cc; CPUS390XState *env =3D &cpu->env; uint8_t ar; =20 @@ -148,24 +146,17 @@ void ioinst_handle_msch(S390CPU *cpu, uint64_t reg1, = uint32_t ipb) } trace_ioinst_sch_id("msch", cssid, ssid, schid); sch =3D css_find_subch(m, cssid, ssid, schid); - if (sch && css_subch_visible(sch)) { - ret =3D css_do_msch(sch, &schib); + if (!sch || !css_subch_visible(sch)) { + setcc(cpu, 3); + return; } - switch (ret) { - case -ENODEV: - cc =3D 3; - break; - case -EBUSY: - cc =3D 2; - break; - case 0: - cc =3D 0; - break; - default: - cc =3D 1; - break; + css_subch_clear_iret(sch); + css_do_msch(sch, &schib); + if (sch->iret.pgm_chk) { + program_interrupt(&cpu->env, sch->iret.irq_code, 4); + return; } - setcc(cpu, cc); + setcc(cpu, sch->iret.cc); } =20 static void copy_orb_from_guest(ORB *dest, const ORB *src) --=20 2.13.5 From nobody Wed Nov 5 05:42:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504111232610904.6710989341291; Wed, 30 Aug 2017 09:40:32 -0700 (PDT) Received: from localhost ([::1]:51554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn62Y-0001sc-Da for importer@patchew.org; Wed, 30 Aug 2017 12:40:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn5yp-0007K5-C8 for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dn5ym-0006Ma-LU for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:39 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55705 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dn5ym-0006LM-FM for qemu-devel@nongnu.org; Wed, 30 Aug 2017 12:36:36 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7UGTHjX091217 for ; Wed, 30 Aug 2017 12:36:35 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cp0gja0mv-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 30 Aug 2017 12:36:35 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 30 Aug 2017 17:36:33 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 30 Aug 2017 17:36:31 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7UGaVTZ21037070; Wed, 30 Aug 2017 16:36:31 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A3D0A52041; Wed, 30 Aug 2017 16:31:57 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 75F095203F; Wed, 30 Aug 2017 16:31:57 +0100 (BST) From: Halil Pasic To: Cornelia Huck Date: Wed, 30 Aug 2017 18:36:09 +0200 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170830163609.50260-1-pasic@linux.vnet.ibm.com> References: <20170830163609.50260-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17083016-0008-0000-0000-000004917049 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17083016-0009-0000-0000-00001E21C2DA Message-Id: <20170830163609.50260-10-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-30_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708300251 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 9/9] s390x: factor out common ioinst handler logic X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Jia Shi , Halil Pasic , Pierre Morel , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Some of ioinst the handlers look very much the same: they basically delegate the work to the appropriate css function (doing some always the same stuff before and after the call to the appropriate css function). Let us create a template and get rid of some code. Signed-off-by: Halil Pasic Suggested-by: Marc Hartmayer Reviewed-by: Pierre Morel --- The handlers for MSCH and SSCH look very similar to our template too. It's just that there is one more parameter to the corresponding css function. Maybe one could do something to unify that too (e.g. some crazy macro) but I don't think it's worth the effort. Another idea was to make the two corresponding functions single argument too (by Dong Jia). --- target/s390x/ioinst.c | 77 ++++++++++-------------------------------------= ---- 1 file changed, 14 insertions(+), 63 deletions(-) diff --git a/target/s390x/ioinst.c b/target/s390x/ioinst.c index a286495219..6583e5216d 100644 --- a/target/s390x/ioinst.c +++ b/target/s390x/ioinst.c @@ -37,7 +37,10 @@ int ioinst_disassemble_sch_ident(uint32_t value, int *m,= int *cssid, int *ssid, return 0; } =20 -void ioinst_handle_xsch(S390CPU *cpu, uint64_t reg1) +/* many ionst handlers look the same: they just delegate to a some css fun= c */ +static void ioinst_handler_template_sch(S390CPU *cpu, uint64_t reg1, + const char *iname, + void (*handler_css)(SubchDev *)) { int cssid, ssid, schid, m; SubchDev *sch; @@ -46,14 +49,14 @@ void ioinst_handle_xsch(S390CPU *cpu, uint64_t reg1) program_interrupt(&cpu->env, PGM_OPERAND, 4); return; } - trace_ioinst_sch_id("xsch", cssid, ssid, schid); + trace_ioinst_sch_id(iname, cssid, ssid, schid); sch =3D css_find_subch(m, cssid, ssid, schid); if (!sch || !css_subch_visible(sch)) { setcc(cpu, 3); return; } css_subch_clear_iret(sch); - css_do_xsch(sch); + handler_css(sch); if (sch->iret.pgm_chk) { program_interrupt(&cpu->env, sch->iret.irq_code, 4); return; @@ -61,52 +64,19 @@ void ioinst_handle_xsch(S390CPU *cpu, uint64_t reg1) setcc(cpu, sch->iret.cc); } =20 -void ioinst_handle_csch(S390CPU *cpu, uint64_t reg1) +void ioinst_handle_xsch(S390CPU *cpu, uint64_t reg1) { - int cssid, ssid, schid, m; - SubchDev *sch; + ioinst_handler_template_sch(cpu, reg1, "xsch", css_do_xsch); +} =20 - if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { - program_interrupt(&cpu->env, PGM_OPERAND, 4); - return; - } - trace_ioinst_sch_id("csch", cssid, ssid, schid); - sch =3D css_find_subch(m, cssid, ssid, schid); - if (!sch || !css_subch_visible(sch)) { - setcc(cpu, 3); - return; - } - css_subch_clear_iret(sch); - css_do_csch(sch); - if (sch->iret.pgm_chk) { - program_interrupt(&cpu->env, sch->iret.irq_code, 4); - return; - } - setcc(cpu, sch->iret.cc); +void ioinst_handle_csch(S390CPU *cpu, uint64_t reg1) +{ + ioinst_handler_template_sch(cpu, reg1, "csch", css_do_csch); } =20 void ioinst_handle_hsch(S390CPU *cpu, uint64_t reg1) { - int cssid, ssid, schid, m; - SubchDev *sch; - - if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { - program_interrupt(&cpu->env, PGM_OPERAND, 4); - return; - } - trace_ioinst_sch_id("hsch", cssid, ssid, schid); - sch =3D css_find_subch(m, cssid, ssid, schid); - if (!sch || !css_subch_visible(sch)) { - setcc(cpu, 3); - return; - } - css_subch_clear_iret(sch); - css_do_hsch(sch); - if (sch->iret.pgm_chk) { - program_interrupt(&cpu->env, sch->iret.irq_code, 4); - return; - } - setcc(cpu, sch->iret.cc); + ioinst_handler_template_sch(cpu, reg1, "hsch", css_do_hsch); } =20 static int ioinst_schib_valid(SCHIB *schib) @@ -720,26 +690,7 @@ void ioinst_handle_schm(S390CPU *cpu, uint64_t reg1, u= int64_t reg2, =20 void ioinst_handle_rsch(S390CPU *cpu, uint64_t reg1) { - int cssid, ssid, schid, m; - SubchDev *sch; - - if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { - program_interrupt(&cpu->env, PGM_OPERAND, 4); - return; - } - trace_ioinst_sch_id("rsch", cssid, ssid, schid); - sch =3D css_find_subch(m, cssid, ssid, schid); - if (!sch || !css_subch_visible(sch)) { - setcc(cpu, 3); - return; - } - css_subch_clear_iret(sch); - css_do_rsch(sch); - if (sch->iret.pgm_chk) { - program_interrupt(&cpu->env, sch->iret.irq_code, 4); - return; - } - setcc(cpu, sch->iret.cc); + ioinst_handler_template_sch(cpu, reg1, "rsch", css_do_rsch); } =20 #define RCHP_REG1_RES(_reg) (_reg & 0x00000000ff00ff00) --=20 2.13.5