Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1651043pxb; Fri, 20 Aug 2021 10:26:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHOVu5/Omlu5bSL0AXAvNeSZk5aiFS8Prni6Att63lnUr3VDyz2S5fQgpT6itsn1kpXmCH X-Received: by 2002:a05:6402:2889:: with SMTP id eg9mr23994670edb.38.1629480407772; Fri, 20 Aug 2021 10:26:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629480407; cv=none; d=google.com; s=arc-20160816; b=sWHDpY+Ok6/idMn2Hh44CLdfeZcbF6z1th6HzVjG5gS8hUUjxzURQkqx8/ss4FRv0U H7EaOxdrHYtWl8sclGuMIDCMXZtUlDfyGpJC4Bn57e4w5stUeoE+WnPvdSaY+s63CYSp vabyGar9Xvmi0VMIaDScXC7Mxo7Kb8dmK73Lg6i1svxnU575ueQmzv2xaskX5VGRApne pALFapk2Tvkj6xgUD0BQg4EMCsowYOkXE5Ju9EBEXdwD8A980EW6LN8haDk/yYNRdTca 9kYNk8zMfcmO+p0JlUeLo7CNsZhvfl1fqbccgXov3Jrs4DUGkbOKQJfk5hOHkqculpdl 14yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=0SwuVXpzATStLT8MQ+rR0GsjOwiW5Sz/wRAd6bCA7JY=; b=oaUTVaDfrVqWZYhE0qaTFXG0D48bjNxrWJOG73IPb37b0pLZqx2aKr1CoghUKmDhee 4caJmfFK5UGEP8H3/GDypMHf2vcMyh1R9lpsA43U8HcDtoyqRv8FS33YonathjX9lzXn BH0NkAB0evA9rfIMf79AIrHmQfBv98igY6MpNvA68GMzoGVt8K3po/gXNOG1iMuHTQCj jb61+XWWJ1I2/jxHnLQHq2v58C6d5fNoMQzl5t2MElym9g0uBalvQPpbeTnr/7euis7N sUmoMrdwcn4e52cVwwzdil9KXXx4dhtFBr6ZRigq4zwYtkxxhFjPRj6s8qcu8yaU4Cpo daLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id di1si7028816edb.582.2021.08.20.10.26.21; Fri, 20 Aug 2021 10:26:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233925AbhHTRYw (ORCPT + 99 others); Fri, 20 Aug 2021 13:24:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:55134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233256AbhHTRYv (ORCPT ); Fri, 20 Aug 2021 13:24:51 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3D39761154; Fri, 20 Aug 2021 17:24:13 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mH8FX-006FEo-B0; Fri, 20 Aug 2021 18:24:11 +0100 Date: Fri, 20 Aug 2021 18:24:12 +0100 Message-ID: <87h7fkyqpv.wl-maz@kernel.org> From: Marc Zyngier To: Matteo Croce Cc: Eric Dumazet , Thierry Reding , netdev@vger.kernel.org, Linux Kernel Mailing List , linux-riscv , Giuseppe Cavallaro , Alexandre Torgue , "David S. Miller" , Jakub Kicinski , Palmer Dabbelt , Paul Walmsley , Drew Fustini , Emil Renner Berthing , Jon Hunter , Will Deacon Subject: Re: [PATCH net-next] stmmac: align RX buffers In-Reply-To: References: <20210614022504.24458-1-mcroce@linux.microsoft.com> <871r71azjw.wl-maz@kernel.org> <202417ef-f8ae-895d-4d07-1f9f3d89b4a4@gmail.com> <87o8a49idp.wl-maz@kernel.org> <20210812121835.405d2e37@linux.microsoft.com> <874kbuapod.wl-maz@kernel.org> <87wnohqty1.wl-maz@kernel.org> <87fsv4qdzm.wl-maz@kernel.org> <87mtpcyrdv.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: mcroce@linux.microsoft.com, eric.dumazet@gmail.com, thierry.reding@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, davem@davemloft.net, kuba@kernel.org, palmer@dabbelt.com, paul.walmsley@sifive.com, drew@beagleboard.org, kernel@esmil.dk, jonathanh@nvidia.com, will@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 20 Aug 2021 18:14:30 +0100, Matteo Croce wrote: > > On Fri, Aug 20, 2021 at 7:09 PM Marc Zyngier wrote: > > > > On Fri, 20 Aug 2021 17:38:14 +0100, > > Matteo Croce wrote: > > > > > > On Fri, Aug 20, 2021 at 6:26 PM Marc Zyngier wrote: > > > > > > > > On Fri, 20 Aug 2021 11:37:03 +0100, > > > > Matteo Croce wrote: > > > > > > > > > > On Thu, Aug 19, 2021 at 6:29 PM Marc Zyngier wrote: > > > > > > > > [...] > > > > > > > > > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h > > > > > > index fcdb1d20389b..244aa6579ef4 100644 > > > > > > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h > > > > > > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h > > > > > > @@ -341,7 +341,7 @@ static inline unsigned int stmmac_rx_offset(struct stmmac_priv *priv) > > > > > > if (stmmac_xdp_is_enabled(priv)) > > > > > > return XDP_PACKET_HEADROOM + NET_IP_ALIGN; > > > > > > > > > > > > - return NET_SKB_PAD + NET_IP_ALIGN; > > > > > > + return 8 + NET_IP_ALIGN; > > > > > > } > > > > > > > > > > > > void stmmac_disable_rx_queue(struct stmmac_priv *priv, u32 queue); > > > > > > > > > > > > I don't see the system corrupting packets anymore. Is that exactly > > > > > > what you had in mind? This really seems to point to a basic buffer > > > > > > overflow. > > > > > > > > [...] > > > > > > > > > Sorry, I meant something like: > > > > > > > > > > - return NET_SKB_PAD + NET_IP_ALIGN; > > > > > + return 8; > > > > > > > > > > I had some hardware which DMA fails if the receive buffer was not word > > > > > aligned, but this seems not the case, as 8 + NET_IP_ALIGN = 10, and > > > > > it's not aligned too. > > > > > > > > No error in that case either, as expected. Given that NET_SKB_PAD is > > > > likely to expand to 64, it is likely a DMA buffer overflow which > > > > probably only triggers for large-ish packets. > > > > > > > > Now, we're almost at -rc7, and we don't have a solution in sight. > > > > > > > > Can we please revert this until we have an understanding of what is > > > > happening? I'll hopefully have more cycles to work on the issue once > > > > 5.14 is out, and hopefully the maintainers of this driver can chime in > > > > (they have been pretty quiet so far). > > > > > > > > Thanks, > > > > > > > > M. > > > > > > > > -- > > > > Without deviation from the norm, progress is not possible. > > > > > > Last try, what about adding only NET_IP_ALIGN and leaving NET_SKB_PAD? > > > > > > - return NET_SKB_PAD + NET_IP_ALIGN; > > > + return NET_IP_ALIGN; > > > > > > I think that alloc_skb adds another NET_SKB_PAD anyway. > > > > I don't see any packet corruption with this. However, this doesn't > > prove that this is correct either. What was the rational for adding > > NET_SKB_PAD the first place? > > > > I think it's wrong. The original offset was 0, and to align it to the > boundary we need to add just NET_IP_ALIGN, which is two. > NET_SKB_PAD is a much bigger value, (I think 64), which is used to > reserve space to prepend an header, e.g. with tunnels. How about the other adjustments that Eric mentioned regarding the size of the buffer? Aren't they required? M. -- Without deviation from the norm, progress is not possible.