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] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 26 Dec 2022 18:36:34 -0500
From:   "Michael S. Tsirkin" <mst@...hat.com>
To:     Jason Wang <jasowang@...hat.com>
Cc:     davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
        pabeni@...hat.com, virtualization@...ts.linux-foundation.org,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        maxime.coquelin@...hat.com, alvaro.karsz@...id-run.com,
        eperezma@...hat.com
Subject: Re: [PATCH 2/4] virtio_ring: switch to use BAD_RING()

On Mon, Dec 26, 2022 at 03:49:06PM +0800, Jason Wang wrote:
> Switch to reuse BAD_RING() to allow common logic to be implemented in
> BAD_RING().
> 
> Signed-off-by: Jason Wang <jasowang@...hat.com>
> ---
> Changes since V1:
> - switch to use BAD_RING in virtio_break_device()
> ---
>  drivers/virtio/virtio_ring.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index 2e7689bb933b..5cfb2fa8abee 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -58,7 +58,8 @@
>  	do {							\
>  		dev_err(&_vq->vq.vdev->dev,			\
>  			"%s:"fmt, (_vq)->vq.name, ##args);	\
> -		(_vq)->broken = true;				\
> +		/* Pairs with READ_ONCE() in virtqueue_is_broken(). */ \

I don't think WRITE_ONCE/READ_ONCE pair as such. Can you point
me at documentation of such pairing?

> +		WRITE_ONCE((_vq)->broken, true);		       \
>  	} while (0)
>  #define START_USE(vq)
>  #define END_USE(vq)
> @@ -2237,7 +2238,7 @@ bool virtqueue_notify(struct virtqueue *_vq)
>  
>  	/* Prod other side to tell it about changes. */
>  	if (!vq->notify(_vq)) {
> -		vq->broken = true;
> +		BAD_RING(vq, "vq %d is broken\n", vq->vq.index);
>  		return false;
>  	}
>  	return true;
> @@ -2786,8 +2787,7 @@ void virtio_break_device(struct virtio_device *dev)
>  	list_for_each_entry(_vq, &dev->vqs, list) {
>  		struct vring_virtqueue *vq = to_vvq(_vq);
>  
> -		/* Pairs with READ_ONCE() in virtqueue_is_broken(). */
> -		WRITE_ONCE(vq->broken, true);
> +		BAD_RING(vq, "Device break vq %d", _vq->index);
>  	}
>  	spin_unlock(&dev->vqs_list_lock);
>  }
> -- 
> 2.25.1

Powered by blists - more mailing lists