Received: from eggs.gnu.org ([2001:4830:134:3::10]:39656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVfvM-0006mk-Mu for qemu-devel@nongnu.org; Wed, 11 Mar 2015 08:39:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YVfvI-0000BQ-Jr for qemu-devel@nongnu.org; Wed, 11 Mar 2015 08:39:44 -0400 Received: from e06smtp11.uk.ibm.com ([195.75.94.107]:45210) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVfvI-0000BE-CL for qemu-devel@nongnu.org; Wed, 11 Mar 2015 08:39:40 -0400 Received: from /spool/local by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 11 Mar 2015 12:39:39 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 9C1271B0805F for ; Wed, 11 Mar 2015 12:39:56 +0000 (GMT) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t2BCdafg1507740 for ; Wed, 11 Mar 2015 12:39:36 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t2B7YgKb024523 for ; Wed, 11 Mar 2015 03:34:42 -0400 Date: Wed, 11 Mar 2015 13:39:33 +0100 From: Thomas Huth Message-ID: <20150311133933.2288ad79@oc7435384737.ibm.com> In-Reply-To: <1426067871-17693-3-git-send-email-cornelia.huck@de.ibm.com> References: <1426067871-17693-1-git-send-email-cornelia.huck@de.ibm.com> <1426067871-17693-3-git-send-email-cornelia.huck@de.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] virtio-ccw: assure be accesses for set-revision List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cornelia Huck Cc: qemu-devel@nongnu.org, mst@redhat.com On Wed, 11 Mar 2015 10:57:51 +0100 Cornelia Huck wrote: > All fields in structures transmitted by ccws are big endian; assure > we handle them as such for the set-revision ccw as well. > > Should be merged into "s390x/virtio-ccw: add virtio set-revision call". > > CC: Thomas Huth > Signed-off-by: Cornelia Huck > --- > hw/s390x/virtio-ccw.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c > index 60f8a14..a64f116 100644 > --- a/hw/s390x/virtio-ccw.c > +++ b/hw/s390x/virtio-ccw.c > @@ -687,7 +687,7 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) > break; > case CCW_CMD_SET_VIRTIO_REV: > len = sizeof(revinfo); > - if (ccw.count < len || (check_len && ccw.count > len)) { > + if (ccw.count < sizeof(revinfo)) { > ret = -EINVAL; > break; > } > @@ -695,7 +695,18 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) > ret = -EFAULT; > break; > } > - cpu_physical_memory_read(ccw.cda, &revinfo, len); > + revinfo.revision = lduw_be_phys(&address_space_memory, ccw.cda); > + revinfo.length = lduw_be_phys(&address_space_memory, > + ccw.cda + sizeof(revinfo.revision)); > + if (ccw.count < len + revinfo.length || > + (check_len && ccw.count > len + revinfo.length)) { > + ret = -EINVAL; > + break; > + } > + /* > + * Once we start to support revisions with additional data, we'll > + * need to fetch it here. Nothing to do for now, though. > + */ > if (dev->revision >= 0 || > revinfo.revision > virtio_ccw_rev_max(dev)) { > ret = -ENOSYS; Looks fine to me. Reviewed-by: Thomas Huth