* [PATCH kvmtool] virtio-net: Fix vq->use_event_idx flag check
@ 2022-09-28 15:16 dinhngoc.tu
2022-09-29 10:01 ` Andre Przywara
2022-09-29 10:14 ` [PATCH kvmtool v2] " Tu Dinh Ngoc
0 siblings, 2 replies; 6+ messages in thread
From: dinhngoc.tu @ 2022-09-28 15:16 UTC (permalink / raw)
To: kvm; +Cc: Tu Dinh Ngoc
From: Tu Dinh Ngoc <dinhngoc.tu@irit.fr>
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.
---
virtio/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/virtio/core.c b/virtio/core.c
index f432421..32e6a7a 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 & (1 << VIRTIO_RING_F_EVENT_IDX));
vq->enabled = true;
if (addr->legacy) {
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH kvmtool] virtio-net: Fix vq->use_event_idx flag check
2022-09-28 15:16 [PATCH kvmtool] virtio-net: Fix vq->use_event_idx flag check dinhngoc.tu
@ 2022-09-29 10:01 ` Andre Przywara
2022-09-29 10:14 ` [PATCH kvmtool v2] " Tu Dinh Ngoc
1 sibling, 0 replies; 6+ messages in thread
From: Andre Przywara @ 2022-09-29 10:01 UTC (permalink / raw)
To: dinhngoc.tu; +Cc: kvm, Will Deacon, Alexandru Elisei, Jean-Philippe Brucker
On Wed, 28 Sep 2022 17:16:15 +0200
dinhngoc.tu@irit.fr wrote:
Hi,
> From: Tu Dinh Ngoc <dinhngoc.tu@irit.fr>
>
> 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.
Indeed, it's used correctly in other parts of the code (virtio/net.c,
virtio/scsi.c), so we need to shift.
Just one thing below, but good catch!
>
> Fix the check for this flag in virtio_init_device_vq.
> ---
> virtio/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/virtio/core.c b/virtio/core.c
> index f432421..32e6a7a 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 & (1 << VIRTIO_RING_F_EVENT_IDX));
Can you make this "1UL << ..." instead? Shifting signed values is quite
fragile.
Cheers,
Andre
> vq->enabled = true;
>
> if (addr->legacy) {
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH kvmtool v2] virtio-net: Fix vq->use_event_idx flag check
2022-09-28 15:16 [PATCH kvmtool] virtio-net: Fix vq->use_event_idx flag check dinhngoc.tu
2022-09-29 10:01 ` Andre Przywara
@ 2022-09-29 10:14 ` Tu Dinh Ngoc
2022-09-29 11:21 ` Andre Przywara
1 sibling, 1 reply; 6+ messages in thread
From: Tu Dinh Ngoc @ 2022-09-29 10:14 UTC (permalink / raw)
To: kvm; +Cc: Andre Przywara, Will Deacon, Alexandru Elisei, Jean-Philippe Brucker
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.
---
virtio/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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) {
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH kvmtool v2] virtio-net: Fix vq->use_event_idx flag check
2022-09-29 10:14 ` [PATCH kvmtool v2] " Tu Dinh Ngoc
@ 2022-09-29 11:21 ` Andre Przywara
2022-09-29 12:18 ` Tu Dinh Ngoc
0 siblings, 1 reply; 6+ messages in thread
From: Andre Przywara @ 2022-09-29 11:21 UTC (permalink / raw)
To: Tu Dinh Ngoc; +Cc: kvm, Will Deacon, Alexandru Elisei, Jean-Philippe Brucker
On Thu, 29 Sep 2022 12:14:21 +0200
Tu Dinh Ngoc <dinhngoc.tu@irit.fr> wrote:
Hi,
thanks for the quick change!
> 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.
I am afraid you need a Signed-off-by: line here, but for the code:
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Cheers,
Andre
> ---
> virtio/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> 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) {
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH kvmtool v2] virtio-net: Fix vq->use_event_idx flag check
2022-09-29 11:21 ` Andre Przywara
@ 2022-09-29 12:18 ` Tu Dinh Ngoc
2022-10-04 11:54 ` Will Deacon
0 siblings, 1 reply; 6+ messages in thread
From: Tu Dinh Ngoc @ 2022-09-29 12:18 UTC (permalink / raw)
To: kvm; +Cc: Andre Przywara, Will Deacon, Alexandru Elisei, Jean-Philippe Brucker
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(-)
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) {
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH kvmtool v2] virtio-net: Fix vq->use_event_idx flag check
2022-09-29 12:18 ` Tu Dinh Ngoc
@ 2022-10-04 11:54 ` Will Deacon
0 siblings, 0 replies; 6+ messages in thread
From: Will Deacon @ 2022-10-04 11:54 UTC (permalink / raw)
To: kvm, Tu Dinh Ngoc
Cc: catalin.marinas, kernel-team, Will Deacon, Andre Przywara,
Jean-Philippe Brucker, Alexandru Elisei
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,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-10-04 11:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-28 15:16 [PATCH kvmtool] virtio-net: Fix vq->use_event_idx flag check dinhngoc.tu
2022-09-29 10:01 ` Andre Przywara
2022-09-29 10:14 ` [PATCH kvmtool v2] " Tu Dinh Ngoc
2022-09-29 11:21 ` Andre Przywara
2022-09-29 12:18 ` Tu Dinh Ngoc
2022-10-04 11:54 ` Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).