From nobody Sat May 4 06:31:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504884394660396.2535664154059; Fri, 8 Sep 2017 08:26:34 -0700 (PDT) Received: from localhost ([::1]:45956 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqLAu-0001UO-5i for importer@patchew.org; Fri, 08 Sep 2017 11:26:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqL9T-0000bA-Ek for qemu-devel@nongnu.org; Fri, 08 Sep 2017 11:25:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqL9O-0004of-Ez for qemu-devel@nongnu.org; Fri, 08 Sep 2017 11:25:03 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:45748 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 1dqL9O-0004nj-8q for qemu-devel@nongnu.org; Fri, 08 Sep 2017 11:24:58 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v88FO09h032292 for ; Fri, 8 Sep 2017 11:24:55 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cuvvtb7gr-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 08 Sep 2017 11:24:54 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 8 Sep 2017 16:24:53 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 8 Sep 2017 16:24:52 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v88FOpdT16187424; Fri, 8 Sep 2017 15:24:51 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9DE74AE04D; Fri, 8 Sep 2017 16:20:03 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6812BAE045; Fri, 8 Sep 2017 16:20:03 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 8 Sep 2017 16:20:03 +0100 (BST) From: Halil Pasic To: Cornelia Huck Date: Fri, 8 Sep 2017 17:24:43 +0200 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170908152446.14606-1-pasic@linux.vnet.ibm.com> References: <20170908152446.14606-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17090815-0040-0000-0000-000003D89607 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17090815-0041-0000-0000-000025D99C77 Message-Id: <20170908152446.14606-2-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-08_10:, , 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-1709080231 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/4] s390x/css: drop data-check in interpretation 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 architecture says that channel-data check is indicating that an uncorrected storage (memory) error has been detected in regard to the data residing in main storage (memory) that is currently used for an I/O operation. The described detection is done using the CBC technology. The ccw interpretation code is however generating a channel-data check effectively when the (device specific) ccw_cb returns -EFAULT. In case of virtio-ccw devices this happens when mapping memory fails, or when a NULL pointer is encountered. So this behavior is not architecture conform. Furthermore the best fit for these situations (null pointer, mapping a piece of guest memory fails) from architectural perspective the condition described as the channel subsystem refers to a location that is not available, which when encountered shall result in a channel-program check. To fix this, all we have to do is to get rid of the switch case matching -EFAULT: the default is generating a channel-program check. --- Was posted as stand alone patch. See: http://patchwork.ozlabs.org/patch/810995/ If you are going to, *please review there*. Signed-off-by: Halil Pasic --- hw/s390x/css.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 901dc6a0f3..09f6ba0310 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -980,15 +980,6 @@ static void sch_handle_start_func_virtual(SubchDev *sc= h) SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; s->cpa =3D sch->channel_prog + 8; break; - case -EFAULT: - /* memory problem, generate channel data check */ - s->ctrl &=3D ~SCSW_ACTL_START_PEND; - s->cstat =3D SCSW_CSTAT_DATA_CHECK; - s->ctrl &=3D ~SCSW_CTRL_MASK_STCTL; - s->ctrl |=3D SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY | - SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; - s->cpa =3D sch->channel_prog + 8; - break; case -EBUSY: /* subchannel busy, generate deferred cc 1 */ s->flags &=3D ~SCSW_FLAGS_MASK_CC; --=20 2.13.5 From nobody Sat May 4 06:31:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504884395394186.04301327945984; Fri, 8 Sep 2017 08:26:35 -0700 (PDT) Received: from localhost ([::1]:45957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqLAw-0001Xu-Ea for importer@patchew.org; Fri, 08 Sep 2017 11:26:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqL9U-0000bD-Bp for qemu-devel@nongnu.org; Fri, 08 Sep 2017 11:25:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqL9P-0004p4-74 for qemu-devel@nongnu.org; Fri, 08 Sep 2017 11:25:04 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:40354 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 1dqL9P-0004oT-1I for qemu-devel@nongnu.org; Fri, 08 Sep 2017 11:24:59 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v88FNtf5005695 for ; Fri, 8 Sep 2017 11:24:56 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cuw50jhk5-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 08 Sep 2017 11:24:56 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 8 Sep 2017 16:24:55 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 8 Sep 2017 16:24:53 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v88FOrlh8913078; Fri, 8 Sep 2017 15:24:53 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D8FEEAE051; Fri, 8 Sep 2017 16:20:04 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A832DAE04D; Fri, 8 Sep 2017 16:20:04 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 8 Sep 2017 16:20:04 +0100 (BST) From: Halil Pasic To: Cornelia Huck Date: Fri, 8 Sep 2017 17:24:44 +0200 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170908152446.14606-1-pasic@linux.vnet.ibm.com> References: <20170908152446.14606-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17090815-0016-0000-0000-000004EB96C0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17090815-0017-0000-0000-000028259E17 Message-Id: <20170908152446.14606-3-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-08_10:, , 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-1709080231 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/4] s390x/css: fix NULL handling for CCW addresses 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" Back then in the time of df1fe5bb49 ("s390: Virtual channel subsystem support.", 2013-01-24) -EIO used to map to a channel-program check (via the default label of the switch statement). Then 2dc95b4cac ("s390x/3270: 3270 data stream handling", 2016-04-01) came along and that changed dramatically. Let us roll back this undesired side effect, and go back to channel-program check. Signed-off-by: Halil Pasic Fixes: 2dc95b4cac "s390x/3270: 3270 data stream handling" --- I'm not sure 0 as CCW address it's strictly illegal. Yes 0 is an unlikely address for a CCW but I would appreciate a PoP reference clarifying this... Another reason to not use Unix/POSIX error codes like this. --- 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 09f6ba0310..a44d87ab3e 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -793,7 +793,7 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_= addr, CCW1 ccw; =20 if (!ccw_addr) { - return -EIO; + return -EINVAL; /* channel-program check */ } /* Check doubleword aligned and 31 or 24 (fmt 0) bit addressable. */ if (ccw_addr & (sch->ccw_fmt_1 ? 0x80000007 : 0xff000007)) { --=20 2.13.5 From nobody Sat May 4 06:31:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504884498648620.2675842269177; Fri, 8 Sep 2017 08:28:18 -0700 (PDT) Received: from localhost ([::1]:45970 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqLCb-0003Zc-Ps for importer@patchew.org; Fri, 08 Sep 2017 11:28:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44067) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqL9U-0000bE-Cg for qemu-devel@nongnu.org; Fri, 08 Sep 2017 11:25:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqL9P-0004pG-Ez for qemu-devel@nongnu.org; Fri, 08 Sep 2017 11:25:04 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54218 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 1dqL9P-0004ov-9A for qemu-devel@nongnu.org; Fri, 08 Sep 2017 11:24:59 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v88FNxLS078061 for ; Fri, 8 Sep 2017 11:24:58 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cuw4mtmcj-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 08 Sep 2017 11:24:58 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 8 Sep 2017 16:24:57 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 8 Sep 2017 16:24:54 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v88FOs2o31129770; Fri, 8 Sep 2017 15:24:54 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1CAADAE04D; Fri, 8 Sep 2017 16:20:06 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E3129AE045; Fri, 8 Sep 2017 16:20:05 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 8 Sep 2017 16:20:05 +0100 (BST) From: Halil Pasic To: Cornelia Huck Date: Fri, 8 Sep 2017 17:24:45 +0200 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170908152446.14606-1-pasic@linux.vnet.ibm.com> References: <20170908152446.14606-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17090815-0012-0000-0000-00000577A117 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17090815-0013-0000-0000-000018F0A824 Message-Id: <20170908152446.14606-4-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-08_10:, , 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-1709080231 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 3/4] s390x/css: remove dubious error handling branch 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 case in question actually never happens. Let us get rid of the dead code. Signed-off-by: Halil Pasic --- hw/s390x/css.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index a44d87ab3e..a9cdd54efc 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -980,13 +980,6 @@ static void sch_handle_start_func_virtual(SubchDev *sc= h) SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; s->cpa =3D sch->channel_prog + 8; break; - case -EBUSY: - /* subchannel busy, generate deferred cc 1 */ - s->flags &=3D ~SCSW_FLAGS_MASK_CC; - s->flags |=3D (1 << 8); - s->ctrl &=3D ~SCSW_CTRL_MASK_STCTL; - s->ctrl |=3D SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; - break; case -EINPROGRESS: /* channel program has been suspended */ s->ctrl &=3D ~SCSW_ACTL_START_PEND; --=20 2.13.5 From nobody Sat May 4 06:31:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504884580001532.1338543373898; Fri, 8 Sep 2017 08:29:40 -0700 (PDT) Received: from localhost ([::1]:45974 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqLDt-0004HH-4A for importer@patchew.org; Fri, 08 Sep 2017 11:29:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqL9W-0000bx-Uc for qemu-devel@nongnu.org; Fri, 08 Sep 2017 11:25:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqL9P-0004pQ-QQ for qemu-devel@nongnu.org; Fri, 08 Sep 2017 11:25:06 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:41020 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 1dqL9P-0004pA-IG for qemu-devel@nongnu.org; Fri, 08 Sep 2017 11:24:59 -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 v88FOYHt022546 for ; Fri, 8 Sep 2017 11:24:59 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0b-001b2d01.pphosted.com with ESMTP id 2curs77yvm-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 08 Sep 2017 11:24:58 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 8 Sep 2017 16:24:56 +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; Fri, 8 Sep 2017 16:24:55 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v88FOt6H20054220; Fri, 8 Sep 2017 15:24:55 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F942AE04D; Fri, 8 Sep 2017 16:20:07 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 270B2AE045; Fri, 8 Sep 2017 16:20:07 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 8 Sep 2017 16:20:07 +0100 (BST) From: Halil Pasic To: Cornelia Huck Date: Fri, 8 Sep 2017 17:24:46 +0200 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170908152446.14606-1-pasic@linux.vnet.ibm.com> References: <20170908152446.14606-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17090815-0020-0000-0000-000003B696D0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17090815-0021-0000-0000-00004247A0FB Message-Id: <20170908152446.14606-5-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-08_10:, , 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-1709080231 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 4/4] s390x/css: fix incorrect length indication 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" We report incorrect length via SCSW program check instead of incorrect length check (SCWS word 2 bit 10 instead of bit 9). Since we have there is no fitting errno for incorrect length, and since I don't like what we do with the errno's, as part of the fix, errnos used for control flow in ccw interpretation are replaced with an enum using more speaking names. For virtio, if incorrect length checking is suppressed we keep the current behavior (channel-program check). Signed-off-by: Halil Pasic --- hw/s390x/3270-ccw.c | 24 +++++----- hw/s390x/css.c | 67 +++++++++++++++----------- hw/s390x/virtio-ccw.c | 128 ++++++++++++++++++++++++---------------------= ---- include/hw/s390x/css.h | 13 ++++- 4 files changed, 127 insertions(+), 105 deletions(-) diff --git a/hw/s390x/3270-ccw.c b/hw/s390x/3270-ccw.c index 1554aa2484..5f9efe7ac6 100644 --- a/hw/s390x/3270-ccw.c +++ b/hw/s390x/3270-ccw.c @@ -18,46 +18,48 @@ #include "hw/s390x/3270-ccw.h" =20 /* Handle READ ccw commands from guest */ -static int handle_payload_3270_read(EmulatedCcw3270Device *dev, CCW1 *ccw) +static CcwProcStatus handle_payload_3270_read(EmulatedCcw3270Device *dev, + CCW1 *ccw) { EmulatedCcw3270Class *ck =3D EMULATED_CCW_3270_GET_CLASS(dev); CcwDevice *ccw_dev =3D CCW_DEVICE(dev); int len; =20 if (!ccw->cda) { - return -EFAULT; + return CSS_DO_PGM_CHK; } =20 len =3D ck->read_payload_3270(dev, ccw->cda, ccw->count); ccw_dev->sch->curr_status.scsw.count =3D ccw->count - len; =20 - return 0; + return CSS_DO_SUCCESS; } =20 /* Handle WRITE ccw commands to write data to client */ -static int handle_payload_3270_write(EmulatedCcw3270Device *dev, CCW1 *ccw) +static CcwProcStatus handle_payload_3270_write(EmulatedCcw3270Device *dev, + CCW1 *ccw) { EmulatedCcw3270Class *ck =3D EMULATED_CCW_3270_GET_CLASS(dev); CcwDevice *ccw_dev =3D CCW_DEVICE(dev); int len; =20 if (!ccw->cda) { - return -EFAULT; + return CSS_DO_PGM_CHK; } =20 len =3D ck->write_payload_3270(dev, ccw->cmd_code, ccw->cda, ccw->coun= t); =20 if (len <=3D 0) { - return -EIO; + return CSS_E_CUSTOM; } =20 ccw_dev->sch->curr_status.scsw.count =3D ccw->count - len; - return 0; + return CSS_DO_SUCCESS; } =20 -static int emulated_ccw_3270_cb(SubchDev *sch, CCW1 ccw) +static CcwProcStatus emulated_ccw_3270_cb(SubchDev *sch, CCW1 ccw) { - int rc =3D 0; + CcwProcStatus rc =3D CSS_DO_SUCCESS; EmulatedCcw3270Device *dev =3D sch->driver_data; =20 switch (ccw.cmd_code) { @@ -72,11 +74,11 @@ static int emulated_ccw_3270_cb(SubchDev *sch, CCW1 ccw) rc =3D handle_payload_3270_read(dev, &ccw); break; default: - rc =3D -ENOSYS; + rc =3D CSS_DO_UNIT_CHK_REJ; break; } =20 - if (rc =3D=3D -EIO) { + if (rc =3D=3D CSS_E_CUSTOM) { /* I/O error, specific devices generate specific conditions */ SCSW *s =3D &sch->curr_status.scsw; =20 diff --git a/hw/s390x/css.c b/hw/s390x/css.c index a9cdd54efc..875e9b00b8 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -784,20 +784,20 @@ static CCW1 copy_ccw_from_guest(hwaddr addr, bool fmt= 1) return ret; } =20 -static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr, +static CcwProcStatus css_interpret_ccw(SubchDev *sch, hwaddr ccw_addr, bool suspend_allowed) { - int ret; + CcwProcStatus ret; bool check_len; int len; CCW1 ccw; =20 if (!ccw_addr) { - return -EINVAL; /* channel-program check */ + return CSS_DO_PGM_CHK; } /* Check doubleword aligned and 31 or 24 (fmt 0) bit addressable. */ if (ccw_addr & (sch->ccw_fmt_1 ? 0x80000007 : 0xff000007)) { - return -EINVAL; + return CSS_DO_PGM_CHK; } =20 /* Translate everything to format-1 ccws - the information is the same= . */ @@ -805,31 +805,31 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr cc= w_addr, =20 /* Check for invalid command codes. */ if ((ccw.cmd_code & 0x0f) =3D=3D 0) { - return -EINVAL; + return CSS_DO_PGM_CHK; } if (((ccw.cmd_code & 0x0f) =3D=3D CCW_CMD_TIC) && ((ccw.cmd_code & 0xf0) !=3D 0)) { - return -EINVAL; + return CSS_DO_PGM_CHK; } if (!sch->ccw_fmt_1 && (ccw.count =3D=3D 0) && (ccw.cmd_code !=3D CCW_CMD_TIC)) { - return -EINVAL; + return CSS_DO_PGM_CHK; } =20 /* We don't support MIDA. */ if (ccw.flags & CCW_FLAG_MIDA) { - return -EINVAL; + return CSS_DO_PGM_CHK; } =20 if (ccw.flags & CCW_FLAG_SUSPEND) { - return suspend_allowed ? -EINPROGRESS : -EINVAL; + return suspend_allowed ? CSS_DO_SUSPEND : CSS_DO_PGM_CHK; } =20 check_len =3D !((ccw.flags & CCW_FLAG_SLI) && !(ccw.flags & CCW_FLAG_D= C)); =20 if (!ccw.cda) { if (sch->ccw_no_data_cnt =3D=3D 255) { - return -EINVAL; + return CSS_DO_PGM_CHK; } sch->ccw_no_data_cnt++; } @@ -838,12 +838,12 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr cc= w_addr, switch (ccw.cmd_code) { case CCW_CMD_NOOP: /* Nothing to do. */ - ret =3D 0; + ret =3D CSS_DO_SUCCESS; break; case CCW_CMD_BASIC_SENSE: if (check_len) { if (ccw.count !=3D sizeof(sch->sense_data)) { - ret =3D -EINVAL; + ret =3D CSS_DO_INCORR_LEN; break; } } @@ -851,7 +851,7 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_= addr, cpu_physical_memory_write(ccw.cda, sch->sense_data, len); sch->curr_status.scsw.count =3D ccw.count - len; memset(sch->sense_data, 0, sizeof(sch->sense_data)); - ret =3D 0; + ret =3D CSS_DO_SUCCESS; break; case CCW_CMD_SENSE_ID: { @@ -861,7 +861,7 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr ccw_= addr, /* Sense ID information is device specific. */ if (check_len) { if (ccw.count !=3D sizeof(sense_id)) { - ret =3D -EINVAL; + ret =3D CSS_DO_PGM_CHK; break; } } @@ -877,37 +877,37 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr cc= w_addr, } cpu_physical_memory_write(ccw.cda, &sense_id, len); sch->curr_status.scsw.count =3D ccw.count - len; - ret =3D 0; + ret =3D CSS_DO_SUCCESS; break; } case CCW_CMD_TIC: if (sch->last_cmd_valid && (sch->last_cmd.cmd_code =3D=3D CCW_CMD_= TIC)) { - ret =3D -EINVAL; + ret =3D CSS_DO_PGM_CHK; break; } if (ccw.flags || ccw.count) { /* We have already sanitized these if converted from fmt 0. */ - ret =3D -EINVAL; + ret =3D CSS_DO_PGM_CHK; break; } sch->channel_prog =3D ccw.cda; - ret =3D -EAGAIN; + ret =3D CSS_DO_CONT_CHAIN; break; default: if (sch->ccw_cb) { /* Handle device specific commands. */ ret =3D sch->ccw_cb(sch, ccw); } else { - ret =3D -ENOSYS; + ret =3D CSS_DO_UNIT_CHK_REJ; } break; } sch->last_cmd =3D ccw; sch->last_cmd_valid =3D true; - if (ret =3D=3D 0) { + if (ret =3D=3D CSS_DO_SUCCESS) { if (ccw.flags & CCW_FLAG_CC) { sch->channel_prog +=3D 8; - ret =3D -EAGAIN; + ret =3D CSS_DO_CONT_CHAIN; } } =20 @@ -920,7 +920,7 @@ static void sch_handle_start_func_virtual(SubchDev *sch) PMCW *p =3D &sch->curr_status.pmcw; SCSW *s =3D &sch->curr_status.scsw; int path; - int ret; + CcwProcStatus ret; bool suspend_allowed; =20 /* Path management: In our simple css, we always choose the only path.= */ @@ -954,10 +954,10 @@ static void sch_handle_start_func_virtual(SubchDev *s= ch) do { ret =3D css_interpret_ccw(sch, sch->channel_prog, suspend_allowed); switch (ret) { - case -EAGAIN: + case CSS_DO_CONT_CHAIN: /* ccw chain, continue processing */ break; - case 0: + case CSS_DO_SUCCESS: /* success */ s->ctrl &=3D ~SCSW_ACTL_START_PEND; s->ctrl &=3D ~SCSW_CTRL_MASK_STCTL; @@ -966,10 +966,10 @@ static void sch_handle_start_func_virtual(SubchDev *s= ch) s->dstat =3D SCSW_DSTAT_CHANNEL_END | SCSW_DSTAT_DEVICE_END; s->cpa =3D sch->channel_prog + 8; break; - case -EIO: + case CSS_E_CUSTOM: /* I/O errors, status depends on specific devices */ break; - case -ENOSYS: + case CSS_DO_UNIT_CHK_REJ: /* unsupported command, generate unit check (command reject) */ s->ctrl &=3D ~SCSW_ACTL_START_PEND; s->dstat =3D SCSW_DSTAT_UNIT_CHECK; @@ -980,12 +980,21 @@ static void sch_handle_start_func_virtual(SubchDev *s= ch) SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; s->cpa =3D sch->channel_prog + 8; break; - case -EINPROGRESS: + case CSS_DO_SUSPEND: /* channel program has been suspended */ s->ctrl &=3D ~SCSW_ACTL_START_PEND; s->ctrl |=3D SCSW_ACTL_SUSP; break; - default: + case CSS_DO_INCORR_LEN: + s->ctrl &=3D ~SCSW_ACTL_START_PEND; + s->cstat =3D SCSW_CSTAT_INCORR_LEN; + s->ctrl &=3D ~SCSW_CTRL_MASK_STCTL; + s->ctrl |=3D SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY | + SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; + s->cpa =3D sch->channel_prog + 8; + break; + + case CSS_DO_PGM_CHK: /* error, generate channel program check */ s->ctrl &=3D ~SCSW_ACTL_START_PEND; s->cstat =3D SCSW_CSTAT_PROG_CHECK; @@ -995,7 +1004,7 @@ static void sch_handle_start_func_virtual(SubchDev *sc= h) s->cpa =3D sch->channel_prog + 8; break; } - } while (ret =3D=3D -EAGAIN); + } while (ret =3D=3D CSS_DO_CONT_CHAIN); =20 } =20 diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index b1976fdd19..3d288b5343 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -207,16 +207,16 @@ static int virtio_ccw_set_vqs(SubchDev *sch, VqInfoBl= ock *info, uint64_t desc =3D info ? info->desc : linfo->queue; =20 if (index >=3D VIRTIO_QUEUE_MAX) { - return -EINVAL; + return CSS_DO_PGM_CHK; } =20 /* Current code in virtio.c relies on 4K alignment. */ if (linfo && desc && (linfo->align !=3D 4096)) { - return -EINVAL; + return CSS_DO_PGM_CHK; } =20 if (!vdev) { - return -EINVAL; + return CSS_DO_PGM_CHK; } =20 if (info) { @@ -231,19 +231,19 @@ static int virtio_ccw_set_vqs(SubchDev *sch, VqInfoBl= ock *info, /* virtio-1 allows changing the ring size. */ if (virtio_queue_get_max_num(vdev, index) < num) { /* Fail if we exceed the maximum number. */ - return -EINVAL; + return CSS_DO_PGM_CHK; } virtio_queue_set_num(vdev, index, num); } else if (virtio_queue_get_num(vdev, index) > num) { /* Fail if we don't have a big enough queue. */ - return -EINVAL; + return CSS_DO_PGM_CHK; } /* We ignore possible increased num for legacy for compatibility. = */ virtio_queue_set_vector(vdev, index, index); } /* tell notify handler in case of config change */ vdev->config_vector =3D VIRTIO_QUEUE_MAX; - return 0; + return CSS_DO_SUCCESS; } =20 static void virtio_ccw_reset_virtio(VirtioCcwDevice *dev, VirtIODevice *vd= ev) @@ -277,14 +277,14 @@ static int virtio_ccw_handle_set_vq(SubchDev *sch, CC= W1 ccw, bool check_len, =20 if (check_len) { if (ccw.count !=3D info_len) { - return -EINVAL; + return CSS_DO_INCORR_LEN; } } else if (ccw.count < info_len) { /* Can't execute command. */ - return -EINVAL; + return CSS_DO_PGM_CHK; } if (!ccw.cda) { - return -EFAULT; + return CSS_DO_PGM_CHK; } if (is_legacy) { linfo.queue =3D address_space_ldq_be(&address_space_memory, ccw.cd= a, @@ -336,7 +336,7 @@ static int virtio_ccw_handle_set_vq(SubchDev *sch, CCW1= ccw, bool check_len, return ret; } =20 -static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) +static CcwProcStatus virtio_ccw_cb(SubchDev *sch, CCW1 ccw) { int ret; VirtioRevInfo revinfo; @@ -353,7 +353,7 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) VirtioThinintInfo *thinint; =20 if (!dev) { - return -EINVAL; + return CSS_DO_PGM_CHK; } =20 trace_virtio_ccw_interpret_ccw(sch->cssid, sch->ssid, sch->schid, @@ -366,7 +366,7 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) * virtio-1 drivers must start with negotiating to a revision >=3D= 1, * so post a command reject for all other commands */ - return -ENOSYS; + return CSS_DO_UNIT_CHK_REJ; } =20 /* Look at the command. */ @@ -376,21 +376,21 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) break; case CCW_CMD_VDEV_RESET: virtio_ccw_reset_virtio(dev, vdev); - ret =3D 0; + ret =3D CSS_DO_SUCCESS; break; case CCW_CMD_READ_FEAT: if (check_len) { if (ccw.count !=3D sizeof(features)) { - ret =3D -EINVAL; + ret =3D CSS_DO_INCORR_LEN; break; } } else if (ccw.count < sizeof(features)) { /* Can't execute command. */ - ret =3D -EINVAL; + ret =3D CSS_DO_PGM_CHK; break; } if (!ccw.cda) { - ret =3D -EFAULT; + ret =3D CSS_DO_PGM_CHK; } else { VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(vdev); =20 @@ -421,22 +421,22 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) features.features, MEMTXATTRS_UNSPECIFIED, NULL); sch->curr_status.scsw.count =3D ccw.count - sizeof(features); - ret =3D 0; + ret =3D CSS_DO_SUCCESS; } break; case CCW_CMD_WRITE_FEAT: if (check_len) { if (ccw.count !=3D sizeof(features)) { - ret =3D -EINVAL; + ret =3D CSS_DO_INCORR_LEN; break; } } else if (ccw.count < sizeof(features)) { /* Can't execute command. */ - ret =3D -EINVAL; + ret =3D CSS_DO_PGM_CHK; break; } if (!ccw.cda) { - ret =3D -EFAULT; + ret =3D CSS_DO_PGM_CHK; } else { features.index =3D address_space_ldub(&address_space_memory, ccw.cda @@ -472,42 +472,42 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) } } sch->curr_status.scsw.count =3D ccw.count - sizeof(features); - ret =3D 0; + ret =3D CSS_DO_SUCCESS; } break; case CCW_CMD_READ_CONF: if (check_len) { if (ccw.count > vdev->config_len) { - ret =3D -EINVAL; + ret =3D CSS_DO_INCORR_LEN; break; } } len =3D MIN(ccw.count, vdev->config_len); if (!ccw.cda) { - ret =3D -EFAULT; + ret =3D CSS_DO_PGM_CHK; } else { virtio_bus_get_vdev_config(&dev->bus, vdev->config); /* XXX config space endianness */ cpu_physical_memory_write(ccw.cda, vdev->config, len); sch->curr_status.scsw.count =3D ccw.count - len; - ret =3D 0; + ret =3D CSS_DO_SUCCESS; } break; case CCW_CMD_WRITE_CONF: if (check_len) { if (ccw.count > vdev->config_len) { - ret =3D -EINVAL; + ret =3D CSS_DO_INCORR_LEN; break; } } len =3D MIN(ccw.count, vdev->config_len); hw_len =3D len; if (!ccw.cda) { - ret =3D -EFAULT; + ret =3D CSS_DO_PGM_CHK; } else { config =3D cpu_physical_memory_map(ccw.cda, &hw_len, 0); if (!config) { - ret =3D -EFAULT; + ret =3D CSS_DO_PGM_CHK; } else { len =3D hw_len; /* XXX config space endianness */ @@ -515,43 +515,43 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) cpu_physical_memory_unmap(config, hw_len, 0, hw_len); virtio_bus_set_vdev_config(&dev->bus, vdev->config); sch->curr_status.scsw.count =3D ccw.count - len; - ret =3D 0; + ret =3D CSS_DO_SUCCESS; } } break; case CCW_CMD_READ_STATUS: if (check_len) { if (ccw.count !=3D sizeof(status)) { - ret =3D -EINVAL; + ret =3D CSS_DO_INCORR_LEN; break; } } else if (ccw.count < sizeof(status)) { /* Can't execute command. */ - ret =3D -EINVAL; + ret =3D CSS_DO_PGM_CHK; break; } if (!ccw.cda) { - ret =3D -EFAULT; + ret =3D CSS_DO_PGM_CHK; } else { address_space_stb(&address_space_memory, ccw.cda, vdev->status, MEMTXATTRS_UNSPECIFIED, NULL); sch->curr_status.scsw.count =3D ccw.count - sizeof(vdev->statu= s);; - ret =3D 0; + ret =3D CSS_DO_SUCCESS; } break; case CCW_CMD_WRITE_STATUS: if (check_len) { if (ccw.count !=3D sizeof(status)) { - ret =3D -EINVAL; + ret =3D CSS_DO_INCORR_LEN; break; } } else if (ccw.count < sizeof(status)) { /* Can't execute command. */ - ret =3D -EINVAL; + ret =3D CSS_DO_PGM_CHK; break; } if (!ccw.cda) { - ret =3D -EFAULT; + ret =3D CSS_DO_PGM_CHK; } else { status =3D address_space_ldub(&address_space_memory, ccw.cda, MEMTXATTRS_UNSPECIFIED, NULL); @@ -566,85 +566,85 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) virtio_ccw_start_ioeventfd(dev); } sch->curr_status.scsw.count =3D ccw.count - sizeof(status); - ret =3D 0; + ret =3D CSS_DO_SUCCESS; } else { /* Trigger a command reject. */ - ret =3D -ENOSYS; + ret =3D CSS_DO_UNIT_CHK_REJ; } } break; case CCW_CMD_SET_IND: if (check_len) { if (ccw.count !=3D sizeof(indicators)) { - ret =3D -EINVAL; + ret =3D CSS_DO_INCORR_LEN; break; } } else if (ccw.count < sizeof(indicators)) { /* Can't execute command. */ - ret =3D -EINVAL; + ret =3D CSS_DO_PGM_CHK; break; } if (sch->thinint_active) { /* Trigger a command reject. */ - ret =3D -ENOSYS; + ret =3D CSS_DO_UNIT_CHK_REJ; break; } if (virtio_get_num_queues(vdev) > NR_CLASSIC_INDICATOR_BITS) { /* More queues than indicator bits --> trigger a reject */ - ret =3D -ENOSYS; + ret =3D CSS_DO_UNIT_CHK_REJ; break; } if (!ccw.cda) { - ret =3D -EFAULT; + ret =3D CSS_DO_PGM_CHK; } else { indicators =3D address_space_ldq_be(&address_space_memory, ccw= .cda, MEMTXATTRS_UNSPECIFIED, NULL= ); dev->indicators =3D get_indicator(indicators, sizeof(uint64_t)= ); sch->curr_status.scsw.count =3D ccw.count - sizeof(indicators); - ret =3D 0; + ret =3D CSS_DO_SUCCESS; } break; case CCW_CMD_SET_CONF_IND: if (check_len) { if (ccw.count !=3D sizeof(indicators)) { - ret =3D -EINVAL; + ret =3D CSS_DO_INCORR_LEN; break; } } else if (ccw.count < sizeof(indicators)) { /* Can't execute command. */ - ret =3D -EINVAL; + ret =3D CSS_DO_PGM_CHK; break; } if (!ccw.cda) { - ret =3D -EFAULT; + ret =3D CSS_DO_PGM_CHK; } else { indicators =3D address_space_ldq_be(&address_space_memory, ccw= .cda, MEMTXATTRS_UNSPECIFIED, NULL= ); dev->indicators2 =3D get_indicator(indicators, sizeof(uint64_t= )); sch->curr_status.scsw.count =3D ccw.count - sizeof(indicators); - ret =3D 0; + ret =3D CSS_DO_SUCCESS; } break; case CCW_CMD_READ_VQ_CONF: if (check_len) { if (ccw.count !=3D sizeof(vq_config)) { - ret =3D -EINVAL; + ret =3D CSS_DO_INCORR_LEN; break; } } else if (ccw.count < sizeof(vq_config)) { /* Can't execute command. */ - ret =3D -EINVAL; + ret =3D CSS_DO_PGM_CHK; break; } if (!ccw.cda) { - ret =3D -EFAULT; + ret =3D CSS_DO_PGM_CHK; } else { vq_config.index =3D address_space_lduw_be(&address_space_memor= y, ccw.cda, MEMTXATTRS_UNSPECIFIED, NULL); if (vq_config.index >=3D VIRTIO_QUEUE_MAX) { - ret =3D -EINVAL; + ret =3D CSS_DO_PGM_CHK; break; } vq_config.num_max =3D virtio_queue_get_num(vdev, @@ -655,31 +655,31 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) MEMTXATTRS_UNSPECIFIED, NULL); sch->curr_status.scsw.count =3D ccw.count - sizeof(vq_config); - ret =3D 0; + ret =3D CSS_DO_SUCCESS; } break; case CCW_CMD_SET_IND_ADAPTER: if (check_len) { if (ccw.count !=3D sizeof(*thinint)) { - ret =3D -EINVAL; + ret =3D CSS_DO_INCORR_LEN; break; } } else if (ccw.count < sizeof(*thinint)) { /* Can't execute command. */ - ret =3D -EINVAL; + ret =3D CSS_DO_PGM_CHK; break; } len =3D sizeof(*thinint); hw_len =3D len; if (!ccw.cda) { - ret =3D -EFAULT; + ret =3D CSS_DO_PGM_CHK; } else if (dev->indicators && !sch->thinint_active) { /* Trigger a command reject. */ - ret =3D -ENOSYS; + ret =3D CSS_DO_UNIT_CHK_REJ; } else { thinint =3D cpu_physical_memory_map(ccw.cda, &hw_len, 0); if (!thinint) { - ret =3D -EFAULT; + ret =3D CSS_DO_PGM_CHK; } else { uint64_t ind_bit =3D ldq_be_p(&thinint->ind_bit); =20 @@ -700,18 +700,18 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) sch->thinint_active =3D ((dev->indicators !=3D NULL) && (dev->summary_indicator !=3D NULL)); sch->curr_status.scsw.count =3D ccw.count - len; - ret =3D 0; + ret =3D CSS_DO_SUCCESS; } } break; case CCW_CMD_SET_VIRTIO_REV: len =3D sizeof(revinfo); if (ccw.count < len) { - ret =3D -EINVAL; + ret =3D CSS_DO_PGM_CHK; break; } if (!ccw.cda) { - ret =3D -EFAULT; + ret =3D CSS_DO_PGM_CHK; break; } revinfo.revision =3D @@ -723,7 +723,7 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) MEMTXATTRS_UNSPECIFIED, NULL); if (ccw.count < len + revinfo.length || (check_len && ccw.count > len + revinfo.length)) { - ret =3D -EINVAL; + ret =3D CSS_DO_PGM_CHK; break; } /* @@ -733,14 +733,14 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) if (dev->revision >=3D 0 || revinfo.revision > virtio_ccw_rev_max(dev) || (dev->force_revision_1 && !revinfo.revision)) { - ret =3D -ENOSYS; + ret =3D CSS_DO_UNIT_CHK_REJ; break; } - ret =3D 0; + ret =3D CSS_DO_SUCCESS; dev->revision =3D revinfo.revision; break; default: - ret =3D -ENOSYS; + ret =3D CSS_DO_UNIT_CHK_REJ; break; } return ret; diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index 0653d3c9be..da518580be 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -75,6 +75,17 @@ typedef struct CMBE { uint32_t reserved[7]; } QEMU_PACKED CMBE; =20 + +typedef enum CcwProcStatus { + CSS_DO_SUCCESS =3D 0, /* requet successful completin */ + CSS_DO_CONT_CHAIN, /* request continue ccw-chaning */ + CSS_DO_SUSPEND, /* request subchannel suspended */ + CSS_DO_PGM_CHK, /* request channel-program check */ + CSS_DO_UNIT_CHK_REJ,/* request unit check cmd reject */ + CSS_DO_INCORR_LEN, /* request incorrect length */ + CSS_E_CUSTOM /* SCSW updated by device */ +} CcwProcStatus; + typedef struct SubchDev SubchDev; struct SubchDev { /* channel-subsystem related things: */ @@ -93,7 +104,7 @@ struct SubchDev { uint16_t migrated_schid; /* used for missmatch detection */ ORB orb; /* transport-provided data: */ - int (*ccw_cb) (SubchDev *, CCW1); + CcwProcStatus (*ccw_cb) (SubchDev *, CCW1); void (*disable_cb)(SubchDev *); int (*do_subchannel_work) (SubchDev *); SenseId id; --=20 2.13.5