Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp595287rdb; Thu, 15 Feb 2024 09:14:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXBVIKf4EPkMG0g/9LyJNpLOpHpkga6oYztJHyFRbodUsK5OensJfrdRabC8lxAP7UZFBmMMSMmC2DNH8aoNry00pXoSWyZL3+HiwGfgg== X-Google-Smtp-Source: AGHT+IGMkqfkA8sEDu21OzXNPKKuTsQM8S8NzSpvFWbj9DHlW5rt6Xg0R7N+H2rFmDRzSblBHGIv X-Received: by 2002:a17:90b:fd6:b0:299:13ce:e6cd with SMTP id gd22-20020a17090b0fd600b0029913cee6cdmr2503988pjb.17.1708017264789; Thu, 15 Feb 2024 09:14:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708017264; cv=pass; d=google.com; s=arc-20160816; b=cGwNZCQkNHHGMvmgLZ6+MVcDsPb2c/t2OhMEC9IAFYTzhNpH06jgFGM0HjdcZwCO8N +/QpnwLgsnjion+mg/nDyW2iKOh/Kf9xm+eaFHQR6Nh1Vbyq3qWJJ4QyP+GrsasgBcsy qQqgXTa1pQenDXVY3LYNYN/DCGHDqkYu18txwohCHDz7OK/Zqrc9n+j/ldLwKNUbYa8/ wBpm9towgKd7NNOnZFmyhTWa72nv26xl3+eRvl51CwGOVuBkTOe9k+tCAOAQ/4gxAGvj YFWN7pW2UIhq3Bc0sJr5c6i47DYcaaNNAglbs04QpNs30fYVL6yKFOYb2Hn69yw1d6Oi zf5A== 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 :dkim-signature; bh=iqJuGfFuA5gl5PeHMO0DsPwaamL0d2WArzsU05LdegI=; fh=7MBIOlGl+q/S6TEOTDmrAT67cey4v7rsr1vlcFOU5OQ=; b=Jv42Ru74sIftFWnbYtkkiEyrqqA5VWs0yqWgDLvxsfaD175O4dWaxI9GXvLwr81Vza m96vswAKgnRgiBLQZl8giK63zMj4UmG1RCaBieDupLlhdHR6JFQqrO77jVAGfdyBaQQY TTYbG6UccFpjv6Zrp9BePyfx4MHcscGxB0ZEAJLe9uoH+3W8PN2L7ZHBvQznFjX+vXjv on1opUzukxDWlrg9RTlwSQB2Q+OyYkijq3e5e59Yn6SRjclt7Tk4IX4W0a6YLiqQraqv b0bs+5lI4h19nL1EtmEX6UrWrMuEzzEPbPm4wQiuPQlLHO5IVJ2kZsIEm94lEZus4h4H fLzA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@bell.net header.s=selector1 header.b=ax+RyCnx; arc=pass (i=1 spf=pass spfdomain=bell.net dkim=pass dkdomain=bell.net); spf=pass (google.com: domain of linux-kernel+bounces-67382-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67382-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d7-20020a17090a498700b0029692a93e67si3271138pjh.64.2024.02.15.09.14.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 09:14:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67382-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 (test mode) header.i=@bell.net header.s=selector1 header.b=ax+RyCnx; arc=pass (i=1 spf=pass spfdomain=bell.net dkim=pass dkdomain=bell.net); spf=pass (google.com: domain of linux-kernel+bounces-67382-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67382-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 7C1A728A22C for ; Thu, 15 Feb 2024 17:14:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E8904136675; Thu, 15 Feb 2024 17:14:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bell.net header.i=@bell.net header.b="ax+RyCnx" Received: from cmx-torrgo001.bell.net (mta-tor-005.bell.net [209.71.212.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20095136663; Thu, 15 Feb 2024 17:14:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.71.212.37 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708017245; cv=none; b=Iwq8pRm1yV5tHB9dhB//S2Kw4fzNdeiFZiW8P7aZT6TBThmXFCLb1Rsls6Hlsd/BEqW4nRRLByZx01EaI6AqYwdbAqEIr10cFyEw6SJ9dOcyMSvJMli0ap0saw4zq8+6wYJcgec6K0w9PgFtgqxBuEU+iEUsuiJnJ35Dv5W+oeg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708017245; c=relaxed/simple; bh=wMQZAjVaywaNaVIoUDPK4cu/c4mz5snPDQld1MSr6hU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=mZtJvty7MuZzzYgscHOx3JpJ5+HDzB8+yr2vWmN/bNjC4fBhMfRYjeWixWtVeIlqnOEMAu8dg4A0gQgL7JIDrA8CwxASLvKCK34aZpuTxdmSuZjOo15jz2IwsByp67i72Jh7JCZ+mGfA/eP0nvJc4SKJgywO+WlrU0w4sbTUg5E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bell.net; spf=pass smtp.mailfrom=bell.net; dkim=pass (2048-bit key) header.d=bell.net header.i=@bell.net header.b=ax+RyCnx; arc=none smtp.client-ip=209.71.212.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bell.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bell.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bell.net; s=selector1; t=1708017243; bh=iqJuGfFuA5gl5PeHMO0DsPwaamL0d2WArzsU05LdegI=; h=Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To:Content-Type; b=ax+RyCnxTJG+jloMAeHNf8E02fuyDq5LinzDY6vhDyHMsgyUueMfN6k5sgL2eSibjfrZgZhGLjN0G5egWaScQmYvomyk4pQipN2877aJzyBHnKiO1UNYCg2/btjAQuJBW7tnxiVQfkX87YDvAxlHBKlbUDq6lecbvzBaeL3qdvfZU1z6BddOBYq+jk7P/siJDaGRkBfCXsGW2t64bGjQPDjfsn1ydPBp9Ms5AuBnXsDZwObrbMssZDETlM6icA56DHJ4UdWChx96FkgghZCvs68C9TKXe/VULj1KsuW7lI6f6V+94F/zcDAVGPWyBbtT9JdycyX5o3lEmmVTx0/FTQ== X-RG-SOPHOS: Clean X-RG-VADE-SC: 0 X-RG-VADE: Clean X-RG-Env-Sender: dave.anglin@bell.net X-RG-Rigid: 65CD68AA000F769D X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvledrvddtgdelkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemuceugffnnfdpqfgfvfenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeflohhhnhcuffgrvhhiugcutehnghhlihhnuceouggrvhgvrdgrnhhglhhinhessggvlhhlrdhnvghtqeenucggtffrrghtthgvrhhnpeekudelfeehieduueejvdekleefffehudefgfejgeekieduleeftdejhffghfeuvdenucffohhmrghinhepghhithhhuhgsrdgtohhmnecukfhppedugedvrdduvdeirdduuddvrddvfeefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghloheplgduledvrdduieekrddvrdeglegnpdhinhgvthepudegvddruddviedrudduvddrvdeffedpmhgrihhlfhhrohhmpegurghvvgdrrghnghhlihhnsegsvghllhdrnhgvthdpnhgspghrtghpthhtohepuddupdhrtghpthhtohepffgrvhhiugdrnfgrihhghhhtsegrtghulhgrsgdrtghomhdprhgtphhtthhopeflrghmvghsrdeuohhtthhomhhlvgihsehhrghnshgvnhhprghrthhnvghrshhhihhprdgtohhmpdhrtghpthhtoheprghkphhmsehlihhnuhigqdhfohhunhgurghtihhonhdrohhrghdprhgtphhtthhopegthhgrrhhlihgvsehrihhvohhsihhntgdrtghomhdprhgt phhtthhopegurghvvgdrrghnghhlihhnsegsvghllhdrnhgvthdprhgtphhtthhopeguvghllhgvrhesghhmgidruggv X-RazorGate-Vade-Verdict: clean 0 X-RazorGate-Vade-Classification: clean Received: from [192.168.2.49] (142.126.112.233) by cmx-torrgo001.bell.net (5.8.814) (authenticated as dave.anglin@bell.net) id 65CD68AA000F769D; Thu, 15 Feb 2024 12:13:42 -0500 Message-ID: <378dba2c-ebc2-404d-a0e8-f507a24ef6d2@bell.net> Date: Thu, 15 Feb 2024 12:13:43 -0500 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 , Guenter Roeck 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> <1d5e059e-5b31-415d-ae41-593415812e94@bell.net> <11fff7fe-ec4c-4340-a67f-d1d54d0712d8@roeck-us.net> <0fa4d53a-6ce7-4f44-81b2-86282f0b9451@roeck-us.net> From: John David Anglin Autocrypt: addr=dave.anglin@bell.net; keydata= xsFNBFJfN1MBEACxBrfJ+5RdCO+UQOUARQLSsnVewkvmNlJRgykqJkkI5BjO2hhScE+MHoTK MoAeKwoLfBwltwoohH5RKxDSAIWajTY5BtkJBT23y0hm37fN2JXHGS4PwwgHTSz63cu5N1MK n8DZ3xbXFmqKtyaWRwdA40dy11UfI4xzX/qWR3llW5lp6ERdsDDGHm5u/xwXdjrAilPDk/av d9WmA4s7TvM/DY3/GCJyNp0aJPcLShU2+1JgBxC6NO6oImVwW07Ico89ETcyaQtlXuGeXYTK UoKdEHQsRf669vwcV5XbmQ6qhur7QYTlOOIdDT+8zmBSlqBLLe09soATDciJnyyXDO1Nf/hZ gcI3lFX86i8Fm7lQvp2oM5tLsODZUTWVT1qAFkHCOJknVwqRZ8MfOvaTE7L9hzQ9QKgIKrSE FRgf+gs1t1vQMRHkIxVWb730C0TGiMGNn2oRUV5O5QEdb/tnH0Te1l+hX540adKZ8/CWzzW9 vcx+qD9IWLRyZMsM9JnmAIvYv06+YIcdpbRYOngWPd2BqvktzIs9mC4n9oU6WmUhBIaGOGnt t/49bTRtJznqm/lgqxtE2NliJN79dbZJuJWe5HkjVa7mP4xtsG59Rh2hat9ByUfROOfoZ0dS sVHF/N6NLWcf44trK9HZdT/wUeftEWtMV9WqxIwsA4cgSHFR2QARAQABzTdKb2huIERhdmlk IEFuZ2xpbiAoRGViaWFuIFBvcnRzKSA8ZGF2ZS5hbmdsaW5AYmVsbC5uZXQ+wsF3BBMBC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lH5OowVFEMhD9s31tciAvBwy T70V9SSrl2hiw38vRzsl In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024-02-15 11:51 a.m., Charlie Jenkins wrote: > On Thu, Feb 15, 2024 at 08:30:22AM -0800, Guenter Roeck wrote: >> On 2/15/24 07:36, Charlie Jenkins wrote: >>> On Thu, Feb 15, 2024 at 12:56:13AM -0800, Guenter Roeck wrote: >>>> On 2/14/24 19:35, Charlie Jenkins wrote: >>>>> On Wed, Feb 14, 2024 at 10:00:37PM -0500, John David Anglin wrote: >>>>>> On 2024-02-14 8:58 p.m., Guenter Roeck wrote: >>>>>>> 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. >>>>>> The carry/borrow bits in the PSW should be saved and restored by the save_specials >>>>>> and rest_specials macros.  They are defined in arch/parisc/include/asm/assembly.h. >>>>> Why would they be needed to be restored in linux? The manual says "The >>>>> PSW is set to the contents of the IPSW by the RETURN FROM INTERRUPTION >>>>> instruction". This means that the PSW must be restored by the hardware. >>>>> >>>>> We can see the QEMU implementation in: >>>>> >>>>> rfi: >>>>> https://github.com/qemu/qemu/blob/v8.2.1/target/hppa/sys_helper.c#L93 >>>>> >>>>> handling interrupt: >>>>> https://github.com/qemu/qemu/blob/v8.2.1/target/hppa/int_helper.c#L109 >>>>> >>>>> However the implementation appears to be faulty. During an RFI, the PSW >>>>> is always set to 0x804000e (regardless of what the PSW was before the >>>>> interrupt). >>>>> >>>> Not sure if I agree. The interrupt handler in Linux is the one which needs to set >>>> IPSW. Looking into the code, I agree with Dave that the tophys macro seems to >>>> clobber the carry bits before psw is saved, so they can not really be restored. >>>> The only issue with that idea is that I can only reproduce the problem with >>>> an interrupted ldd instruction but not, for example, with ldw. This is why it >>>> would be really important to have someone with real hardware test this. >>>> >>>> Thanks, >>>> Guenter >>> Yes, we definitely feedback from somebody with access to hardware, but I >>> do not understand how "The PSW is set to the contents of the IPSW by the >>> RETURN FROM INTERRUPTION" could be interpreted as anything except that >>> the hardware is expected to over-write the contents of the PSW during >>> the rfi. >>> >> Sure, I absolutely agree. But that assumes that IPSW is set correctly >> in the Linux interrupt handler. We do know that something odd happens > The manual defines the saving of PSW as the responsibility of the > hardware as well: "When an interruption occurs, the current value of the > PSW is saved in the Interruption Processor Status Word (IPSW)". I don't > think this should be interpreted to mean that a software interrupt > handler is required to save the IPSW. The IPSW (cr22) is saved by save_specials to regs->gr[0].  It is modified in various places when an interruption is handled.  In the case of emulate_ldd, we have         /* else we handled it, let life go on. */         regs->gr[0]|=PSW_N; This is supposed to nullify the faulting ldd.  I've yet to find where the carry bit is getting set in the PSW. There is a gap between where the hardware sets IPSW and where it is saved to the stack in save_specials.  tophys might clobber the IPSW is there is a double fault.  But it seems more likely that regs->gr[0] is getting clobbered somehow. Dave > > - Charlie > >> when an unaligned ldd is encountered. At least for my part I don't know >> if the problem is in emulate_ldd() in the Linux kernel or in the ldd >> implementation and trap handling in qemu. I do know (from my logs) >> that qemu does see the correct PSW/IPSW values, because they do >> show up correctly in the Linux kernel when running the qemu emulation. >> Only it somehow gets lost when the Linux interrupt handler returns. >> >> Thanks. >> Guenter >> -- John David Anglin dave.anglin@bell.net