Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1829433rbb; Tue, 27 Feb 2024 02:29:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW1BrdG3HOjtlEbUkf+YL/FjmnXCrzVZy6n31IzkEQgnenDsuiCUSj6N2+kspX/Ks+8WrGT8qKWvZDEJriTDjwnkHOw6y9NsJm+dzkMdQ== X-Google-Smtp-Source: AGHT+IEMC7mpEJt2KQeTwEbiEeVRJJyhOSH8FCGnSZMs642go6kKaODUWkG7U8pi63BVWaQyCfcw X-Received: by 2002:a17:906:4717:b0:a3f:2703:1c6a with SMTP id y23-20020a170906471700b00a3f27031c6amr6717132ejq.51.1709029769188; Tue, 27 Feb 2024 02:29:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709029769; cv=pass; d=google.com; s=arc-20160816; b=SeJUGnwMtB4aSurISEa5Uadqmg2j5EVyK95JNyDLbNQ4Un0zofbMmVTTocSIl+1+rq J85oCdc/h92eVud3rSOlrCkELTFC4VUhMg482IxeCqDJ7Kf6+6qMCsO7S0zznYhUuuJZ YLzPv3VWDDN8ZE6JgNQRGMhcVTsNHypLPvtFjJYLdxL0ttb4UBnwYOn2FUULKmikRpR2 SKzwIX+z1LlcXJSTd6U1jJYQI9Id4jYQlWP+eNw2wAAwbpfY9BrW3es/U7TvnDOh0OFJ 0uwskwhTP3iI3OcxAzSnpZ4/D+gT9PQn+rhEF1PPKeC1O6Wln/A6uoqkaiTzhQv4e65f T02A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=AaMsMZWiwvSaJp1atd6FKd0pROFWF3fPGtmIY0iqYYs=; fh=mpIgTbouB1PWfJLtmpiGTJjNYcFx4+lOJVRPHhBIPXw=; b=yAOAHIL5mVKsOe3k19MXCPczy5s1kzfTXnDVoN0ypQEu7/IBajel2wipsN9juyAG92 Yg3jGB8SbplPpYU5QBR9LYFEp8a1IfjOZCZI8XOnwdVjJGQiim4DDdHRdCSpM04ZuXpQ BZycTLET2V0LLh40hojU2GW1v/zVcefnxTUSTpsPuB6/tQVKgg8v/Q11PSdgLhyaAumx oPu8E1jD5XE/vicB8YgxaF5WrJV/R07Bizxnx6nphLIiLQFIo1/ryYC4AX0ToQ55EdvX s5WVggCKXHA8AG6nFy8Q002rOp6/AwelTTXK2RikSwALLrZad9038JFHgoy7trKC65No Fl/A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=nJOIxtZ5; arc=pass (i=1 dkim=pass dkdomain=armlinux.org.uk dmarc=pass fromdomain=armlinux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-83035-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83035-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id p18-20020a17090635d200b00a3f7f1fcc73si612601ejb.347.2024.02.27.02.29.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 02:29:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83035-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=nJOIxtZ5; arc=pass (i=1 dkim=pass dkdomain=armlinux.org.uk dmarc=pass fromdomain=armlinux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-83035-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83035-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C8E6C1F22A8D for ; Tue, 27 Feb 2024 10:29:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DDB1D1386D6; Tue, 27 Feb 2024 10:29:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="nJOIxtZ5" Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9837E1386C7; Tue, 27 Feb 2024 10:29:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709029743; cv=none; b=hFjLIb00hpu/FR5eVPCvhMSqSjmBALpArWttLPVhI/cosj3VpODeoBswQ5rgeo6gbP8xGcCzJIu45WTHCLwL+u/9QPTXBP295Kp9hAU6iuA/qFKcywbza030tPzmBhsTNZ86fkI+fFgpDumCd2AQm9352Wk0IMagyLe6XPHxF6g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709029743; c=relaxed/simple; bh=2nSH7ifbYm3tqDkxI8g0ViATvBk6HRIg3r24rsscvwk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fLHJjBiIYM5JCY0QxQpOhTz3dSUm30/rhSSuz0G2lizuM8sw31beIq6WCX0a4e46KSCe0uo2ZrUdUVdy1qgGSidXePOEEK/qQ5RX+MdhEP6UGdn4UCC6HqWIp1yGkcxLJWQtftc7dsmIoulY8NqfWZTEGoCca1c663pDUP9Q00k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=nJOIxtZ5; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=AaMsMZWiwvSaJp1atd6FKd0pROFWF3fPGtmIY0iqYYs=; b=nJOIxtZ52FqIAVUFl2d7cP0vTC F1ANU0h5omGFVqaHz+i1HZQ/9eCovQVlWBEKYvHWcTgj/WlJK5s9ngZ2ESModv77AqFeEFgfOYNhM WuunX11xsvZ1EFu00Byzj9MB2hE2+TuhPu6d9p6pJcC4XIZ7tcmnEOZdLNgYiubkOCbQxMEt1a2wR l5lRgW/fVcaLTA6xaKpEElQO/kDQrISXdGzbUm3M4GGs3itlVmricP/bMq29RcArGak8WDOnK3xyi 7KK4fDE0xQatqYO1vGATvNtgxUAr8Wj3DEWWPkYSbrodbniRmVPfY0Kap03XGhONynL7yldslsE1S lXYyXE9w==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:55912) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1reuhc-0007lc-2j; Tue, 27 Feb 2024 10:28:48 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1reuhZ-0007JB-VJ; Tue, 27 Feb 2024 10:28:46 +0000 Date: Tue, 27 Feb 2024 10:28:45 +0000 From: "Russell King (Oracle)" To: Christophe Leroy Cc: Guenter Roeck , Charlie Jenkins , David Laight , Palmer Dabbelt , Andrew Morton , Helge Deller , "James E.J. Bottomley" , Parisc List , Arnd Bergmann , "linux-kernel@vger.kernel.org" , Palmer Dabbelt , Linux ARM Subject: Re: [PATCH v10] lib: checksum: Use aligned accesses for ip_fast_csum and csum_ipv6_magic tests Message-ID: References: <20240223-fix_sparse_errors_checksum_tests-v10-1-b6a45914b7d8@rivosinc.com> <7ae930a7-3b10-4470-94ee-89cb650b3349@csgroup.eu> <9b4ce664-3ddb-4789-9d5d-8824f9089c48@csgroup.eu> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9b4ce664-3ddb-4789-9d5d-8824f9089c48@csgroup.eu> Sender: Russell King (Oracle) On Tue, Feb 27, 2024 at 06:47:38AM +0000, Christophe Leroy wrote: > > > Le 27/02/2024 ? 00:48, Guenter Roeck a ?crit?: > > On 2/26/24 15:17, Charlie Jenkins wrote: > >> On Mon, Feb 26, 2024 at 10:33:56PM +0000, David Laight wrote: > >>> ... > >>>> I think you misunderstand. "NET_IP_ALIGN offset is what the kernel > >>>> defines to be supported" is a gross misinterpretation. It is not > >>>> "defined to be supported" at all. It is the _preferred_ alignment > >>>> nothing more, nothing less. > >> > >> This distinction is arbitrary in practice, but I am open to being proven > >> wrong if you have data to back up this statement. If the driver chooses > >> to not follow this, then the driver might not work. ARM defines the > >> NET_IP_ALIGN to be 2 to pad out the header to be on the supported > >> alignment. If the driver chooses to pad with one byte instead of 2 > >> bytes, the driver may fail to work as the CPU may stall after the > >> misaligned access. > >> > >>> > >>> I'm sure I've seen code that would realign IP headers to a 4 byte > >>> boundary before processing them - but that might not have been in > >>> Linux. > >>> > >>> I'm also sure there are cpu which will fault double length misaligned > >>> memory transfers - which might be used to marginally speed up code. > >>> Assuming more than 4 byte alignment for the IP header is likely > >>> 'wishful thinking'. > >>> > >>> There is plenty of ethernet hardware that can only write frames > >>> to even boundaries and plenty of cpu that fault misaligned accesses. > >>> There are even cases of both on the same silicon die. > >>> > >>> You also pretty much never want a fault handler to fixup misaligned > >>> ethernet frames (or really anything else for that matter). > >>> It is always going to be better to check in the code itself. > >>> > >>> x86 has just made people 'sloppy' :-) > >>> > >>> ????David > >>> > >>> - > >>> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, > >>> MK1 1PT, UK > >>> Registration No: 1397386 (Wales) > >>> > >> > >> If somebody has a solution they deem to be better, I am happy to change > >> this test case. Otherwise, I would appreciate a maintainer resolving > >> this discussion and apply this fix. > >> > > Agreed. > > > > I do have a couple of patches which add explicit unaligned tests as well as > > corner case tests (which are intended to trigger as many carry overflows > > as possible). Once I get those working reliably, I'll be happy to submit > > them as additional tests. > > > > The functions definitely have to work at least with and without VLAN, > which means the alignment cannot be greater than 4 bytes. That's also > the outcome of the discussion. Thanks for completely ignoring what I've said. No. The alignment ends up being commonly 2 bytes. As I've said several times, network drivers do _not_ have to respect NET_IP_ALIGN. There are 32-bit ARM drivers which have a DMA engine in them which can only DMA to a 32-bit aligned address. This means that the start of the ethernet header is placed at a 32-bit aligned address making the IP header misaligned to 32-bit. I don't see what is so difficult to understand about this... but it seems that my comments on this are being ignored time and time again, and I can only think that those who are ignoring my comments have some alterior motive here. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!