Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1369737rdb; Mon, 19 Feb 2024 13:12:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX/lfUp7vgxIRyc678y40XPon8BiamMMbfCmwrtCNGnEPKn+2yTGQvKt0T/1WoU1VFXeVbcgo/hf5h95YAH9yFmqg09ag8qnEmnfI4iYg== X-Google-Smtp-Source: AGHT+IFd4+JDFOZrBw1lW7CHT7hOJxmCIUbsdbFZnzICb3tdy+HsfswNGEiCaQT0Jh6tWjK0KNAN X-Received: by 2002:a17:902:d54c:b0:1db:a55b:617e with SMTP id z12-20020a170902d54c00b001dba55b617emr15703710plf.39.1708377157208; Mon, 19 Feb 2024 13:12:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708377157; cv=pass; d=google.com; s=arc-20160816; b=1HRFSxhpp7FwEFlcTrLPV5jMxWSXL/XSbksCPN2hjuapGtq+LyTYQ/6SwVsHCAGK78 eEVP5H3XLopuIdzIsxCESiVpSbj3ZvhKGRiPS4YiKJKMmt8IKuLCk7QWJjL7LsD2xpKd NjrPhu2qFfZNVed+ZfEG5N7eYoMx4vdzwk87TjfRk6q6n+tQVglVBndjV65Wo3kya6Nd /YKtGqr+yvhwcr1yMfJ/nC2YhDQLkp+8iY9r4TTtT6rXnJs2wLXWRlizZTrAfjCpUVHO P1+cD+sGx2qX1HxtlzDJHznVw7YapG2XETKhUQMkRb+shc4deoIS8nfkLzEzRnrYpX8/ 8bXA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport: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=vvPNKYFTWkc289i0W7kxt6IdfeushDEt1kcc7HiKntk=; fh=Aw8qs9E89d1DVkNEPbV+TGmJ4LyYbQ1Q/GrG4/MYAbc=; b=jfRNdO5YS2cBc5bn35cQph9s3FahkCXuvjoRKEvC9VDXIMf5iUZ7K5WtNvrFaARKKI v7z5kKPbBdpUKmFVMr62cMWOkGQDT+zhDpMRv0uLBaQS9Trf1ND3mibcUefKY5K0/fi4 af1QLaIP4tHy7mnmJ4rGhZBa8dcmbeJj1PP4/L6LnaOP1XN0llzui8ZZVEnl2h1RI3ku +j1ap2UDh8xdOxQ5qWXs0ZSwRjCR2N2Ze8ieap7tRzXHEhQXRHCXGO7B1Te/HSvH8Mm+ xMysZA20wjX3YQu0hkITHY/lSey573dURecz3zPxxyMiuuDMMZxmdzENMh0tLfhfGpar 4O2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=c7WVwgx6; arc=pass (i=1 spf=pass spfdomain=gmx.de dkim=pass dkdomain=gmx.de dmarc=pass fromdomain=gmx.de); spf=pass (google.com: domain of linux-kernel+bounces-71993-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71993-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c16-20020a170902d49000b001d95d399425si5150529plg.35.2024.02.19.13.12.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 13:12:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71993-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=c7WVwgx6; arc=pass (i=1 spf=pass spfdomain=gmx.de dkim=pass dkdomain=gmx.de dmarc=pass fromdomain=gmx.de); spf=pass (google.com: domain of linux-kernel+bounces-71993-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71993-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de 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 DE2FF281E67 for ; Mon, 19 Feb 2024 21:12:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 122F053E0E; Mon, 19 Feb 2024 21:12:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=deller@gmx.de header.b="c7WVwgx6" Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (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 A30432E40C; Mon, 19 Feb 2024 21:12:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708377143; cv=none; b=TEgtCLmSWuV5TlCI57DOchP4AGGKSegzaZtN/WkCSlQdbq5g+cKWdx20Uf5FCklHPI0SogWBQ+WcXQL20+8lYK1XaxWkktKu1XG0TbRa2ZFUJo6v1RPQlbI7WDHb+a8vw3Tzc5N0kARl1PqDeKqetgBY87ChYoX+kWEacI/Ame4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708377143; c=relaxed/simple; bh=0dZt+PoXfdZjATe9Hle1yjYnVPuWZbSyuYqI8JtPTyI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=VkB8eLp9UeX7CeK9UQfPX2fghLPDfi53v9TJvFkdXd0wF7+BfbKsh+h9eggpq/eSXfTfx5hbHsaWZ5CF4HuWWrKskQYjMZAf/ghfGGm34A/RC7qIqhPhabwvbJOk9zfHF8FtWLfuz27y9Yxh90Hafg+JnhY4auUQMhvanKzvqvU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=deller@gmx.de header.b=c7WVwgx6; arc=none smtp.client-ip=212.227.15.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1708377116; x=1708981916; i=deller@gmx.de; bh=0dZt+PoXfdZjATe9Hle1yjYnVPuWZbSyuYqI8JtPTyI=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From: In-Reply-To; b=c7WVwgx63vW+1+V/3MLGwGLn2Qtulsk+acm5XXbJBG/uZ395dd//8DMzunFxm2ZN E77Rul+fNDWwLXi4IRCgMXS7DnKapGVH9SdugUYc52Gk77XRsGtVPfhh109uChFga /K6YoNPHGP3EpvDNsOYj3fmdsYlwCEz2Dj+tJLjBquBYaQdsvQSLgazZ5ODDOAa1K 14UA98ixhFr4AB4K6bypqvWbbijI8/6uFOaqTwBPVgZ9w8FVhB10Ou8qkGVBz1xh2 M26QQr9cyA+4lTlAqaqUl0et3ukdvTtVeWD/BtZtWXPO7aLn+7Sh7njcKgm+QA/N6 kUIWS01GWsxdypbXjA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.20.55] ([94.134.155.130]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MrQEn-1r7Z8u48Nb-00oU3p; Mon, 19 Feb 2024 22:11:56 +0100 Message-ID: Date: Mon, 19 Feb 2024 22:11:54 +0100 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] parisc: Fix csum_ipv6_magic on 64-bit systems Content-Language: en-US To: Charlie Jenkins , Helge Deller , Guenter Roeck Cc: "James E . J . Bottomley" , linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Palmer Dabbelt References: <20240213234631.940055-1-linux@roeck-us.net> From: Helge Deller Autocrypt: addr=deller@gmx.de; keydata= xsFNBF3Ia3MBEAD3nmWzMgQByYAWnb9cNqspnkb2GLVKzhoH2QD4eRpyDLA/3smlClbeKkWT HLnjgkbPFDmcmCz5V0Wv1mKYRClAHPCIBIJgyICqqUZo2qGmKstUx3pFAiztlXBANpRECgwJ r+8w6mkccOM9GhoPU0vMaD/UVJcJQzvrxVHO8EHS36aUkjKd6cOpdVbCt3qx8cEhCmaFEO6u CL+k5AZQoABbFQEBocZE1/lSYzaHkcHrjn4cQjc3CffXnUVYwlo8EYOtAHgMDC39s9a7S90L 69l6G73lYBD/Br5lnDPlG6dKfGFZZpQ1h8/x+Qz366Ojfq9MuuRJg7ZQpe6foiOtqwKym/zV dVvSdOOc5sHSpfwu5+BVAAyBd6hw4NddlAQUjHSRs3zJ9OfrEx2d3mIfXZ7+pMhZ7qX0Axlq Lq+B5cfLpzkPAgKn11tfXFxP+hcPHIts0bnDz4EEp+HraW+oRCH2m57Y9zhcJTOJaLw4YpTY GRUlF076vZ2Hz/xMEvIJddRGId7UXZgH9a32NDf+BUjWEZvFt1wFSW1r7zb7oGCwZMy2LI/G aHQv/N0NeFMd28z+deyxd0k1CGefHJuJcOJDVtcE1rGQ43aDhWSpXvXKDj42vFD2We6uIo9D 1VNre2+uAxFzqqf026H6cH8hin9V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anxZGKEkSHHOm8jHwvQWvPP73pvuPBEPtKGLzbgd7OOcGZWtq2hNC6cRtsRdDx 4TAGMCz4j238m+2mdbdhRh3iBnWT5yPFfnv/2IjFAk+sdix1Mrr+LIDF++kiekeq0yUpDdc4 ExBy2xf6dd+tuFFBp3/VDN4U0UfG4QJ2fg19zE5Z8dS4jGIbLg== In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:pn7BuT8QnGgJrmUlidl4hqDNTJzUmHdoIWuZZCrKCcMbxez94wL 8MUeuvnqPESfBm7fscuOLzg2kzSvlzE/jeU7ZWu4SpZvTKr5genWqjhIlt7jiupkHfnXrnw 0oBnVKlpPcigtCBfFS/yXPcNydgo4jEpCBtSIZfjhfqIfgMU4AgQjBiIx9aSGgVpfOIl7m+ A/nqeYhIvukciFGullm8g== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:Q7Q0tzYfQ+M=;lRDRA532PjXeWWWLG1jFHwul3th oEGKD0gSV7no/i7InUgvbWuysvU9zFfPChXc+FI/PxYQJYYmb13htbntI7IJIP2MR3d5oH2oY P7RiXGkjfGoQK7QcC7xAeJkNxBcPOoBbf51zNiC0B15kPiWwwwrP6hu4ziW/HEia+7RG5VdA6 SMS1ZXwJs0Bv4Te/iG4lZW7DY3fQF3tuSQ8xlihVJm2LhJAYS2yWaxBU1u8wQaZustm9f9POS y0jUXCjKOgOsFHgd6UbWWIrT2qYdwsl2h/4U13tcUwExGRZBbBGnvDPKNkNvpwWc4hLPDO2Hs 6flvq82Be9ULWAZQ5u1D1foaUO7/JbwVTSUu/pOYnYPetmMP6sDyg/mwuzRWIKMVrHAbQnyow uCImILBZE2L1XTlyqzMwOCyvuqpKD6usQEXzystfUY7xgYg7AdQqyVLNvMJ/Ufh5hLtqfu506 HhWAZoYp4czqmhQiRmj+LHf/7BP1/qmujbRAzs/eEf418Di+Hwt3+ns1Lazb5BSLnzLPgl483 ykWoAGZkVvqawG4q9SxIw2PdBq9hKSYIm1/7StQ0cU47N0b65bvtofoFDrSUCp6ZNAlvF2/HF eV9X6JsZuf4qYigrT36e0+2NyoMduHFDLt406byBpzVB7xVcbu3mDmz7nfOuDzq9zPmFNNiRS 6CucUpJ9ClAyHovLtU7SuHjyYod3HzJy/rBTxPc5VaBunMUv3fK/EHRbYzk5DHzWAfPEoitzK UI1m0MgBQf+UurI5FeEzJMNEduuqLVzkDgvEMLJNG+8lkNEhTAL3Fpra7cdgIEESIs/bGLrOx Yo8QH/bXItPHEjbiqcwUShxFbgf4+B1CHi2kDwQu7JFj4= On 2/17/24 04:00, Charlie Jenkins wrote: > On Fri, Feb 16, 2024 at 01:38:51PM +0100, Helge Deller wrote: >> * Guenter Roeck : >>> hppa 64-bit systems calculates the IPv6 checksum using 64-bit add >>> operations. The last add folds protocol and length fields into the 64-= bit >>> result. While unlikely, this operation can overflow. The overflow can = be >>> triggered with a code sequence such as the following. >>> >>> /* try to trigger massive overflows */ >>> memset(tmp_buf, 0xff, sizeof(struct in6_addr)); >>> csum_result =3D csum_ipv6_magic((struct in6_addr *)tmp_buf, >>> (struct in6_addr *)tmp_buf, >>> 0xffff, 0xff, 0xffffffff); >>> >>> Fix the problem by adding any overflows from the final add operation i= nto >>> the calculated checksum. Fortunately, we can do this without additiona= l >>> cost by replacing the add operation used to fold the checksum into 32 = bit >>> with "add,dc" to add in the missing carry. >> >> >> Gunter, >> >> Thanks for your patch for 32- and 64-bit systems. >> But I think it's time to sunset the parisc inline assembly for ipv4/ipv= 6 >> checksumming. >> The patch below converts the code to use standard C-coding (taken from = the >> s390 header file) and it survives the v8 lib/checksum patch. >> >> Opinions? >> [...] > We can do better than this! By inspection this looks like a performance > regression. > [...] > Similar story again here where the add with carry is not well translated > into C, resulting in significantly worse assembly. Using __u64 seems to > be a big contributing factor for why the 32-bit assembly is worse. > > I am not sure the best way to represent this in a clean way in C. > > add with carry is not well understood by GCC 12.3 it seems. These > functions are generally heavily optimized on every architecture, so I > think it is worth it to default to assembly if you aren't able to > achieve comparable performance in C. Thanks a lot for your analysis!!! I've now reverted my change to switch to generic code and applied the 3 suggested patches from Guenter which fix the hppa assembly. Let's see how they behave in the for-next git tree during the next few day= s. Helge