# Re: \[PATCH net-next 01/16\] libeth: convert to netmem

- From: Mina Almasry \<hidden\>
- Date: 2025-05-28 03:49:46 
- List: netdev
- Page: https://ratatoskr.run/netdev/2025/05/7923626
- Thread: https://ratatoskr.run/netdev/2025/05/7923434/t.md

```text
On Tue, May 27, 2025 at 6:57 PM Jakub Kicinski [ref] wrote:
> > -     dst = page_address(hdr->page) + hdr->offset + hdr->page->pp->p.offset;
> > -     src = page_address(buf->page) + buf->offset + buf->page->pp->p.offset;
> > -     memcpy(dst, src, LARGEST_ALIGN(copy));
> > +     hdr_page = __netmem_to_page(hdr->netmem);
> > +     buf_page = __netmem_to_page(buf->netmem);
> > +     dst = page_address(hdr_page) + hdr->offset + hdr_page->pp->p.offset;
> > +     src = page_address(buf_page) + buf->offset + buf_page->pp->p.offset;
> >
> > +     memcpy(dst, src, LARGEST_ALIGN(copy));
> >       buf->offset += copy;
> >
> >       return copy;
> > @@ -3302,11 +3306,12 @@ static u32 idpf_rx_hsplit_wa(const struct libeth_fqe *hdr,
> >   */
> >  struct sk_buff *idpf_rx_build_skb(const struct libeth_fqe *buf, u32 size)
> >  {
> > -     u32 hr = buf->page->pp->p.offset;
> > +     struct page *buf_page = __netmem_to_page(buf->netmem);
> > +     u32 hr = buf_page->pp->p.offset;
> >       struct sk_buff *skb;
> >       void *va;
> >
> > -     va = page_address(buf->page) + buf->offset;
> > +     va = page_address(buf_page) + buf->offset;
> >       prefetch(va + hr);
>
> If you don't want to have to validate the low bit during netmem -> page
> conversions - you need to clearly maintain the separation between
> the two in the driver. These __netmem_to_page() calls are too much of
> a liability.

Would it make sense to add a DEBUG_NET_WARN_ON_ONCE to
__netmem_to_page to catch misuse in a driver independent way? Or is
that not good enough because there may be latent issues only hit in
production where the debug is disabled.

-- 
Thanks,
Mina
```
