summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorBernd Edlinger <bernd.edlinger@hotmail.de>2019-12-21 22:09:45 +0100
committerBernd Edlinger <bernd.edlinger@hotmail.de>2019-12-23 16:57:42 +0100
commit665de4d48aef2507022a7d74f5c7f6e339d5e6bc (patch)
tree340c450ffa701f74bf7488c1462d32919cd59c0e /crypto
parenteff5076a78502d1ac04669e44127d4bd7c0a9ce7 (diff)
Fix aesni_cbc_sha256_enc_avx2 backtrace info
We store a secondary frame pointer info for the debugger in the red zone. This fixes a crash in the unwinder when this function is interrupted. Additionally the missing cfi function annotation is added to aesni_cbc_sha256_enc_shaext. [extended tests] Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10674)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/aes/asm/aesni-sha256-x86_64.pl58
1 files changed, 44 insertions, 14 deletions
diff --git a/crypto/aes/asm/aesni-sha256-x86_64.pl b/crypto/aes/asm/aesni-sha256-x86_64.pl
index 6527fe28a7..f6d97ed8ed 100644
--- a/crypto/aes/asm/aesni-sha256-x86_64.pl
+++ b/crypto/aes/asm/aesni-sha256-x86_64.pl
@@ -1088,7 +1088,23 @@ $code.=<<___;
vmovdqa $t0,0x00(%rsp)
xor $a1,$a1
vmovdqa $t1,0x20(%rsp)
+___
+$code.=<<___ if (!$win64);
+# temporarily use %rsi as frame pointer
+ mov $_rsp,%rsi
+.cfi_def_cfa %rsi,8
+___
+$code.=<<___;
lea -$PUSH8(%rsp),%rsp
+___
+$code.=<<___ if (!$win64);
+# 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 %rsi,-8(%rsp)
+.cfi_cfa_expression %rsp-8,deref,+8
+___
+$code.=<<___;
mov $B,$a3
vmovdqa $t2,0x00(%rsp)
xor $C,$a3 # magic
@@ -1110,7 +1126,17 @@ my @X = @_;
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) {
+ &lea ("%rsp","-$PUSH8(%rsp)");
+$code.=<<___ if (!$win64);
+.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));
@@ -1236,26 +1262,28 @@ $code.=<<___;
jbe .Loop_avx2
lea (%rsp),$Tbl
+# temporarily use $Tbl as index to $_rsp
+# this avoids the need to save a secondary frame pointer at -8(%rsp)
+.cfi_cfa_expression $Tbl+`16*$SZ+7*8`,deref,+8
.Ldone_avx2:
- lea ($Tbl),%rsp
- mov $_ivp,$ivp
- mov $_rsp,%rsi
+ mov 16*$SZ+4*8($Tbl),$ivp
+ mov 16*$SZ+7*8($Tbl),%rsi
.cfi_def_cfa %rsi,8
vmovdqu $iv,($ivp) # output IV
vzeroall
___
$code.=<<___ if ($win64);
- movaps `$framesz+16*0`(%rsp),%xmm6
- movaps `$framesz+16*1`(%rsp),%xmm7
- movaps `$framesz+16*2`(%rsp),%xmm8
- movaps `$framesz+16*3`(%rsp),%xmm9
- movaps `$framesz+16*4`(%rsp),%xmm10
- movaps `$framesz+16*5`(%rsp),%xmm11
- movaps `$framesz+16*6`(%rsp),%xmm12
- movaps `$framesz+16*7`(%rsp),%xmm13
- movaps `$framesz+16*8`(%rsp),%xmm14
- movaps `$framesz+16*9`(%rsp),%xmm15
+ movaps `$framesz+16*0`($Tbl),%xmm6
+ movaps `$framesz+16*1`($Tbl),%xmm7
+ movaps `$framesz+16*2`($Tbl),%xmm8
+ movaps `$framesz+16*3`($Tbl),%xmm9
+ movaps `$framesz+16*4`($Tbl),%xmm10
+ movaps `$framesz+16*5`($Tbl),%xmm11
+ movaps `$framesz+16*6`($Tbl),%xmm12
+ movaps `$framesz+16*7`($Tbl),%xmm13
+ movaps `$framesz+16*8`($Tbl),%xmm14
+ movaps `$framesz+16*9`($Tbl),%xmm15
___
$code.=<<___;
mov -48(%rsi),%r15
@@ -1343,6 +1371,7 @@ $code.=<<___;
.type ${func}_shaext,\@function,6
.align 32
${func}_shaext:
+.cfi_startproc
mov `($win64?56:8)`(%rsp),$inp # load 7th argument
___
$code.=<<___ if ($win64);
@@ -1559,6 +1588,7 @@ $code.=<<___ if ($win64);
___
$code.=<<___;
ret
+.cfi_endproc
.size ${func}_shaext,.-${func}_shaext
___
}
id='n333' href='#n333'>333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495