Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2634719rdb; Mon, 12 Feb 2024 11:00:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV9l6b6eF70wgbif0lILBsy/l2E2hw+1hFVEJMAtgNY01GsSAnDoaDtFHlxHnI3Wt8LS/kH2jB+iq0ENDTb+4HoskeBFel/sW0oozRiZA== X-Google-Smtp-Source: AGHT+IF0MWD8Wh32t2MaRmj6TfIybOroVfdAXfmKfjUo1UvIp1tP2C0NAdhXOZNzTEV1E/caUW5X X-Received: by 2002:a05:6a21:8cc1:b0:19e:3af0:af33 with SMTP id ta1-20020a056a218cc100b0019e3af0af33mr5622332pzb.60.1707764434663; Mon, 12 Feb 2024 11:00:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707764434; cv=pass; d=google.com; s=arc-20160816; b=zymeNxP3ndFjYhXhbcFVuIJp56cY+tJUCwxZawWqaHLfGNrzEEcXDXcCkR235uC4UL yh6I9yP48MYMjgYZQ74YOnLDAhAzRkn5zjexLYCXXV0z9RFKwICIBzlC8xCTLcDVT8rN HRLQepYXaQP4xwVk8ttsz0qId7DaFSdxiCLAV2zAa6AzVt+MP4OPT4PCT+QgtrOJQZNW 0ddHmG+gKccEUFtEobPRP9hqIMVDEUem2DvgKy8Q+VTyazAaQ2lgzb6mQlWsyC+WyCn/ FkTz2tXSJXycIFr95e4dZm/VoSiiK8E1e5sDn/I6DyjAuE25db4CUKpWSHF0LFHLRPSo D/aA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=hZ+z4h99xk76bC0VjnOkqFzJOKFwImGd/nxclb3UUVI=; fh=Vj7TotBJBHrhEIsPDQQVbRVIkzAeCruRNOytNTgsdXs=; b=AW0DEpBj0mYxym7b3LGv42K9UIKJwsBiZoTJ1XB9+l/QTMBDMZOYCWExcpO6lFBr6v VWFhCiCx9W4DXiRvFmEQ/5tK2t/R1eHYuVWb0qdo3Y+yHf2iSpfP2Val2GwMxSqwFYQS mcKy56WyQceDR+4nXjN0FMklaicTMFL5DIoKpxNUwOl5fcljOOKuIMs+fbj4Xqozbwf1 cA+VXFKNWM74hPXF4JFVZPN5v2t/noO5RuzZwAD3G2zrelEsZ3XjOfrPMZY9zR6R+3U6 1SF58fvdUxBKYRnOPXbbVKc5f8d7BnQhsq9kjrtFqH29l3tZu3QYVxJLFG8ZKR72qUbZ mAcQ==; 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=gynNsN1O; 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-62205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62205-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCXH06u4bhJbWtoSZpdhTl4+hdiehXEl4g/bexbLMYpAqxok72stxq3ok14XcLKnI9J/DDPnpFpt56Q5KtnWnd1YLnyYJ4/8MSmR8MgmEw== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q10-20020a056a00084a00b006e0eaf31b59si943098pfk.41.2024.02.12.11.00.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 11:00:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=gynNsN1O; 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-62205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62205-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 39EF0B22C88 for ; Mon, 12 Feb 2024 18:41:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EBFE941236; Mon, 12 Feb 2024 18:41:33 +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="gynNsN1O" Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (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 13BD941206 for ; Mon, 12 Feb 2024 18:41:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707763293; cv=none; b=ppAXmJFHbJJgZnoMh0+nc/rCFGCsx3NI55Essu1qMCH7d15Vk9BTlJKWpWmfD0mN0HvSBq4kYYdoxprNlIBo5e+gFz4M0xRv4GhGs6mrgggR6c+QREUJINDqPnjmUefA3y+YG0DGdpyK521LoanyYlFal1nYrC2ktk2cZXediCg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707763293; c=relaxed/simple; bh=3Dt864qUNEbymlghTdrDS4OLQ1vHcnhvXcqDgliILAo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BJnfOChDKi1atcVdn/2Wr1bDVrR7cOg9/q+RWGK83YDkxdpepLIRGmdVIG2hN7liq2pSicUJud2+rktxjhYbtO/9giYMRnVCYmKF2TTOzac3wbrku3c1rNvWplbVi/cTkQPVDSEdB3hL/lFpjAjpFceCYpUDLE/tF61hXKawUAQ= 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=gynNsN1O; arc=none smtp.client-ip=209.85.128.180 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-yw1-f180.google.com with SMTP id 00721157ae682-604966eaf6eso32022177b3.1 for ; Mon, 12 Feb 2024 10:41:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1707763290; x=1708368090; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=hZ+z4h99xk76bC0VjnOkqFzJOKFwImGd/nxclb3UUVI=; b=gynNsN1OFvr4vbDYEZTsj4wi7hN0ZCAF/esKZbGrnXOqoKUQV63VXp9ZXn0apYABMO OVzE1BfoEygUkbh48DIFM3+uFHaYpPBzoxZisz14Ll7sfgIPAaEbRwm0WttP9LT6ExSA ahZ3KM0rYLM+NB03TNBMUSA5tgTj5vteYFsr68zmUho/bxeIoPXaCjM2STO2siJuNI22 UT/pKeACGFTCu230PQzEI6cp/b9JZ6AzFX7B7P0hRj6nwR19c06KuUlx/TMLdlXpW4R8 PyN3H6OmlVKL37KLV+gHAZMKNLtm6ay9ExdchSlGyH0LmItwVSTrorocGJwJZSZWxzi1 BTww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707763290; x=1708368090; h=in-reply-to: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=hZ+z4h99xk76bC0VjnOkqFzJOKFwImGd/nxclb3UUVI=; b=m65QtlNsma63w52xyAWbGUxZRnBTP1ngmOEprQV9H2Ze7WU4kqcSf2sHKdLpcH2AOb 1iuAflfo8UaH7XiIR4iOxzLvVuOiG3/uvWPI25o82kV6SVG5tU2HGoj1KKKEThmXmudt HAqKMZFWuTD33AlRRwKDIVpInDBJJsQ7c5WM2qUiwpALvJpn9matLlGcaMqU4uwl7Na8 4USvAddMjTRsWiqMHGhmmqaWqRUeOcPhC+qB2q9980t4DUXQishxZGV4d80ZUsQgmDUX kqoBM9MS4+0V68xv6moOnkImcoTWK9v1CBVKx1aVwUza6XLcNmG9p82btQvN8BWdS0eN fWhw== X-Forwarded-Encrypted: i=1; AJvYcCXg6UeenDdUc6jGSur7StfF6odTNUgtXWWBL6sVPJWQhpR1iqnJtJvZX3dtxXobo+fOCvsZ+zVIZkc1RBW9Gklv+eh/Iu5NkytpsXx5 X-Gm-Message-State: AOJu0Ywie6yJNxfw/IeqHsR2zngcEBl6vfSs1sjJq77ma8OtvnkdFCLk S4IRsJhKKHOwqlF7wRGI/oNAQxdku8wSAKOfBA8ewalI0XD+IKj/btKoRnkIthU= X-Received: by 2002:a81:8395:0:b0:607:7a9a:4066 with SMTP id t143-20020a818395000000b006077a9a4066mr955361ywf.2.1707763290013; Mon, 12 Feb 2024 10:41:30 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVcG6jKDgpj4ZPVkJTxjwMfnlr6nEbPD9QZKPNlefMcVBVjbx9R18RFoMIPeICtwnZvKJiaL/oziV4QQLRmEVQALJ1I2MGvjUCjzaUfiXi5hKgqHKRAOwLkCgH+jbecf2LkYSjX4CliKNX5Jpkb1gFfE6FLMQWQcpsGUwWfUni5qquk4rEu50Bjhbz4gRa7QA4+tIvT Received: from ghost ([50.146.0.2]) by smtp.gmail.com with ESMTPSA id h13-20020a81b40d000000b00604941e2f1fsm1269354ywi.130.2024.02.12.10.41.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 10:41:29 -0800 (PST) Date: Mon, 12 Feb 2024 13:41:28 -0500 From: Charlie Jenkins To: Guenter Roeck Cc: Al Viro , David Laight , Palmer Dabbelt , Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 2/2] lib: checksum: Use aligned accesses for ip_fast_csum and csum_ipv6_magic tests Message-ID: 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> 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=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Feb 12, 2024 at 10:34:10AM -0800, Guenter Roeck wrote: > 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 > We can align this against IP_ALIGNMENT since it should always be aligned against the IP header + NET_IP_ALIGN. - Charlie