All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio-ccw: commands on revision-less devices
@ 2021-02-16 11:18 Cornelia Huck
  2021-02-16 11:33 ` Thomas Huth
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Cornelia Huck @ 2021-02-16 11:18 UTC (permalink / raw)
  To: Halil Pasic
  Cc: Thomas Huth, Michael S. Tsirkin, Cornelia Huck, qemu-devel,
	Christian Borntraeger, qemu-s390x

The virtio standard specifies that any non-transitional device must
reject commands prior to revision setting (which we do) and else
assume revision 0 (legacy) if the driver sends a non-revision-setting
command first. We neglected to do the latter.

Fortunately, nearly everything worked as intended anyway; the only
problem was not properly rejecting revision setting after some other
command had been issued. Easy to fix by setting revision to 0 if
we see a non-revision command on a legacy-capable revision-less
device.

Signed-off-by: Cornelia Huck <cohuck@redhat.com>
---
 hw/s390x/virtio-ccw.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 4582e94ae7dc..06c06056814b 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -327,13 +327,20 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
                                    ccw.cmd_code);
     check_len = !((ccw.flags & CCW_FLAG_SLI) && !(ccw.flags & CCW_FLAG_DC));
 
-    if (dev->force_revision_1 && dev->revision < 0 &&
-        ccw.cmd_code != CCW_CMD_SET_VIRTIO_REV) {
-        /*
-         * virtio-1 drivers must start with negotiating to a revision >= 1,
-         * so post a command reject for all other commands
-         */
-        return -ENOSYS;
+    if (dev->revision < 0 && ccw.cmd_code != CCW_CMD_SET_VIRTIO_REV) {
+        if (dev->force_revision_1) {
+            /*
+             * virtio-1 drivers must start with negotiating to a revision >= 1,
+             * so post a command reject for all other commands
+             */
+            return -ENOSYS;
+        } else {
+            /*
+             * If the driver issues any command that is not SET_VIRTIO_REV,
+             * we'll have to operate the device in legacy mode.
+             */
+            dev->revision = 0;
+        }
     }
 
     /* Look at the command. */
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-02-21 11:53 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-16 11:18 [PATCH] virtio-ccw: commands on revision-less devices Cornelia Huck
2021-02-16 11:33 ` Thomas Huth
2021-02-16 11:40 ` Michael S. Tsirkin
2021-02-16 11:51   ` Cornelia Huck
2021-02-16 11:58     ` Michael S. Tsirkin
2021-02-16 14:19 ` Halil Pasic
2021-02-16 15:54   ` Cornelia Huck
2021-02-17 14:39     ` Halil Pasic
2021-02-18 13:51       ` Cornelia Huck
2021-02-18 18:51         ` Halil Pasic
2021-02-19 11:21 ` Cornelia Huck
2021-02-19 17:01   ` Cornelia Huck
2021-02-21 11:48   ` Michael S. Tsirkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.