From patchwork Tue Feb 27 20:33:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 207436 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2970173dyb; Tue, 27 Feb 2024 13:17:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW73zjowd3r3A+HjejUeuJkAvpc9ZU+Qu5uGRNvZWuo2qdrAmxKiLBFHPPWJDyStiWf4O1GK+DuGPaDqK1UT4KArBW2eQ== X-Google-Smtp-Source: AGHT+IGURJ5IQwN/sHXXXxea9XUaKC35LVZFGgIMsMikl03z50QXtp0d1+jp4gmytoVqic6xLy2l X-Received: by 2002:a17:903:2447:b0:1db:f811:66f7 with SMTP id l7-20020a170903244700b001dbf81166f7mr12350250pls.60.1709068624740; Tue, 27 Feb 2024 13:17:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709068624; cv=pass; d=google.com; s=arc-20160816; b=XIZjlBfWH8LgmIPmbNiKcm5XXoKB85K4LLuAaIvRe3eP738QQ7Utmed0IaG9FQJwMz use/8fZhvlT5bRxUlSP0eykxfh0SNpMeXPgBMsmEhsIq+2+9JQR4NmpTPNxB2fvzhw0Q ynnjhX7Sn8lXQmMuMOVnMn8SWiT/SkLir60BC7uC20Mw5zw1/HPx47QVqYTPKH2ISqTA yxX0jozrK4tH3OCYDxRBGuytVqxHOQHEttee5uCbxWGW0RssjPlhBb3dkDyDFMvjzPm6 Z7pmIzFnZDNcxFTgX8M7djO/nLA8Bb0Ia7NiHf67svAfDdNX6GVeuGtn+cFCoYLdAeD5 KSNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:sender:dkim-signature; bh=VmNpj3QbyAWLz70sR9q5u6BAhTl239U+KB2ZQ1R5C38=; fh=lmYizQ65NBPSE9GEogFJI6qjk4fSz+GMvBfiqvmBE3U=; b=bxJx/QBNq2sNdbJOxh0uby2LQi03Qm6j9g8YVe7FGpkWn9lN0n89aodF3Mhj6CbP44 XiTbz83DTJasa5TLXHSTO5jLgYZUQIa9YxO3uBIVNolu48TNq4btARDkIl/GFj5d0YkX yOsOnYSrNbMD2m4d54AqY9EC6iXFu9Dyj7L1lw28jGETv7rct1SkWgIOonGU8x5ZhKW6 gdtC67FeP9ssXly38OpjuCaTdVXn+s0PZaTOgD/XMJ4h8GeKxCVTWqq/X1dzAqibxcfd l9lDPqLezAWIMhkTK+2H0XismFG9wDYdDNl24HZRl2HpjSFRf6MyZGPTsRWrgsbUc0zW z22Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=m1SvBTmr; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-83980-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83980-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e12-20020a170902ed8c00b001dc744f5313si1935833plj.193.2024.02.27.13.17.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 13:17:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83980-ouuuleilei=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=@gmail.com header.s=20230601 header.b=m1SvBTmr; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-83980-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83980-ouuuleilei=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 021C5B25356 for ; Tue, 27 Feb 2024 20:34:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1F7814DFFD; Tue, 27 Feb 2024 20:34:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="m1SvBTmr" Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.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 9C2F04DA0C; Tue, 27 Feb 2024 20:33:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709066038; cv=none; b=W+bUeq2C/+tjmmxpgQa60f9pjk+pymmObhEnZ0xy+SAL/6RfuB0/imjO0OHISCN6hCBIHmnH2odqr93WBMwfSDAZjzAM7zIAruT0I/NGuBOzOtg5UUd+e96XOVU1i95Lk7vydiS5FuYP4USNLBSDYqFMn4mRkUq6Sl2jk+75Ca8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709066038; c=relaxed/simple; bh=vd+TyTSWQWOfYY26tKvy0OG6e8JjBYLWstVKW/u4Ebg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=BaGwKBkugnUnvCrqp9iyO4ky+CJZziZSnX+QSouos8z55hwhb2cETsO9j0zEWAkRyhWGU9wmJTW0YVZyH2OTMDsZpJmGboVYuEW+bbrSQ0YsiJzGMtOOfDBNNvTKvQRNRQLqi+As4lfcPhYrfeQfMIq0HRMMGGCvFitzdusQ9pk= 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=m1SvBTmr; arc=none smtp.client-ip=209.85.214.180 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-f180.google.com with SMTP id d9443c01a7336-1db6e0996ceso35312495ad.2; Tue, 27 Feb 2024 12:33:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709066036; x=1709670836; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=VmNpj3QbyAWLz70sR9q5u6BAhTl239U+KB2ZQ1R5C38=; b=m1SvBTmrWjETUJdQBwe55tCx7SZEhVWLaoqq1GORDMN2zkuH8ZO+mdmzKyoq+Z/1gP OAXc7DZ1XwAI8NoUzB0jSBKm2i5PZiEJUvLGUWkAYxkqu4DyWgTNqfDEP/e9rsWxYgBu VIBF//wHva/LmDYPRA71/qE5lcj9PL27AeRoNPZJpmPXWa1kQLpAqVsGyUkPUbV/eXk4 1PjJ6WzEmXpqlj1rJqSatXVtmS0hZe0KZT8lh1FYSkX7SpQy/I1wmrpDOvRef/YSndRN T3RIpDAn43cv+UmpoCGa6vAf9to1FWOQRSAiWBaejqVb77wLxfm3/Kizr7G3DdFsG2Ri OVnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709066036; x=1709670836; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=VmNpj3QbyAWLz70sR9q5u6BAhTl239U+KB2ZQ1R5C38=; b=HGXy6Vw10TfKPydiDqJ0EXPQxO13lOGBa8OcH9afZXrdc9A3WyBMoBU0tFYdD/hQjy QkcoULwZhDML8vYa18BVdcY5oNBCFEk6rRSS5HQDcX7kK10m/Wvbz+XjVAI1YzHKW8Ov nog4mnIyG4BwaeEm5z1nJ5LsE5EKiggu9+YgAdZvOPQOwiRJoM7mWO5dmMpvgrnrol7I 00K5SnKuWBW0BfkheQbuSPGb00yf0XvAeJLViJxEQVKuMmEK9s+KJ7Rs6Bt/OOSStYmO qB2qxNUtMbsjQNGFBozobASeXBx1DjKQPHXKEw63JOmVQ1gSTinF6fJUjil+/LO19PIM GAvg== X-Forwarded-Encrypted: i=1; AJvYcCWRVOqa80taZ1bOSWZLfZXX8kMJxajaIu8ZWp8t9+AsUWN8SNYbg1ipmTiCP/UVQ9vWllFZzl2tg+5sMO5siubhtWzkGI8sW3QhGRib+SXOi/34kivjChX/OvviopotMQ9sE8h0B6S0/fgP X-Gm-Message-State: AOJu0Yw6Wp7r0sB/BskdR5raMjocx6+Nq7OR8o44q34wtDbZ0qTeK+/L pGBIrOq0krG7GsYD5O/ECZzVVHaw/60DNT2ZZ1i7BfAy10rzPu1b X-Received: by 2002:a17:902:f688:b0:1dc:3d5:bdcc with SMTP id l8-20020a170902f68800b001dc03d5bdccmr13443056plg.42.1709066035823; Tue, 27 Feb 2024 12:33:55 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id w23-20020a1709027b9700b001db5241804csm1941363pll.20.2024.02.27.12.33.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 12:33:55 -0800 (PST) Sender: Guenter Roeck From: Guenter Roeck To: Helge Deller Cc: "James E . J . Bottomley" , linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH v2] parisc: Strip upper 32 bit of sum in csum_ipv6_magic for 64-bit builds Date: Tue, 27 Feb 2024 12:33:51 -0800 Message-Id: <20240227203351.3445929-1-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792088342226888892 X-GMAIL-MSGID: 1792088342226888892 IPv6 checksum tests with unaligned addresses on 64-bit builds result in unexpected failures. Expected expected == csum_result, but expected == 46591 (0xb5ff) csum_result == 46381 (0xb52d) with alignment offset 1 Oddly enough, the problem disappeared after adding test code into the beginning of csum_ipv6_magic(). As it turns out, the 'sum' parameter of csum_ipv6_magic() is declared as __wsum, which is a 32-bit variable. However, it is treated as 64-bit variable in the 64-bit assembler code. Tests showed that the upper 32 bit of the register used to pass the variable are _not_ cleared when entering the function. This can result in checksum calculation errors. Clearing the upper 32 bit of 'sum' as first operation in the assembler code fixes the problem. Acked-by: Helge Deller Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Guenter Roeck --- v2: Updated subject, clarified that the problem only affects 64-bit builds, added Helge's Acked-by: tag. arch/parisc/include/asm/checksum.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/parisc/include/asm/checksum.h b/arch/parisc/include/asm/checksum.h index c949aa20fa16..2aceebcd695c 100644 --- a/arch/parisc/include/asm/checksum.h +++ b/arch/parisc/include/asm/checksum.h @@ -126,6 +126,7 @@ static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr, ** Try to keep 4 registers with "live" values ahead of the ALU. */ +" depdi 0, 31, 32, %0\n"/* clear upper half of incoming checksum */ " ldd,ma 8(%1), %4\n" /* get 1st saddr word */ " ldd,ma 8(%2), %5\n" /* get 1st daddr word */ " add %4, %0, %0\n"