From patchwork Tue May 5 15:00:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 468138 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0B9A214033F for ; Wed, 6 May 2015 01:01:23 +1000 (AEST) Received: from localhost ([::1]:39848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpeLZ-0003BG-2F for incoming@patchwork.ozlabs.org; Tue, 05 May 2015 11:01:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpeKn-00029p-3n for qemu-devel@nongnu.org; Tue, 05 May 2015 11:00:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YpeKb-00069l-Rj for qemu-devel@nongnu.org; Tue, 05 May 2015 11:00:33 -0400 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:53253) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpeKb-00069F-IJ for qemu-devel@nongnu.org; Tue, 05 May 2015 11:00:21 -0400 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 5 May 2015 16:00:20 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp17.uk.ibm.com (192.168.101.147) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 5 May 2015 16:00:18 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id D51102190063 for ; Tue, 5 May 2015 15:59:59 +0100 (BST) Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t45F0H1b131410 for ; Tue, 5 May 2015 15:00:17 GMT Received: from d06av03.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t45F0GCL009452 for ; Tue, 5 May 2015 09:00:17 -0600 Received: from gondolin.boeblingen.de.ibm.com (dyn-9-152-224-143.boeblingen.de.ibm.com [9.152.224.143]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t45F0FJP009399; Tue, 5 May 2015 09:00:16 -0600 From: Cornelia Huck To: mst@redhat.com Date: Tue, 5 May 2015 17:00:10 +0200 Message-Id: <1430838011-19843-3-git-send-email-cornelia.huck@de.ibm.com> X-Mailer: git-send-email 2.4.0 In-Reply-To: <1430838011-19843-1-git-send-email-cornelia.huck@de.ibm.com> References: <1430838011-19843-1-git-send-email-cornelia.huck@de.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15050515-0029-0000-0000-0000047AA4A9 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.113 Cc: Cornelia Huck , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 2/3] virtio-ccw: BE accesses in SET_VIRTIO_REV X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org updates "s390x/virtio-ccw: add virtio set-revision call" Signed-off-by: Cornelia Huck --- hw/s390x/virtio-ccw.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 230b280..e778da9 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -723,7 +723,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 < len) { ret = -EINVAL; break; } @@ -731,7 +731,22 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) ret = -EFAULT; break; } - cpu_physical_memory_read(ccw.cda, &revinfo, len); + revinfo.revision = + address_space_lduw_be(&address_space_memory, ccw.cda, + MEMTXATTRS_UNSPECIFIED, NULL); + revinfo.length = + address_space_lduw_be(&address_space_memory, + ccw.cda + sizeof(revinfo.revision), + MEMTXATTRS_UNSPECIFIED, NULL); + 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, vdev)) { ret = -ENOSYS;