Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp187913rdb; Wed, 14 Feb 2024 17:58:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW3XnP9QJ+ElPrJk58+6XyF0Wci8XhXsm9fDoaCHSVHRDDrvigxDhzpIyplr7+kFKASlVjhwFA3AxmWi1kLhSzG1s/MN+WS9oVVHr/rSw== X-Google-Smtp-Source: AGHT+IEqI7YeWUGZbmqloqb360CpEVZjx1MJhYX/f9GIGZrnvk34xOGiaLFmMAGg2mklYnxhcHvU X-Received: by 2002:a05:620a:2159:b0:785:7387:4c0e with SMTP id m25-20020a05620a215900b0078573874c0emr486253qkm.21.1707962300092; Wed, 14 Feb 2024 17:58:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707962300; cv=pass; d=google.com; s=arc-20160816; b=dKE0rGEeX0YX49eUKu2AamWqLpZndsWoofktFDw5mQLRrWKD0qgospUHWR5Kp9oj8d o8sgJBnVS34e+xUvz8wxm68zgXNKwoslrxJVOJtIpxlCS0rjKf6lGLKNUj51FEsUWMAz 5gWM7KDrTQJxgizKCZt+nwUxGK0aO47FKNtszxV5gpJuvnlYaUpdFKdLks8J1SmBVt5c y8MgKJI73KJMShsHz1bRoIY8Q/Ap8Ydyf7dP7wmzsxRAVQDdFT6XmqM63/2ckiYBfeuB 3gxau49U8R3veJOW+yOtgB3XrAX7UOwYEByh+kI0FIVyVnCK2j4RjT3RRdardiFWCYeb o3PA== 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=htGW/e8GI+F2UFASV1GomX9AsIMgFedKg9ypjTyRfqk=; fh=vz4dpMILz5g9qoPzcgvlWqfoNlqQ/GhlJGQQEjdoWd8=; b=ycLVLXQlu0mdfWhOqoNoTqJ4n+K1coAKJZCZ4zN+cN8yGi3Ua9dgngCGF5xsSEIcCC mjAkj1AvOptljlpRZjhRXWS8C0AYUBrasAxGCry9CZjAVM9Vjvu2EaI0vcVa5n8LIwEY pwDgZ51Co16mNJpg4iPa4QQxLmMuHmy9BcBDGQ4fSWl581fdGrKtlQeC8RQ+LFQc15ic bLCyMgJgJc1UHyBIRLwOiR3jE7iFB2OXYBTeK7Keo9RqEMJbF19gdNBLMY+/0uwl4Qtq +NbfDNtqIYOyHTHZ44QjZppYt2MfKGv+MrGtcdUzVg0dWpA/DXyoXAj0gYjsHlcToTSu HzHQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Y5WoLlHd; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-66234-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66234-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id l8-20020a05620a28c800b00785db666b7esi480691qkp.739.2024.02.14.17.58.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 17:58:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66234-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Y5WoLlHd; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-66234-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66234-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 C47221C2333A for ; Thu, 15 Feb 2024 01:58:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 158E61C15; Thu, 15 Feb 2024 01:58:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y5WoLlHd" Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (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 3B26D184E; Thu, 15 Feb 2024 01:58:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707962294; cv=none; b=mzoVLNBUJUMtImrnyeF2GUFXbzR9duNjTjWrO/RXXjBmryNT4uZgwCWzGP6duJBp9NB4ZZMR6vopx52q9+6iCf3d9uOnMY9xSf327S2B7uGqCnw6TeVgSoivxgOc+rnTWYoTNYharygYJF5/x7msyOf5snxBCyfZfapi074IW2g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707962294; c=relaxed/simple; bh=dyYKjfJrvnkHCRfDScJsdh2BCcE8PsyhqJ4uBpiLcQA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=mmm8sbETePUtcJC8TZyC1jSlHYpozwJfKV9mzHaKDPuItxONjJXd1Xsf9qV7kL6YYN4LH3etiAbemf7eeosET51uKXzR764/WY9LuEqez1DY7D39re2biRspu11Tn/vJulmzAGu0QgpMVjc+3UtUdbnFO2O3XbFR2J0B+QLn2BI= 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=Y5WoLlHd; arc=none smtp.client-ip=209.85.215.174 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-pg1-f174.google.com with SMTP id 41be03b00d2f7-5dbf7b74402so345084a12.0; Wed, 14 Feb 2024 17:58:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707962291; x=1708567091; 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=htGW/e8GI+F2UFASV1GomX9AsIMgFedKg9ypjTyRfqk=; b=Y5WoLlHdxLNB+YmSyCzT9XQ+7ui5YD5RxUc41pyGgDAmkRjcxfTfsXmukcanLM1tjk TmdFUYraYKMSD9s1iKmSJpo0OH20HM/YBZW/s7nmyakI/Z9/CXqzTNoGVCa7qMK+JTuN udB7MhnYBgM4T11hp7yoa9eK0Wi+b8iw/aHFuMy/FvMEpWfiZ04NnUP9pqOKwNTnfp4C Qj1rMO/4g31vA1r+RQ3G5top4I1hrveaysMt/EoQtiEfYYMuN/VBqzcBJLiTQAx0eqSP b1CLhKrMGN1/PoDgpC0av/SQWQ2dMM3kGq5MRF+xkQRxZjR5P/V+N0jTdKPHvnnzFk24 Yreg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707962291; x=1708567091; 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=htGW/e8GI+F2UFASV1GomX9AsIMgFedKg9ypjTyRfqk=; b=MTzK3O3uOqLJBtry644QYEBu8+OKySByUA388bKTVcgNLhyXslCIp73lmKomWhSh3J TWArQ9FH+A6amgp9v4BfHgpbeUdXWzGIkM5WNi9FkacL/SJ162fq3T1O2XRqSBezbv94 kbyblHZD0hQuog0c0bpuq6CxvxStg+FAPvG7xynIVlrmhHUeEEKsLtGca4DK8oJ/lp8f H7kXWynS6XPanZ82ani5DCuWPeNyZltVRY++45i0Nmij7dd23U5hyn1GhX2kA4WLqo7D +1DDQ1kjNX5W5nQ9PjwRy/rQUGFmxSsBgp5szp8VpRN8NOrj+QG46yKF7AjJ96XZkX6I va+w== X-Forwarded-Encrypted: i=1; AJvYcCViQ+UGP7CENfRp86OMYo7/hSf3LiVuFjVGFOzO6dzMG5fHOeo5YV1ZC+Q/N85mQB62oZ3kzYwnIHrb3vdMpEpS4EZGeog3TjJTNPVASwp0wRnyTVgeVDY6R+SZVUqvzpdaAluH10CWQca7 X-Gm-Message-State: AOJu0YwmIlEN55Ma3TUSnbbTVbnINJgCAoo65/evaYVZDe7g+WOomSjP ny2H8YtMVaq0ULRJGe5CXcFEGNo+R0qks7++X5k8+0MLKbKuRUBhSnHr8OGt X-Received: by 2002:a05:6a20:e605:b0:1a0:686b:afec with SMTP id my5-20020a056a20e60500b001a0686bafecmr605289pzb.10.1707962291398; Wed, 14 Feb 2024 17:58:11 -0800 (PST) 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 x41-20020a056a0018a900b006e02f4bb4e4sm127106pfh.18.2024.02.14.17.58.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Feb 2024 17:58:10 -0800 (PST) Sender: Guenter Roeck Message-ID: Date: Wed, 14 Feb 2024 17:58:09 -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 v8 2/2] lib: checksum: Use aligned accesses for ip_fast_csum and csum_ipv6_magic tests Content-Language: en-US To: Charlie Jenkins Cc: David Laight , Palmer Dabbelt , Andrew Morton , Helge Deller , "James E.J. Bottomley" , Parisc List , Al Viro , linux-kernel@vger.kernel.org References: <20240214-fix_sparse_errors_checksum_tests-v8-0-36b60e673593@rivosinc.com> <20240214-fix_sparse_errors_checksum_tests-v8-2-36b60e673593@rivosinc.com> <2ec91b11-23c7-4beb-8cef-c68367c8f029@roeck-us.net> 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 gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RTNZT8ICq/Jmvl0SpbHRvYwa2DhNsK0YjHFQBB0FX IdhdUEzNefcNcYvqigJpdICoP2e4yJSyflHFO4dr0OrdnGLe1Zi/8Xo/2+M1dSSEt196rXaC kwu2KgIgmkRBb3cp2vIBBIIowU8W3qC1+w+RdMUrZxKGWJ3juwcgveJlzMpMZNyM1jobSXZ0 VHGMNJ3MwXlrEFPXaYJgibcg6brM6wGfX/LBvc/haWw4yO24lT5eitm4UBdIy9pKkKmHHh7s jfZJkB5fWKVdoCv/omy6UyH6ykLOPFugl+hVL2Prf8xrXuZe1CMS7ID9Lc8FaL1ROIN/W8Vk BIsJMaWOhks//7d92Uf3EAr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k WkRwrSuCn7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Charlie, On 2/14/24 17:30, Charlie Jenkins wrote: > On Wed, Feb 14, 2024 at 03:03:07PM -0800, Guenter Roeck wrote: >> On 2/14/24 13:41, Charlie Jenkins wrote: >>> The test cases for ip_fast_csum and csum_ipv6_magic were failing on a >>> variety of architectures that are big endian or do not support >>> misalgined accesses. Both of these test cases are changed to support big >>> and little endian architectures. >>> >>> The test for ip_fast_csum is changed to align the data along (14 + >>> NET_IP_ALIGN) bytes which is the alignment of an IP header. The test for >>> csum_ipv6_magic aligns the data using a struct. An extra padding field >>> is added to the struct to ensure that the size of the struct is the same >>> on all architectures (44 bytes). >>> >>> The test for csum_ipv6_magic somewhat arbitrarily aligned saddr and >>> daddr. This would fail on parisc64 due to the following code snippet in >>> arch/parisc/include/asm/checksum.h: >>> >>> add %4, %0, %0\n" >>> ldd,ma 8(%1), %6\n" >>> ldd,ma 8(%2), %7\n" >>> add,dc %5, %0, %0\n" >>> >>> The second add is expecting carry flags from the first add. Normally, >>> a double word load (ldd) does not modify the carry flags. However, >>> because saddr and daddr may be misaligned, ldd triggers a misalignment >>> trap that gets handled in arch/parisc/kernel/unaligned.c. This causes >>> many additional instructions to be executed between the two adds. This >>> can be easily solved by adding the carry into %0 before executing the >>> ldd. >>> >> >> I really think this is a bug either in the trap handler or in the hppa64 >> qemu emulation. Only unaligned ldd instructions affect (actually, >> unconditionally set) the carry flag. That doesn't happen with unaligned >> ldw instructions. It would be worthwhile tracking this down since there are >> lots of unaligned data accesses (8-byte accesses on 4-byte aligned addresses) >> when running the kernel in 64-bit mode. On the other side, I guess this >> is a different problem. Not sure though if that should even be mentioned >> here since that makes it sound as if it would be expected that such >> accesses impact the carry flag. > > I wasn't confident it was a bug somewhere so that's why I sent this patch. > > However, I have just found the section of the processor manual [1] I was > looking for (Section Privileged Software-Accessible Registers subsection > Processor Status Word (PSW)): > > "Processor state is encoded in a 64-bit register called the Processor > Status Word (PSW). When an interruption occurs, the current value of the > PSW is saved in the Interruption Processor Status Word (IPSW) and > usually all defined PSW bits are set to 0. > > "The PSW is set to the contents of the IPSW by the RETURN FROM > INTERRUPTION instruction. The interruption handler may restore the > original PSW, modify selected bits, or may change the PSW to an entirely > new value." > > Stored in the PSW register are the "Carry/borrow bits". This confirms > that the carry/borrow bits should be restored. The save is supposed to > automatically happen upon an interrupt and restored by the RETURN FROM > INTERRUPTION, thus this is a QEMU bug and not a Linux bug (please > correct me if I am wrong). > I know that much (I looked into the manual as well), I just really don't know if this is a Linux bug or a QEMU bug, and I have not been able to nail it down. I think someone with access to hardware will need to confirm. Specifically: Yes, the carry/borrow bits should be restored. Question is if the Linux kernel's interrupt handler doesn't restore the carry bits or if the problem is on the qemu side. > This v8 was not needed after-all it seems. It would be best to stick > with the v7. > I tend to agree; after all, v7 exposes the problem, making it easier to determine if the problem can be reproduced on real hardware. FWIW,I wrote some test code which exposes the problem. It is quite easy to show that carry is always set after executing ldd on an unaligned address. That is also why I know for sure that the problem is not seen with ldw on unaligned addresses. Thanks, Guenter