Skip to content

Commit

Permalink
Fix sha512_block_data_order_avx2 backtrace info
Browse files Browse the repository at this point in the history
We store a secondary frame pointer info for the debugger
in the red zone.

Fixes openssl#8853

[extended tests]
  • Loading branch information
bernd-edlinger committed Aug 18, 2019
1 parent cae665d commit dbd2e03
Showing 1 changed file with 48 additions and 3 deletions.
51 changes: 48 additions & 3 deletions crypto/sha/asm/sha512-x86_64.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1930,7 +1930,11 @@ ()
mov $inp,$_inp # save inp, 2nd arh
mov %rdx,$_end # save end pointer, "3rd" arg
mov %rax,$_rsp # save copy of %rsp
.cfi_cfa_expression $_rsp,deref,+8
# the frame info is at $_rsp, but the stack is moving...
# so a second frame pointer is saved at -8(%rsp)
# that is in the red zone
mov %rax,-8(%rsp)
.cfi_cfa_expression %rsp-8,deref,+8
___
$code.=<<___ if ($win64);
movaps %xmm6,16*$SZ+32(%rsp)
Expand Down Expand Up @@ -1993,6 +1997,11 @@ ()
xor $a1,$a1
vmovdqa $t1,0x20(%rsp)
lea -$PUSH8(%rsp),%rsp
.cfi_cfa_expression %rsp+`$PUSH8-8`,deref,+8
# copy secondary frame pointer to new location again at -8(%rsp)
mov $PUSH8-8(%rsp),%rdi
mov %rdi,-8(%rsp)
.cfi_cfa_expression %rsp-8,deref,+8
mov $B,$a3
vmovdqa $t2,0x00(%rsp)
xor $C,$a3 # magic
Expand All @@ -2012,7 +2021,18 @@ ()
my @insns = (&$body,&$body,&$body,&$body); # 96 instructions
my $base = "+2*$PUSH8(%rsp)";

&lea ("%rsp","-$PUSH8(%rsp)") if (($j%2)==0);
if (($j%2)==0) {
$code.=<<___;
lea -$PUSH8(%rsp),%rsp
.cfi_cfa_expression %rsp+`$PUSH8-8`,deref,+8
# copy secondary frame pointer to new location again at -8(%rsp)
pushq $PUSH8-8(%rsp)
.cfi_cfa_expression %rsp,deref,+8
lea 8(%rsp),%rsp
.cfi_cfa_expression %rsp-8,deref,+8
___
}

foreach (Xupdate_256_AVX()) { # 29 instructions
eval;
eval(shift(@insns));
Expand Down Expand Up @@ -2084,6 +2104,11 @@ ()
vpaddq 0x40($Tbl),@X[6],$t2
vmovdqa $t3,0x60(%rsp)
lea -$PUSH8(%rsp),%rsp
.cfi_cfa_expression %rsp+`$PUSH8-8`,deref,+8
# copy secondary frame pointer to new location again at -8(%rsp)
mov $PUSH8-8(%rsp),%rdi
mov %rdi,-8(%rsp)
.cfi_cfa_expression %rsp-8,deref,+8
vpaddq 0x60($Tbl),@X[7],$t3
vmovdqa $t0,0x00(%rsp)
xor $a1,$a1
Expand All @@ -2107,7 +2132,18 @@ ()
my @insns = (&$body,&$body); # 48 instructions
my $base = "+2*$PUSH8(%rsp)";

&lea ("%rsp","-$PUSH8(%rsp)") if (($j%4)==0);
if (($j%4)==0) {
$code.=<<___;
lea -$PUSH8(%rsp),%rsp
.cfi_cfa_expression %rsp+`$PUSH8-8`,deref,+8
# copy secondary frame pointer to new location again at -8(%rsp)
pushq $PUSH8-8(%rsp)
.cfi_cfa_expression %rsp,deref,+8
lea 8(%rsp),%rsp
.cfi_cfa_expression %rsp-8,deref,+8
___
}

foreach (Xupdate_512_AVX()) { # 23 instructions
eval;
if ($_ !~ /\;$/) {
Expand Down Expand Up @@ -2182,6 +2218,13 @@ ()
add $a1,$A
#mov `2*$SZ*$rounds+8`(%rsp),$inp # $_inp
lea `2*$SZ*($rounds-8)`(%rsp),%rsp
# restore frame pointer to original location at $_rsp
.cfi_cfa_expression $_rsp,deref,+8
# copy secondary frame pointer to new location again at -8(%rsp)
pushq $_rsp
.cfi_cfa_expression %rsp,deref,+8
lea 8(%rsp),%rsp
.cfi_cfa_expression %rsp-8,deref,+8
add $SZ*0($ctx),$A
add $SZ*1($ctx),$B
Expand Down Expand Up @@ -2210,6 +2253,8 @@ ()
.Ldone_avx2:
lea ($Tbl),%rsp
# restore frame pointer to original location at $_rsp
.cfi_cfa_expression $_rsp,deref,+8
mov $_rsp,%rsi
.cfi_def_cfa %rsi,8
vzeroupper
Expand Down

0 comments on commit dbd2e03

Please sign in to comment.