qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/1] virtio: fix feature bit checks


From: Michael S. Tsirkin
Subject: Re: [Qemu-devel] [PATCH 1/1] virtio: fix feature bit checks
Date: Fri, 12 Dec 2014 11:08:21 +0200

On Fri, Dec 12, 2014 at 10:01:46AM +0100, Cornelia Huck wrote:
> Several places check against the feature bit number instead of against
> the feature bit. Fix them.
> 
> Reported-by: Thomas Huth <address@hidden>
> Signed-off-by: Cornelia Huck <address@hidden>

Cc: stable?

> ---
>  hw/scsi/virtio-scsi.c       | 2 +-
>  hw/virtio/dataplane/vring.c | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
> index ef48550..a44c410 100644
> --- a/hw/scsi/virtio-scsi.c
> +++ b/hw/scsi/virtio-scsi.c
> @@ -144,7 +144,7 @@ static int virtio_scsi_parse_req(VirtIOSCSIReq *req,
>       *
>       * TODO: always disable this workaround for virtio 1.0 devices.
>       */
> -    if ((vdev->guest_features & VIRTIO_F_ANY_LAYOUT) == 0) {
> +    if ((vdev->guest_features & (1 << VIRTIO_F_ANY_LAYOUT)) == 0) {
>          req_size = req->elem.out_sg[0].iov_len;
>          resp_size = req->elem.in_sg[0].iov_len;
>      }
> diff --git a/hw/virtio/dataplane/vring.c b/hw/virtio/dataplane/vring.c
> index 61f6d83..78c6f45 100644
> --- a/hw/virtio/dataplane/vring.c
> +++ b/hw/virtio/dataplane/vring.c
> @@ -133,12 +133,12 @@ bool vring_should_notify(VirtIODevice *vdev, Vring 
> *vring)
>       * interrupts. */
>      smp_mb();
>  
> -    if ((vdev->guest_features & VIRTIO_F_NOTIFY_ON_EMPTY) &&
> +    if ((vdev->guest_features & (1 << VIRTIO_F_NOTIFY_ON_EMPTY)) &&
>          unlikely(vring->vr.avail->idx == vring->last_avail_idx)) {
>          return true;
>      }
>  
> -    if (!(vdev->guest_features & VIRTIO_RING_F_EVENT_IDX)) {
> +    if (!(vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX))) {
>          return !(vring->vr.avail->flags & VRING_AVAIL_F_NO_INTERRUPT);
>      }
>      old = vring->signalled_used;
> -- 
> 1.8.5.5



reply via email to

[Prev in Thread] Current Thread [Next in Thread]