mbox series

[v2,0/3] crypto: x86/blowfish - Cleanup and convert to ECB/CBC macros

Message ID 20230131012624.6230-1-peter@n8pjl.ca (mailing list archive)
Headers show
Series crypto: x86/blowfish - Cleanup and convert to ECB/CBC macros | expand

Message

Peter Lafreniere Jan. 31, 2023, 1:26 a.m. UTC
We can acheive a reduction in code size by cleaning up unused logic in
assembly functions, and by replacing handwritten ECB/CBC routines with
helper macros from 'ecb_cbc_helpers.h'.

Additionally, these changes can allow future x86_64 optimized
implementations to take advantage of blowfish-x86_64's fast 1-way and
4-way functions with less code churn.

When testing the patch, I saw a few percent lower cycle counts per
iteration on Intel Skylake for both encryption and decryption. This
is merely a single observation and this series has not been rigorously
benchmarked, as performance changes are not expected. 

v1 -> v2:
 - Fixed typo that caused an assembler failure
 - Added note about performance to cover letter

Peter Lafreniere (3):
  crypto: x86/blowfish - Remove unused encode parameter
  crypto: x86/blowfish - Convert to use ECB/CBC helpers
  crypto: x86/blowfish - Eliminate use of SYM_TYPED_FUNC_START in asm

 arch/x86/crypto/blowfish-x86_64-asm_64.S |  71 ++++----
 arch/x86/crypto/blowfish_glue.c          | 200 +++--------------------
 2 files changed, 55 insertions(+), 216 deletions(-)

Comments

Ard Biesheuvel Jan. 31, 2023, 8:11 a.m. UTC | #1
On Tue, 31 Jan 2023 at 02:26, Peter Lafreniere <peter@n8pjl.ca> wrote:
>
> We can acheive a reduction in code size by cleaning up unused logic in
> assembly functions, and by replacing handwritten ECB/CBC routines with
> helper macros from 'ecb_cbc_helpers.h'.
>
> Additionally, these changes can allow future x86_64 optimized
> implementations to take advantage of blowfish-x86_64's fast 1-way and
> 4-way functions with less code churn.
>

'future x86_64 optimized implementations' of blowfish? That is a joke, right?

> When testing the patch, I saw a few percent lower cycle counts per
> iteration on Intel Skylake for both encryption and decryption. This
> is merely a single observation and this series has not been rigorously
> benchmarked, as performance changes are not expected.
>
> v1 -> v2:
>  - Fixed typo that caused an assembler failure
>  - Added note about performance to cover letter
>
> Peter Lafreniere (3):
>   crypto: x86/blowfish - Remove unused encode parameter
>   crypto: x86/blowfish - Convert to use ECB/CBC helpers
>   crypto: x86/blowfish - Eliminate use of SYM_TYPED_FUNC_START in asm
>

Tested-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Ard Biesheuvel <ardb@kernel.org>


>  arch/x86/crypto/blowfish-x86_64-asm_64.S |  71 ++++----
>  arch/x86/crypto/blowfish_glue.c          | 200 +++--------------------
>  2 files changed, 55 insertions(+), 216 deletions(-)
>
> --
> 2.39.1
>
Herbert Xu Feb. 10, 2023, 9:45 a.m. UTC | #2
Peter Lafreniere <peter@n8pjl.ca> wrote:
> We can acheive a reduction in code size by cleaning up unused logic in
> assembly functions, and by replacing handwritten ECB/CBC routines with
> helper macros from 'ecb_cbc_helpers.h'.
> 
> Additionally, these changes can allow future x86_64 optimized
> implementations to take advantage of blowfish-x86_64's fast 1-way and
> 4-way functions with less code churn.
> 
> When testing the patch, I saw a few percent lower cycle counts per
> iteration on Intel Skylake for both encryption and decryption. This
> is merely a single observation and this series has not been rigorously
> benchmarked, as performance changes are not expected. 
> 
> v1 -> v2:
> - Fixed typo that caused an assembler failure
> - Added note about performance to cover letter
> 
> Peter Lafreniere (3):
>  crypto: x86/blowfish - Remove unused encode parameter
>  crypto: x86/blowfish - Convert to use ECB/CBC helpers
>  crypto: x86/blowfish - Eliminate use of SYM_TYPED_FUNC_START in asm
> 
> arch/x86/crypto/blowfish-x86_64-asm_64.S |  71 ++++----
> arch/x86/crypto/blowfish_glue.c          | 200 +++--------------------
> 2 files changed, 55 insertions(+), 216 deletions(-)

All applied.  Thanks.