[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 5/8] virtio-ccw: commands on revision-less devices
From: |
Cornelia Huck |
Subject: |
[PULL 5/8] virtio-ccw: commands on revision-less devices |
Date: |
Fri, 5 Mar 2021 16:55:14 +0100 |
The virtio standard specifies that any non-transitional device must
reject commands prior to revision setting (which we do). Devices
that are transitional need to assume revision 0 (legacy) if the
driver sends a non-revision-setting command first in order to
support legacy drivers. 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.
Found by code inspection, not observed in the wild.
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Halil Pasic <pasic@linux.ibm.com>
Message-Id: <20210216111830.1087847-1-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
- [PULL 0/8] s390x update, Cornelia Huck, 2021/03/05
- [PULL 1/8] s390x/cpu_model: disallow unpack for --only-migratable, Cornelia Huck, 2021/03/05
- [PULL 3/8] hw/s390x: fix build for virtio-9p-ccw, Cornelia Huck, 2021/03/05
- [PULL 4/8] s390x/pci: restore missing Query PCI Function CLP data, Cornelia Huck, 2021/03/05
- [PULL 2/8] target/s390x/arch_dump: Fix warning for the name field in the PT_NOTE section, Cornelia Huck, 2021/03/05
- [PULL 5/8] virtio-ccw: commands on revision-less devices,
Cornelia Huck <=
- [PULL 6/8] css: SCHIB measurement block origin must be aligned, Cornelia Huck, 2021/03/05
- [PULL 8/8] target/s390x/kvm: Simplify debug code, Cornelia Huck, 2021/03/05
- [PULL 7/8] vfio-ccw: Do not read region ret_code after write, Cornelia Huck, 2021/03/05
- Re: [PULL 0/8] s390x update, Peter Maydell, 2021/03/05