virtio: feature bit fixup
cover virtio: feature bit fixup
When reviewing my feature bit changes for 1.0, Thomas noticed that I accidentally fixed a bug :) There are two further places with the same problem that Thomas noticed as well.
I wonder why we didn't see problems before...
Cornelia Huck (1):
virtio: fix feature bit checks
hw/scsi/virtio-scsi.c | 2 +- hw/virtio/dataplane/vring.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
1.8.5.5
PATCH 1/1 virtio: fix feature bit checks
Several places check against the feature bit number instead of against the feature bit. Fix them.
--- hw/scsi/virtio-scsi.c | 2 +- hw/virtio/dataplane/vring.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
hw/scsi/virtio-scsi.c +1 -1
@@ -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; }
hw/virtio/dataplane/vring.c +2 -2
@@ -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;
Signature · 1 line
1.8.5.5
Re: [Qemu-devel] [PATCH 1/1] virtio: fix feature bit checks
Quoted 5 lines · Cornelia Huck
Several places check against the feature bit number instead of against the feature bit. Fix them.
Reported-by Thomas Huth <[email protected]>Signed-off-by Cornelia Huck <[email protected]>
Quoted 39 lines
--- hw/scsi/virtio-scsi.c | 2 +- hw/virtio/dataplane/vring.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)hw/scsi/virtio-scsi.c +1
-1@@ -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; }hw/virtio/dataplane/vring.c +2
-2@@ -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;Signature · 1 line
1.8.5.5
Re: [Qemu-devel] [PATCH 1/1] virtio: fix feature bit checks
Quoted 8 lines · On Fri, 12 Dec 2014 11:08:21 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Cornelia Huck
Several places check against the feature bit number instead of against the feature bit. Fix them.
Reported-by Thomas Huth <[email protected]>Signed-off-by Cornelia Huck <[email protected]>Cc stable?
Hm, yeah. Can you add it?
Quoted 5 lines
Quoted 5 lines
--- hw/scsi/virtio-scsi.c | 2 +- hw/virtio/dataplane/vring.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
Re: [Qemu-devel] [PATCH 1/1] virtio: fix feature bit checks
Quoted 7 lines · Cornelia Huck
Quoted 4 lines · On Fri, 12 Dec 2014 11:08:21 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 3 lines · Cornelia Huck
Several places check against the feature bit number instead of against the feature bit. Fix them.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Reported-by Thomas Huth <[email protected]>Signed-off-by Cornelia Huck <[email protected]>Cc stable?Hm, yeah. Can you add it?
Ccing [email protected]
Fam
Re: [Qemu-devel] [PATCH 1/1] virtio: fix feature bit checks
In reply to Cornelia HuckQuoted 32 lines · On Fri, 12 Dec 2014 10:01:46 +0100 Cornelia Huck <[email protected]>…
Several places check against the feature bit number instead of against the feature bit. Fix them.
Reported-by Thomas Huth <[email protected]>Signed-off-by Cornelia Huck <[email protected]>--- hw/scsi/virtio-scsi.c | 2 +- hw/virtio/dataplane/vring.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)hw/scsi/virtio-scsi.c +1
-1@@ -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; }hw/virtio/dataplane/vring.c +0
-1@@ -133,12 +133,12 @@ bool vring_should_notify(VirtIODevice *vdev, Vring *vring)* interrupts. */ smp_mb (); - if ((vdev->guest_features & VIRTIO_F_NOTIFY_ON_EMPTY) &&
hw/virtio/dataplane/vring.c bool vring_should_notify(VirtIODevice *vdev, Vring *vring) · line 144
Quoted 10 lines
hw/virtio/dataplane/vring.c +2
-1+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;
Ping ... somebody taking care of this? It's a bug fix for current code, so IMHO this patch should not wait for the inclusion of the other virtio-1 stuff...
Thomas
Re: [Qemu-devel] [PATCH 1/1] virtio: fix feature bit checks
Quoted 50 lines · Thomas Huth
Quoted 32 lines · On Fri, 12 Dec 2014 10:01:46 +0100 Cornelia Huck <[email protected]>…
Several places check against the feature bit number instead of against the feature bit. Fix them.
Reported-by Thomas Huth <[email protected]>Signed-off-by Cornelia Huck <[email protected]>--- hw/scsi/virtio-scsi.c | 2 +- hw/virtio/dataplane/vring.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)hw/scsi/virtio-scsi.c +1
-1@@ -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; }hw/virtio/dataplane/vring.c +0
-1@@ -133,12 +133,12 @@ bool vring_should_notify(VirtIODevice *vdev, Vring *vring)* interrupts. */ smp_mb (); - if ((vdev->guest_features & VIRTIO_F_NOTIFY_ON_EMPTY) &&hw/virtio/dataplane/vring.c bool vring_should_notify(VirtIODevice *vdev, Vring *vring) · line 144
Quoted 10 lines
hw/virtio/dataplane/vring.c +2
-1+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;Ping ... somebody taking care of this? It's a bug fix for current code, so IMHO this patch should not wait for the inclusion of the other virtio-1 stuff...
Quoted 1 line
Thomas
It's in my queue.