]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
lib/crypto: x86/sha256: Remove unnecessary checks for nblocks==0
authorEric Biggers <ebiggers@kernel.org>
Fri, 4 Jul 2025 02:39:58 +0000 (19:39 -0700)
committerEric Biggers <ebiggers@kernel.org>
Fri, 4 Jul 2025 17:23:56 +0000 (10:23 -0700)
Since sha256_blocks() is called only with nblocks >= 1, remove
unnecessary checks for nblocks == 0 from the x86 SHA-256 assembly code.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20250704023958.73274-3-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
lib/crypto/x86/sha256-avx-asm.S
lib/crypto/x86/sha256-avx2-asm.S
lib/crypto/x86/sha256-ni-asm.S
lib/crypto/x86/sha256-ssse3-asm.S

index 798a7f07fa013bba9aadd8b4c55a7b27bba07e18..c1aceb3ba3a3a6e56603d783997e188df93ca5cb 100644 (file)
@@ -357,7 +357,6 @@ SYM_FUNC_START(sha256_transform_avx)
        and     $~15, %rsp              # align stack pointer
 
        shl     $6, NUM_BLKS            # convert to bytes
-       jz      .Ldone_hash
        add     INP, NUM_BLKS           # pointer to end of data
        mov     NUM_BLKS, _INP_END(%rsp)
 
@@ -446,8 +445,6 @@ SYM_FUNC_START(sha256_transform_avx)
        cmp     _INP_END(%rsp), INP
        jne     .Lloop0
 
-.Ldone_hash:
-
        mov     %rbp, %rsp
        popq    %rbp
        popq    %r15
index 62a46993359e619cca6b0c2535b71d7af3fc3be6..eb8836fb9695c1ac378e56060dc05e87c688ecdf 100644 (file)
@@ -535,7 +535,6 @@ SYM_FUNC_START(sha256_transform_rorx)
        and     $-32, %rsp      # align rsp to 32 byte boundary
 
        shl     $6, NUM_BLKS    # convert to bytes
-       jz      .Ldone_hash
        lea     -64(INP, NUM_BLKS), NUM_BLKS # pointer to last block
        mov     NUM_BLKS, _INP_END(%rsp)
 
index 9ebbacbb9c13b39975ef4ae2006ecee0ef88c4e9..4bd9490ffc662194a921d73d657e107cdc3a0c9c 100644 (file)
 SYM_FUNC_START(sha256_ni_transform)
 
        shl             $6, NUM_BLKS            /*  convert to bytes */
-       jz              .Ldone_hash
        add             DATA_PTR, NUM_BLKS      /* pointer to end of data */
 
        /*
@@ -163,8 +162,6 @@ SYM_FUNC_START(sha256_ni_transform)
        movdqu          STATE1, 0*16(STATE_PTR)
        movdqu          STATE0, 1*16(STATE_PTR)
 
-.Ldone_hash:
-
        RET
 SYM_FUNC_END(sha256_ni_transform)
 
index 820fc8bbc29fd2d69d8cf98f4bcabba1da8cb10b..383b8eec7ebe90fdd544a694e996ac47a1282cda 100644 (file)
@@ -364,7 +364,6 @@ SYM_FUNC_START(sha256_transform_ssse3)
        and     $~15, %rsp
 
        shl     $6, NUM_BLKS             # convert to bytes
-       jz      .Ldone_hash
        add     INP, NUM_BLKS
        mov     NUM_BLKS, _INP_END(%rsp) # pointer to end of data
 
@@ -457,8 +456,6 @@ SYM_FUNC_START(sha256_transform_ssse3)
        cmp     _INP_END(%rsp), INP
        jne     .Lloop0
 
-.Ldone_hash:
-
        mov     %rbp, %rsp
        popq    %rbp
        popq    %r15