From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYuFA-0002IP-7W for qemu-devel@nongnu.org; Mon, 07 Sep 2015 07:05:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYu0E-0006Xj-T3 for qemu-devel@nongnu.org; Mon, 07 Sep 2015 06:50:25 -0400 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:60607) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYu0E-0006Ws-L6 for qemu-devel@nongnu.org; Mon, 07 Sep 2015 06:50:22 -0400 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 7 Sep 2015 11:50:19 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 6295B17D805A for ; Mon, 7 Sep 2015 11:52:02 +0100 (BST) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t87AoHda24641558 for ; Mon, 7 Sep 2015 10:50:17 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t87AoGo9022988 for ; Mon, 7 Sep 2015 04:50:16 -0600 Date: Mon, 7 Sep 2015 12:50:11 +0200 From: David Hildenbrand Message-ID: <20150907125011.33d835b0@thinkpad-w530> In-Reply-To: <1441356869-57861-4-git-send-email-cornelia.huck@de.ibm.com> References: <1441356869-57861-1-git-send-email-cornelia.huck@de.ibm.com> <1441356869-57861-4-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 3/4] virtio-ccw: feature bits > 31 handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cornelia Huck Cc: borntraeger@de.ibm.com, jasowang@redhat.com, qemu-devel@nongnu.org, mst@redhat.com > We currently switch off the VERSION_1 feature bit if the guest has > not negotiated at least revision 1. As no feature bits beyond 31 are > valid however unless VERSION_1 has been negotiated, make sure that > legacy guests never see a feature bit beyond 31. > > Signed-off-by: Cornelia Huck > --- > hw/s390x/virtio-ccw.c | 21 ++++++++------------- > 1 file changed, 8 insertions(+), 13 deletions(-) > > diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c > index 85e2a5d..eed7b3e 100644 > --- a/hw/s390x/virtio-ccw.c > +++ b/hw/s390x/virtio-ccw.c > @@ -468,15 +468,12 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) > NULL); > if (features.index == 0) { > features.features = (uint32_t)vdev->host_features; > - } else if (features.index == 1) { > - features.features = (uint32_t)(vdev->host_features >> 32); > + } else if ((features.index == 1) && (dev->revision >= 1)) { > /* > - * Don't offer version 1 to the guest if it did not > - * negotiate at least revision 1. > + * Only offer feature bits beyond 31 if the guest has > + * negotiated at least revision 1. > */ > - if (dev->revision <= 0) { > - features.features &= ~(1 << (VIRTIO_F_VERSION_1 - 32)); > - } > + features.features = (uint32_t)(vdev->host_features >> 32); > } else { > /* Return zeroes if the guest supports more feature bits. */ > features.features = 0; > @@ -515,14 +512,12 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) > virtio_set_features(vdev, > (vdev->guest_features & 0xffffffff00000000ULL) | > features.features); > - } else if (features.index == 1) { > + } else if ((features.index == 1) && (dev->revision >= 1)) { > /* > - * The guest should not set version 1 if it didn't > - * negotiate a revision >= 1. > + * If the guest did not negotiate at least revision 1, > + * we did not offer it any feature bits beyond 31. Such a > + * guest passing us any bit here is therefore buggy. > */ > - if (dev->revision <= 0) { > - features.features &= ~(1 << (VIRTIO_F_VERSION_1 - 32)); > - } > virtio_set_features(vdev, > (vdev->guest_features & 0x00000000ffffffffULL) | > ((uint64_t)features.features << 32)); Looks sane to me! Reviewed-by: David Hildenbrand David