From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796408029; b=ndSzXquX7tVPlKA+bpDmEPlWc4W6/428QjBNfLi/CS1ouIfc0bZSx0GguKwEMMSJ+cd+ yo73KNPo8xzJmD+rxnyC3anFp6IW9aXMtpCjG7Ze2OGSxF9rNCRxoEidR/VsFA5Py72c8 bIkXYDPP2cC4Dk3dNvqlBptPSfZ1Ffnac1p5ouPOPpiehi7ecrBhaESn1MWX37WqXce2p o9eCpmwggVg6skGDDc882A/dqR1cNplXCCmrQ642C3Nq5M/P4Kko97ZSIgaZuBa1v5WA2 l49bnsTBb55ChxrGN2aCT36Wi9f6duVf4N2fVjXl/pyqPU7FahBfsffwJmvfHcz1QMw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796408029; h=Received:DKIM-Signature:From:To:Cc:Subject:In-Reply-To:References: Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=vFm0cq+jdo5aWkMZtk7hv1Gdyg4t1Cea+ccAfvUywk0=; b=NJjQoDsYWdTI5qTv9KEAyRdbYDtLdJOOVNom52Gzoi5A0Lat0QHf3zndu30/JneGzeKT czlp79wKbKgsuBFENoQwj9r4DMOCP+iUOIpkB9LxC7CzkW1aIsTwpPmh1IZVvAiHgvPuH pwepRVYNJxWPu/PBxdcxE5MbtipHrvTnOPgWYIgASajZVjxAyBtrfD3kPUpOhrjrKj5A0 uqtTKcuYp8yzNJbML+CN195v7W9rmYyGGeqOp0JWemlVflIxpMrYIt0DlfJiytfMjgBiy M94KEiRcub9dy/PTroAQelgPRelktrG0a2tPalKC0xGZ9jvzJGnPbxKyoPdUPff6j2A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GpcK+3LX; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1AF5606A32C for ; Fri, 4 Dec 2026 18:13:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GpcK+3LX Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D4911F00A11; Fri, 4 Dec 2026 18:13:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796408028; bh=vFm0cq+jdo5aWkMZtk7hv1Gdyg4t1Cea+ccAfvUywk0=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=GpcK+3LXM/TzIvp0dCeKTnHphPOlESu6gIv4hHSmM3WOiFLS13VXS17ZCUYoJz1Xa NS8CsgVTAo3tgMNBiswGPysBgQjzFsOj8EmNrj6HlsnzXCeGMhoXZCR9JmQH3xYD9a 0TVGmIcXbFzLt+z/t8ZITKP7ycrsiu/XDYojxl435QoxxBoitutGtKw5h5Tb8YzUkQ kwxB3y4ipqw6UxcDSE1ej33Wqpc27QUNlIIvYYbD4VhNriqD0sn/zmF6lhAIAUpbEe On4gpR+UQ0oy+ks/Uhcj1FbuYh0rWY+CedpQDK4bcsC+UIkXFNeoZahafH+tVN4oxn JL7ufEh7agEHQ== From: =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= To: Maciej Fijalkowski , netdev@vger.kernel.org Cc: magnus.karlsson@intel.com, stfomichev@gmail.com, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, matttbe@kernel.org, Maciej Fijalkowski Subject: Re: [PATCH net] xsk: don't call virt_to_netmem() on vmapped UMEM addresses In-Reply-To: <20261204160411.1167875-1-maciej.fijalkowski@intel.com> References: <20261204160411.1167875-1-maciej.fijalkowski@intel.com> Date: Fri, 04 Dec 2026 19:13:45 +0100 Message-ID: <87ld64zzfq.fsf@all.your.base.are.belong.to.us> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Maciej Fijalkowski writes: > xsk_buff_add_frag() gets the page of an RX frag via > virt_to_netmem(xdp->data). The UMEM is vmap()ed, so xdp->data is a > vmalloc address and virt_to_page() is not valid for it. With > CONFIG_DEBUG_VIRTUAL, __phys_addr() catches this on the first frame > that spans more than one buffer, in NAPI context: > > kernel BUG at arch/x86/mm/physaddr.c:28! > Oops: invalid opcode: 0000 [#1] SMP NOPTI > RIP: 0010:__phys_addr+0x3a/0x50 > Call Trace: > > ice_clean_rx_irq_zc+0x16a/0xba0 [ice] > ice_napi_poll+0x2b3/0xfa0 [ice] > __napi_poll+0x2c/0x1e0 > net_rx_action+0x122/0x2a0 > handle_softirqs+0x104/0x360 > __irq_exit_rcu+0xb5/0xf0 > common_interrupt+0x81/0xa0 > > Kernel panic - not syncing: Fatal exception in interrupt > > ice, i40e and idpf (through libeth) are affected. This was triggered in > netdev CI, where the debug hosts hit it on E810 and X710 running > drivers/net/xsk.py, added to net-next by commit 4c810fcd484d > ("selftests: drv-net: run the AF_XDP tests over veth or a NIC"). Its > rx_SEND_RECEIVE_9K_PACKETS case reproduces it on E810 with > CONFIG_DEBUG_VIRTUAL=3Dy, without kernel changes or error injection. > > Without DEBUG_VIRTUAL nothing checks the translation. The frag ends up > with a struct page that does not back the buffer, but on x86-64 > page_address() of it yields the original address again, so this went > unnoticed. ice and i40e had the same virt_to_page() open-coded since > v6.6, before the commit below moved it into the helper, so kernels > older than v6.14 need a separate fix in those drivers. Ha! Fun times! You ended up in the direct map on the way back! [...] > diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c > index 5ec092f7cb6f..5891ac6b1f01 100644 > --- a/net/xdp/xsk_buff_pool.c > +++ b/net/xdp/xsk_buff_pool.c > @@ -459,15 +459,21 @@ void xp_dma_unmap(struct xsk_buff_pool *pool, unsig= ned long attrs) > } > EXPORT_SYMBOL(xp_dma_unmap); >=20=20 > -static void xp_check_dma_contiguity(struct xsk_dma_map *dma_map) > +static void xp_check_dma_contiguity(struct xsk_dma_map *dma_map, > + struct page **pages) > { > + dma_addr_t *dma =3D dma_map->dma_pages; > u32 i; >=20=20 > + /* The CPU reaches RX frags through page_address(), so pages also > + * need to be physically contiguous when an IOMMU translates. > + */ > for (i =3D 0; i < dma_map->dma_pages_cnt - 1; i++) { > - if (dma_map->dma_pages[i] + PAGE_SIZE =3D=3D dma_map->dma_pages[i + 1]) > - dma_map->dma_pages[i] |=3D XSK_NEXT_PG_CONTIG_MASK; > + if (dma[i] + PAGE_SIZE =3D=3D dma[i + 1] && > + page_to_pfn(pages[i]) + 1 =3D=3D page_to_pfn(pages[i + 1])) > + dma[i] |=3D XSK_NEXT_PG_CONTIG_MASK; > else > - dma_map->dma_pages[i] &=3D ~XSK_NEXT_PG_CONTIG_MASK; > + dma[i] &=3D ~XSK_NEXT_PG_CONTIG_MASK; Hmm, aren't we being overly pessimistic for the Tx side now? Tx needs DMA contig, but the requirement of contig pfn is only for the odd frag behavior. Would it be possible to do the pfn config check in the fill ring validation, or would this have effect on the performance more than here? I'm OK with this, but I think we might be regressing on a case that used to work for Tx. OTOH, we'll get a weird asymmetry. Then again, who uses unaligned! ;-) (Let's see what Sashiko says -- I'm leaning towards being happy with this!) Happy weekend! Bj=C3=B6rn