Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2623504rdb; Mon, 12 Feb 2024 10:35:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUVFbkLG4xFRqgMpMDSmtzqo0PjebEzQCFE1++/ijQIfX3zbdrTYSuM3rg6IwORf68V99mKI/OP7c9GPE95LldXQNhitUX8fVM5eC8QVA== X-Google-Smtp-Source: AGHT+IHVB6EvfJLvzUM3UdY9Wbu98Ztv6WR2dam79TWGvQ5F+U3cqQjvV6XxUhpBdzfISAHBgo8p X-Received: by 2002:aa7:8895:0:b0:6e0:329b:3335 with SMTP id z21-20020aa78895000000b006e0329b3335mr484042pfe.8.1707762912627; Mon, 12 Feb 2024 10:35:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707762912; cv=pass; d=google.com; s=arc-20160816; b=sFqXimwXF+U0NzFKaLx+4DeiFOB1SGxYr+TltmtoNxMZ1AHsb30EhWy6PUyDxnf7uS ka5FgdSo+5FNWVySMJvnOlZeOGgJ05NiMKCtPQoYs1moCb+WR9jtRmp9ev8rdJIOVGOf 8eHlmaBxpKxhMBQXBo+7WMOT3OY0d96akrbOSSWYSh+mTomyJAbyk+7vhmK4XVi6pT3F YOedwFmXOzHdWFI368M+XXUtHC2vAnOQHr0MJWkMDRZEvdejH/kc6fzgCbvKcUP5YUdi HZHWdK5DdvNFf7kcjCdDAN2PmzqMDz0UPJqMzVcsy+f5CwoK8prm1mNAwI/998yB8Fe0 fiHw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :sender:dkim-signature; bh=8xZH+LJYr2ytTKnIB9iZBFvkzmm+Pih3Yq/pScGROjM=; fh=GZEFy0V4/7xiSwVNnX7qTf4JHahum56qWMi/LdzMhRs=; b=PPkkIL0q05PaDJKf+BJvAVAj8yXysm1xHIf4cS8WhM5sHWMULrheFdDRJ0fePM4dUp KKxTLImGr6xzTeXZrUwK4AAGWex+fxJiv9OMgcga2EDuiAx3+lUcM7IxQw+h7cP8MwJN Fzfo7gbcdxeW3f6VBnw+hKdh3ZuiShJ5UCDnN30Cf/wEDtrkteQSJG8DUiMkf4cQhuJo HVskacmfE47TpSavKXwlL/orGq0+R0OB3Eq7S8i663k+HxC0aH66KmsEff8nah5/fo57 PgicP9jA1oLOmO9Xwr8RzhKPKmF1OYI5sF+2KRicCK3NapkzewHjcT3IA5gQcfk28wCv MrFA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NkjsHmxc; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-62193-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62193-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCUbx8m5eI6Lw5BGRz8spWEvJf8zROz4AZq4XGM8WieM8gfobPa4X/FFBlZ09bw67SBAESW/c33MA0HP9AMGz+7mcDYX5GSCEVrsAyhu+g== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id be7-20020a056a001f0700b006e07eb192fasi5186465pfb.165.2024.02.12.10.35.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 10:35:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62193-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NkjsHmxc; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-62193-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62193-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 634D3284919 for ; Mon, 12 Feb 2024 18:34:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0EF594177B; Mon, 12 Feb 2024 18:34:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NkjsHmxc" Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 732F6405FD for ; Mon, 12 Feb 2024 18:34:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707762854; cv=none; b=J2SBsKF1qOJ0QtdXqSSl1c1o70etFtm9vwnbr3ROtHGl9gE3Y/ahvfTxfDCNgmmIZ3wsXJfw6YzW+EgGGgf1T5qBvk02Y4u/zYIdWVOiVJOGpBE8EPZ4BzcuY72R1ZS7mc0zVBTPAmTnRrNA4fV+Z3dgMHBEqBGPE4YZb8coT9s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707762854; c=relaxed/simple; bh=rLdlJk7YMDLMzy9CS/8OoqlIhyb+H0Bw/6gJglvDQ/0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=XkQXBMgzZRqF0lSyCctaUleXg3sWUqxcbScu2EAPM6AaL7oc92350HrdNdwNjjyFgYvZPJy5iSrc5HKh0yd+CYR7Y87kJimiM18tmFQLF53nzc27C3hQrlBx+CjGiBODkev4r9sQKaGE6mC09NMC2LDml2MZDXORBlAj4ENL1sM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NkjsHmxc; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1da0cd9c0e5so25006875ad.0 for ; Mon, 12 Feb 2024 10:34:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707762852; x=1708367652; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=8xZH+LJYr2ytTKnIB9iZBFvkzmm+Pih3Yq/pScGROjM=; b=NkjsHmxcxwY5KDsMTb5LF9A/eKo5H3m61zJA8P92Qw3MD88oW2yyOrI/oof1K/HxwJ rKCTjWETzJqCjV7lcSRhP10DQYhHpfM8Y/3q3zEd47jcZrK9vZocHhId4Lsjr3g2FeAd vN04oDFDeB4tzLW4esUV0mjmdV05yeTl96LW7WIOhjp7Q6rPJHNYevB4VN0XBwXA0A6y qSfVt7xAEKlkNVGRrT7xxdl0eDKSbtiQH3EnxugmjfBvrfLRfaKm451enrY/df8fF2vy 0v0Fyq4S+I2MZluOY66B0tWatnMmzSvsY2OoypssbjAUfdK9ZQ3J0409LVNN7t2wJwFn S/Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707762852; x=1708367652; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8xZH+LJYr2ytTKnIB9iZBFvkzmm+Pih3Yq/pScGROjM=; b=MKOYeCFm4brxNEu1uxtQAvBBs+NtrGUv3gToURAa6ptKm8wbzdSV/JqtTAk7d57UzW Mal27t0UBnM5dGNv9yLEe5BDOLqzkq34YoJDcB+iBR2AA+ZBc5ajO7Yz2IZ6jVApD+PY XrwjpXV/UF4u2Et++HLmz1v2fCEmdoZyKhijBeftxCLUU8AwPtP7M6VLxyODVB5wD6QP bGSoNs95LZ/ZB5PBTkRW+aa+LOKzjWIoadpzxb2l5DAhLuyeszM+QAI3TyUsSyFmrUuu CAEDjJFgBP7BZ0ub/AdY1+7SNDpuVDdnwwLkD0L/0RK+Ct5GV6hdiwbcYqvStIsOYLLt +g0w== X-Forwarded-Encrypted: i=1; AJvYcCValvILMyeY/3Bs1VHjSaKrhYN7chaVsNGA8EAvF+IJsz/EfeoJuEy0k/LpmGmFqBjc6uH99jMR7G5P5ETwAjTAvExTP24jwyJWlTo/ X-Gm-Message-State: AOJu0Yw0xOpDvnjZiKjLy9RlzJ2eliPnlH5ivqgD7bUOwIT79WA4PD0o 3NcliA2w5uO+uRS9gk9hfh2Ax+R8slWAlDO7bS+plmYrD9bOF46dYaAwu63A X-Received: by 2002:a17:903:32c3:b0:1d9:7587:8298 with SMTP id i3-20020a17090332c300b001d975878298mr371566plr.23.1707762851651; Mon, 12 Feb 2024 10:34:11 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUQU8W767PmlSwLi9hHXQE6YkfKKIqjtr3nPZAFxfqS9iKxlNwTsW1fuNwsFnWIIvJRh6iPpkXWrgHl+Ql6F/HIZar14eynHFYYh7+loi7a+9+nPi5cLRxUZHdxx+2MiswwEdTvBzh0TO2ctSktuBQUwFgbLMFK3Db0SJvOP3iplsMJCxUffhkXNPG2dgR8WQi/J2PA Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id iw11-20020a170903044b00b001d986ce6893sm649405plb.198.2024.02.12.10.34.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Feb 2024 10:34:11 -0800 (PST) Sender: Guenter Roeck Message-ID: Date: Mon, 12 Feb 2024 10:34:10 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 2/2] lib: checksum: Use aligned accesses for ip_fast_csum and csum_ipv6_magic tests Content-Language: en-US To: Al Viro Cc: Charlie Jenkins , David Laight , Palmer Dabbelt , Andrew Morton , linux-kernel@vger.kernel.org References: <20240207-fix_sparse_errors_checksum_tests-v6-0-4caa9629705b@rivosinc.com> <20240207-fix_sparse_errors_checksum_tests-v6-2-4caa9629705b@rivosinc.com> <20240212062614.GI608142@ZenIV> <52393411-8313-4e94-9618-916b57f7d52e@roeck-us.net> <20240212181217.GK608142@ZenIV> From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RTNZT8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yovVAPncvV9eGA/vtnd3xEZXQiSt91kBSqK28yjxAqK/c3G6i7IX2rg6pzgqh hiH3/1qM2M/LSuqAv0Rwrt/k+pZXE+B4Ud42hwmMr0TfhNxG+X7YKvjKC+SjPjqp0CaztQ0H nsDLSLElVROxCd9m8CAUuHplgmR3seYCOrT4jriMFBtKNPtj2EE4DNV4s7k0Zy+6iRQ8G8ng QjsSqYJx8iAR8JRB7Gm2rQOMv8lSRdjva++GT0VLXtHULdlzg8VjDnFZ3lfz5PWEOeIMk7Rj trjv82EZtrhLuLjHRCaG50OOm0hwPSk1J64R8O3HjSLdertmw7eyAYOo4RuWJguYMg5DRnBk WkRwrSuCn7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= In-Reply-To: <20240212181217.GK608142@ZenIV> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2/12/24 10:12, Al Viro wrote: > On Mon, Feb 12, 2024 at 09:18:14AM -0800, Guenter Roeck wrote: > >> Almost. Turns out the csum parameter of csum_ipv6_magic() needs to be in >> network byte order, and the length parameter needs to be in host byte order. >> So instead of >> data.len = data_ptr->len; >> data.csum = (__force __wsum)htonl((__force u32)data_ptr->csum); >> it needs to be something like >> data.len = ntohl(data_ptr->len); >> data.csum = data_ptr->csum; >> >> Also, as you mentioned, either the returned checksum or the expected >> checksum needs to be converted for the comparison because one is in >> network byte order and the other in host byte order. > > for (int i = 0; i < NUM_IPv6_TESTS; i++) { > struct args { > struct in6_addr saddr; > struct in6_addr daddr; > __be32 len; > __wsum csum; > unsigned char proto; > } __packed data = (struct args *)(random_buf + i); > CHECK_EQ(cpu_to_le16(expected_csum_ipv6_magic[i]), > csum_ipv6_magic(data.saddr, data.daddr, ntohl(data.len), > data.proto, data.sum)); > } > and to hell with field-by-field copying. __packed here will tell the compiler > that alignment of the entire thing is 1 - the total size of fields is 41 bytes, > so "no padding" translates into "can't even assume that address is even". > Except that the data pointer needs to be aligned because otherwise architectures not supporting unaligned accesses will bail out (as observed on mps2-an385). But then I am no longer sure if that is correct - maybe csum_ipv6_magic() is supposed to be able to handle unaligned accesses. If so, maybe it would be more appropriate to skip this test on the affected architectures. Guenter