From: "Michael S. Tsirkin" <mst@redhat.com>
To: Omar Elghoul <oelghoul@linux.ibm.com>
Cc: vishs@meta.com, andrew+netdev@lunn.ch, davem@davemloft.net,
dw@davidwei.uk, edumazet@google.com, eperezma@redhat.com,
ilias.apalodimas@linaro.org, jasowang@redhat.com,
kernel-team@meta.com, kuba@kernel.org,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
pabeni@redhat.com, technoboy85@gmail.com,
virtualization@lists.linux.dev, xuanzhuo@linux.alibaba.com
Subject: Re: [PATCH net-next v11] virtio_net: add page_pool support for buffer allocation
Date: Mon, 23 Mar 2026 12:58:25 -0400 [thread overview]
Message-ID: <20260323122728-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20260323114313-mutt-send-email-mst@kernel.org>
On Mon, Mar 23, 2026 at 11:52:34AM -0400, Michael S. Tsirkin wrote:
> On Mon, Mar 23, 2026 at 11:01:31AM -0400, Omar Elghoul wrote:
> > Hi,
> >
> > I've been testing linux-next (tags later than 03/17) and hit new issues in
> > virtio-net on s390x. I bisected the issue, and I found this patch to be the
> > first buggy commit.
> >
> > The issue seems to only be reproducible when running in Secure Execution.
> > Tested in a KVM guest, the virtio-net performance appears greatly reduced,
> > and the dmesg output shows many instances of the following error messages.
> >
> > Partial relevant logs
> > =====================
> > [ 49.332028] macvtap0: bad gso: type: 0, size: 0, flags 1 tunnel 0 tnl csum 0
> > [ 74.365668] macvtap0: bad gso: type: 2e, size: 27948, flags 0 tunnel 0 tnl csum 0
> > [ 403.302168] macvtap0: bad csum: flags: 2, gso_type: 23 rx_tnl_csum 0
> > [ 403.302271] macvtap0: bad csum: flags: 2, gso_type: e0 rx_tnl_csum 0
> > [ 403.302279] macvtap0: bad csum: flags: 2, gso_type: e1 rx_tnl_csum 0
> > [ 403.309492] macvtap0: bad csum: flags: 2, gso_type: 4c rx_tnl_csum 0
> > [ 403.317029] macvtap0: bad csum: flags: 2, gso_type: e0 rx_tnl_csum 0
> >
> > Steps to reproduce
> > ==================
> > 1. Boot a Linux guest implementing this patch under QEMU/KVM (*) with SE
> > enabled and a virtio-net-ccw device attached.
> > 2. Run dmesg. The error message is usually already present at boot time,
> > but if not, it can be reproduced by creating any network traffic.
> >
> > (*) This patch was not tested in a non-KVM hypervisor environment.
> >
> > I've further confirmed that reverting this patch onto its parent commit
> > resolves the issue. Please let me know if you'd like me to test a fix or if
> > you would need more information.
> >
> > Thanks in advance.
> >
> > Best,
> > Omar
>
> Well... I am not sure how I missed it. Obvious in hindsight:
>
> static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
> void *buf, unsigned int len, void **ctx,
> unsigned int *xdp_xmit,
> struct virtnet_rq_stats *stats)
> {
> struct net_device *dev = vi->dev;
> struct sk_buff *skb;
> u8 flags;
>
> if (unlikely(len < vi->hdr_len + ETH_HLEN)) {
> pr_debug("%s: short packet %i\n", dev->name, len);
> DEV_STATS_INC(dev, rx_length_errors);
> virtnet_rq_free_buf(vi, rq, buf);
> return;
> }
>
> /* About the flags below:
> * 1. Save the flags early, as the XDP program might overwrite them.
> * These flags ensure packets marked as VIRTIO_NET_HDR_F_DATA_VALID
> * stay valid after XDP processing.
> * 2. XDP doesn't work with partially checksummed packets (refer to
> * virtnet_xdp_set()), so packets marked as
> * VIRTIO_NET_HDR_F_NEEDS_CSUM get dropped during XDP processing.
> */
>
> if (vi->mergeable_rx_bufs) {
> flags = ((struct virtio_net_common_hdr *)buf)->hdr.flags;
> skb = receive_mergeable(dev, vi, rq, buf, ctx, len, xdp_xmit,
> stats);
> } else if (vi->big_packets) {
> void *p = page_address((struct page *)buf);
>
> flags = ((struct virtio_net_common_hdr *)p)->hdr.flags;
> skb = receive_big(dev, vi, rq, buf, len, stats);
> } else {
> flags = ((struct virtio_net_common_hdr *)buf)->hdr.flags;
> skb = receive_small(dev, vi, rq, buf, ctx, len, xdp_xmit, stats);
> }
>
>
> So we are reading the header, before dma sync, which is within
> receive_mergeable and friends:
>
> static struct sk_buff *receive_mergeable(struct net_device *dev,
> struct virtnet_info *vi,
> struct receive_queue *rq,
> void *buf,
> void *ctx,
> unsigned int len,
> unsigned int *xdp_xmit,
> struct virtnet_rq_stats *stats)
> {
> struct virtio_net_hdr_mrg_rxbuf *hdr = buf;
> int num_buf = virtio16_to_cpu(vi->vdev, hdr->num_buffers);
> struct page *page = virt_to_head_page(buf);
> int offset = buf - page_address(page);
> struct sk_buff *head_skb, *curr_skb;
> unsigned int truesize = mergeable_ctx_to_truesize(ctx);
> unsigned int headroom = mergeable_ctx_to_headroom(ctx);
>
> head_skb = NULL;
>
> if (rq->use_page_pool_dma)
> page_pool_dma_sync_for_cpu(rq->page_pool, page, offset, len);
>
>
>
> Just as a test, the below should fix it (compiled only), but the real
> fix is more complex since we need to be careful to avoid expensive syncing
> twice.
>
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 97035b49bae7..57b4f5954bed 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -931,9 +931,19 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
>
> static void *virtnet_rq_get_buf(struct receive_queue *rq, u32 *len, void **ctx)
> {
> + void *buf;
> +
> BUG_ON(!rq->page_pool);
>
> - return virtqueue_get_buf_ctx(rq->vq, len, ctx);
> + buf = virtqueue_get_buf_ctx(rq->vq, len, ctx);
> + if (buf && rq->use_page_pool_dma && *len) {
> + struct page *page = virt_to_head_page(buf);
> + int offset = buf - page_address(page);
> +
> + page_pool_dma_sync_for_cpu(rq->page_pool, page, offset, *len);
> + }
> +
> + return buf;
> }
>
> static void virtnet_rq_unmap_free_buf(struct virtqueue *vq, void *buf)
>
>
>
>
> --
> MST
or maybe like this:
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 97035b49bae7..835f52651006 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1956,13 +1956,6 @@ static struct sk_buff *receive_small(struct net_device *dev,
*/
buf -= VIRTNET_RX_PAD + xdp_headroom;
- if (rq->use_page_pool_dma) {
- int offset = buf - page_address(page) +
- VIRTNET_RX_PAD + xdp_headroom;
-
- page_pool_dma_sync_for_cpu(rq->page_pool, page, offset, len);
- }
-
len -= vi->hdr_len;
u64_stats_add(&stats->bytes, len);
@@ -2398,9 +2391,6 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
head_skb = NULL;
- if (rq->use_page_pool_dma)
- page_pool_dma_sync_for_cpu(rq->page_pool, page, offset, len);
-
u64_stats_add(&stats->bytes, len - vi->hdr_len);
if (check_mergeable_len(dev, ctx, len))
@@ -2563,6 +2553,13 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
return;
}
+ if (rq->use_page_pool_dma) {
+ struct page *page = virt_to_head_page(buf);
+ int offset = buf - page_address(page);
+
+ page_pool_dma_sync_for_cpu(rq->page_pool, page, offset, len);
+ }
+
/* About the flags below:
* 1. Save the flags early, as the XDP program might overwrite them.
* These flags ensure packets marked as VIRTIO_NET_HDR_F_DATA_VALID
next prev parent reply other threads:[~2026-03-23 16:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 18:31 [PATCH net-next v11] virtio_net: add page_pool support for buffer allocation Vishwanath Seshagiri
2026-03-13 7:51 ` Jason Wang
2026-03-13 9:26 ` Vishwanath Seshagiri
2026-03-16 7:41 ` Jason Wang
2026-03-13 16:50 ` Vishwanath Seshagiri
2026-03-16 7:35 ` Jason Wang
2026-03-16 9:56 ` Michael S. Tsirkin
2026-03-16 10:43 ` Michael S. Tsirkin
2026-03-16 11:57 ` Vishwanath Seshagiri
2026-03-16 12:04 ` Michael S. Tsirkin
2026-03-17 2:30 ` patchwork-bot+netdevbpf
2026-03-23 15:01 ` Omar Elghoul
2026-03-23 15:01 ` Omar Elghoul
2026-03-23 15:52 ` Michael S. Tsirkin
2026-03-23 16:54 ` Omar Elghoul
2026-03-23 17:10 ` Michael S. Tsirkin
2026-03-23 16:58 ` Michael S. Tsirkin [this message]
2026-03-23 17:09 ` Omar Elghoul
2026-03-23 17:50 ` Vishwanath Seshagiri
2026-03-23 23:37 ` Michael S. Tsirkin
2026-03-24 0:34 ` Jason Wang
2026-03-24 8:20 ` Aithal, Srikanth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260323122728-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=dw@davidwei.uk \
--cc=edumazet@google.com \
--cc=eperezma@redhat.com \
--cc=ilias.apalodimas@linaro.org \
--cc=jasowang@redhat.com \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oelghoul@linux.ibm.com \
--cc=pabeni@redhat.com \
--cc=technoboy85@gmail.com \
--cc=virtualization@lists.linux.dev \
--cc=vishs@meta.com \
--cc=xuanzhuo@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.