[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC v5 12/19] virtio: disallow late feature changes
From: |
Cornelia Huck |
Subject: |
[Qemu-devel] [PATCH RFC v5 12/19] virtio: disallow late feature changes for virtio-1 |
Date: |
Tue, 2 Dec 2014 14:00:20 +0100 |
For virtio-1 devices, the driver must not attempt to set feature bits
after it set FEATURES_OK in the device status. Simply reject it in
that case.
Signed-off-by: Cornelia Huck <address@hidden>
---
hw/virtio/virtio.c | 16 ++++++++++++++--
include/hw/virtio/virtio.h | 2 ++
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 508dccf..4f2dc48 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -980,7 +980,7 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
vmstate_save_state(f, &vmstate_virtio, vdev);
}
-int virtio_set_features(VirtIODevice *vdev, uint64_t val)
+static int __virtio_set_features(VirtIODevice *vdev, uint64_t val)
{
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
VirtioBusClass *vbusk = VIRTIO_BUS_GET_CLASS(qbus);
@@ -996,6 +996,18 @@ int virtio_set_features(VirtIODevice *vdev, uint64_t val)
return bad ? -1 : 0;
}
+int virtio_set_features(VirtIODevice *vdev, uint64_t val)
+{
+ /*
+ * The driver must not attempt to set features after feature negotiation
+ * has finished.
+ */
+ if (vdev->status & VIRTIO_CONFIG_S_FEATURES_OK) {
+ return -EINVAL;
+ }
+ return __virtio_set_features(vdev, val);
+}
+
int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id)
{
int i, ret;
@@ -1028,7 +1040,7 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int
version_id)
qemu_get_be32s(f, &features);
/* XXX features >= 32 */
- if (virtio_set_features(vdev, features) < 0) {
+ if (__virtio_set_features(vdev, features) < 0) {
supported_features = k->get_features(qbus->parent);
error_report("Features 0x%x unsupported. Allowed features: 0x%lx",
features, supported_features);
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 80ee313..9a984c2 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -32,6 +32,8 @@
#define VIRTIO_CONFIG_S_DRIVER 2
/* Driver has used its parts of the config, and is happy */
#define VIRTIO_CONFIG_S_DRIVER_OK 4
+/* Driver has finished configuring features */
+#define VIRTIO_CONFIG_S_FEATURES_OK 8
/* We've given up on this device. */
#define VIRTIO_CONFIG_S_FAILED 0x80
--
1.7.9.5
- Re: [Qemu-devel] [PATCH RFC v5 07/19] virtio: allow virtio-1 queue layout, (continued)
- Re: [Qemu-devel] [PATCH RFC v5 07/19] virtio: allow virtio-1 queue layout, Cornelia Huck, 2014/12/02
- Re: [Qemu-devel] [PATCH RFC v5 07/19] virtio: allow virtio-1 queue layout, Michael S. Tsirkin, 2014/12/02
- Re: [Qemu-devel] [PATCH RFC v5 07/19] virtio: allow virtio-1 queue layout, Cornelia Huck, 2014/12/03
- Re: [Qemu-devel] [PATCH RFC v5 07/19] virtio: allow virtio-1 queue layout, Cornelia Huck, 2014/12/03
- Re: [Qemu-devel] [PATCH RFC v5 07/19] virtio: allow virtio-1 queue layout, Michael S. Tsirkin, 2014/12/03
- Re: [Qemu-devel] [PATCH RFC v5 07/19] virtio: allow virtio-1 queue layout, Cornelia Huck, 2014/12/03
- Re: [Qemu-devel] [PATCH RFC v5 07/19] virtio: allow virtio-1 queue layout, Michael S. Tsirkin, 2014/12/03
- Re: [Qemu-devel] [PATCH RFC v5 07/19] virtio: allow virtio-1 queue layout, Cornelia Huck, 2014/12/03
[Qemu-devel] [PATCH RFC v5 08/19] dataplane: allow virtio-1 devices, Cornelia Huck, 2014/12/02
[Qemu-devel] [PATCH RFC v5 09/19] s390x/css: Add a callback for when subchannel gets disabled, Cornelia Huck, 2014/12/02
[Qemu-devel] [PATCH RFC v5 12/19] virtio: disallow late feature changes for virtio-1,
Cornelia Huck <=
[Qemu-devel] [PATCH RFC v5 11/19] s390x/virtio-ccw: support virtio-1 set_vq format, Cornelia Huck, 2014/12/02
[Qemu-devel] [PATCH RFC v5 10/19] s390x/virtio-ccw: add virtio set-revision call, Cornelia Huck, 2014/12/02
[Qemu-devel] [PATCH RFC v5 13/19] virtio: allow to fail setting status, Cornelia Huck, 2014/12/02
[Qemu-devel] [PATCH RFC v5 15/19] virtio-net: no writeable mac for virtio-1, Cornelia Huck, 2014/12/02
[Qemu-devel] [PATCH RFC v5 14/19] s390x/virtio-ccw: enable virtio 1.0, Cornelia Huck, 2014/12/02
[Qemu-devel] [PATCH RFC v5 16/19] virtio-net: support longer header, Cornelia Huck, 2014/12/02