From patchwork Thu Jan 6 15:21:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Laight X-Patchwork-Id: 12705495 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8280C433F5 for ; Thu, 6 Jan 2022 15:22:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240435AbiAFPWF (ORCPT ); Thu, 6 Jan 2022 10:22:05 -0500 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.85.151]:46735 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240422AbiAFPWF (ORCPT ); Thu, 6 Jan 2022 10:22:05 -0500 Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-132-q9hJDqqMPxmmiZ5MKZZQew-1; Thu, 06 Jan 2022 15:21:52 +0000 X-MC-Unique: q9hJDqqMPxmmiZ5MKZZQew-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Thu, 6 Jan 2022 15:21:51 +0000 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.026; Thu, 6 Jan 2022 15:21:51 +0000 From: David Laight To: 'Eric Dumazet' , 'Peter Zijlstra' CC: "'tglx@linutronix.de'" , "'mingo@redhat.com'" , 'Borislav Petkov' , "'dave.hansen@linux.intel.com'" , 'X86 ML' , "'hpa@zytor.com'" , "'alexanderduyck@fb.com'" , 'open list' , 'netdev' , "'Noah Goldstein'" Subject: [PATCH ] x86/lib: Simplify code for !CONFIG_DCACHE_WORD_ACCESS in csum-partial_64.c Thread-Topic: [PATCH ] x86/lib: Simplify code for !CONFIG_DCACHE_WORD_ACCESS in csum-partial_64.c Thread-Index: AdgDEH+mtMhrZ9ynRvybrK9s3y5Pbw== Date: Thu, 6 Jan 2022 15:21:51 +0000 Message-ID: <5f848b1cd6f844f6bc66fbec44237e08@AcuMS.aculab.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If load_unaligned_zeropad() can't be used (um builds) then just add together the final bytes and do a single 'adc' to add to the 64bit sum. Signed-off-by: David Laight --- It is a shame that this code is needed at all. I doubt um would ever fault just reading the 32bit value. arch/x86/lib/csum-partial_64.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/arch/x86/lib/csum-partial_64.c b/arch/x86/lib/csum-partial_64.c index 061b1ed74d6a..edd3e579c2a7 100644 --- a/arch/x86/lib/csum-partial_64.c +++ b/arch/x86/lib/csum-partial_64.c @@ -73,41 +73,28 @@ __wsum csum_partial(const void *buff, int len, __wsum sum) buff += 8; } if (len & 7) { + unsigned long trail; #ifdef CONFIG_DCACHE_WORD_ACCESS unsigned int shift = (8 - (len & 7)) * 8; - unsigned long trail; trail = (load_unaligned_zeropad(buff) << shift) >> shift; - - asm("addq %[trail],%[res]\n\t" - "adcq $0,%[res]" - : [res] "+r" (temp64) - : [trail] "r" (trail)); #else + trail = 0; if (len & 4) { - asm("addq %[val],%[res]\n\t" - "adcq $0,%[res]" - : [res] "+r" (temp64) - : [val] "r" ((u64)*(u32 *)buff) - : "memory"); + trail += *(u32 *)buff; buff += 4; } if (len & 2) { - asm("addq %[val],%[res]\n\t" - "adcq $0,%[res]" - : [res] "+r" (temp64) - : [val] "r" ((u64)*(u16 *)buff) - : "memory"); + trail += *(u16 *)buff; buff += 2; } - if (len & 1) { - asm("addq %[val],%[res]\n\t" - "adcq $0,%[res]" - : [res] "+r" (temp64) - : [val] "r" ((u64)*(u8 *)buff) - : "memory"); - } + if (len & 1) + trail += *(u8 *)buff; #endif + asm("addq %[trail],%[res]\n\t" + "adcq $0,%[res]" + : [res] "+r" (temp64) + : [trail] "r" (trail)); } result = add32_with_carry(temp64 >> 32, temp64 & 0xffffffff); return (__force __wsum)result;