[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH RFC v6 12/20] virtio: disallow late feature chan
From: |
Thomas Huth |
Subject: |
Re: [Qemu-devel] [PATCH RFC v6 12/20] virtio: disallow late feature changes for virtio-1 |
Date: |
Fri, 12 Dec 2014 11:55:38 +0100 |
On Thu, 11 Dec 2014 14:25:14 +0100
Cornelia Huck <address@hidden> wrote:
> 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 57190ba..a3dd67b 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -978,7 +978,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)
Maybe avoid the double underscores here? But unfortunately, I also fail
to come up with a better suggestion for a name here ...
> {
> BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
> VirtioBusClass *vbusk = VIRTIO_BUS_GET_CLASS(qbus);
> @@ -994,6 +994,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;
> + }
Hmm, according to your patch description, the FEATURES_OK check only
applies to virtio-1.0 devices ... so shouldn't there be a check for
virtio-1 here? Or did I miss something?
> + return __virtio_set_features(vdev, val);
> +}
Thomas
- [Qemu-devel] [PATCH RFC v6 03/20] virtio: feature bit manipulation helpers, (continued)
- [Qemu-devel] [PATCH RFC v6 03/20] virtio: feature bit manipulation helpers, Cornelia Huck, 2014/12/11
- [Qemu-devel] [PATCH RFC v6 06/20] virtio: endianness checks for virtio 1.0 devices, Cornelia Huck, 2014/12/11
- [Qemu-devel] [PATCH RFC v6 05/20] virtio: support more feature bits, Cornelia Huck, 2014/12/11
- [Qemu-devel] [PATCH RFC v6 08/20] dataplane: allow virtio-1 devices, Cornelia Huck, 2014/12/11
- [Qemu-devel] [PATCH RFC v6 10/20] s390x/virtio-ccw: add virtio set-revision call, Cornelia Huck, 2014/12/11
- [Qemu-devel] [PATCH RFC v6 09/20] s390x/css: Add a callback for when subchannel gets disabled, Cornelia Huck, 2014/12/11
- [Qemu-devel] [PATCH RFC v6 12/20] virtio: disallow late feature changes for virtio-1, Cornelia Huck, 2014/12/11
- Re: [Qemu-devel] [PATCH RFC v6 12/20] virtio: disallow late feature changes for virtio-1,
Thomas Huth <=
- [Qemu-devel] [PATCH RFC v6 07/20] virtio: allow virtio-1 queue layout, Cornelia Huck, 2014/12/11
- [Qemu-devel] [PATCH RFC v6 13/20] virtio: allow to fail setting status, Cornelia Huck, 2014/12/11
- [Qemu-devel] [PATCH RFC v6 14/20] s390x/virtio-ccw: enable virtio 1.0, Cornelia Huck, 2014/12/11
- [Qemu-devel] [PATCH RFC v6 11/20] s390x/virtio-ccw: support virtio-1 set_vq format, Cornelia Huck, 2014/12/11
- [Qemu-devel] [PATCH RFC v6 15/20] virtio-net: no writeable mac for virtio-1, Cornelia Huck, 2014/12/11
- [Qemu-devel] [PATCH RFC v6 18/20] virtio: support revision-specific features, Cornelia Huck, 2014/12/11