mbuf data crossing a page boundary

From: Roger Pau Monné <royger_at_FreeBSD.org>
Date: Fri, 24 Dec 2021 11:18:47 UTC
Hello,

A user (on Cc) recently reported an issue on xen-devel when using
FreeBSD as a Xen guest on a Linux host. Upon further examination the
issue is caused by FreeBSD Xen virtual network adapter receiving an
mbuf that contains a data buffer that crosses a page boundary. This is
not an mbuf chain, a single mbuf that has 'mtod(m, vm_offset_t) &
PAGE_MASK) + m->m_len > PAGE_SIZE'.

The Xen virtual network interface doesn't support jumbo frames or
anything like that, here is the ifconfig output of the adapter:

xn0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=503<RXCSUM,TXCSUM,TSO4,LRO>
    ether 00:18:3c:51:6e:4c
    inet 192.168.1.9 netmask 0xffffff00 broadcast 192.168.1.255
    media: Ethernet manual
    status: active
    nd6 options=1<PERFORMNUD>

This issue seems to be only reproducible when using the iSCSI target
mode on FreeBSD.

Is it expected for network interfaces to handle mbufs that have data
crossing a page boundary even when not supporting jumbo frames?

If so, what's the best way to handle those? I would think using
bus_dma, but it seems overkill to use it just to split an mbuf that
crosses a page boundary. I could also add code in the Xen virtual
adapter to split those mbufs, but it's a bit clumsy IMO.

For reference, the xen-devel thread where this is also discussed:

https://lists.xenproject.org/archives/html/xen-devel/2021-12/msg01581.html

Thanks, Roger.