From patchwork Mon Feb 6 03:31:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lafreniere X-Patchwork-Id: 651140 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 BAD1EC61DA4 for ; Mon, 6 Feb 2023 03:31:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229523AbjBFDbx (ORCPT ); Sun, 5 Feb 2023 22:31:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbjBFDbx (ORCPT ); Sun, 5 Feb 2023 22:31:53 -0500 Received: from aib29gb122.yyz1.oracleemaildelivery.com (aib29gb122.yyz1.oracleemaildelivery.com [192.29.72.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 105B614214 for ; Sun, 5 Feb 2023 19:31:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oci-2023; d=n8pjl.ca; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=u7pdwP/3oyBlzQgNDoODdl5XTVcgq9zSeMGjx0xoxT4=; b=g1hgqx7Mvhdx836I7K1rJTWykZ7E7SlIAInvOQS8CLf8jo/WejRQpmK3+fjMz4ikvdZGxoxoiTpT j1Pa27eOeTMPstuaQchHCleBQ+d45FZelOGjRwIC10LSb4BwmIJXfp8Oej8Ih3Nf5gLFPwCGi7Xq sUD6LdobA/l4QmM1+/PJfqNlqA0QGWY6aeLsPNDJECqezyGmPbyO0vAB8PitYeyuOkFhEvgAt0kh Ep15Fg999qDQtBb9Ia67EtQP1DeJnma1cYgOFJCvosB85pvmrSqKYob6+khEBdQNwGONmwIajH60 Ai513ipB3JrRoUUqcgrrbFRxLL7E1jdrfx2iZw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-yyz-20200204; d=yyz1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=u7pdwP/3oyBlzQgNDoODdl5XTVcgq9zSeMGjx0xoxT4=; b=pGfmFL07yRiwtUw3LKA2uzwnuN7trpTibZl9BdJWRSmnB2D6dSZXWixEC3mk0xxb9YLN3GBgdrra GyRBLNZ4bIYELcCyZfUpWl3zdFoBv2hmYb1sAsRfnB1rVytPzpF5v10TmpngO3+WdYorIVqFYdWu eTGuSbRIun0IsryPeb/rRgOTJzkyfgtAUr/z42fJ3rFpYOhIoITmRNAeV7S364SmEvb8yNeXdQ6h a2L5e/P+oVPGqM2zlUGNYvB7DA0jRp1w4nJaNU+zMqvnh9zkicXmNgW+OYzH3OVcyd1/izmxmHFz 8ypDKdIz/YUH+qW/POX9n+jhtNbUz03d9GpDMA== Received: by omta-ad1-fd1-101-ca-toronto-1.omtaad1.vcndpyyz.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20230123 64bit (built Jan 23 2023)) with ESMTPS id <0RPN00LZT353JPA0@omta-ad1-fd1-101-ca-toronto-1.omtaad1.vcndpyyz.oraclevcn.com> for linux-crypto@vger.kernel.org; Mon, 06 Feb 2023 03:31:51 +0000 (GMT) From: Peter Lafreniere To: linux-crypto@vger.kernel.org Cc: Peter Lafreniere , x86@kernel.org, jussi.kivilinna@mbnet.fi Subject: [PATCH 1/3] crypto: x86/twofish-3way - Remove unused encode parameter Date: Sun, 5 Feb 2023 22:31:33 -0500 Message-id: <5fb76bfe51ed23aa0e8a36aece76510d85bddfb2.1675653010.git.peter@n8pjl.ca> X-Mailer: git-send-email 2.39.1 In-reply-to: References: MIME-version: 1.0 Content-transfer-encoding: 8bit Reporting-Meta: AAFM0bY0qh8/6zbmsPQzEX+WOYHeLRhAzCfu1eznTJ2bOIpFPUo5XCr17EtjzhYF ut6+H4y7kaUVFnofIfQMlKq4IAriR8XX+JzEooOuidZgt6M2zx+ipYiQ+EysciHJ 4dmKNjc2zrFdE1cIBsDhTYQnGrXDkcykQQuTafUMGEklD28XNGIv33AYYa3cty55 BtndZckSp9kD0P+ePySIaoeJbNbVuVd+opjJvH4yby6fmFM0BdHWLajFgWJgiwK5 le6ETDef06u2byn6pitIK5wIwExDkRa61JF4WsAASuODR6NdKErwgbcdzorG19cF U7JXYp0m3ecc4DJ53/Jd8Y4AWTTY3IgyGmZcU6Y2CIliJKuwDI5DR0tWUO+DVxpg FWoKfbND/5XaIaznATUGTRWFmeUqvNUOhXKbo2GrrukPxxhWu7ygoKnqOSSBPZM= Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org __twofish_enc_blk_3way() takes a third parameter which is always hardcoded to false. Remove it to simplify twofish_enc_blk_3way. There are also callers in other x86 crypto modules. Modify those to call the assembly function directly. Signed-off-by: Peter Lafreniere --- arch/x86/crypto/twofish-x86_64-asm_64-3way.S | 18 ++---------------- arch/x86/crypto/twofish.h | 3 +-- arch/x86/crypto/twofish_avx_glue.c | 5 ----- arch/x86/crypto/twofish_glue_3way.c | 7 +------ 4 files changed, 4 insertions(+), 29 deletions(-) diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S index d2288bf38a8a..fa11513dbbf1 100644 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S @@ -220,18 +220,16 @@ rorq $32, RAB2; \ outunpack3(mov, RIO, 2, RAB, 2); -SYM_FUNC_START(__twofish_enc_blk_3way) +SYM_FUNC_START(twofish_enc_blk_3way) /* input: * %rdi: ctx, CTX * %rsi: dst * %rdx: src, RIO - * %rcx: bool, if true: xor output */ pushq %r13; pushq %r12; pushq %rbx; - pushq %rcx; /* bool xor */ pushq %rsi; /* dst */ inpack_enc3(); @@ -248,10 +246,6 @@ SYM_FUNC_START(__twofish_enc_blk_3way) pop_cd(); popq RIO; /* dst */ - popq RT1; /* bool xor */ - - testb RT1bl, RT1bl; - jnz .L__enc_xor3; outunpack_enc3(mov); @@ -259,15 +253,7 @@ SYM_FUNC_START(__twofish_enc_blk_3way) popq %r12; popq %r13; RET; - -.L__enc_xor3: - outunpack_enc3(xor); - - popq %rbx; - popq %r12; - popq %r13; - RET; -SYM_FUNC_END(__twofish_enc_blk_3way) +SYM_FUNC_END(twofish_enc_blk_3way) SYM_FUNC_START(twofish_dec_blk_3way) /* input: diff --git a/arch/x86/crypto/twofish.h b/arch/x86/crypto/twofish.h index 12df400e6d53..feb0a6f820a6 100644 --- a/arch/x86/crypto/twofish.h +++ b/arch/x86/crypto/twofish.h @@ -11,8 +11,7 @@ asmlinkage void twofish_enc_blk(const void *ctx, u8 *dst, const u8 *src); asmlinkage void twofish_dec_blk(const void *ctx, u8 *dst, const u8 *src); /* 3-way parallel cipher functions */ -asmlinkage void __twofish_enc_blk_3way(const void *ctx, u8 *dst, const u8 *src, - bool xor); +asmlinkage void twofish_enc_blk_3way(const void *ctx, u8 *dst, const u8 *src); asmlinkage void twofish_dec_blk_3way(const void *ctx, u8 *dst, const u8 *src); /* helpers from twofish_x86_64-3way module */ diff --git a/arch/x86/crypto/twofish_avx_glue.c b/arch/x86/crypto/twofish_avx_glue.c index 3eb3440b477a..257a79f4cb58 100644 --- a/arch/x86/crypto/twofish_avx_glue.c +++ b/arch/x86/crypto/twofish_avx_glue.c @@ -33,11 +33,6 @@ static int twofish_setkey_skcipher(struct crypto_skcipher *tfm, return twofish_setkey(&tfm->base, key, keylen); } -static inline void twofish_enc_blk_3way(const void *ctx, u8 *dst, const u8 *src) -{ - __twofish_enc_blk_3way(ctx, dst, src, false); -} - static int ecb_encrypt(struct skcipher_request *req) { ECB_WALK_START(req, TF_BLOCK_SIZE, TWOFISH_PARALLEL_BLOCKS); diff --git a/arch/x86/crypto/twofish_glue_3way.c b/arch/x86/crypto/twofish_glue_3way.c index 90454cf18e0d..c331c4ca9363 100644 --- a/arch/x86/crypto/twofish_glue_3way.c +++ b/arch/x86/crypto/twofish_glue_3way.c @@ -15,7 +15,7 @@ #include "twofish.h" #include "ecb_cbc_helpers.h" -EXPORT_SYMBOL_GPL(__twofish_enc_blk_3way); +EXPORT_SYMBOL_GPL(twofish_enc_blk_3way); EXPORT_SYMBOL_GPL(twofish_dec_blk_3way); static int twofish_setkey_skcipher(struct crypto_skcipher *tfm, @@ -24,11 +24,6 @@ static int twofish_setkey_skcipher(struct crypto_skcipher *tfm, return twofish_setkey(&tfm->base, key, keylen); } -static inline void twofish_enc_blk_3way(const void *ctx, u8 *dst, const u8 *src) -{ - __twofish_enc_blk_3way(ctx, dst, src, false); -} - void twofish_dec_blk_cbc_3way(const void *ctx, u8 *dst, const u8 *src) { u8 buf[2][TF_BLOCK_SIZE]; From patchwork Mon Feb 6 03:31:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lafreniere X-Patchwork-Id: 651389 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 CD818C61DA4 for ; Mon, 6 Feb 2023 03:32:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229533AbjBFDc1 (ORCPT ); Sun, 5 Feb 2023 22:32:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbjBFDc0 (ORCPT ); Sun, 5 Feb 2023 22:32:26 -0500 Received: from aib29gb125.yyz1.oracleemaildelivery.com (aib29gb125.yyz1.oracleemaildelivery.com [192.29.72.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 744B414214 for ; Sun, 5 Feb 2023 19:32:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oci-2023; d=n8pjl.ca; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=ZtmSC+ucqFQV9IcCq8FgHtVQ8AfPSZnLwQrC7fNgyE8=; b=N7Va+MXQ0mEyNItsXXObEquNvza5rIqmA9TiL8yOQk2qs2mlJxL5DXuzeOityUPJ0mVreJ6dLymf qfaxB6n80eI+6zonQ0O5nsmJRYr5DCg2CCWEHD9iJOjkHnuyHfYk81leXZe/tNWXdXpZSYVjlujj eCH/fXsGIu6X4OlKctvxB/ipiXtJvCkldwuIpDLkYroeFuVB4UHfxg42YhG0IS3GAY0zvBiiaQ4/ QnOThJ2CvQ/+pKOS+7wD0n18f6zVEgFs6COmQh4VK3ilH7UYmGfcYAwCCgf3HPfuVWRik5vF3vTf SzzVm/cctkWKIDi94TQbOihQvp2T9WaNcfvEsQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-yyz-20200204; d=yyz1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=ZtmSC+ucqFQV9IcCq8FgHtVQ8AfPSZnLwQrC7fNgyE8=; b=nO1aQ9LGhlgYVuY9I16OTfnwEL0J4o4UvQii1LL/E4U0M+SNSadcEIwZT8rxh6coQIl+MQDIp/CL K3muAl3wCXWYjmZsJlgHaXi7q9DW3nhChrBO15gIx4p0vP5UymlhhaoqmqQYeSmRlYCqI4KhMGEk /hfNsOOgm4W14tw4j/LpFOYsA5MESXw6RBpJfUKvh6gALbWAlGZdfAyAsBTYbvNHhFf4DCPq8y/U eUCBUxh/y8U+yIgEyE/0tPVKnYmZq9uWvQjZIi/5X3GEhJFCAI6U9S8pk9HMMJCvb/lqVGJT646b qpfRN/BHELryd9C4/UeC4z30u4dCFRrUyJ9WDw== Received: by omta-ad1-fd2-102-ca-toronto-1.omtaad1.vcndpyyz.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20230123 64bit (built Jan 23 2023)) with ESMTPS id <0RPN00O663607Q90@omta-ad1-fd2-102-ca-toronto-1.omtaad1.vcndpyyz.oraclevcn.com> for linux-crypto@vger.kernel.org; Mon, 06 Feb 2023 03:32:24 +0000 (GMT) From: Peter Lafreniere To: linux-crypto@vger.kernel.org Cc: Peter Lafreniere , x86@kernel.org, jussi.kivilinna@mbnet.fi Subject: [PATCH 2/3] crypto: x86/twofish-3way - Perform cbc xor in assembly Date: Sun, 5 Feb 2023 22:31:34 -0500 Message-id: <80b492462c1741c384f326a01856791a517bc251.1675653010.git.peter@n8pjl.ca> X-Mailer: git-send-email 2.39.1 In-reply-to: References: MIME-version: 1.0 Content-transfer-encoding: 8bit Reporting-Meta: AAFM0bY0qh8/6zbmsPQzEX+WOYHeLRhAzCfu1eznTJ2bOIpFPUo5XCr17EtjzhYF ut6+H4y7kaUVFnofIfQclKq4IAriR8XX+Jxgh1uK15MEfN9a97Sjp2qLpv1mGxkl eyMVcrL5oEMLKbGEz6Z9lYPICf8TZA5ko0rcFrlmrCmR9tsn+7OlRncNkx83HILI oqtKwvlCBzqcEIi1eVy1VWcwvJZAHz8xb3oXo2YxhIr6z0VH9KM9koYv6ocS8Vro getiybh91Eg6KVlQlYKLZb0/LMP3AHgCPTbl44JAxa1J76gF9h82OfNwYkxME4D/ mS1lryDh+cx3BFA9sY28b0vCkhDuE3yGm+fjqvMkIf27FVkAQz+rKR0KSz1qP6Yz lVbcpaLg5KTZSgKXdr8YJEfsNVC7YdoBspsnXF1BLIZj1geDNRL7v+jpg0okYnM= Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Optimize twofish-3way cbc decryption by keeping intermediate results in registers until computations are finished, rather than storing in assembly, then immediately reloading them in glue code. Additionally, keeping all operations in assembly can avoid a memcpy() call when the decryption is being done in place. cbc decoding speedups: (tcrypt mode=202 on a znver1) 64B: +7.7%, 128B: +6.3%, 256B: +6.8% Signed-off-by: Peter Lafreniere --- arch/x86/crypto/twofish-x86_64-asm_64-3way.S | 33 ++++++++++++++++++-- arch/x86/crypto/twofish.h | 16 ++++++++-- arch/x86/crypto/twofish_glue_3way.c | 15 +-------- 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S index fa11513dbbf1..29e0fe664386 100644 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S @@ -220,6 +220,20 @@ rorq $32, RAB2; \ outunpack3(mov, RIO, 2, RAB, 2); +#define outunpack_cbc_dec3() \ + rorq $32, RCD0; \ + rorq $32, RCD1; \ + xorq (RT1), RCD1; \ + rorq $32, RCD2; \ + xorq 16(RT1), RCD2; \ + outunpack3(mov, RIO, 0, RCD, 0); \ + rorq $32, RAB0; \ + rorq $32, RAB1; \ + xorq 8(RT1), RAB1; \ + rorq $32, RAB2; \ + xorq 24(RT1), RAB2; \ + outunpack3(mov, RIO, 2, RAB, 2); + SYM_FUNC_START(twofish_enc_blk_3way) /* input: * %rdi: ctx, CTX @@ -255,17 +269,20 @@ SYM_FUNC_START(twofish_enc_blk_3way) RET; SYM_FUNC_END(twofish_enc_blk_3way) -SYM_FUNC_START(twofish_dec_blk_3way) +SYM_FUNC_START(__twofish_dec_blk_3way) /* input: * %rdi: ctx, CTX * %rsi: dst * %rdx: src, RIO + * %rcx: cbc (bool) */ pushq %r13; pushq %r12; pushq %rbx; pushq %rsi; /* dst */ + pushq %rdx; /* src */ + pushq %rcx; /* cbc */ inpack_dec3(); @@ -280,12 +297,24 @@ SYM_FUNC_START(twofish_dec_blk_3way) decrypt_cycle3(RAB, CD, 0); pop_cd(); + popq RT0; /* cbc */ + popq RT1; /* src */ popq RIO; /* dst */ + testq RT0, RT0; + jnz .L_dec_cbc; + outunpack_dec3(); popq %rbx; popq %r12; popq %r13; RET; -SYM_FUNC_END(twofish_dec_blk_3way) + +.L_dec_cbc: + outunpack_cbc_dec3(); + popq %rbx; + popq %r12; + popq %r13; + RET; +SYM_FUNC_END(__twofish_dec_blk_3way) diff --git a/arch/x86/crypto/twofish.h b/arch/x86/crypto/twofish.h index feb0a6f820a6..ede02a8b36d4 100644 --- a/arch/x86/crypto/twofish.h +++ b/arch/x86/crypto/twofish.h @@ -12,9 +12,19 @@ asmlinkage void twofish_dec_blk(const void *ctx, u8 *dst, const u8 *src); /* 3-way parallel cipher functions */ asmlinkage void twofish_enc_blk_3way(const void *ctx, u8 *dst, const u8 *src); -asmlinkage void twofish_dec_blk_3way(const void *ctx, u8 *dst, const u8 *src); +asmlinkage void __twofish_dec_blk_3way(const void *ctx, u8 *dst, + const u8 *src, bool cbc); -/* helpers from twofish_x86_64-3way module */ -extern void twofish_dec_blk_cbc_3way(const void *ctx, u8 *dst, const u8 *src); +/* helpers for use of __twofish_dec_blk_3way() */ +static inline void twofish_dec_blk_3way(const void *ctx, u8 *dst, + const u8 *src) +{ + return __twofish_dec_blk_3way(ctx, dst, src, false); +} +static inline void twofish_dec_blk_cbc_3way(const void *ctx, u8 *dst, + const u8 *src) +{ + return __twofish_dec_blk_3way(ctx, dst, src, true); +} #endif /* ASM_X86_TWOFISH_H */ diff --git a/arch/x86/crypto/twofish_glue_3way.c b/arch/x86/crypto/twofish_glue_3way.c index c331c4ca9363..1f6944620dc5 100644 --- a/arch/x86/crypto/twofish_glue_3way.c +++ b/arch/x86/crypto/twofish_glue_3way.c @@ -16,7 +16,7 @@ #include "ecb_cbc_helpers.h" EXPORT_SYMBOL_GPL(twofish_enc_blk_3way); -EXPORT_SYMBOL_GPL(twofish_dec_blk_3way); +EXPORT_SYMBOL_GPL(__twofish_dec_blk_3way); static int twofish_setkey_skcipher(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen) @@ -24,19 +24,6 @@ static int twofish_setkey_skcipher(struct crypto_skcipher *tfm, return twofish_setkey(&tfm->base, key, keylen); } -void twofish_dec_blk_cbc_3way(const void *ctx, u8 *dst, const u8 *src) -{ - u8 buf[2][TF_BLOCK_SIZE]; - const u8 *s = src; - - if (dst == src) - s = memcpy(buf, src, sizeof(buf)); - twofish_dec_blk_3way(ctx, dst, src); - crypto_xor(dst + TF_BLOCK_SIZE, s, sizeof(buf)); - -} -EXPORT_SYMBOL_GPL(twofish_dec_blk_cbc_3way); - static int ecb_encrypt(struct skcipher_request *req) { ECB_WALK_START(req, TF_BLOCK_SIZE, -1); From patchwork Mon Feb 6 03:31:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lafreniere X-Patchwork-Id: 651139 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 83156C61DA4 for ; Mon, 6 Feb 2023 03:33:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229499AbjBFDdB (ORCPT ); Sun, 5 Feb 2023 22:33:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbjBFDdB (ORCPT ); Sun, 5 Feb 2023 22:33:01 -0500 Received: from aib29gb127.yyz1.oracleemaildelivery.com (aib29gb127.yyz1.oracleemaildelivery.com [192.29.72.127]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1A541631B for ; Sun, 5 Feb 2023 19:32:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oci-2023; d=n8pjl.ca; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=CmS6jCxptoO9vSmseA54nl/palyPlbLDD4usnOrfUsw=; b=VrEjxSoeHVMZ8XzbB9f2rGlavK9harItP9NQoKHyaysaPXqEcBoLlSry1JQnYWJ4ic6tJs/47EOa oA8WQkXsPGkQT8iTb9WTQFSDFstlUNzv2cP7GmGeNVIHOrJ1ClQFXxBzpXSC2PvRjnFbOIScvgHA GFWgJaKGob8Jcw/L5O55BMdfEPYiVGPt7FYkaR7dikwRm3risCVU1p2MlTaJjB/4LXHunOqtZwlH M3tjqKLLxwNckGkKeCZl2zYr1tu86+7QSPfCw0a+VmpSDJo3nkGWMq8Q3KF/7ccqG3ghxWMhI/u8 rdcknnQn3d8fM7hfGbaAB7cckvZhkcRf8NeBoQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-yyz-20200204; d=yyz1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=CmS6jCxptoO9vSmseA54nl/palyPlbLDD4usnOrfUsw=; b=PeE1o5D4w5VffTcykvKNbJuI5zhWN1pb7iyhonUJefMTCNvWlmBWSy0iyhPtyGtH3obpC4Neoh9i qzUbhzjFLq3fFG2Sn5Y2iYlO9YIdk+a/dxe5M5UtgBd8tAAXOpJeEnOLRuu4Cdi3nW3kJogR6QJ5 Iw9oQtH+MQafSKK8ZoVXZsSo4zxvW2WyCHX0TtT5dNz4yMXXVmTu8awoVaVN8Jov+kpZlgNtLUYa jz+1rXApmZBpl6tuR6JxBbOrRZXMLIdeqQPuTLJIzSWQ3CcRyeniMbDJJkbu2K0aWsN5f7w/xw5L hxHp8LHN1+cqxF8ouB/HszXfmDHbQ12WuG0L7Q== Received: by omta-ad1-fd3-102-ca-toronto-1.omtaad1.vcndpyyz.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20230123 64bit (built Jan 23 2023)) with ESMTPS id <0RPN00E8X36YFX80@omta-ad1-fd3-102-ca-toronto-1.omtaad1.vcndpyyz.oraclevcn.com> for linux-crypto@vger.kernel.org; Mon, 06 Feb 2023 03:32:58 +0000 (GMT) From: Peter Lafreniere To: linux-crypto@vger.kernel.org Cc: Peter Lafreniere , x86@kernel.org, jussi.kivilinna@mbnet.fi Subject: [PATCH 3/3] crypto: x86/twofish-3way - Remove unused macro argument Date: Sun, 5 Feb 2023 22:31:35 -0500 Message-id: <39dcdd3216a4163e43cb922892047c86a2a6abef.1675653010.git.peter@n8pjl.ca> X-Mailer: git-send-email 2.39.1 In-reply-to: References: MIME-version: 1.0 Content-transfer-encoding: 8bit Reporting-Meta: AAFM0bY0qh8/6zbmsPQzEX+WOYHeLRhAzCfu1eznTJ2bOIpFPUo5XCr17EtjzhYF ut6+H4y7kaUVFnofIfQnlKq4IAriR8XX+Jwp6k3m3MpVF0yDCmm+nqOlqAWyCytQ czXTsFm00VVBGr7AjRZ24JrQT5IAZ80lxhw26fMs4X9S8AcVolPEu+/OA0TSAeiR kI72ZH1lanIoqMhJBXVxRytrl9XAdTbXBg/u9A1fTpMTtSiQKI44wGRy5qweo1nb gSpjEYRflxDx2A1bAUEQmww2Hl97wQDYcdzO3egQU2rDMI9JsC0+9/fDoAnSFDNK pB2shxth1mfBU4O/CdcncN2DIiZmRwamBHbsmq4mJShrKi62mZFNwFMoKJQKaEOz a2xP6ake2mamGClKJq5zqLfItsbAPZKx12NwFSTafl5nxbhBzbJS6KUsjbn4hdU= Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The outunpack3() macro has an op parameter that is only ever called with "mov". Removing that argument altogether leads to gains to code readability. There is no effect on the resulting binary. Signed-off-by: Peter Lafreniere --- arch/x86/crypto/twofish-x86_64-asm_64-3way.S | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S index 29e0fe664386..c2cd9b5406da 100644 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S @@ -182,23 +182,23 @@ movq 4*(8+(n))(in), xy ## 2; \ xorq w+4*m(CTX), xy ## 2; -#define outunpack3(op, out, n, xy, m) \ +#define outunpack3(out, n, xy, m) \ xorq w+4*m(CTX), xy ## 0; \ - op ## q xy ## 0, 4*(n)(out); \ + movq xy ## 0, 4*(n)(out); \ \ xorq w+4*m(CTX), xy ## 1; \ - op ## q xy ## 1, 4*(4+(n))(out); \ + movq xy ## 1, 4*(4+(n))(out); \ \ xorq w+4*m(CTX), xy ## 2; \ - op ## q xy ## 2, 4*(8+(n))(out); + movq xy ## 2, 4*(8+(n))(out); #define inpack_enc3() \ inpack3(RIO, 0, RAB, 0); \ inpack3(RIO, 2, RCD, 2); -#define outunpack_enc3(op) \ - outunpack3(op, RIO, 2, RAB, 6); \ - outunpack3(op, RIO, 0, RCD, 4); +#define outunpack_enc3() \ + outunpack3(RIO, 2, RAB, 6); \ + outunpack3(RIO, 0, RCD, 4); #define inpack_dec3() \ inpack3(RIO, 0, RAB, 4); \ @@ -214,11 +214,11 @@ rorq $32, RCD0; \ rorq $32, RCD1; \ rorq $32, RCD2; \ - outunpack3(mov, RIO, 0, RCD, 0); \ + outunpack3(RIO, 0, RCD, 0); \ rorq $32, RAB0; \ rorq $32, RAB1; \ rorq $32, RAB2; \ - outunpack3(mov, RIO, 2, RAB, 2); + outunpack3(RIO, 2, RAB, 2); #define outunpack_cbc_dec3() \ rorq $32, RCD0; \ @@ -226,13 +226,13 @@ xorq (RT1), RCD1; \ rorq $32, RCD2; \ xorq 16(RT1), RCD2; \ - outunpack3(mov, RIO, 0, RCD, 0); \ + outunpack3(RIO, 0, RCD, 0); \ rorq $32, RAB0; \ rorq $32, RAB1; \ xorq 8(RT1), RAB1; \ rorq $32, RAB2; \ xorq 24(RT1), RAB2; \ - outunpack3(mov, RIO, 2, RAB, 2); + outunpack3(RIO, 2, RAB, 2); SYM_FUNC_START(twofish_enc_blk_3way) /* input: @@ -261,7 +261,7 @@ SYM_FUNC_START(twofish_enc_blk_3way) popq RIO; /* dst */ - outunpack_enc3(mov); + outunpack_enc3(); popq %rbx; popq %r12;