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]
Message-ID: <1699528202.3090942-4-xuanzhuo@linux.alibaba.com>
Date: Thu, 9 Nov 2023 19:10:02 +0800
From: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
To: "Michael S. Tsirkin" <mst@...hat.com>
Cc: netdev@...r.kernel.org,
 "David S. Miller" <davem@...emloft.net>,
 Eric Dumazet <edumazet@...gle.com>,
 Jakub Kicinski <kuba@...nel.org>,
 Paolo Abeni <pabeni@...hat.com>,
 Jason Wang <jasowang@...hat.com>,
 Alexei Starovoitov <ast@...nel.org>,
 Daniel Borkmann <daniel@...earbox.net>,
 Jesper Dangaard Brouer <hawk@...nel.org>,
 John Fastabend <john.fastabend@...il.com>,
 virtualization@...ts.linux-foundation.org,
 bpf@...r.kernel.org
Subject: Re: [PATCH net-next v2 17/21] virtio_net: xsk: rx: skip dma unmap when rq is bind with AF_XDP

On Thu, 9 Nov 2023 03:15:03 -0500, "Michael S. Tsirkin" <mst@...hat.com> wrote:
> On Tue, Nov 07, 2023 at 11:12:23AM +0800, Xuan Zhuo wrote:
> > When rq is bound with AF_XDP, the buffer dma is managed
> > by the AF_XDP APIs. So the buffer got from the virtio core should
> > skip the dma unmap operation.
> >
> > Signed-off-by: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
>
>
> I don't get it - is this like a bugfix?

I want focus on this. So let it as an independent commit.

> And why do we need our own flag and checks?
> Doesn't virtio core DTRT?


struct vring_virtqueue {
	[....]

	/* Do DMA mapping by driver */
	bool premapped;

We can not.

So I add own flag.

Thanks.


>
> > ---
> >  drivers/net/virtio/main.c       | 8 +++++---
> >  drivers/net/virtio/virtio_net.h | 3 +++
> >  drivers/net/virtio/xsk.c        | 1 +
> >  3 files changed, 9 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/virtio/main.c b/drivers/net/virtio/main.c
> > index 15943a22e17d..a318b2533b94 100644
> > --- a/drivers/net/virtio/main.c
> > +++ b/drivers/net/virtio/main.c
> > @@ -430,7 +430,7 @@ static void *virtnet_rq_get_buf(struct virtnet_rq *rq, u32 *len, void **ctx)
> >  	void *buf;
> >
> >  	buf = virtqueue_get_buf_ctx(rq->vq, len, ctx);
> > -	if (buf && rq->do_dma)
> > +	if (buf && rq->do_dma_unmap)
> >  		virtnet_rq_unmap(rq, buf, *len);
> >
> >  	return buf;
> > @@ -561,8 +561,10 @@ static void virtnet_set_premapped(struct virtnet_info *vi)
> >
> >  		/* disable for big mode */
> >  		if (vi->mergeable_rx_bufs || !vi->big_packets) {
> > -			if (!virtqueue_set_dma_premapped(vi->rq[i].vq))
> > +			if (!virtqueue_set_dma_premapped(vi->rq[i].vq)) {
> >  				vi->rq[i].do_dma = true;
> > +				vi->rq[i].do_dma_unmap = true;
> > +			}
> >  		}
> >  	}
> >  }
> > @@ -3944,7 +3946,7 @@ void virtnet_rq_free_unused_buf(struct virtqueue *vq, void *buf)
> >
> >  	rq = &vi->rq[i];
> >
> > -	if (rq->do_dma)
> > +	if (rq->do_dma_unmap)
> >  		virtnet_rq_unmap(rq, buf, 0);
> >
> >  	virtnet_rq_free_buf(vi, rq, buf);
> > diff --git a/drivers/net/virtio/virtio_net.h b/drivers/net/virtio/virtio_net.h
> > index 1242785e311e..2005d0cd22e2 100644
> > --- a/drivers/net/virtio/virtio_net.h
> > +++ b/drivers/net/virtio/virtio_net.h
> > @@ -135,6 +135,9 @@ struct virtnet_rq {
> >  	/* Do dma by self */
> >  	bool do_dma;
> >
> > +	/* Do dma unmap after getting buf from virtio core. */
> > +	bool do_dma_unmap;
> > +
> >  	struct {
> >  		struct xsk_buff_pool *pool;
> >
> > diff --git a/drivers/net/virtio/xsk.c b/drivers/net/virtio/xsk.c
> > index e737c3353212..b09c473c29fb 100644
> > --- a/drivers/net/virtio/xsk.c
> > +++ b/drivers/net/virtio/xsk.c
> > @@ -210,6 +210,7 @@ static int virtnet_rq_bind_xsk_pool(struct virtnet_info *vi, struct virtnet_rq *
> >  		xdp_rxq_info_unreg(&rq->xsk.xdp_rxq);
> >
> >  	rq->xsk.pool = pool;
> > +	rq->do_dma_unmap = !pool;
> >
> >  	virtnet_rx_resume(vi, rq);
> >
> > --
> > 2.32.0.3.g01195cf9f
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ