From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 24020C54798 for ; Tue, 27 Feb 2024 19:04:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To: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-Owner; bh=JQ8zODa7fe+jLr3G09Gj1KDsKUCYl1gAMhiBqxul3PQ=; b=ghdEAtMn6IjALM TCXeKdKxUeNnhXqkF9dSkKISeIicVgRQ7OAtfN6a1PU2ltZw+zC258QgyG6dCzphJVNqChiWfvuJo XCierwpUZBm9qfqz9Bg4ioAX7KuMtQOEp5EASmabeGFQH1EvRl7SfubCWFAX8Z0lWmzv55mZ0HQ/Q GUOI8T37Ipum1RG4QHikO/4qKs5OKPmnh7QmL2xpKVQ3DEW+DQ8fQ6mp+xCVDuSvDADttfnykUYpZ Q7RF8ynKWxoTX5WDBF7uINvJt/WKlsI+AN42ahK7WPA9YwdZeJRqfoLjMNYZENG6BU+BfXvzRe/cq 89DuV0zVQv+1fjTcSAeg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rf2kN-00000006Xps-1Tny; Tue, 27 Feb 2024 19:04:11 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rf2kK-00000006XoZ-15Qo for linux-arm-kernel@lists.infradead.org; Tue, 27 Feb 2024 19:04:09 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1dc139ed11fso963395ad.0 for ; Tue, 27 Feb 2024 11:04:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1709060647; x=1709665447; darn=lists.infradead.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=OMAkp8kLDRBH6DaL/T38O2uylPO/mVKUbw4jqD28o5s=; b=ZjQTHaS7p5GwM/x1bnTeHOi2ddH/dcgBDVVXr3k/ckzMlnpxhYT7Tyd70R6IFfXP+H IyOkQlYbOP1FnHRAykhjNWoYqUydHBCoY4+pQ04Niveh77W6UbNM7FVaoejz4p+6Ykew AiQgJWaW5KzG1QvFFSINzgAEbneL/bbovFWwIXe0B7yAXMHkYfRu56U6X6ubZEeGNIUy 38JTQr0wN6FKlkrLTmFkRuBais6vvn4TfK5fiLm0Il5zPCMjkuU/zeh4TpNzRpZGZ+bi Q/rZbc4aIhT8JhEpy171yJ79I50/RdGJZa8dzu0+o+hz/rJVNgIf/gPu4fT50AcsS1bN p0oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709060647; x=1709665447; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OMAkp8kLDRBH6DaL/T38O2uylPO/mVKUbw4jqD28o5s=; b=eYF3jdaJ5qtXJK+yKUZAsV8/lSJ/mDaX8DKFh9VFUUWTq6ce1oEPiOMYeJbqhZhDet 9msZDF7xemakijsCUzUWDVIjD0pRrAi/7Z9l3xnzg9mRDgGx16ioUkJBqyM2L0LZ7L8n MVMC171ra9oJmKkJ0DdlhdwbHGAdV9ZqCW9IkFTFJOf50vhc9yK3YNNurEtGh5468I5O V2a0IY4Kb91d+j7pHFYQJNUTvVqGbWXm+uJcAcYExeUxz57svsT430pjT/1nYkiiGath 4II/ltbzO/I0sVE4VJ7R47Juss/FdDXkIwNHIPSv+2bp6HSNqDxkwthailBXaT4TfGU7 RDLg== X-Forwarded-Encrypted: i=1; AJvYcCVMcrw1X8QUU6NUZBR/xQ0jVp71zQqBNlJpLEmHmmbh1E7kiUApufioNxODJ0de3OMI0WuE2J6fFwlrCUh/CwRhXIiO54Dq1vcyewveqXzoLmQ5T18= X-Gm-Message-State: AOJu0YygoYcaCq7OCIXD0+FWMzfGiye/rhpeIqiQ7wqK9DSO5YqqcfB/ QiQcDqq8rv1nhlOlus9r+/UNU1VZO79tyQfOV8kMlrFCh4vMrWgHKg6b7cAR63YhCdEtOdzJpP9 xexU= X-Google-Smtp-Source: AGHT+IHwNiMOfwGTEtSm5pHYqi8a9YlCde2eYXlQmXpSj0XEr1i8os+B9NNEoL8yfU4lANtZTlklkA== X-Received: by 2002:a17:902:c40b:b0:1d9:4106:b8b5 with SMTP id k11-20020a170902c40b00b001d94106b8b5mr234072plk.11.1709060647382; Tue, 27 Feb 2024 11:04:07 -0800 (PST) Received: from ghost ([50.213.54.97]) by smtp.gmail.com with ESMTPSA id v21-20020a1709028d9500b001db5753e8b8sm1848211plo.218.2024.02.27.11.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 11:04:06 -0800 (PST) Date: Tue, 27 Feb 2024 11:04:04 -0800 From: Charlie Jenkins To: Christophe Leroy Cc: "Russell King (Oracle)" , Guenter Roeck , 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: <9b4ce664-3ddb-4789-9d5d-8824f9089c48@csgroup.eu> <9f756413-806c-4cd0-a6cf-8dd82af14e88@csgroup.eu> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240227_110408_463113_EBC5A81E X-CRM114-Status: GOOD ( 52.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Feb 27, 2024 at 06:35:04PM +0000, Christophe Leroy wrote: > = > = > Le 27/02/2024 =E0 19:21, Charlie Jenkins a =E9crit=A0: > > On Tue, Feb 27, 2024 at 06:11:24PM +0000, Christophe Leroy wrote: > >> > >> > >> Le 27/02/2024 =E0 18:54, Charlie Jenkins a =E9crit=A0: > >>> On Tue, Feb 27, 2024 at 11:32:19AM +0000, Christophe Leroy wrote: > >>>> > >>>> > >>>> Le 27/02/2024 =E0 11:28, Russell King (Oracle) a =E9crit=A0: > >>>>> On Tue, Feb 27, 2024 at 06:47:38AM +0000, Christophe Leroy wrote: > >>>>>> > >>>>>> > >>>>>> Le 27/02/2024 =E0 00:48, Guenter Roeck a =E9crit=A0: > >>>>>>> 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 ke= rnel > >>>>>>>>>> defines to be supported" is a gross misinterpretation. It is n= ot > >>>>>>>>>> "defined to be supported" at all. It is the _preferred_ alignm= ent > >>>>>>>>>> nothing more, nothing less. > >>>>>>>> > >>>>>>>> This distinction is arbitrary in practice, but I am open to bein= g 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 by= te > >>>>>>>>> boundary before processing them - but that might not have been = in > >>>>>>>>> Linux. > >>>>>>>>> > >>>>>>>>> I'm also sure there are cpu which will fault double length misa= ligned > >>>>>>>>> memory transfers - which might be used to marginally speed up c= ode. > >>>>>>>>> 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 acce= sses. > >>>>>>>>> There are even cases of both on the same silicon die. > >>>>>>>>> > >>>>>>>>> You also pretty much never want a fault handler to fixup misali= gned > >>>>>>>>> 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' :-) > >>>>>>>>> > >>>>>>>>> =A0=A0=A0=A0David > >>>>>>>>> > >>>>>>>>> - > >>>>>>>>> Registered Address Lakeside, Bramley Road, Mount Farm, Milton K= eynes, > >>>>>>>>> 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 resol= ving > >>>>>>>> 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 ov= erflows > >>>>>>> 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 VL= AN, > >>>>>> which means the alignment cannot be greater than 4 bytes. That's a= lso > >>>>>> the outcome of the discussion. > >>>>> > >>>>> Thanks for completely ignoring what I've said. No. The alignment en= ds 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 addr= ess > >>>>> 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 agai= n, > >>>>> and I can only think that those who are ignoring my comments have > >>>>> some alterior motive here. > >>>>> > >>>> > >>>> I'm sorry for this misunderstanding. I'm not ignoring what you said = at > >>>> all. I understood that ARM is able to handle unaligned accesses with > >>>> some exception handlers at worst case and that DMA constraints may l= ead > >>>> to the IP header beeing on a 2 bytes alignment only. > >>>> > >>>> However I also understood from others that some architectures can't > >>>> handle such a 2 bytes only alignments. > >>>> > >>>> It's been suggested during the discussion that alignment tests shoul= d be > >>>> added later in a follow-up patch. So for the time being I'm trying to > >>>> find a compromise and get the existing tests working on all platforms > >>>> but with a smaller alignment than the 16-bytes alignment brought by > >>>> Charlie's v10 patch. And a 4 bytes alignment seemed to me to be a go= od > >>>> compromise for this fix. The idea is also to make the fix as minimal= as > >>>> possible, unlike Charlie's patch that is churning up the tests quite > >>>> heavily. > >>> > >>> Do you have a list of platforms this is failing on? I haven't seen any > >>> reports that haven't been fixed. > >> > >> I don't have such a list, but I guess you do ? If all platforms have > >> already been fixed, why are you sending this patch at all ? > > = > > This patch is what is doing the "fixing". Over the course of 10 versions > > I have "fixed" the test cases to work on platforms that have various > > alignment and endianness constraints. The endianness changes were picked > > off of these patches and spun out into a different patch by you. > > = > > I originally introduced these two new test cases since I wrote the riscv > > checksum function implementations and these tests were helpful for me > > and I figured they may be helpful for somebody else too. > = > I see. > = > Then you mis-understood. I don't say your patch leave any platform = > unfixed. I say that your patch seems bigger than required, it is a = > churn. In addition your patch assumes an alignment of 16-bytes which, as = > explained by Russell, it just wrong. At least an alignment of 4 bytes = > must work on any platforms because of VLANs. Pardon my ignorance but I do not understand why VLANs cause this test case to be incorrect/introduce churn. The VLAN tag is a 4-byte field that is optionally included in an ethernet header. This causes the header to change from 14 bytes to 18 bytes. If the architecture defines NET_IP_ALIGN to 2, this pads the ethernet header by 2 bytes, causing the payload to be aligned along 16 bytes without VLAN and 20 bytes with VLAN. Another test case can be added that aligns along 18 + NET_IP_ALIGN but that does not achieve the goal of reducing churn and I would not expect those additionally 4 bytes to highlight bugs in any implementation. - Charlie > = > Christophe _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel