diff mbox series

[kvmtool,v2] virtio-net: Fix vq->use_event_idx flag check

Message ID 20220929121858.156-1-dinhngoc.tu@irit.fr (mailing list archive)
State New, archived
Headers show
Series [kvmtool,v2] virtio-net: Fix vq->use_event_idx flag check | expand

Commit Message

Tu Dinh Ngoc Sept. 29, 2022, 12:18 p.m. UTC
VIRTIO_RING_F_EVENT_IDX is a bit position value, but
virtio_init_device_vq populates vq->use_event_idx by ANDing this value
directly to vdev->features.

Fix the check for this flag in virtio_init_device_vq.

Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Tu Dinh Ngoc <dinhngoc.tu@irit.fr>
---
 virtio/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Will Deacon Oct. 4, 2022, 11:54 a.m. UTC | #1
On Thu, 29 Sep 2022 14:18:58 +0200, Tu Dinh Ngoc wrote:
> VIRTIO_RING_F_EVENT_IDX is a bit position value, but
> virtio_init_device_vq populates vq->use_event_idx by ANDing this value
> directly to vdev->features.
> 
> Fix the check for this flag in virtio_init_device_vq.
> 
> 
> [...]

Applied to kvmtool (master), thanks!

[1/1] virtio-net: Fix vq->use_event_idx flag check
      https://git.kernel.org/will/kvmtool/c/717a3ab0a195

Cheers,
diff mbox series

Patch

diff --git a/virtio/core.c b/virtio/core.c
index f432421..ea0e5b6 100644
--- a/virtio/core.c
+++ b/virtio/core.c
@@ -165,7 +165,7 @@  void virtio_init_device_vq(struct kvm *kvm, struct virtio_device *vdev,
 	struct vring_addr *addr = &vq->vring_addr;
 
 	vq->endian		= vdev->endian;
-	vq->use_event_idx	= (vdev->features & VIRTIO_RING_F_EVENT_IDX);
+	vq->use_event_idx	= (vdev->features & (1UL << VIRTIO_RING_F_EVENT_IDX));
 	vq->enabled		= true;
 
 	if (addr->legacy) {