lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250928192719.7ea3a825@pumpkin>
Date: Sun, 28 Sep 2025 19:27:19 +0100
From: David Laight <david.laight.linux@...il.com>
To: Jason Wang <jasowang@...hat.com>
Cc: mst@...hat.com, xuanzhuo@...ux.alibaba.com, eperezma@...hat.com,
 virtualization@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH V7 12/19] virtio_ring: use u16 for last_used_idx in
 virtqueue_poll_split()

On Thu, 25 Sep 2025 18:37:01 +0800
Jason Wang <jasowang@...hat.com> wrote:

> Use u16 for last_used_idx in virtqueue_poll_split() to align with the
> spec.

If you care about performance you should pretty much never use 'u16' for
function parameters, return values or any arithmetic.
Just because the domain of the variable is [0..65535] doesn't mean that
'unsigned int' isn't the correct type.

> 
> Acked-by: Eugenio Pérez <eperezma@...hat.com>
> Reviewed-by: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
> Signed-off-by: Jason Wang <jasowang@...hat.com>
> ---
>  drivers/virtio/virtio_ring.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index 58c03a8aab85..4679a027dc53 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -806,7 +806,7 @@ static void detach_buf_split(struct vring_virtqueue *vq, unsigned int head,
>  }
>  
>  static bool virtqueue_poll_split(const struct vring_virtqueue *vq,
> -				 unsigned int last_used_idx)
> +				 u16 last_used_idx)
>  {
>  	return (u16)last_used_idx != virtio16_to_cpu(vq->vq.vdev,

You can't want that (u16) cast now, I doubt it was ever needed.
Note that the compiler promotes the value to 'signed int',
so the LHS of the comparison is actually (int)(u16)last_used_idx.

	David

>  			vq->split.vring.used->idx);


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ