[{"id":1771647,"web_url":"http://patchwork.ozlabs.org/comment/1771647/","msgid":"<20170920074238.GH11080@bjsdjshi@linux.vnet.ibm.com>","list_archive_url":null,"date":"2017-09-20T07:42:38","subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","submitter":{"id":68897,"url":"http://patchwork.ozlabs.org/api/people/68897/","name":"Dong Jia Shi","email":"bjsdjshi@linux.vnet.ibm.com"},"content":"* Halil Pasic <pasic@linux.vnet.ibm.com> [2017-09-19 20:27:45 +0200]:\n\n> Let's add indirect data addressing support for our virtual channel\n> subsystem. This implementation does not bother with any kind of\n> prefetching. We simply step through the IDAL on demand.\n> \n> Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com>\n> Signed-off-by: Cornelia Huck <cohuck@redhat.com>\n> ---\n>  hw/s390x/css.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n>  1 file changed, 116 insertions(+), 1 deletion(-)\n> \n> diff --git a/hw/s390x/css.c b/hw/s390x/css.c\n> index 2d37a9ddde..a3ce6d89b6 100644\n> --- a/hw/s390x/css.c\n> +++ b/hw/s390x/css.c\n> @@ -827,6 +827,121 @@ incr:\n>      return 0;\n>  }\n> \n> +/* returns values between 1 and bsz, where bsz is a power of 2 */\n> +static inline uint16_t ida_continuous_left(hwaddr cda, uint64_t bsz)\n> +{\n> +    return bsz - (cda & (bsz - 1));\n> +}\n> +\n> +static inline uint64_t ccw_ida_block_size(uint8_t flags)\n> +{\n> +    if ((flags & CDS_F_C64) && !(flags & CDS_F_I2K)) {\n> +        return 1ULL << 12;\n> +    }\n> +    return 1ULL << 11;\n> +}\n> +\n> +static inline int ida_read_next_idaw(CcwDataStream *cds, bool ccw_fmt1,\n> +                                     bool idaw_fmt_2)\n> +{\n> +    union {uint64_t fmt2; uint32_t fmt1; } idaw;\n> +    int ret;\n> +    hwaddr idaw_addr;\n> +\n> +    if (idaw_fmt_2) {\n> +        idaw_addr = cds->cda_orig + sizeof(idaw.fmt2) * cds->at_idaw;\n> +        if (idaw_addr & 0x07 && cds_ccw_addrs_ok(idaw_addr, 0, ccw_fmt1)) {\n> +            return -EINVAL; /* channel program check */\n> +        }\n> +        ret = address_space_rw(&address_space_memory, idaw_addr,\nAhh, just got one question here:\nDo we need to considerate endianess for idaw_addr?\n\n> +                               MEMTXATTRS_UNSPECIFIED, (void *) &idaw.fmt2,\n> +                               sizeof(idaw.fmt2), false);\n> +        cds->cda = be64_to_cpu(idaw.fmt2);\n> +    } else {\n> +        idaw_addr = cds->cda_orig + sizeof(idaw.fmt1) * cds->at_idaw;\n> +        if (idaw_addr & 0x03 && cds_ccw_addrs_ok(idaw_addr, 0, ccw_fmt1)) {\n> +            return -EINVAL; /* channel program check */\n> +        }\n> +        ret = address_space_rw(&address_space_memory, idaw_addr,\n> +                               MEMTXATTRS_UNSPECIFIED, (void *) &idaw.fmt1,\n> +                               sizeof(idaw.fmt1), false);\n> +        cds->cda = be64_to_cpu(idaw.fmt1);\nStill need to check bit 0x80000000 here I think.\n\n> +    }\n> +    ++(cds->at_idaw);\n> +    if (ret != MEMTX_OK) {\n> +        /* assume inaccessible address */\n> +        return -EINVAL; /* channel program check */\n> +\nExtra line.\n\n> +    }\n> +    return 0;\n> +}\n> +\n> +static int ccw_dstream_rw_ida(CcwDataStream *cds, void *buff, int len,\n> +                              CcwDataStreamOp op)\n> +{\n> +    uint64_t bsz = ccw_ida_block_size(cds->flags);\n> +    int ret = 0;\n> +    uint16_t cont_left, iter_len;\n> +    const bool idaw_fmt2 = cds->flags & CDS_F_C64;\n> +    bool ccw_fmt1 = cds->flags & CDS_F_FMT;\nUse 'const bool' either? Although I doubt the value of using const here.\n;)\n\n> +\n> +    ret = cds_check_len(cds, len);\n> +    if (ret <= 0) {\n> +        return ret;\n> +    }\n\n[...]","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxsDP1Ttsz9s81\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 17:43:16 +1000 (AEST)","from localhost ([::1]:47238 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1duZf7-0001sd-DV\n\tfor incoming@patchwork.ozlabs.org; Wed, 20 Sep 2017 03:43:13 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:57285)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <bjsdjshi@linux.vnet.ibm.com>) id 1duZel-0001sJ-P6\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 03:42:53 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <bjsdjshi@linux.vnet.ibm.com>) id 1duZeh-0003Xy-MO\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 03:42:51 -0400","from mx0a-001b2d01.pphosted.com ([148.163.156.1]:38124)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <bjsdjshi@linux.vnet.ibm.com>)\n\tid 1duZeh-0003Sj-D0\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 03:42:47 -0400","from pps.filterd (m0098410.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv8K7eCGl045626\n\tfor <qemu-devel@nongnu.org>; Wed, 20 Sep 2017 03:42:45 -0400","from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151])\n\tby mx0a-001b2d01.pphosted.com with ESMTP id 2d3e87bqvf-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <qemu-devel@nongnu.org>; Wed, 20 Sep 2017 03:42:45 -0400","from localhost\n\tby e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <qemu-devel@nongnu.org> from <bjsdjshi@linux.vnet.ibm.com>;\n\tWed, 20 Sep 2017 01:42:44 -0600","from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17)\n\tby e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway:\n\tAuthorized Use Only! Violators will be prosecuted; \n\tWed, 20 Sep 2017 01:42:41 -0600","from b03ledav002.gho.boulder.ibm.com\n\t(b03ledav002.gho.boulder.ibm.com [9.17.130.233])\n\tby b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with\n\tESMTP id v8K7geEY524614; Wed, 20 Sep 2017 00:42:40 -0700","from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id C938B136044;\n\tWed, 20 Sep 2017 01:42:40 -0600 (MDT)","from localhost (unknown [9.115.112.23])\n\tby b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP id\n\t275FB136049; Wed, 20 Sep 2017 01:42:39 -0600 (MDT)"],"Date":"Wed, 20 Sep 2017 15:42:38 +0800","From":"Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>","To":"Halil Pasic <pasic@linux.vnet.ibm.com>","Mail-Followup-To":"Halil Pasic <pasic@linux.vnet.ibm.com>,\n\tCornelia Huck <cohuck@redhat.com>,\n\tDong Jia Shi <bjsdjshi@linux.vnet.ibm.com>,\n\tPierre Morel <pmorel@linux.vnet.ibm.com>, qemu-devel@nongnu.org","References":"<20170919182745.90280-1-pasic@linux.vnet.ibm.com>\n\t<20170919182745.90280-6-pasic@linux.vnet.ibm.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20170919182745.90280-6-pasic@linux.vnet.ibm.com>","Organization":"(IBM CSL)","X-URL":"http://ibm.com/","User-Agent":"Mutt/1.5.21 (2010-09-15)","X-TM-AS-GCONF":"00","x-cbid":"17092007-0008-0000-0000-00000898F175","X-IBM-SpamModules-Scores":"","X-IBM-SpamModules-Versions":"BY=3.00007766; HX=3.00000241; KW=3.00000007;\n\tPH=3.00000004; SC=3.00000230; SDB=6.00919648; UDB=6.00462039;\n\tIPR=6.00699874; \n\tBA=6.00005598; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009;\n\tZB=6.00000000; \n\tZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017219;\n\tXFM=3.00000015; UTC=2017-09-20 07:42:42","X-IBM-AV-DETECTION":"SAVI=unused REMOTE=unused XFE=unused","x-cbparentid":"17092007-0009-0000-0000-0000440BDC6B","Message-Id":"<20170920074238.GH11080@bjsdjshi@linux.vnet.ibm.com>","X-Proofpoint-Virus-Version":"vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-09-20_01:, , signatures=0","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n\tspamscore=0 suspectscore=0\n\tmalwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam\n\tadjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000\n\tdefinitions=main-1709200106","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy]","X-Received-From":"148.163.156.1","Subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>,\n\tCornelia Huck <cohuck@redhat.com>,\n\tPierre Morel <pmorel@linux.vnet.ibm.com>, qemu-devel@nongnu.org","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1771663,"web_url":"http://patchwork.ozlabs.org/comment/1771663/","msgid":"<20170920101159.0aaff3d6.cohuck@redhat.com>","list_archive_url":null,"date":"2017-09-20T08:11:59","subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","submitter":{"id":71914,"url":"http://patchwork.ozlabs.org/api/people/71914/","name":"Cornelia Huck","email":"cohuck@redhat.com"},"content":"On Tue, 19 Sep 2017 20:27:45 +0200\nHalil Pasic <pasic@linux.vnet.ibm.com> wrote:\n\n> Let's add indirect data addressing support for our virtual channel\n> subsystem. This implementation does not bother with any kind of\n> prefetching. We simply step through the IDAL on demand.\n> \n> Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com>\n> Signed-off-by: Cornelia Huck <cohuck@redhat.com>\n\nMy s-o-b is a bit preliminary ;)\n\n> ---\n>  hw/s390x/css.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n>  1 file changed, 116 insertions(+), 1 deletion(-)\n> \n> diff --git a/hw/s390x/css.c b/hw/s390x/css.c\n> index 2d37a9ddde..a3ce6d89b6 100644\n> --- a/hw/s390x/css.c\n> +++ b/hw/s390x/css.c\n> @@ -827,6 +827,121 @@ incr:\n>      return 0;\n>  }\n>  \n> +/* returns values between 1 and bsz, where bsz is a power of 2 */\n> +static inline uint16_t ida_continuous_left(hwaddr cda, uint64_t bsz)\n> +{\n> +    return bsz - (cda & (bsz - 1));\n> +}\n> +\n> +static inline uint64_t ccw_ida_block_size(uint8_t flags)\n> +{\n> +    if ((flags & CDS_F_C64) && !(flags & CDS_F_I2K)) {\n> +        return 1ULL << 12;\n> +    }\n> +    return 1ULL << 11;\n> +}\n> +\n> +static inline int ida_read_next_idaw(CcwDataStream *cds, bool ccw_fmt1,\n> +                                     bool idaw_fmt_2)\n> +{\n> +    union {uint64_t fmt2; uint32_t fmt1; } idaw;\n> +    int ret;\n> +    hwaddr idaw_addr;\n> +\n> +    if (idaw_fmt_2) {\n> +        idaw_addr = cds->cda_orig + sizeof(idaw.fmt2) * cds->at_idaw;\n> +        if (idaw_addr & 0x07 && cds_ccw_addrs_ok(idaw_addr, 0, ccw_fmt1)) {\n\nSo, what is supposed to happen if the idaw_addr is not aligned\ncorrectly _and_ is violating the limits?\n\n> +            return -EINVAL; /* channel program check */\n> +        }\n> +        ret = address_space_rw(&address_space_memory, idaw_addr,\n> +                               MEMTXATTRS_UNSPECIFIED, (void *) &idaw.fmt2,\n> +                               sizeof(idaw.fmt2), false);\n> +        cds->cda = be64_to_cpu(idaw.fmt2);\n> +    } else {\n> +        idaw_addr = cds->cda_orig + sizeof(idaw.fmt1) * cds->at_idaw;\n> +        if (idaw_addr & 0x03 && cds_ccw_addrs_ok(idaw_addr, 0, ccw_fmt1)) {\n> +            return -EINVAL; /* channel program check */\n> +        }\n> +        ret = address_space_rw(&address_space_memory, idaw_addr,\n> +                               MEMTXATTRS_UNSPECIFIED, (void *) &idaw.fmt1,\n> +                               sizeof(idaw.fmt1), false);\n> +        cds->cda = be64_to_cpu(idaw.fmt1);\n> +    }\n> +    ++(cds->at_idaw);\n> +    if (ret != MEMTX_OK) {\n> +        /* assume inaccessible address */\n> +        return -EINVAL; /* channel program check */\n> +\n> +    }\n> +    return 0;\n> +}","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx08.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx08.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=cohuck@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxstG47Mrz9s8J\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 18:12:37 +1000 (AEST)","from localhost ([::1]:47344 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dua7X-0002Og-33\n\tfor incoming@patchwork.ozlabs.org; Wed, 20 Sep 2017 04:12:35 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:57748)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <cohuck@redhat.com>) id 1dua77-0002OL-2Y\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 04:12:14 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <cohuck@redhat.com>) id 1dua74-0001b7-BI\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 04:12:09 -0400","from mx1.redhat.com ([209.132.183.28]:43428)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <cohuck@redhat.com>) id 1dua74-0001Xo-27\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 04:12:06 -0400","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 10338C0587F1;\n\tWed, 20 Sep 2017 08:12:05 +0000 (UTC)","from gondolin (ovpn-117-98.ams2.redhat.com [10.36.117.98])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 5A783600CA;\n\tWed, 20 Sep 2017 08:12:02 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 10338C0587F1","Date":"Wed, 20 Sep 2017 10:11:59 +0200","From":"Cornelia Huck <cohuck@redhat.com>","To":"Halil Pasic <pasic@linux.vnet.ibm.com>","Message-ID":"<20170920101159.0aaff3d6.cohuck@redhat.com>","In-Reply-To":"<20170919182745.90280-6-pasic@linux.vnet.ibm.com>","References":"<20170919182745.90280-1-pasic@linux.vnet.ibm.com>\n\t<20170919182745.90280-6-pasic@linux.vnet.ibm.com>","Organization":"Red Hat GmbH","MIME-Version":"1.0","Content-Type":"text/plain; charset=US-ASCII","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.11","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.32]);\n\tWed, 20 Sep 2017 08:12:05 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>,\n\tPierre Morel <pmorel@linux.vnet.ibm.com>, qemu-devel@nongnu.org","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1771883,"web_url":"http://patchwork.ozlabs.org/comment/1771883/","msgid":"<20170920103312.50b8b69b.cohuck@redhat.com>","list_archive_url":null,"date":"2017-09-20T08:33:12","subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","submitter":{"id":71914,"url":"http://patchwork.ozlabs.org/api/people/71914/","name":"Cornelia Huck","email":"cohuck@redhat.com"},"content":"On Wed, 20 Sep 2017 15:42:38 +0800\nDong Jia Shi <bjsdjshi@linux.vnet.ibm.com> wrote:\n\n> * Halil Pasic <pasic@linux.vnet.ibm.com> [2017-09-19 20:27:45 +0200]:\n> \n> > Let's add indirect data addressing support for our virtual channel\n> > subsystem. This implementation does not bother with any kind of\n> > prefetching. We simply step through the IDAL on demand.\n> > \n> > Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com>\n> > Signed-off-by: Cornelia Huck <cohuck@redhat.com>\n> > ---\n> >  hw/s390x/css.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n> >  1 file changed, 116 insertions(+), 1 deletion(-)\n> > \n> > diff --git a/hw/s390x/css.c b/hw/s390x/css.c\n> > index 2d37a9ddde..a3ce6d89b6 100644\n> > --- a/hw/s390x/css.c\n> > +++ b/hw/s390x/css.c\n> > @@ -827,6 +827,121 @@ incr:\n> >      return 0;\n> >  }\n> > \n> > +/* returns values between 1 and bsz, where bsz is a power of 2 */\n> > +static inline uint16_t ida_continuous_left(hwaddr cda, uint64_t bsz)\n> > +{\n> > +    return bsz - (cda & (bsz - 1));\n> > +}\n> > +\n> > +static inline uint64_t ccw_ida_block_size(uint8_t flags)\n> > +{\n> > +    if ((flags & CDS_F_C64) && !(flags & CDS_F_I2K)) {\n> > +        return 1ULL << 12;\n> > +    }\n> > +    return 1ULL << 11;\n> > +}\n> > +\n> > +static inline int ida_read_next_idaw(CcwDataStream *cds, bool ccw_fmt1,\n> > +                                     bool idaw_fmt_2)\n> > +{\n> > +    union {uint64_t fmt2; uint32_t fmt1; } idaw;\n> > +    int ret;\n> > +    hwaddr idaw_addr;\n> > +\n> > +    if (idaw_fmt_2) {\n> > +        idaw_addr = cds->cda_orig + sizeof(idaw.fmt2) * cds->at_idaw;\n> > +        if (idaw_addr & 0x07 && cds_ccw_addrs_ok(idaw_addr, 0, ccw_fmt1)) {\n> > +            return -EINVAL; /* channel program check */\n> > +        }\n> > +        ret = address_space_rw(&address_space_memory, idaw_addr,  \n> Ahh, just got one question here:\n> Do we need to considerate endianess for idaw_addr?\n\nThat is taken care of below.\n\nAnd the previous version worked on my laptop via tcg ;)\n\n> \n> > +                               MEMTXATTRS_UNSPECIFIED, (void *) &idaw.fmt2,\n> > +                               sizeof(idaw.fmt2), false);\n> > +        cds->cda = be64_to_cpu(idaw.fmt2);\n> > +    } else {\n> > +        idaw_addr = cds->cda_orig + sizeof(idaw.fmt1) * cds->at_idaw;\n> > +        if (idaw_addr & 0x03 && cds_ccw_addrs_ok(idaw_addr, 0, ccw_fmt1)) {\n> > +            return -EINVAL; /* channel program check */\n> > +        }\n> > +        ret = address_space_rw(&address_space_memory, idaw_addr,\n> > +                               MEMTXATTRS_UNSPECIFIED, (void *) &idaw.fmt1,\n> > +                               sizeof(idaw.fmt1), false);\n> > +        cds->cda = be64_to_cpu(idaw.fmt1);  \n> Still need to check bit 0x80000000 here I think.\n\nYes, I think this is 'must be zero' for format-1 idaws, and not covered\nby the ccw-format specific checks above. (Although the PoP can be a bit\nconfusing with many similar terms...)\n\n> \n> > +    }\n> > +    ++(cds->at_idaw);\n> > +    if (ret != MEMTX_OK) {\n> > +        /* assume inaccessible address */\n> > +        return -EINVAL; /* channel program check */\n> > +  \n> Extra line.\n> \n> > +    }\n> > +    return 0;\n> > +}\n> > +\n> > +static int ccw_dstream_rw_ida(CcwDataStream *cds, void *buff, int len,\n> > +                              CcwDataStreamOp op)\n> > +{\n> > +    uint64_t bsz = ccw_ida_block_size(cds->flags);\n> > +    int ret = 0;\n> > +    uint16_t cont_left, iter_len;\n> > +    const bool idaw_fmt2 = cds->flags & CDS_F_C64;\n> > +    bool ccw_fmt1 = cds->flags & CDS_F_FMT;  \n> Use 'const bool' either? Although I doubt the value of using const here.\n> ;)\n\nBoth being the same is still a good idea.\n\n> \n> > +\n> > +    ret = cds_check_len(cds, len);\n> > +    if (ret <= 0) {\n> > +        return ret;\n> > +    }  \n> \n> [...]\n>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx06.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx06.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=cohuck@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xy1Xs2k1dz9s7h\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 23:58:05 +1000 (AEST)","from localhost ([::1]:48254 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dufVr-0003XT-HP\n\tfor incoming@patchwork.ozlabs.org; Wed, 20 Sep 2017 09:58:03 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:57284)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <cohuck@redhat.com>) id 1duexn-0007u3-Rg\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 09:24:33 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <cohuck@redhat.com>) id 1duewj-0007Lu-NX\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 09:22:51 -0400","from mx1.redhat.com ([209.132.183.28]:34682)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <cohuck@redhat.com>) id 1duewi-0007K5-SN\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 09:21:45 -0400","from smtp.corp.redhat.com\n\t(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 0780B356E1;\n\tWed, 20 Sep 2017 08:33:17 +0000 (UTC)","from gondolin (ovpn-117-98.ams2.redhat.com [10.36.117.98])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id D046A18A75;\n\tWed, 20 Sep 2017 08:33:15 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 0780B356E1","Date":"Wed, 20 Sep 2017 10:33:12 +0200","From":"Cornelia Huck <cohuck@redhat.com>","To":"Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>","Message-ID":"<20170920103312.50b8b69b.cohuck@redhat.com>","In-Reply-To":"<20170920074238.GH11080@bjsdjshi@linux.vnet.ibm.com>","References":"<20170919182745.90280-1-pasic@linux.vnet.ibm.com>\n\t<20170919182745.90280-6-pasic@linux.vnet.ibm.com>\n\t<20170920074238.GH11080@bjsdjshi@linux.vnet.ibm.com>","Organization":"Red Hat GmbH","MIME-Version":"1.0","Content-Type":"text/plain; charset=US-ASCII","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.12","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.30]);\n\tWed, 20 Sep 2017 08:33:17 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Halil Pasic <pasic@linux.vnet.ibm.com>,\n\tPierre Morel <pmorel@linux.vnet.ibm.com>, qemu-devel@nongnu.org","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1771915,"web_url":"http://patchwork.ozlabs.org/comment/1771915/","msgid":"<20170920131844.066e53d7.cohuck@redhat.com>","list_archive_url":null,"date":"2017-09-20T11:18:44","subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","submitter":{"id":71914,"url":"http://patchwork.ozlabs.org/api/people/71914/","name":"Cornelia Huck","email":"cohuck@redhat.com"},"content":"On Wed, 20 Sep 2017 13:13:01 +0200\nHalil Pasic <pasic@linux.vnet.ibm.com> wrote:\n\n> On 09/20/2017 10:33 AM, Cornelia Huck wrote:\n> > On Wed, 20 Sep 2017 15:42:38 +0800\n> > Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com> wrote:\n> >   \n> >> * Halil Pasic <pasic@linux.vnet.ibm.com> [2017-09-19 20:27:45 +0200]:\n\n> >>> +                               MEMTXATTRS_UNSPECIFIED, (void *) &idaw.fmt2,\n> >>> +                               sizeof(idaw.fmt2), false);\n> >>> +        cds->cda = be64_to_cpu(idaw.fmt2);\n> >>> +    } else {\n> >>> +        idaw_addr = cds->cda_orig + sizeof(idaw.fmt1) * cds->at_idaw;\n> >>> +        if (idaw_addr & 0x03 && cds_ccw_addrs_ok(idaw_addr, 0, ccw_fmt1)) {\n> >>> +            return -EINVAL; /* channel program check */\n> >>> +        }\n> >>> +        ret = address_space_rw(&address_space_memory, idaw_addr,\n> >>> +                               MEMTXATTRS_UNSPECIFIED, (void *) &idaw.fmt1,\n> >>> +                               sizeof(idaw.fmt1), false);\n> >>> +        cds->cda = be64_to_cpu(idaw.fmt1);    \n> >> Still need to check bit 0x80000000 here I think.  \n> > \n> > Yes, I think this is 'must be zero' for format-1 idaws, and not covered\n> > by the ccw-format specific checks above. (Although the PoP can be a bit\n> > confusing with many similar terms...)\n> >  \n> \n> It's taken care of in ccw_dstream_rw_ida before the actual\n> access happens. Code looks like this:\n> +        if (!idaw_fmt2 && (cds->cda + iter_len) >= (1ULL << 31)) {\n> +                ret = -EINVAL; /* channel program check */\n> +                goto err;\n> +        }\n> \n> The idea was to have it similar to the non-indirect case.\n\n<looks at patch again>\n\nAh, I was simply looking for the wrong pattern. Looks correct.\n\n\n> >>> +static int ccw_dstream_rw_ida(CcwDataStream *cds, void *buff, int len,\n> >>> +                              CcwDataStreamOp op)\n> >>> +{\n> >>> +    uint64_t bsz = ccw_ida_block_size(cds->flags);\n> >>> +    int ret = 0;\n> >>> +    uint16_t cont_left, iter_len;\n> >>> +    const bool idaw_fmt2 = cds->flags & CDS_F_C64;\n> >>> +    bool ccw_fmt1 = cds->flags & CDS_F_FMT;    \n> >> Use 'const bool' either? Although I doubt the value of using const here.\n> >> ;)  \n> > \n> > Both being the same is still a good idea.\n> >   \n> \n> Yeah. For which one should I go (with const or without)?\n\nFor the one you prefer :) (I'm not sure if the const adds value here.)","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=cohuck@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xy26L2d3Sz9s82\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 00:23:38 +1000 (AEST)","from localhost ([::1]:48418 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dufua-0002GB-BF\n\tfor incoming@patchwork.ozlabs.org; Wed, 20 Sep 2017 10:23:36 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:48138)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <cohuck@redhat.com>) id 1dufMi-0004Xu-Pr\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 09:48:37 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <cohuck@redhat.com>) id 1dufMf-0002QE-NW\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 09:48:36 -0400","from mx1.redhat.com ([209.132.183.28]:54276)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <cohuck@redhat.com>) id 1dufMf-0002PM-CB\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 09:48:33 -0400","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id E5CD5C05091C;\n\tWed, 20 Sep 2017 11:18:48 +0000 (UTC)","from gondolin (ovpn-117-98.ams2.redhat.com [10.36.117.98])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id CD4D5600CA;\n\tWed, 20 Sep 2017 11:18:47 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com E5CD5C05091C","Date":"Wed, 20 Sep 2017 13:18:44 +0200","From":"Cornelia Huck <cohuck@redhat.com>","To":"Halil Pasic <pasic@linux.vnet.ibm.com>","Message-ID":"<20170920131844.066e53d7.cohuck@redhat.com>","In-Reply-To":"<009428a2-fb31-ecc9-d477-4cdea226f2d8@linux.vnet.ibm.com>","References":"<20170919182745.90280-1-pasic@linux.vnet.ibm.com>\n\t<20170919182745.90280-6-pasic@linux.vnet.ibm.com>\n\t<20170920074238.GH11080@bjsdjshi@linux.vnet.ibm.com>\n\t<20170920103312.50b8b69b.cohuck@redhat.com>\n\t<009428a2-fb31-ecc9-d477-4cdea226f2d8@linux.vnet.ibm.com>","Organization":"Red Hat GmbH","MIME-Version":"1.0","Content-Type":"text/plain; charset=US-ASCII","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.11","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.31]);\n\tWed, 20 Sep 2017 11:18:49 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>,\n\tPierre Morel <pmorel@linux.vnet.ibm.com>, qemu-devel@nongnu.org","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1771985,"web_url":"http://patchwork.ozlabs.org/comment/1771985/","msgid":"<009428a2-fb31-ecc9-d477-4cdea226f2d8@linux.vnet.ibm.com>","list_archive_url":null,"date":"2017-09-20T11:13:01","subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","submitter":{"id":68297,"url":"http://patchwork.ozlabs.org/api/people/68297/","name":"Halil Pasic","email":"pasic@linux.vnet.ibm.com"},"content":"On 09/20/2017 10:33 AM, Cornelia Huck wrote:\n> On Wed, 20 Sep 2017 15:42:38 +0800\n> Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com> wrote:\n> \n>> * Halil Pasic <pasic@linux.vnet.ibm.com> [2017-09-19 20:27:45 +0200]:\n>>\n>>> Let's add indirect data addressing support for our virtual channel\n>>> subsystem. This implementation does not bother with any kind of\n>>> prefetching. We simply step through the IDAL on demand.\n>>>\n>>> Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com>\n>>> Signed-off-by: Cornelia Huck <cohuck@redhat.com>\n>>> ---\n>>>  hw/s390x/css.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n>>>  1 file changed, 116 insertions(+), 1 deletion(-)\n>>>\n>>> diff --git a/hw/s390x/css.c b/hw/s390x/css.c\n>>> index 2d37a9ddde..a3ce6d89b6 100644\n>>> --- a/hw/s390x/css.c\n>>> +++ b/hw/s390x/css.c\n>>> @@ -827,6 +827,121 @@ incr:\n>>>      return 0;\n>>>  }\n>>>\n>>> +/* returns values between 1 and bsz, where bsz is a power of 2 */\n>>> +static inline uint16_t ida_continuous_left(hwaddr cda, uint64_t bsz)\n>>> +{\n>>> +    return bsz - (cda & (bsz - 1));\n>>> +}\n>>> +\n>>> +static inline uint64_t ccw_ida_block_size(uint8_t flags)\n>>> +{\n>>> +    if ((flags & CDS_F_C64) && !(flags & CDS_F_I2K)) {\n>>> +        return 1ULL << 12;\n>>> +    }\n>>> +    return 1ULL << 11;\n>>> +}\n>>> +\n>>> +static inline int ida_read_next_idaw(CcwDataStream *cds, bool ccw_fmt1,\n>>> +                                     bool idaw_fmt_2)\n>>> +{\n>>> +    union {uint64_t fmt2; uint32_t fmt1; } idaw;\n>>> +    int ret;\n>>> +    hwaddr idaw_addr;\n>>> +\n>>> +    if (idaw_fmt_2) {\n>>> +        idaw_addr = cds->cda_orig + sizeof(idaw.fmt2) * cds->at_idaw;\n>>> +        if (idaw_addr & 0x07 && cds_ccw_addrs_ok(idaw_addr, 0, ccw_fmt1)) {\n>>> +            return -EINVAL; /* channel program check */\n>>> +        }\n>>> +        ret = address_space_rw(&address_space_memory, idaw_addr,  \n>> Ahh, just got one question here:\n>> Do we need to considerate endianess for idaw_addr?\n> \n> That is taken care of below.\n> \n> And the previous version worked on my laptop via tcg ;)\n\nNod.\n\n> \n>>\n>>> +                               MEMTXATTRS_UNSPECIFIED, (void *) &idaw.fmt2,\n>>> +                               sizeof(idaw.fmt2), false);\n>>> +        cds->cda = be64_to_cpu(idaw.fmt2);\n>>> +    } else {\n>>> +        idaw_addr = cds->cda_orig + sizeof(idaw.fmt1) * cds->at_idaw;\n>>> +        if (idaw_addr & 0x03 && cds_ccw_addrs_ok(idaw_addr, 0, ccw_fmt1)) {\n>>> +            return -EINVAL; /* channel program check */\n>>> +        }\n>>> +        ret = address_space_rw(&address_space_memory, idaw_addr,\n>>> +                               MEMTXATTRS_UNSPECIFIED, (void *) &idaw.fmt1,\n>>> +                               sizeof(idaw.fmt1), false);\n>>> +        cds->cda = be64_to_cpu(idaw.fmt1);  \n>> Still need to check bit 0x80000000 here I think.\n> \n> Yes, I think this is 'must be zero' for format-1 idaws, and not covered\n> by the ccw-format specific checks above. (Although the PoP can be a bit\n> confusing with many similar terms...)\n>\n\nIt's taken care of in ccw_dstream_rw_ida before the actual\naccess happens. Code looks like this:\n+        if (!idaw_fmt2 && (cds->cda + iter_len) >= (1ULL << 31)) {\n+                ret = -EINVAL; /* channel program check */\n+                goto err;\n+        }\n\nThe idea was to have it similar to the non-indirect case.\n \n>>\n>>> +    }\n>>> +    ++(cds->at_idaw);\n>>> +    if (ret != MEMTX_OK) {\n>>> +        /* assume inaccessible address */\n>>> +        return -EINVAL; /* channel program check */\n>>> +  \n>> Extra line.\n>>\n>>> +    }\n>>> +    return 0;\n>>> +}\n>>> +\n>>> +static int ccw_dstream_rw_ida(CcwDataStream *cds, void *buff, int len,\n>>> +                              CcwDataStreamOp op)\n>>> +{\n>>> +    uint64_t bsz = ccw_ida_block_size(cds->flags);\n>>> +    int ret = 0;\n>>> +    uint16_t cont_left, iter_len;\n>>> +    const bool idaw_fmt2 = cds->flags & CDS_F_C64;\n>>> +    bool ccw_fmt1 = cds->flags & CDS_F_FMT;  \n>> Use 'const bool' either? Although I doubt the value of using const here.\n>> ;)\n> \n> Both being the same is still a good idea.\n> \n\nYeah. For which one should I go (with const or without)?\n\n>>\n>>> +\n>>> +    ret = cds_check_len(cds, len);\n>>> +    if (ret <= 0) {\n>>> +        return ret;\n>>> +    }  \n>>\n>> [...]\n>>\n>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xy3XG2ZYzz9sPt\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 01:27:42 +1000 (AEST)","from localhost ([::1]:48854 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dugua-0004wK-Cu\n\tfor incoming@patchwork.ozlabs.org; Wed, 20 Sep 2017 11:27:40 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:60271)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <pasic@linux.vnet.ibm.com>) id 1dufzL-0008TS-2m\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 10:28:36 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <pasic@linux.vnet.ibm.com>) id 1dufzF-0002QB-7Y\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 10:28:31 -0400","from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60488)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <pasic@linux.vnet.ibm.com>)\n\tid 1dufys-0001pd-Jm\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 10:28:25 -0400","from pps.filterd (m0098396.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv8KBBZbD078806\n\tfor <qemu-devel@nongnu.org>; Wed, 20 Sep 2017 07:13:08 -0400","from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111])\n\tby mx0a-001b2d01.pphosted.com with ESMTP id 2d3mf8tcw3-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <qemu-devel@nongnu.org>; Wed, 20 Sep 2017 07:13:07 -0400","from localhost\n\tby e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <qemu-devel@nongnu.org> from <pasic@linux.vnet.ibm.com>;\n\tWed, 20 Sep 2017 12:13:05 +0100","from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198)\n\tby e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP\n\tGateway: Authorized Use Only! Violators will be prosecuted; \n\tWed, 20 Sep 2017 12:13:02 +0100","from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com\n\t[9.149.105.61])\n\tby b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with\n\tESMTP id v8KBD1or21430498; Wed, 20 Sep 2017 11:13:01 GMT","from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 3BBE011C050;\n\tWed, 20 Sep 2017 12:09:04 +0100 (BST)","from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id E6FB411C04C;\n\tWed, 20 Sep 2017 12:09:03 +0100 (BST)","from oc3836556865.ibm.com (unknown [9.152.224.207])\n\tby d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP;\n\tWed, 20 Sep 2017 12:09:03 +0100 (BST)"],"To":"Cornelia Huck <cohuck@redhat.com>,\n\tDong Jia Shi <bjsdjshi@linux.vnet.ibm.com>","References":"<20170919182745.90280-1-pasic@linux.vnet.ibm.com>\n\t<20170919182745.90280-6-pasic@linux.vnet.ibm.com>\n\t<20170920074238.GH11080@bjsdjshi@linux.vnet.ibm.com>\n\t<20170920103312.50b8b69b.cohuck@redhat.com>","From":"Halil Pasic <pasic@linux.vnet.ibm.com>","Date":"Wed, 20 Sep 2017 13:13:01 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<20170920103312.50b8b69b.cohuck@redhat.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"8bit","X-TM-AS-GCONF":"00","x-cbid":"17092011-0020-0000-0000-000003B9A2CF","X-IBM-AV-DETECTION":"SAVI=unused REMOTE=unused XFE=unused","x-cbparentid":"17092011-0021-0000-0000-0000424B59EF","Message-Id":"<009428a2-fb31-ecc9-d477-4cdea226f2d8@linux.vnet.ibm.com>","X-Proofpoint-Virus-Version":"vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-09-20_03:, , signatures=0","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n\tspamscore=0 suspectscore=0\n\tmalwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam\n\tadjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000\n\tdefinitions=main-1709200152","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy]","X-Received-From":"148.163.156.1","Subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Pierre Morel <pmorel@linux.vnet.ibm.com>, qemu-devel@nongnu.org","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1772029,"web_url":"http://patchwork.ozlabs.org/comment/1772029/","msgid":"<64127cd2-bb90-650d-0f55-149a811edcf5@linux.vnet.ibm.com>","list_archive_url":null,"date":"2017-09-20T11:01:51","subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","submitter":{"id":68297,"url":"http://patchwork.ozlabs.org/api/people/68297/","name":"Halil Pasic","email":"pasic@linux.vnet.ibm.com"},"content":"On 09/20/2017 10:11 AM, Cornelia Huck wrote:\n> On Tue, 19 Sep 2017 20:27:45 +0200\n> Halil Pasic <pasic@linux.vnet.ibm.com> wrote:\n> \n>> Let's add indirect data addressing support for our virtual channel\n>> subsystem. This implementation does not bother with any kind of\n>> prefetching. We simply step through the IDAL on demand.\n>>\n>> Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com>\n>> Signed-off-by: Cornelia Huck <cohuck@redhat.com>\n> \n> My s-o-b is a bit preliminary ;)\n> \n>> ---\n>>  hw/s390x/css.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n>>  1 file changed, 116 insertions(+), 1 deletion(-)\n>>\n>> diff --git a/hw/s390x/css.c b/hw/s390x/css.c\n>> index 2d37a9ddde..a3ce6d89b6 100644\n>> --- a/hw/s390x/css.c\n>> +++ b/hw/s390x/css.c\n>> @@ -827,6 +827,121 @@ incr:\n>>      return 0;\n>>  }\n>>  \n>> +/* returns values between 1 and bsz, where bsz is a power of 2 */\n>> +static inline uint16_t ida_continuous_left(hwaddr cda, uint64_t bsz)\n>> +{\n>> +    return bsz - (cda & (bsz - 1));\n>> +}\n>> +\n>> +static inline uint64_t ccw_ida_block_size(uint8_t flags)\n>> +{\n>> +    if ((flags & CDS_F_C64) && !(flags & CDS_F_I2K)) {\n>> +        return 1ULL << 12;\n>> +    }\n>> +    return 1ULL << 11;\n>> +}\n>> +\n>> +static inline int ida_read_next_idaw(CcwDataStream *cds, bool ccw_fmt1,\n>> +                                     bool idaw_fmt_2)\n>> +{\n>> +    union {uint64_t fmt2; uint32_t fmt1; } idaw;\n>> +    int ret;\n>> +    hwaddr idaw_addr;\n>> +\n>> +    if (idaw_fmt_2) {\n>> +        idaw_addr = cds->cda_orig + sizeof(idaw.fmt2) * cds->at_idaw;\n>> +        if (idaw_addr & 0x07 && cds_ccw_addrs_ok(idaw_addr, 0, ccw_fmt1)) {\n> \n> So, what is supposed to happen if the idaw_addr is not aligned\n> correctly _and_ is violating the limits?\n\nYou are right this is obviously wrong.\n\nShould have been \nif (idaw_addr & 0x07 || !cds_ccw_addrs_ok(idaw_addr, 0, ccw_fmt1)) {\n\n> \n>> +            return -EINVAL; /* channel program check */\n>> +        }\n>> +        ret = address_space_rw(&address_space_memory, idaw_addr,\n>> +                               MEMTXATTRS_UNSPECIFIED, (void *) &idaw.fmt2,\n>> +                               sizeof(idaw.fmt2), false);\n>> +        cds->cda = be64_to_cpu(idaw.fmt2);\n>> +    } else {\n>> +        idaw_addr = cds->cda_orig + sizeof(idaw.fmt1) * cds->at_idaw;\n>> +        if (idaw_addr & 0x03 && cds_ccw_addrs_ok(idaw_addr, 0, ccw_fmt1)) {\n\nSame here.\n\n>> +            return -EINVAL; /* channel program check */\n>> +        }\n>> +        ret = address_space_rw(&address_space_memory, idaw_addr,\n>> +                               MEMTXATTRS_UNSPECIFIED, (void *) &idaw.fmt1,\n>> +                               sizeof(idaw.fmt1), false);\n>> +        cds->cda = be64_to_cpu(idaw.fmt1);\n>> +    }\n>> +    ++(cds->at_idaw);\n>> +    if (ret != MEMTX_OK) {\n>> +        /* assume inaccessible address */\n>> +        return -EINVAL; /* channel program check */\n>> +\n>> +    }\n>> +    return 0;\n>> +}\n>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xy4XG5rbnz9s7c\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 02:12:46 +1000 (AEST)","from localhost ([::1]:49380 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1duhcC-0001B5-SH\n\tfor incoming@patchwork.ozlabs.org; Wed, 20 Sep 2017 12:12:44 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:34150)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <pasic@linux.vnet.ibm.com>) id 1duhL3-0003CH-RZ\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 11:55:06 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <pasic@linux.vnet.ibm.com>) id 1duhKy-0004Uj-62\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 11:55:01 -0400","from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35636\n\thelo=mx0a-001b2d01.pphosted.com)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <pasic@linux.vnet.ibm.com>)\n\tid 1duhKx-0004Sq-QY\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 11:54:55 -0400","from pps.filterd (m0098421.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv8KAxPxB134688\n\tfor <qemu-devel@nongnu.org>; Wed, 20 Sep 2017 07:01:57 -0400","from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110])\n\tby mx0a-001b2d01.pphosted.com with ESMTP id 2d3phjt8cm-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <qemu-devel@nongnu.org>; Wed, 20 Sep 2017 07:01:57 -0400","from localhost\n\tby e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <qemu-devel@nongnu.org> from <pasic@linux.vnet.ibm.com>;\n\tWed, 20 Sep 2017 12:01:55 +0100","from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198)\n\tby e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP\n\tGateway: Authorized Use Only! Violators will be prosecuted; \n\tWed, 20 Sep 2017 12:01:52 +0100","from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com\n\t[9.149.105.61])\n\tby b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with\n\tESMTP id v8KB1qZ217236206; Wed, 20 Sep 2017 11:01:52 GMT","from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 6DA1511C04C;\n\tWed, 20 Sep 2017 11:57:54 +0100 (BST)","from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 1D7A911C04A;\n\tWed, 20 Sep 2017 11:57:54 +0100 (BST)","from oc3836556865.ibm.com (unknown [9.152.224.207])\n\tby d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP;\n\tWed, 20 Sep 2017 11:57:54 +0100 (BST)"],"To":"Cornelia Huck <cohuck@redhat.com>","References":"<20170919182745.90280-1-pasic@linux.vnet.ibm.com>\n\t<20170919182745.90280-6-pasic@linux.vnet.ibm.com>\n\t<20170920101159.0aaff3d6.cohuck@redhat.com>","From":"Halil Pasic <pasic@linux.vnet.ibm.com>","Date":"Wed, 20 Sep 2017 13:01:51 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<20170920101159.0aaff3d6.cohuck@redhat.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-TM-AS-GCONF":"00","x-cbid":"17092011-0016-0000-0000-000004EEA2C1","X-IBM-AV-DETECTION":"SAVI=unused REMOTE=unused XFE=unused","x-cbparentid":"17092011-0017-0000-0000-00002828DA6C","Message-Id":"<64127cd2-bb90-650d-0f55-149a811edcf5@linux.vnet.ibm.com>","X-Proofpoint-Virus-Version":"vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-09-20_03:, , signatures=0","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n\tspamscore=0 suspectscore=0\n\tmalwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam\n\tadjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000\n\tdefinitions=main-1709200149","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy]","X-Received-From":"148.163.158.5","Subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>,\n\tPierre Morel <pmorel@linux.vnet.ibm.com>, qemu-devel@nongnu.org","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1772059,"web_url":"http://patchwork.ozlabs.org/comment/1772059/","msgid":"<268904f1-0b31-3255-02da-c3248abef6a2@linux.vnet.ibm.com>","list_archive_url":null,"date":"2017-09-20T16:46:57","subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","submitter":{"id":68297,"url":"http://patchwork.ozlabs.org/api/people/68297/","name":"Halil Pasic","email":"pasic@linux.vnet.ibm.com"},"content":"On 09/20/2017 01:18 PM, Cornelia Huck wrote:\n> On Wed, 20 Sep 2017 13:13:01 +0200\n> Halil Pasic <pasic@linux.vnet.ibm.com> wrote:\n> \n>> On 09/20/2017 10:33 AM, Cornelia Huck wrote:\n>>> On Wed, 20 Sep 2017 15:42:38 +0800\n>>> Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com> wrote:\n>>>   \n>>>> * Halil Pasic <pasic@linux.vnet.ibm.com> [2017-09-19 20:27:45 +0200]:\n> \n>>>>> +                               MEMTXATTRS_UNSPECIFIED, (void *) &idaw.fmt2,\n>>>>> +                               sizeof(idaw.fmt2), false);\n>>>>> +        cds->cda = be64_to_cpu(idaw.fmt2);\n>>>>> +    } else {\n>>>>> +        idaw_addr = cds->cda_orig + sizeof(idaw.fmt1) * cds->at_idaw;\n>>>>> +        if (idaw_addr & 0x03 && cds_ccw_addrs_ok(idaw_addr, 0, ccw_fmt1)) {\n>>>>> +            return -EINVAL; /* channel program check */\n>>>>> +        }\n>>>>> +        ret = address_space_rw(&address_space_memory, idaw_addr,\n>>>>> +                               MEMTXATTRS_UNSPECIFIED, (void *) &idaw.fmt1,\n>>>>> +                               sizeof(idaw.fmt1), false);\n>>>>> +        cds->cda = be64_to_cpu(idaw.fmt1);    \n>>>> Still need to check bit 0x80000000 here I think.  \n>>>\n>>> Yes, I think this is 'must be zero' for format-1 idaws, and not covered\n>>> by the ccw-format specific checks above. (Although the PoP can be a bit\n>>> confusing with many similar terms...)\n>>>  \n>>\n>> It's taken care of in ccw_dstream_rw_ida before the actual\n>> access happens. Code looks like this:\n>> +        if (!idaw_fmt2 && (cds->cda + iter_len) >= (1ULL << 31)) {\n>> +                ret = -EINVAL; /* channel program check */\n>> +                goto err;\n>> +        }\n>>\n>> The idea was to have it similar to the non-indirect case.\n> \n> <looks at patch again>\n> \n> Ah, I was simply looking for the wrong pattern. Looks correct.\n> \n> \n\nThinking about this some more. Since in case of IDA we are guaranteed\nto never cross a block boundary with a single IDAW we won't ever cross\nblock boundary. So we can do the check in ida_read_next_idaw by checking\nbit 0x80000000 on the ccw->cda. So we could keep idaw_fmt2 and ccw_fmt1\nlocal to ida_read_next_idaw and save one goto err. I think that would\nlook a bit nicer than what I have here in v3. Agree?\n\n>>>>> +static int ccw_dstream_rw_ida(CcwDataStream *cds, void *buff, int len,\n>>>>> +                              CcwDataStreamOp op)\n>>>>> +{\n>>>>> +    uint64_t bsz = ccw_ida_block_size(cds->flags);\n>>>>> +    int ret = 0;\n>>>>> +    uint16_t cont_left, iter_len;\n>>>>> +    const bool idaw_fmt2 = cds->flags & CDS_F_C64;\n>>>>> +    bool ccw_fmt1 = cds->flags & CDS_F_FMT;    \n>>>> Use 'const bool' either? Although I doubt the value of using const here.\n>>>> ;)  \n>>>\n>>> Both being the same is still a good idea.\n>>>   \n>>\n>> Yeah. For which one should I go (with const or without)?\n> \n> For the one you prefer :) (I'm not sure if the const adds value here.)\n> \n\nI think we generally don't care about const-ness in such situations,\nso I think I won't use consts.\n\nI intend to fix the issues we have found and do a v4 tomorrow, unless\nsomebody screams -- could do it today but I would like to give Dong\nJia an opportunity to react. On the other hand waiting more that that\nwill IMHO do us no favor either (I think of our storage/memory hierarchy).\n\nRegards,\nHalil","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xy5JS5rhsz9sP1\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 02:47:34 +1000 (AEST)","from localhost ([::1]:49767 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dui9q-0007HQ-Uq\n\tfor incoming@patchwork.ozlabs.org; Wed, 20 Sep 2017 12:47:30 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:33642)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <pasic@linux.vnet.ibm.com>) id 1dui9V-0007H3-PN\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 12:47:10 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <pasic@linux.vnet.ibm.com>) id 1dui9R-0008Dc-MW\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 12:47:09 -0400","from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44296)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <pasic@linux.vnet.ibm.com>)\n\tid 1dui9R-0008Bt-Du\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 12:47:05 -0400","from pps.filterd (m0098410.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv8KGkvuA085300\n\tfor <qemu-devel@nongnu.org>; Wed, 20 Sep 2017 12:47:04 -0400","from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110])\n\tby mx0a-001b2d01.pphosted.com with ESMTP id 2d3s8mvect-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <qemu-devel@nongnu.org>; Wed, 20 Sep 2017 12:47:02 -0400","from localhost\n\tby e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <qemu-devel@nongnu.org> from <pasic@linux.vnet.ibm.com>;\n\tWed, 20 Sep 2017 17:47:00 +0100","from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195)\n\tby e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP\n\tGateway: Authorized Use Only! Violators will be prosecuted; \n\tWed, 20 Sep 2017 17:46:58 +0100","from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com\n\t[9.149.105.60])\n\tby b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with\n\tESMTP id v8KGkwgH18415764; Wed, 20 Sep 2017 16:46:58 GMT","from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id C780842041;\n\tWed, 20 Sep 2017 17:43:08 +0100 (BST)","from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 720B34203F;\n\tWed, 20 Sep 2017 17:43:08 +0100 (BST)","from oc3836556865.ibm.com (unknown [9.152.224.207])\n\tby d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP;\n\tWed, 20 Sep 2017 17:43:08 +0100 (BST)"],"To":"Cornelia Huck <cohuck@redhat.com>","References":"<20170919182745.90280-1-pasic@linux.vnet.ibm.com>\n\t<20170919182745.90280-6-pasic@linux.vnet.ibm.com>\n\t<20170920074238.GH11080@bjsdjshi@linux.vnet.ibm.com>\n\t<20170920103312.50b8b69b.cohuck@redhat.com>\n\t<009428a2-fb31-ecc9-d477-4cdea226f2d8@linux.vnet.ibm.com>\n\t<20170920131844.066e53d7.cohuck@redhat.com>","From":"Halil Pasic <pasic@linux.vnet.ibm.com>","Date":"Wed, 20 Sep 2017 18:46:57 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<20170920131844.066e53d7.cohuck@redhat.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"8bit","X-TM-AS-GCONF":"00","x-cbid":"17092016-0016-0000-0000-000004EEBE7F","X-IBM-AV-DETECTION":"SAVI=unused REMOTE=unused XFE=unused","x-cbparentid":"17092016-0017-0000-0000-00002828F7F7","Message-Id":"<268904f1-0b31-3255-02da-c3248abef6a2@linux.vnet.ibm.com>","X-Proofpoint-Virus-Version":"vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-09-20_04:, , signatures=0","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n\tspamscore=0 suspectscore=0\n\tmalwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam\n\tadjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000\n\tdefinitions=main-1709200226","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy]","X-Received-From":"148.163.156.1","Subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>,\n\tPierre Morel <pmorel@linux.vnet.ibm.com>, qemu-devel@nongnu.org","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1772337,"web_url":"http://patchwork.ozlabs.org/comment/1772337/","msgid":"<20170921005036.GL11080@bjsdjshi@linux.vnet.ibm.com>","list_archive_url":null,"date":"2017-09-21T00:50:36","subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","submitter":{"id":68897,"url":"http://patchwork.ozlabs.org/api/people/68897/","name":"Dong Jia Shi","email":"bjsdjshi@linux.vnet.ibm.com"},"content":"* Halil Pasic <pasic@linux.vnet.ibm.com> [2017-09-20 18:46:57 +0200]:\n\n> \n> \n> On 09/20/2017 01:18 PM, Cornelia Huck wrote:\n> > On Wed, 20 Sep 2017 13:13:01 +0200\n> > Halil Pasic <pasic@linux.vnet.ibm.com> wrote:\n> > \n> >> On 09/20/2017 10:33 AM, Cornelia Huck wrote:\n> >>> On Wed, 20 Sep 2017 15:42:38 +0800\n> >>> Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com> wrote:\n> >>>   \n> >>>> * Halil Pasic <pasic@linux.vnet.ibm.com> [2017-09-19 20:27:45 +0200]:\n> > \n> >>>>> +                               MEMTXATTRS_UNSPECIFIED, (void *) &idaw.fmt2,\n> >>>>> +                               sizeof(idaw.fmt2), false);\n> >>>>> +        cds->cda = be64_to_cpu(idaw.fmt2);\n> >>>>> +    } else {\n> >>>>> +        idaw_addr = cds->cda_orig + sizeof(idaw.fmt1) * cds->at_idaw;\n> >>>>> +        if (idaw_addr & 0x03 && cds_ccw_addrs_ok(idaw_addr, 0, ccw_fmt1)) {\n> >>>>> +            return -EINVAL; /* channel program check */\n> >>>>> +        }\n> >>>>> +        ret = address_space_rw(&address_space_memory, idaw_addr,\n> >>>>> +                               MEMTXATTRS_UNSPECIFIED, (void *) &idaw.fmt1,\n> >>>>> +                               sizeof(idaw.fmt1), false);\n> >>>>> +        cds->cda = be64_to_cpu(idaw.fmt1);    \n> >>>> Still need to check bit 0x80000000 here I think.  \n> >>>\n> >>> Yes, I think this is 'must be zero' for format-1 idaws, and not covered\n> >>> by the ccw-format specific checks above. (Although the PoP can be a bit\n> >>> confusing with many similar terms...)\n> >>>  \n> >>\n> >> It's taken care of in ccw_dstream_rw_ida before the actual\n> >> access happens. Code looks like this:\n> >> +        if (!idaw_fmt2 && (cds->cda + iter_len) >= (1ULL << 31)) {\n> >> +                ret = -EINVAL; /* channel program check */\n> >> +                goto err;\n> >> +        }\n> >>\n> >> The idea was to have it similar to the non-indirect case.\n> > \n> > <looks at patch again>\n> > \n> > Ah, I was simply looking for the wrong pattern. Looks correct.\n> > \n> > \n> \n> Thinking about this some more. Since in case of IDA we are guaranteed\n> to never cross a block boundary with a single IDAW we won't ever cross\n> block boundary. So we can do the check in ida_read_next_idaw by checking\n> bit 0x80000000 on the ccw->cda. So we could keep idaw_fmt2 and ccw_fmt1\n> local to ida_read_next_idaw and save one goto err. I think that would\n> look a bit nicer than what I have here in v3. Agree?\nAgree. That would also do the check in the first place. Sounds better.\n\n> \n> >>>>> +static int ccw_dstream_rw_ida(CcwDataStream *cds, void *buff, int len,\n> >>>>> +                              CcwDataStreamOp op)\n> >>>>> +{\n> >>>>> +    uint64_t bsz = ccw_ida_block_size(cds->flags);\n> >>>>> +    int ret = 0;\n> >>>>> +    uint16_t cont_left, iter_len;\n> >>>>> +    const bool idaw_fmt2 = cds->flags & CDS_F_C64;\n> >>>>> +    bool ccw_fmt1 = cds->flags & CDS_F_FMT;    \n> >>>> Use 'const bool' either? Although I doubt the value of using const here.\n> >>>> ;)  \n> >>>\n> >>> Both being the same is still a good idea.\n> >>>   \n> >>\n> >> Yeah. For which one should I go (with const or without)?\n> > \n> > For the one you prefer :) (I'm not sure if the const adds value here.)\n> > \n> \n> I think we generally don't care about const-ness in such situations,\n> so I think I won't use consts.\n> \n> I intend to fix the issues we have found and do a v4 tomorrow, unless\n> somebody screams -- could do it today but I would like to give Dong\n> Jia an opportunity to react.\nThanks. I'm coming. :)\n\n> On the other hand waiting more that that will IMHO do us no favor\n> either (I think of our storage/memory hierarchy).\n> \n> Regards,\n> Halil","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xyJ2Y5JXwz9ryv\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 10:51:16 +1000 (AEST)","from localhost ([::1]:51259 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1duphy-0002WX-50\n\tfor incoming@patchwork.ozlabs.org; Wed, 20 Sep 2017 20:51:14 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:58538)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <bjsdjshi@linux.vnet.ibm.com>) id 1dupha-0002Uq-7y\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 20:50:51 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <bjsdjshi@linux.vnet.ibm.com>) id 1duphX-0002Aj-3j\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 20:50:50 -0400","from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53774)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <bjsdjshi@linux.vnet.ibm.com>)\n\tid 1duphW-00029m-IY\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 20:50:46 -0400","from pps.filterd (m0098410.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv8L0mXgc025115\n\tfor <qemu-devel@nongnu.org>; Wed, 20 Sep 2017 20:50:44 -0400","from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203])\n\tby mx0a-001b2d01.pphosted.com with ESMTP id 2d3wmrgxt8-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <qemu-devel@nongnu.org>; Wed, 20 Sep 2017 20:50:44 -0400","from localhost\n\tby e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <qemu-devel@nongnu.org> from <bjsdjshi@linux.vnet.ibm.com>;\n\tWed, 20 Sep 2017 20:50:42 -0400","from b01cxnp22034.gho.pok.ibm.com (9.57.198.24)\n\tby e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway:\n\tAuthorized Use Only! Violators will be prosecuted; \n\tWed, 20 Sep 2017 20:50:39 -0400","from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com\n\t[9.57.199.111])\n\tby b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP\n\tid v8L0ocnL53411952; Thu, 21 Sep 2017 00:50:39 GMT","from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 87287AC048;\n\tWed, 20 Sep 2017 20:51:11 -0400 (EDT)","from localhost (unknown [9.115.112.23])\n\tby b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id C25FFAC043;\n\tWed, 20 Sep 2017 20:51:10 -0400 (EDT)"],"Date":"Thu, 21 Sep 2017 08:50:36 +0800","From":"Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>","To":"Halil Pasic <pasic@linux.vnet.ibm.com>","Mail-Followup-To":"Halil Pasic <pasic@linux.vnet.ibm.com>,\n\tCornelia Huck <cohuck@redhat.com>,\n\tDong Jia Shi <bjsdjshi@linux.vnet.ibm.com>,\n\tPierre Morel <pmorel@linux.vnet.ibm.com>, qemu-devel@nongnu.org","References":"<20170919182745.90280-1-pasic@linux.vnet.ibm.com>\n\t<20170919182745.90280-6-pasic@linux.vnet.ibm.com>\n\t<20170920074238.GH11080@bjsdjshi@linux.vnet.ibm.com>\n\t<20170920103312.50b8b69b.cohuck@redhat.com>\n\t<009428a2-fb31-ecc9-d477-4cdea226f2d8@linux.vnet.ibm.com>\n\t<20170920131844.066e53d7.cohuck@redhat.com>\n\t<268904f1-0b31-3255-02da-c3248abef6a2@linux.vnet.ibm.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<268904f1-0b31-3255-02da-c3248abef6a2@linux.vnet.ibm.com>","Organization":"(IBM CSL)","X-URL":"http://ibm.com/","User-Agent":"Mutt/1.5.21 (2010-09-15)","X-TM-AS-GCONF":"00","x-cbid":"17092100-0008-0000-0000-00000283983D","X-IBM-SpamModules-Scores":"","X-IBM-SpamModules-Versions":"BY=3.00007770; HX=3.00000241; KW=3.00000007;\n\tPH=3.00000004; SC=3.00000230; SDB=6.00919991; UDB=6.00462245;\n\tIPR=6.00700218; \n\tBA=6.00005599; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009;\n\tZB=6.00000000; \n\tZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017227;\n\tXFM=3.00000015; UTC=2017-09-21 00:50:40","X-IBM-AV-DETECTION":"SAVI=unused REMOTE=unused XFE=unused","x-cbparentid":"17092100-0009-0000-0000-000036C4B63E","Message-Id":"<20170921005036.GL11080@bjsdjshi@linux.vnet.ibm.com>","X-Proofpoint-Virus-Version":"vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-09-20_06:, , signatures=0","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n\tspamscore=0 suspectscore=0\n\tmalwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam\n\tadjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000\n\tdefinitions=main-1709210009","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy]","X-Received-From":"148.163.156.1","Subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>,\n\tCornelia Huck <cohuck@redhat.com>,\n\tPierre Morel <pmorel@linux.vnet.ibm.com>, qemu-devel@nongnu.org","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1772350,"web_url":"http://patchwork.ozlabs.org/comment/1772350/","msgid":"<20170921011007.GM11080@bjsdjshi@linux.vnet.ibm.com>","list_archive_url":null,"date":"2017-09-21T01:10:07","subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","submitter":{"id":68897,"url":"http://patchwork.ozlabs.org/api/people/68897/","name":"Dong Jia Shi","email":"bjsdjshi@linux.vnet.ibm.com"},"content":"* Halil Pasic <pasic@linux.vnet.ibm.com> [2017-09-20 13:13:01 +0200]:\n\n> \n> \n> On 09/20/2017 10:33 AM, Cornelia Huck wrote:\n> > On Wed, 20 Sep 2017 15:42:38 +0800\n> > Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com> wrote:\n> > \n> >> * Halil Pasic <pasic@linux.vnet.ibm.com> [2017-09-19 20:27:45 +0200]:\n> >>\n> >>> Let's add indirect data addressing support for our virtual channel\n> >>> subsystem. This implementation does not bother with any kind of\n> >>> prefetching. We simply step through the IDAL on demand.\n> >>>\n> >>> Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com>\n> >>> Signed-off-by: Cornelia Huck <cohuck@redhat.com>\n> >>> ---\n> >>>  hw/s390x/css.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n> >>>  1 file changed, 116 insertions(+), 1 deletion(-)\n> >>>\n> >>> diff --git a/hw/s390x/css.c b/hw/s390x/css.c\n> >>> index 2d37a9ddde..a3ce6d89b6 100644\n> >>> --- a/hw/s390x/css.c\n> >>> +++ b/hw/s390x/css.c\n> >>> @@ -827,6 +827,121 @@ incr:\n> >>>      return 0;\n> >>>  }\n> >>>\n> >>> +/* returns values between 1 and bsz, where bsz is a power of 2 */\n> >>> +static inline uint16_t ida_continuous_left(hwaddr cda, uint64_t bsz)\n> >>> +{\n> >>> +    return bsz - (cda & (bsz - 1));\n> >>> +}\n> >>> +\n> >>> +static inline uint64_t ccw_ida_block_size(uint8_t flags)\n> >>> +{\n> >>> +    if ((flags & CDS_F_C64) && !(flags & CDS_F_I2K)) {\n> >>> +        return 1ULL << 12;\n> >>> +    }\n> >>> +    return 1ULL << 11;\n> >>> +}\n> >>> +\n> >>> +static inline int ida_read_next_idaw(CcwDataStream *cds, bool ccw_fmt1,\n> >>> +                                     bool idaw_fmt_2)\n> >>> +{\n> >>> +    union {uint64_t fmt2; uint32_t fmt1; } idaw;\n> >>> +    int ret;\n> >>> +    hwaddr idaw_addr;\n> >>> +\n> >>> +    if (idaw_fmt_2) {\n> >>> +        idaw_addr = cds->cda_orig + sizeof(idaw.fmt2) * cds->at_idaw;\n> >>> +        if (idaw_addr & 0x07 && cds_ccw_addrs_ok(idaw_addr, 0, ccw_fmt1)) {\n> >>> +            return -EINVAL; /* channel program check */\n> >>> +        }\n> >>> +        ret = address_space_rw(&address_space_memory, idaw_addr,  \n> >> Ahh, just got one question here:\n> >> Do we need to considerate endianess for idaw_addr?\n> > \n> > That is taken care of below.\n> > \n> > And the previous version worked on my laptop via tcg ;)\n> \n> Nod.\n\nMy fault!\n\nI was thinking of the idaw_addr itself, not the content of it. Now I\nrealized that, since we already converted (cds->cda_orig) in\ncopy_ccw_from_guest(), there is no need to convert (idaw_addr +\nidaw_size * idaw_index) anymore.\n\nPlease ingnore my noise. ;P\n\n> \n> > \n> >>\n> >>> +                               MEMTXATTRS_UNSPECIFIED, (void *) &idaw.fmt2,\n> >>> +                               sizeof(idaw.fmt2), false);\n> >>> +        cds->cda = be64_to_cpu(idaw.fmt2);\n> >>> +    } else {\n> >>> +        idaw_addr = cds->cda_orig + sizeof(idaw.fmt1) * cds->at_idaw;\n> >>> +        if (idaw_addr & 0x03 && cds_ccw_addrs_ok(idaw_addr, 0, ccw_fmt1)) {\n> >>> +            return -EINVAL; /* channel program check */\n> >>> +        }\n> >>> +        ret = address_space_rw(&address_space_memory, idaw_addr,\n> >>> +                               MEMTXATTRS_UNSPECIFIED, (void *) &idaw.fmt1,\n> >>> +                               sizeof(idaw.fmt1), false);\n> >>> +        cds->cda = be64_to_cpu(idaw.fmt1);  \n\n[...]","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xyJTD721hz9s0g\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 11:10:47 +1000 (AEST)","from localhost ([::1]:51296 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1duq0q-0005Wm-7a\n\tfor incoming@patchwork.ozlabs.org; Wed, 20 Sep 2017 21:10:44 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:36918)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <bjsdjshi@linux.vnet.ibm.com>) id 1duq0R-0005VN-98\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 21:10:20 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <bjsdjshi@linux.vnet.ibm.com>) id 1duq0M-0002so-78\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 21:10:19 -0400","from mx0b-001b2d01.pphosted.com ([148.163.158.5]:42340\n\thelo=mx0a-001b2d01.pphosted.com)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <bjsdjshi@linux.vnet.ibm.com>)\n\tid 1duq0M-0002ja-0V\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 21:10:14 -0400","from pps.filterd (m0098417.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv8L18ZGL038095\n\tfor <qemu-devel@nongnu.org>; Wed, 20 Sep 2017 21:10:13 -0400","from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158])\n\tby mx0a-001b2d01.pphosted.com with ESMTP id 2d4351s8te-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <qemu-devel@nongnu.org>; Wed, 20 Sep 2017 21:10:12 -0400","from localhost\n\tby e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <qemu-devel@nongnu.org> from <bjsdjshi@linux.vnet.ibm.com>;\n\tWed, 20 Sep 2017 19:10:11 -0600","from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17)\n\tby e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway:\n\tAuthorized Use Only! Violators will be prosecuted; \n\tWed, 20 Sep 2017 19:10:10 -0600","from b03ledav001.gho.boulder.ibm.com\n\t(b03ledav001.gho.boulder.ibm.com [9.17.130.232])\n\tby b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with\n\tESMTP id v8L1A90266322682; Wed, 20 Sep 2017 18:10:09 -0700","from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id BAFFE6E03A;\n\tWed, 20 Sep 2017 19:10:09 -0600 (MDT)","from localhost (unknown [9.115.112.23])\n\tby b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 0FDAB6E038;\n\tWed, 20 Sep 2017 19:10:08 -0600 (MDT)"],"Date":"Thu, 21 Sep 2017 09:10:07 +0800","From":"Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>","To":"Halil Pasic <pasic@linux.vnet.ibm.com>","Mail-Followup-To":"Halil Pasic <pasic@linux.vnet.ibm.com>,\n\tCornelia Huck <cohuck@redhat.com>,\n\tDong Jia Shi <bjsdjshi@linux.vnet.ibm.com>,\n\tPierre Morel <pmorel@linux.vnet.ibm.com>, qemu-devel@nongnu.org","References":"<20170919182745.90280-1-pasic@linux.vnet.ibm.com>\n\t<20170919182745.90280-6-pasic@linux.vnet.ibm.com>\n\t<20170920074238.GH11080@bjsdjshi@linux.vnet.ibm.com>\n\t<20170920103312.50b8b69b.cohuck@redhat.com>\n\t<009428a2-fb31-ecc9-d477-4cdea226f2d8@linux.vnet.ibm.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<009428a2-fb31-ecc9-d477-4cdea226f2d8@linux.vnet.ibm.com>","Organization":"(IBM CSL)","X-URL":"http://ibm.com/","User-Agent":"Mutt/1.5.21 (2010-09-15)","X-TM-AS-GCONF":"00","x-cbid":"17092101-0024-0000-0000-0000173968D4","X-IBM-SpamModules-Scores":"","X-IBM-SpamModules-Versions":"BY=3.00007770; HX=3.00000241; KW=3.00000007;\n\tPH=3.00000004; SC=3.00000230; SDB=6.00919998; UDB=6.00462248;\n\tIPR=6.00700224; \n\tBA=6.00005599; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009;\n\tZB=6.00000000; \n\tZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017227;\n\tXFM=3.00000015; UTC=2017-09-21 01:10:11","X-IBM-AV-DETECTION":"SAVI=unused REMOTE=unused XFE=unused","x-cbparentid":"17092101-0025-0000-0000-00004CCD2892","Message-Id":"<20170921011007.GM11080@bjsdjshi@linux.vnet.ibm.com>","X-Proofpoint-Virus-Version":"vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-09-20_06:, , signatures=0","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n\tspamscore=0 suspectscore=0\n\tmalwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam\n\tadjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000\n\tdefinitions=main-1709210014","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy]","X-Received-From":"148.163.158.5","Subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>,\n\tCornelia Huck <cohuck@redhat.com>,\n\tPierre Morel <pmorel@linux.vnet.ibm.com>, qemu-devel@nongnu.org","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1772492,"web_url":"http://patchwork.ozlabs.org/comment/1772492/","msgid":"<20170921093118.677e0819.cohuck@redhat.com>","list_archive_url":null,"date":"2017-09-21T07:31:18","subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","submitter":{"id":71914,"url":"http://patchwork.ozlabs.org/api/people/71914/","name":"Cornelia Huck","email":"cohuck@redhat.com"},"content":"On Thu, 21 Sep 2017 08:50:36 +0800\nDong Jia Shi <bjsdjshi@linux.vnet.ibm.com> wrote:\n\n> * Halil Pasic <pasic@linux.vnet.ibm.com> [2017-09-20 18:46:57 +0200]:\n\n> > Thinking about this some more. Since in case of IDA we are guaranteed\n> > to never cross a block boundary with a single IDAW we won't ever cross\n> > block boundary. So we can do the check in ida_read_next_idaw by checking\n> > bit 0x80000000 on the ccw->cda. So we could keep idaw_fmt2 and ccw_fmt1\n> > local to ida_read_next_idaw and save one goto err. I think that would\n> > look a bit nicer than what I have here in v3. Agree?  \n> Agree. That would also do the check in the first place. Sounds better.\n\nCan't argue with nicer code, either :) Looking forward to the next\nversion.","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=cohuck@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xySwr3y4lz9s7v\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 17:31:52 +1000 (AEST)","from localhost ([::1]:52162 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1duvxc-0000wJ-PU\n\tfor incoming@patchwork.ozlabs.org; Thu, 21 Sep 2017 03:31:48 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:56482)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <cohuck@redhat.com>) id 1duvxG-0000w2-Ky\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 03:31:27 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <cohuck@redhat.com>) id 1duvxD-0007Ly-IN\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 03:31:26 -0400","from mx1.redhat.com ([209.132.183.28]:35100)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <cohuck@redhat.com>) id 1duvxD-0007L8-DZ\n\tfor qemu-devel@nongnu.org; Thu, 21 Sep 2017 03:31:23 -0400","from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 385F480F90;\n\tThu, 21 Sep 2017 07:31:22 +0000 (UTC)","from gondolin (dhcp-192-215.str.redhat.com [10.33.192.215])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 544AC5C8B2;\n\tThu, 21 Sep 2017 07:31:21 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 385F480F90","Date":"Thu, 21 Sep 2017 09:31:18 +0200","From":"Cornelia Huck <cohuck@redhat.com>","To":"Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>","Message-ID":"<20170921093118.677e0819.cohuck@redhat.com>","In-Reply-To":"<20170921005036.GL11080@bjsdjshi@linux.vnet.ibm.com>","References":"<20170919182745.90280-1-pasic@linux.vnet.ibm.com>\n\t<20170919182745.90280-6-pasic@linux.vnet.ibm.com>\n\t<20170920074238.GH11080@bjsdjshi@linux.vnet.ibm.com>\n\t<20170920103312.50b8b69b.cohuck@redhat.com>\n\t<009428a2-fb31-ecc9-d477-4cdea226f2d8@linux.vnet.ibm.com>\n\t<20170920131844.066e53d7.cohuck@redhat.com>\n\t<268904f1-0b31-3255-02da-c3248abef6a2@linux.vnet.ibm.com>\n\t<20170921005036.GL11080@bjsdjshi@linux.vnet.ibm.com>","Organization":"Red Hat GmbH","MIME-Version":"1.0","Content-Type":"text/plain; charset=US-ASCII","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.16","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.27]);\n\tThu, 21 Sep 2017 07:31:22 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v3 5/5] s390x/css: support ccw IDA","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Halil Pasic <pasic@linux.vnet.ibm.com>,\n\tPierre Morel <pmorel@linux.vnet.ibm.com>, qemu-devel@nongnu.org","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]