LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: dahi@linux.vnet.ibm.com, cornelia.huck@de.ibm.com,
	rusty@rustcorp.com.au,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	linux390@de.ibm.com, Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	linux-s390@vger.kernel.org
Subject: [PATCH v3 2/6] virtio_ccw: legacy: don't negotiate rev 1/features
Date: Mon, 8 Dec 2014 15:05:54 +0200	[thread overview]
Message-ID: <1418042769-25539-3-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1418042769-25539-1-git-send-email-mst@redhat.com>

Legacy balloon device doesn't pretend to support revision 1 or 64 bit
features.

But just in case someone implements a broken one that does, let's not
even try to drive legacy only devices using revision 1, and let's not
give them a chance to say they support VIRTIO_F_VERSION_1 by not reading
high feature bits.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 drivers/s390/kvm/virtio_ccw.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c
index 4a3e6e5..c792b5f 100644
--- a/drivers/s390/kvm/virtio_ccw.c
+++ b/drivers/s390/kvm/virtio_ccw.c
@@ -733,6 +733,9 @@ static u64 virtio_ccw_get_features(struct virtio_device *vdev)
 
 	rc = le32_to_cpu(features->features);
 
+	if (vcdev->revision == 0)
+		goto out_free;
+
 	/* Read second half of the feature bits from the host. */
 	features->index = 1;
 	ccw->cmd_code = CCW_CMD_READ_FEAT;
@@ -775,6 +778,9 @@ static void virtio_ccw_finalize_features(struct virtio_device *vdev)
 	ccw->cda = (__u32)(unsigned long)features;
 	ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_FEAT);
 
+	if (vcdev->revision == 0)
+		goto out_free;
+
 	features->index = 1;
 	features->features = cpu_to_le32(vdev->features >> 32);
 	/* Write the second half of the feature bits to the host. */
@@ -1182,9 +1188,13 @@ static int virtio_ccw_online(struct ccw_device *cdev)
 	vcdev->vdev.id.vendor = cdev->id.cu_type;
 	vcdev->vdev.id.device = cdev->id.cu_model;
 
-	ret = virtio_ccw_set_transport_rev(vcdev);
-	if (ret)
-		goto out_free;
+	if (virtio_device_is_legacy_only(vcdev->vdev.id)) {
+		vcdev->revision = 0;
+	} else {
+		ret = virtio_ccw_set_transport_rev(vcdev);
+		if (ret)
+			goto out_free;
+	}
 
 	ret = register_virtio_device(&vcdev->vdev);
 	if (ret) {
-- 
MST


  parent reply	other threads:[~2014-12-08 13:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-08 13:05 [PATCH v3 0/6] virtio 1.0 enhancements Michael S. Tsirkin
2014-12-08 13:05 ` [PATCH v3 1/6] virtio: add API to detect legacy devices Michael S. Tsirkin
2014-12-08 13:05 ` Michael S. Tsirkin [this message]
2014-12-09 10:35   ` [PATCH v3 2/6] virtio_ccw: legacy: don't negotiate rev 1/features Cornelia Huck
2014-12-08 13:05 ` [PATCH v3 3/6] virtio: allow finalize_features to fail Michael S. Tsirkin
2014-12-09 10:46   ` Cornelia Huck
2014-12-09 12:07     ` Michael S. Tsirkin
2014-12-09 12:56       ` Cornelia Huck
2014-12-08 13:06 ` [PATCH v3 4/6] virtio_ccw: rev 1 devices set VIRTIO_F_VERSION_1 Michael S. Tsirkin
2014-12-09 11:01   ` Cornelia Huck
2014-12-09 12:21     ` Michael S. Tsirkin
2014-12-09 17:23       ` Cornelia Huck
2014-12-09 18:55         ` Michael S. Tsirkin
2014-12-09 19:40         ` Michael S. Tsirkin
2014-12-10  8:41           ` Cornelia Huck
2014-12-08 13:06 ` [PATCH v3 5/6] virtio_balloon: drop legacy_only driver flag Michael S. Tsirkin
2014-12-09 11:24   ` Cornelia Huck
2014-12-08 13:06 ` [PATCH v3 6/6] virtio: " Michael S. Tsirkin
2014-12-09 11:24   ` Cornelia Huck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1418042769-25539-3-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=dahi@linux.vnet.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux390@de.ibm.com \
    --cc=rusty@rustcorp.com.au \
    --cc=schwidefsky@de.ibm.com \
    --subject='Re: [PATCH v3 2/6] virtio_ccw: legacy: don'\''t negotiate rev 1/features' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).