Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2077941rbb; Tue, 27 Feb 2024 09:55:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWRa7V5P09h7EwEj3+i3aHQJ4dZWb81gebmSq62wcXbOp3TDbBWS7nlVymDZrkUxapS3BCdnJ4Wwxqb+Wzlb9P8NkZPeQnic8koXpC8bg== X-Google-Smtp-Source: AGHT+IHE4/2fOL0W9dvx8oPJO/VB/5FVJxawfAXUJdcg+L8aFIBUmOfp8FSTLxTY87ltQafrpi34 X-Received: by 2002:a05:620a:2116:b0:787:c697:7dfb with SMTP id l22-20020a05620a211600b00787c6977dfbmr2908990qkl.53.1709056503192; Tue, 27 Feb 2024 09:55:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709056503; cv=pass; d=google.com; s=arc-20160816; b=vVxhCd1Exki4z0g0Lr2VDQmND7Wd+b8jsWffxYLapNLfzCNCD6AoAEQcoKu7Op9IDA ULKL6XWI6mszSHU764vFldj2C43hRRhsqDSdwn0kEPKtmG8l427ThJ8ZMZJhIKhCmtNY oU3Z/0oEM+cytxs/Uh3q0qVnsxQYG/2H5XNrnLLFDQk+5Lv9geoNlAgN2aP3F9MIKqOf VE/tM7eO0vVJIHtwocqIFJDovQFc8cc4XrRPe69AGY6vgF04yWu+clD12VREx8iXDA78 Hmq+zpmYxLPgyYuz7RusrstNXDZU6QUmM7xxmC7p4tVO2/51Vcs8IyvwOCs/80JKTyz2 al9w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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=kIdksP1jXgRqd1isvnR0Pk+ChLgtGPiZTFxnnPSsol0=; fh=vEjwvcP9FPmPuOICP8dSrpsv1iDeoIpdt2c9zBkWeN0=; b=bOEMpqFKUAfeNKIB1xL9MsIjAoSA00+rN7HV4BhWt4HRjrw/uVFv8FMT/keu/7BUgI QAePeHOiS4HZ1TZz8CNVyz6jUkv865oky4kc1GpotD2Vm9WKAc86CvYSzF7Q755TFjWV 28fef5Q3EtZZggMJow2S5wVuVHFABBjOBzfQZ+G7LSDFRU56gV2FePXdY2rXjT2khwX6 7mUUj9FZw5RVxuQashBzmE6p4mVU+Stg1lU+rdxE/1kyNM8QKDoKVSeAjkSzru0Wi6Ud EN2vZEIKZtIphL/Vm1KjsHdPr4IIyToQr4JAgKU1MlX7Xnmz9jJL0665NKvfZYA5lcN4 JRzA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=TZyWEU8Y; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-83777-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83777-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j6-20020a37c246000000b00787d3498ad8si4822129qkm.86.2024.02.27.09.55.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 09:55:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83777-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=TZyWEU8Y; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-83777-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83777-linux.lists.archive=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id DDB081C2380D for ; Tue, 27 Feb 2024 17:55:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD3314EB4A; Tue, 27 Feb 2024 17:54:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="TZyWEU8Y" Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D30B4E1A0 for ; Tue, 27 Feb 2024 17:54:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709056495; cv=none; b=X8POIkx6kUwzzivaDs9A42mmodMtvCNmdaobgIPq2EGl5xiILH+2KZubntKdvnfKVdDXUQEuaEPtKS/VD/HT/B7t9eUZaHLcuzgoV72+2J7t9I9u6fpYK8C91vrzcnaLca1sHdwy7D9v1x/1E2Uhuo/o8KQuC4hwQ5lwVSPtHXk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709056495; c=relaxed/simple; bh=VUAaY8wxXr5bUffmJpFRqHV2oMwBf/vlf3I5G3UUTGI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JHLyqNq7cui4VhHOZY3coagXGLRl3ICIwA3EaPBAXOiRkkwqq7epBDez/fbcPZG/zCn6XUdFYyhNf12lAOx/zq6f/GoS/fZgE5bY5yj22154Y1tsl7garJFVN2aLzV8OKNV0nj5RBzuMkouliO+ER5Cc2CamQsOx2BB9+LphNM0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=TZyWEU8Y; arc=none smtp.client-ip=209.85.215.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-5e4613f2b56so3154489a12.1 for ; Tue, 27 Feb 2024 09:54:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1709056493; x=1709661293; darn=vger.kernel.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=kIdksP1jXgRqd1isvnR0Pk+ChLgtGPiZTFxnnPSsol0=; b=TZyWEU8YoReS0giYCuMX1yk0jFICaJG4jcTNykPXsJyGXS0HB3e575BABK55a37ndj RA9Jq1AZc9Fo0YiGhRES7wMMw1hd5DMFGHQmIbl+3dISOBQtnNoB1PIF0EwBR3Q4ud2U OgUK7jkuXJnp3DaEEKtIqz8fwdYV34vv3uC4+Vykw0v/ZxuLe28u5alurmnyQyn44Lq8 SRgnrLEBF004FrIBQTzf3vQhDgxTy0TPu45xbgUTU1pqjb8FghAmkNybbnnA0NFBTSfS +lGFOD9+hnorDVSbGrGzyNybkSBySiIWJ8WSecbsgA7IpVJR2kdD8lNv7Y1XqBwsAeaI JMEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709056493; x=1709661293; 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=kIdksP1jXgRqd1isvnR0Pk+ChLgtGPiZTFxnnPSsol0=; b=CVEoyd7TxUxl4z6L14UVzYIqnPo2jENwt3yuGtN6gV0Y0e1MjojuFsemztX7kznJuk COGBT3YVx6NVuJc46cOs5++tVDi9B1uQ5ebm205IFuncGQZ0jB153cp90Gtvn4F8ucMb 3xcEuXwlOqXocdVHclpDmfefYrR3cJFvyWY9sd3wCsOUEaO8yFFLndoH/dNwjkQHAkBe oT7OCi2DhIpepCHRuN9Vpw8o7tIS5n+K4fheee8khIuzm7sNzZd/5UOXx4O4piYw0Y7U rKuPIyyoRSgJm1JlimpGR4+9YUKuC2G0cxqsU0aHgRn3yjcH7h3wSnmew1kEfHs7ehk8 97UA== X-Forwarded-Encrypted: i=1; AJvYcCWK6hy72TfFfR1m8obpbDnyyYuG3n9nSpPo3gTPAXmNmqFK5bxN0YCU+S7Sf+o2miTDzwOskeLgAJl4SYqrz4o3BW4erNO4v1qMaeey X-Gm-Message-State: AOJu0YwGG80xeIcmAEkMlsW9fSMWYqLSoYEgh/LXE0vZ1vMk2rEKG76S Eq1zlx25xn6A/rrI73KgbavNPxwu66JnGKzdbHMdRkc9Y5lUE5het+ikaIg9JYk= X-Received: by 2002:a17:90a:6f01:b0:299:75aa:8949 with SMTP id d1-20020a17090a6f0100b0029975aa8949mr7822691pjk.22.1709056493179; Tue, 27 Feb 2024 09:54:53 -0800 (PST) Received: from ghost (mobile-166-137-160-039.mycingular.net. [166.137.160.39]) by smtp.gmail.com with ESMTPSA id n15-20020a17090ade8f00b002995e9aca72sm6856207pjv.29.2024.02.27.09.54.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 09:54:52 -0800 (PST) Date: Tue, 27 Feb 2024 09:54:49 -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> 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: On Tue, Feb 27, 2024 at 11:32:19AM +0000, Christophe Leroy wrote: > > > Le 27/02/2024 ? 11:28, Russell King (Oracle) a ?crit?: > > 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. > > > > 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 lead > 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 should 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 good > 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. - Charlie > > But maybe I misunderstood some of the discussion and indeed 2 bytes > alignment would work on all platforms and only an odd alignment is > problematic ?