diff options
author | Attila Fülöp <[email protected]> | 2021-04-17 00:11:26 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-16 15:11:26 -0700 |
commit | a9c93ac533488b78262e86821f04a22cac8be76d (patch) | |
tree | 911c8559b8c5b207c560fedff70a3c9997083fbd /module/icp | |
parent | f2286383d017856a276e6ea73f2a61f85b99df35 (diff) |
ICP: Add missing stack frame info to SHA asm files
Since the assembly routines calculating SHA checksums don't use
a standard stack layout, CFI directives are needed to unroll the
stack.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Attila Fülöp <[email protected]>
Closes #11733
Diffstat (limited to 'module/icp')
-rw-r--r-- | module/icp/asm-x86_64/sha1/sha1-x86_64.S | 24 | ||||
-rw-r--r-- | module/icp/asm-x86_64/sha2/sha256_impl.S | 26 | ||||
-rw-r--r-- | module/icp/asm-x86_64/sha2/sha512_impl.S | 26 |
3 files changed, 72 insertions, 4 deletions
diff --git a/module/icp/asm-x86_64/sha1/sha1-x86_64.S b/module/icp/asm-x86_64/sha1/sha1-x86_64.S index cb923784a..fc844cd8c 100644 --- a/module/icp/asm-x86_64/sha1/sha1-x86_64.S +++ b/module/icp/asm-x86_64/sha1/sha1-x86_64.S @@ -69,16 +69,27 @@ sha1_block_data_order(SHA1_CTX *ctx, const void *inpp, size_t blocks) #define _ASM #include <sys/asm_linkage.h> ENTRY_NP(sha1_block_data_order) +.cfi_startproc + mov %rsp,%rax +.cfi_def_cfa_register %rax push %rbx +.cfi_offset %rbx,-16 push %rbp +.cfi_offset %rbp,-24 push %r12 - mov %rsp,%rax +.cfi_offset %r12,-32 mov %rdi,%r8 # reassigned argument +.cfi_register %rdi, %r8 sub $72,%rsp mov %rsi,%r9 # reassigned argument +.cfi_register %rsi, %r9 and $-64,%rsp mov %rdx,%r10 # reassigned argument +.cfi_register %rdx, %r10 mov %rax,64(%rsp) +# echo ".cfi_cfa_expression %rsp+64,deref,+8" | +# openssl/crypto/perlasm/x86_64-xlate.pl +.cfi_escape 0x0f,0x06,0x77,0xc0,0x00,0x06,0x23,0x08 mov 0(%r8),%edx mov 4(%r8),%esi @@ -1337,10 +1348,15 @@ ENTRY_NP(sha1_block_data_order) sub $1,%r10 jnz .Lloop mov 64(%rsp),%rsp - pop %r12 - pop %rbp - pop %rbx +.cfi_def_cfa %rsp,8 + movq -24(%rsp),%r12 +.cfi_restore %r12 + movq -16(%rsp),%rbp +.cfi_restore %rbp + movq -8(%rsp),%rbx +.cfi_restore %rbx ret +.cfi_endproc SET_SIZE(sha1_block_data_order) .data diff --git a/module/icp/asm-x86_64/sha2/sha256_impl.S b/module/icp/asm-x86_64/sha2/sha256_impl.S index 766b75355..28b048d2d 100644 --- a/module/icp/asm-x86_64/sha2/sha256_impl.S +++ b/module/icp/asm-x86_64/sha2/sha256_impl.S @@ -83,12 +83,21 @@ SHA256TransformBlocks(SHA2_CTX *ctx, const void *in, size_t num) #include <sys/asm_linkage.h> ENTRY_NP(SHA256TransformBlocks) +.cfi_startproc + movq %rsp, %rax +.cfi_def_cfa_register %rax push %rbx +.cfi_offset %rbx,-16 push %rbp +.cfi_offset %rbp,-24 push %r12 +.cfi_offset %r12,-32 push %r13 +.cfi_offset %r13,-40 push %r14 +.cfi_offset %r14,-48 push %r15 +.cfi_offset %r15,-56 mov %rsp,%rbp # copy %rsp shl $4,%rdx # num*16 sub $16*4+4*8,%rsp @@ -99,6 +108,9 @@ ENTRY_NP(SHA256TransformBlocks) mov %rsi,16*4+1*8(%rsp) # save inp, 2nd arg mov %rdx,16*4+2*8(%rsp) # save end pointer, "3rd" arg mov %rbp,16*4+3*8(%rsp) # save copy of %rsp +# echo ".cfi_cfa_expression %rsp+88,deref,+56" | +# openssl/crypto/perlasm/x86_64-xlate.pl +.cfi_escape 0x0f,0x06,0x77,0xd8,0x00,0x06,0x23,0x38 #.picmeup %rbp # The .picmeup pseudo-directive, from perlasm/x86_64_xlate.pl, puts @@ -2026,14 +2038,28 @@ ENTRY_NP(SHA256TransformBlocks) jb .Lloop mov 16*4+3*8(%rsp),%rsp +.cfi_def_cfa %rsp,56 pop %r15 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r15 pop %r14 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r14 pop %r13 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r13 pop %r12 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r12 pop %rbp +.cfi_adjust_cfa_offset -8 +.cfi_restore %rbp pop %rbx +.cfi_adjust_cfa_offset -8 +.cfi_restore %rbx ret +.cfi_endproc SET_SIZE(SHA256TransformBlocks) .data diff --git a/module/icp/asm-x86_64/sha2/sha512_impl.S b/module/icp/asm-x86_64/sha2/sha512_impl.S index 6e3761876..746c85a98 100644 --- a/module/icp/asm-x86_64/sha2/sha512_impl.S +++ b/module/icp/asm-x86_64/sha2/sha512_impl.S @@ -84,12 +84,21 @@ SHA512TransformBlocks(SHA2_CTX *ctx, const void *in, size_t num) #include <sys/asm_linkage.h> ENTRY_NP(SHA512TransformBlocks) +.cfi_startproc + movq %rsp, %rax +.cfi_def_cfa_register %rax push %rbx +.cfi_offset %rbx,-16 push %rbp +.cfi_offset %rbp,-24 push %r12 +.cfi_offset %r12,-32 push %r13 +.cfi_offset %r13,-40 push %r14 +.cfi_offset %r14,-48 push %r15 +.cfi_offset %r15,-56 mov %rsp,%rbp # copy %rsp shl $4,%rdx # num*16 sub $16*8+4*8,%rsp @@ -100,6 +109,9 @@ ENTRY_NP(SHA512TransformBlocks) mov %rsi,16*8+1*8(%rsp) # save inp, 2nd arg mov %rdx,16*8+2*8(%rsp) # save end pointer, "3rd" arg mov %rbp,16*8+3*8(%rsp) # save copy of %rsp +# echo ".cfi_cfa_expression %rsp+152,deref,+56" | +# openssl/crypto/perlasm/x86_64-xlate.pl +.cfi_escape 0x0f,0x06,0x77,0x98,0x01,0x06,0x23,0x38 #.picmeup %rbp # The .picmeup pseudo-directive, from perlasm/x86_64_xlate.pl, puts @@ -2027,14 +2039,28 @@ ENTRY_NP(SHA512TransformBlocks) jb .Lloop mov 16*8+3*8(%rsp),%rsp +.cfi_def_cfa %rsp,56 pop %r15 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r15 pop %r14 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r14 pop %r13 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r13 pop %r12 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r12 pop %rbp +.cfi_adjust_cfa_offset -8 +.cfi_restore %rbp pop %rbx +.cfi_adjust_cfa_offset -8 +.cfi_restore %rbx ret +.cfi_endproc SET_SIZE(SHA512TransformBlocks) .data |