mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net v3 0/2] virtio_net: AF_XDP zero-copy fixes for arm64 and XDP queues
@ 2026-11-10 15:29 Haishuang Yan
  2026-11-10 15:30 ` [PATCH net v3 1/2] virtio_net: Don't DMA map the kernel image for the AF_XDP TX header Haishuang Yan
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Haishuang Yan @ 2026-11-10 15:29 UTC (permalink / raw)
  To: Michael S. Tsirkin, Jason Wang, Xuan Zhuo
  Cc: Eugenio Pérez, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
	Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
	netdev, virtualization, bpf, linux-kernel

Two AF_XDP zero-copy fixes for virtio_net.

Patch 1: on arm64, binding a zero-copy socket fails with -ENOMEM and a
"rejecting DMA map of vmalloc memory" warning whenever the device uses
the DMA API (e.g. VIRTIO_F_ACCESS_PLATFORM), because the static TX
header lives in the kernel image, which arm64 maps in the vmalloc area.

Patch 2: removing XDP, explicitly or when the device is unregistered,
can leave a zero-copy pool bound to a queue above curr_queue_pairs.
Unbinding the socket then fails in the driver, and the queue is
refilled from the freed pool.

The suspend fix that was patch 3 in v2 is dropped from this series.
Review found problems with it for pools on queues above
curr_queue_pairs; it will be reworked and sent separately on top of
these two.

Testing used KASAN kernels in QEMU with virtio-net-pci and
iommu_platform=on:

- Patch 1 on arm64 (TCG, virt): binding an XDP_ZEROCOPY socket fails
  without the patch and succeeds with it.
- Patch 2 on x86_64 (KVM, q35, intel-iommu, two queue pairs): with a
  socket bound to an XDP queue, removing XDP and then closing the
  socket gives "Failed to disable zero-copy!" and a KASAN
  use-after-free in xp_alloc_batch() on net, and no warnings with this
  series. Unbinding the device from virtio_net with XDP attached and a
  socket on an XDP queue gives "Failed to disable zero-copy!" on net,
  and no warning with this series. In both cases the unregister then
  keeps waiting for eth0 to become free; that also happens with only
  XDP attached and no socket, so it is a separate issue.

The issues were found with the help of an AI coding assistant.

Changes in v3:
- Drop patch 3, to be reworked and sent separately (Sashiko).
- Patch 2: mention the unregister path in the changelog (Sashiko).
- Rebased on net 1d5e2c57e9ff; the code of patches 1 and 2 is
  unchanged.

Changes in v2:
- Patch 1: drop the sentence about cache lines from the changelog
  (Sashiko).
- New patch 2, for a pool left on a queue above curr_queue_pairs
  (Sashiko).
- Patch 3: rework (Sashiko).

v2: https://lore.kernel.org/netdev/20261108193845.73621-1-yanhaishuang@cmss.chinamobile.com/
v1: https://lore.kernel.org/netdev/20261107125723.33547-1-yanhaishuang@cmss.chinamobile.com/

Haishuang Yan (2):
  virtio_net: Don't DMA map the kernel image for the AF_XDP TX header
  virtio_net: Disable AF_XDP pools on queues above curr_queue_pairs

 drivers/net/virtio_net.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)


base-commit: 1d5e2c57e9ffc134e14b3f837c8d7c53b508bd22
-- 
2.43.0




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-17  0:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10 15:29 [PATCH net v3 0/2] virtio_net: AF_XDP zero-copy fixes for arm64 and XDP queues Haishuang Yan
2026-11-10 15:30 ` [PATCH net v3 1/2] virtio_net: Don't DMA map the kernel image for the AF_XDP TX header Haishuang Yan
2026-11-10 15:30 ` [PATCH net v3 2/2] virtio_net: Disable AF_XDP pools on queues above curr_queue_pairs Haishuang Yan
2026-11-17  0:08   ` Jakub Kicinski
2026-11-17  0:20 ` [PATCH net v3 0/2] virtio_net: AF_XDP zero-copy fixes for arm64 and XDP queues patchwork-bot+netdevbpf
2026-11-17  0:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®