]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
virtio_net: Fix mismatched buf address when unmapping for small packets
authorWenbo Li <liwenbo.martin@bytedance.com>
Thu, 19 Sep 2024 08:13:51 +0000 (16:13 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 14:29:42 +0000 (16:29 +0200)
commite9e3424d6d4b34d2c15071c71ec249a9f78ff341
treeb6e9dd538a0f27ae4b1b28ec8c2e943cf63fe73a
parentccd3e6ff05e5236d1b9535f23f3e6622e0bb32b8
virtio_net: Fix mismatched buf address when unmapping for small packets

[ Upstream commit c11a49d58ad229a1be1ebe08a2b68fedf83db6c8 ]

Currently, the virtio-net driver will perform a pre-dma-mapping for
small or mergeable RX buffer. But for small packets, a mismatched address
without VIRTNET_RX_PAD and xdp_headroom is used for unmapping.

That will result in unsynchronized buffers when SWIOTLB is enabled, for
example, when running as a TDX guest.

This patch unifies the address passed to the virtio core as the address of
the virtnet header and fixes the mismatched buffer address.

Changes from v2: unify the buf that passed to the virtio core in small
and merge mode.
Changes from v1: Use ctx to get xdp_headroom.

Fixes: 295525e29a5b ("virtio_net: merge dma operations when filling mergeable buffers")
Signed-off-by: Wenbo Li <liwenbo.martin@bytedance.com>
Signed-off-by: Jiahui Cen <cenjiahui@bytedance.com>
Signed-off-by: Ying Fang <fangying.tommy@bytedance.com>
Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Link: https://patch.msgid.link/20240919081351.51772-1-liwenbo.martin@bytedance.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/virtio_net.c