Re: [PATCH net] virtio-net: fix overflow inside virtnet_rq_alloc

2024-08-20 Thread Si-Wei Liu
On 8/20/2024 1:09 PM, Michael S. Tsirkin wrote: On Tue, Aug 20, 2024 at 12:44:46PM -0700, Si-Wei Liu wrote: On 8/20/2024 12:19 AM, Xuan Zhuo wrote: leads to regression on VM with the sysctl value of: - net.core.high_order_alloc_disable=1 which could see reliable crashes or scp failure (sc

Re: [PATCH net] virtio-net: fix overflow inside virtnet_rq_alloc

2024-08-20 Thread Michael S. Tsirkin
On Tue, Aug 20, 2024 at 03:19:13PM +0800, Xuan Zhuo wrote: > leads to regression on VM with the sysctl value of: > > - net.core.high_order_alloc_disable=1 > > which could see reliable crashes or scp failure (scp a file 100M in size > to VM): > > The issue is that the virtnet_rq_dma takes up 16 b

Re: [PATCH net] virtio-net: fix overflow inside virtnet_rq_alloc

2024-08-20 Thread Michael S. Tsirkin
On Tue, Aug 20, 2024 at 12:44:46PM -0700, Si-Wei Liu wrote: > > > On 8/20/2024 12:19 AM, Xuan Zhuo wrote: > > leads to regression on VM with the sysctl value of: > > > > - net.core.high_order_alloc_disable=1 > > > > which could see reliable crashes or scp failure (scp a file 100M in size > > to

Re: [PATCH net] virtio-net: fix overflow inside virtnet_rq_alloc

2024-08-20 Thread Si-Wei Liu
On 8/20/2024 12:19 AM, Xuan Zhuo wrote: leads to regression on VM with the sysctl value of: - net.core.high_order_alloc_disable=1 which could see reliable crashes or scp failure (scp a file 100M in size to VM): The issue is that the virtnet_rq_dma takes up 16 bytes at the beginning of a new

Re: [PATCH net] virtio-net: fix overflow inside virtnet_rq_alloc

2024-08-20 Thread Michael S. Tsirkin
On Tue, Aug 20, 2024 at 03:19:13PM +0800, Xuan Zhuo wrote: > leads to regression on VM with the sysctl value of: > > - net.core.high_order_alloc_disable=1 > which could see reliable crashes or scp failure (scp a file 100M in size > to VM): > > The issue is that the virtnet_rq_dma takes up 16

Re: [PATCH net] virtio-net: fix overflow inside virtnet_rq_alloc

2024-08-20 Thread Alexander Lobakin
From: Xuan Zhuo Date: Tue, 20 Aug 2024 15:19:13 +0800 > leads to regression on VM with the sysctl value of: Where's the beginning of the sentence? You mean, "This overflow leads"? > > - net.core.high_order_alloc_disable=1 This `- ` can be removed - at least some syntax highlighters color it i

[PATCH net-next 06/13] virtio_ring: remove API virtqueue_set_dma_premapped

2024-08-20 Thread Xuan Zhuo
Now, this API is useless. remove it. Signed-off-by: Xuan Zhuo --- drivers/virtio/virtio_ring.c | 48 include/linux/virtio.h | 2 -- 2 files changed, 50 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 7efddc7

[PATCH net-next 11/13] virtio_net: xsk: tx: handle the transmitted xsk buffer

2024-08-20 Thread Xuan Zhuo
virtnet_free_old_xmit distinguishes three type ptr(skb, xdp frame, xsk buffer) by the last bits of the pointer. Signed-off-by: Xuan Zhuo --- drivers/net/virtio_net.c | 85 1 file changed, 59 insertions(+), 26 deletions(-) diff --git a/drivers/net/virtio_

[PATCH net-next 12/13] virtio_net: update tx timeout record

2024-08-20 Thread Xuan Zhuo
If send queue sent some packets, we update the tx timeout record to prevent the tx timeout. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio_net.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index a898568bed5

[PATCH net-next 13/13] virtio_net: xdp_features add NETDEV_XDP_ACT_XSK_ZEROCOPY

2024-08-20 Thread Xuan Zhuo
Now, we supported AF_XDP(xsk). Add NETDEV_XDP_ACT_XSK_ZEROCOPY to xdp_features. Signed-off-by: Xuan Zhuo --- drivers/net/virtio_net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 28c5f9e77fa3..8e4578ec1937 100644

[PATCH net-next 03/13] virtio_ring: packed: harden dma unmap for indirect

2024-08-20 Thread Xuan Zhuo
1. this commit hardens dma unmap for indirect 2. the subsequent commit uses the struct extra to record whether the buffers need to be unmapped or not. So we need a struct extra for every desc, whatever it is indirect or not. Signed-off-by: Xuan Zhuo --- drivers/virtio/virtio_ring.c | 57 ++

[PATCH net-next 08/13] virtio_net: xsk: bind/unbind xsk for tx

2024-08-20 Thread Xuan Zhuo
This patch implement the logic of bind/unbind xsk pool to sq and rq. Signed-off-by: Xuan Zhuo --- drivers/net/virtio_net.c | 54 1 file changed, 54 insertions(+) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 96abee36738b..6a36a20

[PATCH net-next 10/13] virtio_net: xsk: tx: support xmit xsk buffer

2024-08-20 Thread Xuan Zhuo
The driver's tx napi is very important for XSK. It is responsible for obtaining data from the XSK queue and sending it out. At the beginning, we need to trigger tx napi. Signed-off-by: Xuan Zhuo --- drivers/net/virtio_net.c | 127 ++- 1 file changed, 125 inse

[PATCH net-next 09/13] virtio_net: xsk: prevent disable tx napi

2024-08-20 Thread Xuan Zhuo
Since xsk's TX queue is consumed by TX NAPI, if sq is bound to xsk, then we must stop tx napi from being disabled. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio_net.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/

[PATCH net-next 07/13] virtio_net: refactor the xmit type

2024-08-20 Thread Xuan Zhuo
Because the af-xdp will introduce a new xmit type, so I refactor the xmit type mechanism first. We use the last two bits of the pointer to distinguish the xmit type, so we can distinguish four xmit types. Now we have three types: skb, orphan and xdp. Signed-off-by: Xuan Zhuo --- drivers/net/vir

[PATCH net-next 04/13] virtio_ring: perform premapped operations based on per-buffer

2024-08-20 Thread Xuan Zhuo
The current configuration sets the virtqueue (vq) to premapped mode, implying that all buffers submitted to this queue must be mapped ahead of time. This presents a challenge for the virtnet send queue (sq): the virtnet driver would be required to keep track of dma information for vq size * 17, whi

[PATCH net-next 05/13] virtio-net: rq submits premapped buffer per buffer

2024-08-20 Thread Xuan Zhuo
virtio-net rq submits premapped buffer per buffer. And removes the call of the virtnet_rq_set_premapped(). Signed-off-by: Xuan Zhuo --- drivers/net/virtio_net.c | 31 --- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers

[PATCH net-next 02/13] virtio_ring: split: harden dma unmap for indirect

2024-08-20 Thread Xuan Zhuo
1. this commit hardens dma unmap for indirect 2. the subsequent commit uses the struct extra to record whether the buffers need to be unmapped or not. So we need a struct extra for every desc, whatever it is indirect or not. Signed-off-by: Xuan Zhuo --- drivers/virtio/virtio_ring.c | 122 +

[PATCH net-next 00/13] virtio-net: support AF_XDP zero copy (tx)

2024-08-20 Thread Xuan Zhuo
## AF_XDP XDP socket(AF_XDP) is an excellent bypass kernel network framework. The zero copy feature of xsk (XDP socket) needs to be supported by the driver. The performance of zero copy is very good. mlx5 and intel ixgbe already support this feature, This patch set allows virtio-net to support xsk

[PATCH net-next 01/13] virtio_ring: introduce vring_need_unmap_buffer

2024-08-20 Thread Xuan Zhuo
To make the code readable, introduce vring_need_unmap_buffer() to replace do_unmap. use_dma_api premapped -> vring_need_unmap_buffer() 1. false falsefalse 2. truefalsetrue 3. truetrue false Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drive

[PATCH net] virtio-net: fix overflow inside virtnet_rq_alloc

2024-08-20 Thread Xuan Zhuo
leads to regression on VM with the sysctl value of: - net.core.high_order_alloc_disable=1 which could see reliable crashes or scp failure (scp a file 100M in size to VM): The issue is that the virtnet_rq_dma takes up 16 bytes at the beginning of a new frag. When the frag size is larger than PAGE