3 # ====================================================================
4 # Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
5 # project. The module is, however, dual licensed under OpenSSL and
6 # CRYPTOGAMS licenses depending on where you obtain it. For further
7 # details see http://www.openssl.org/~appro/cryptogams/.
8 # ====================================================================
12 # Companion to x86_64-mont.pl that optimizes cache-timing attack
13 # countermeasures. The subroutines are produced by replacing bp[i]
14 # references in their x86_64-mont.pl counterparts with cache-neutral
15 # references to powers table computed in BN_mod_exp_mont_consttime.
16 # In addition subroutine that scatters elements of the powers table
17 # is implemented, so that scatter-/gathering can be tuned without
18 # bn_exp.c modifications.
22 if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
24 $win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
26 $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
27 ( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or
28 ( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
29 die "can't locate x86_64-xlate.pl";
31 open OUT,"| \"$^X\" $xlate $flavour $output";
34 # int bn_mul_mont_gather5(
35 $rp="%rdi"; # BN_ULONG *rp,
36 $ap="%rsi"; # const BN_ULONG *ap,
37 $bp="%rdx"; # const BN_ULONG *bp,
38 $np="%rcx"; # const BN_ULONG *np,
39 $n0="%r8"; # const BN_ULONG *n0,
40 $num="%r9"; # int num,
41 # int idx); # 0 to 2^5-1, "index" in $bp holding
42 # pre-computed powers of a', interlaced
43 # in such manner that b[0] is $bp[idx],
44 # b[1] is [2^5+idx], etc.
56 .globl bn_mul_mont_gather5
57 .type bn_mul_mont_gather5,\@function,6
69 movd `($win64?56:8)`(%rsp),%xmm5 # load 7th argument
82 lea -264(%rsp,%r11,8),%rsp # tp=alloca(8*(num+2)+256+8)
83 and \$-1024,%rsp # minimize TLB usage
85 mov %rax,8(%rsp,$num,8) # tp[num+1]=%rsp
87 # Some OSes, *cough*-dows, insist on stack being "wired" to
88 # physical memory in strictly sequential manner, i.e. if stack
89 # allocation spans two pages, then reference to farmost one can
90 # be punishable by SEGV. But page walking can do good even on
91 # other OSes, because it guarantees that villain thread hits
92 # the guard page before it can make damage to innocent one...
98 .byte 0x2e # predict non-taken
101 lea 128($bp),%r12 # reassign $bp (+size optimization)
104 $STRIDE=2**5*8; # 5 is "window size"
105 $N=$STRIDE/4; # should match cache line size
107 movdqa 0(%r10),%xmm0 # 00000001000000010000000000000000
108 movdqa 16(%r10),%xmm1 # 00000002000000020000000200000002
109 lea 24-112(%rsp,$num,8),%r10# place the mask after tp[num+3] (+ICache optimization)
112 pshufd \$0,%xmm5,%xmm5 # broadcast index
116 ########################################################################
117 # calculate mask by comparing 0..31 to index and save result to stack
121 pcmpeqd %xmm5,%xmm0 # compare to 1,0
125 for($k=0;$k<$STRIDE/16-4;$k+=4) {
128 pcmpeqd %xmm5,%xmm1 # compare to 3,2
129 movdqa %xmm0,`16*($k+0)+112`(%r10)
133 pcmpeqd %xmm5,%xmm2 # compare to 5,4
134 movdqa %xmm1,`16*($k+1)+112`(%r10)
138 pcmpeqd %xmm5,%xmm3 # compare to 7,6
139 movdqa %xmm2,`16*($k+2)+112`(%r10)
144 movdqa %xmm3,`16*($k+3)+112`(%r10)
148 $code.=<<___; # last iteration can be optimized
151 movdqa %xmm0,`16*($k+0)+112`(%r10)
156 movdqa %xmm1,`16*($k+1)+112`(%r10)
159 movdqa %xmm2,`16*($k+2)+112`(%r10)
160 pand `16*($k+0)-128`($bp),%xmm0 # while it's still in register
162 pand `16*($k+1)-128`($bp),%xmm1
163 pand `16*($k+2)-128`($bp),%xmm2
164 movdqa %xmm3,`16*($k+3)+112`(%r10)
165 pand `16*($k+3)-128`($bp),%xmm3
169 for($k=0;$k<$STRIDE/16-4;$k+=4) {
171 movdqa `16*($k+0)-128`($bp),%xmm4
172 movdqa `16*($k+1)-128`($bp),%xmm5
173 movdqa `16*($k+2)-128`($bp),%xmm2
174 pand `16*($k+0)+112`(%r10),%xmm4
175 movdqa `16*($k+3)-128`($bp),%xmm3
176 pand `16*($k+1)+112`(%r10),%xmm5
178 pand `16*($k+2)+112`(%r10),%xmm2
180 pand `16*($k+3)+112`(%r10),%xmm3
187 pshufd \$0x4e,%xmm0,%xmm1
190 movq %xmm0,$m0 # m0=bp[0]
192 mov ($n0),$n0 # pull n0[0] value
199 mulq $m0 # ap[0]*bp[0]
203 imulq $lo0,$m1 # "tp[0]"*n0
207 add %rax,$lo0 # discarded
220 add $hi0,$hi1 # np[j]*m1+ap[j]*bp[0]
223 mov $hi1,-16(%rsp,$j,8) # tp[j-1]
227 mulq $m0 # ap[j]*bp[0]
239 mov ($ap),%rax # ap[0]
241 add $hi0,$hi1 # np[j]*m1+ap[j]*bp[0]
243 mov $hi1,-16(%rsp,$j,8) # tp[j-1]
250 mov $hi1,-8(%rsp,$num,8)
251 mov %rdx,(%rsp,$num,8) # store upmost overflow bit
257 lea 24+128(%rsp,$num,8),%rdx # where 256-byte mask is (+size optimization)
262 for($k=0;$k<$STRIDE/16;$k+=4) {
264 movdqa `16*($k+0)-128`($bp),%xmm0
265 movdqa `16*($k+1)-128`($bp),%xmm1
266 movdqa `16*($k+2)-128`($bp),%xmm2
267 movdqa `16*($k+3)-128`($bp),%xmm3
268 pand `16*($k+0)-128`(%rdx),%xmm0
269 pand `16*($k+1)-128`(%rdx),%xmm1
271 pand `16*($k+2)-128`(%rdx),%xmm2
273 pand `16*($k+3)-128`(%rdx),%xmm3
280 pshufd \$0x4e,%xmm4,%xmm0
283 movq %xmm0,$m0 # m0=bp[i]
289 mulq $m0 # ap[0]*bp[i]
290 add %rax,$lo0 # ap[0]*bp[i]+tp[0]
294 imulq $lo0,$m1 # tp[0]*n0
298 add %rax,$lo0 # discarded
301 mov 8(%rsp),$lo0 # tp[1]
312 add $lo0,$hi1 # np[j]*m1+ap[j]*bp[i]+tp[j]
315 mov $hi1,-16(%rsp,$j,8) # tp[j-1]
319 mulq $m0 # ap[j]*bp[i]
323 add $hi0,$lo0 # ap[j]*bp[i]+tp[j]
333 mov ($ap),%rax # ap[0]
335 add $lo0,$hi1 # np[j]*m1+ap[j]*bp[i]+tp[j]
338 mov $hi1,-16(%rsp,$j,8) # tp[j-1]
344 add $lo0,$hi1 # pull upmost overflow bit
346 mov $hi1,-8(%rsp,$num,8)
347 mov %rdx,(%rsp,$num,8) # store upmost overflow bit
353 xor $i,$i # i=0 and clear CF!
354 mov (%rsp),%rax # tp[0]
355 lea (%rsp),$ap # borrow ap for tp
359 .Lsub: sbb ($np,$i,8),%rax
360 mov %rax,($rp,$i,8) # rp[i]=tp[i]-np[i]
361 mov 8($ap,$i,8),%rax # tp[i+1]
363 dec $j # doesnn't affect CF!
366 sbb \$0,%rax # handle upmost overflow bit
373 or $np,$ap # ap=borrow?tp:rp
375 .Lcopy: # copy or in-place refresh
377 mov $i,(%rsp,$i,8) # zap temporary vector
378 mov %rax,($rp,$i,8) # rp[i]=tp[i]
383 mov 8(%rsp,$num,8),%rsi # restore %rsp
395 .size bn_mul_mont_gather5,.-bn_mul_mont_gather5
398 my @A=("%r10","%r11");
399 my @N=("%r13","%rdi");
401 .type bn_mul4x_mont_gather5,\@function,6
403 bn_mul4x_mont_gather5:
406 movd `($win64?56:8)`(%rsp),%xmm5 # load 7th argument
419 lea -256(%rsp,%r11,8),%rsp # tp=alloca(8*(num+4)+256)
420 and \$-1024,%rsp # minimize TLB usage
422 mov %rax,8(%rsp,$num,8) # tp[num+1]=%rsp
429 .byte 0x2e # predict non-taken
430 jnc .Lmul4x_page_walk
432 mov $rp,16(%rsp,$num,8) # tp[num+2]=$rp
433 lea 128(%rdx),%r12 # reassign $bp (+size optimization)
436 $STRIDE=2**5*8; # 5 is "window size"
437 $N=$STRIDE/4; # should match cache line size
439 movdqa 0(%r10),%xmm0 # 00000001000000010000000000000000
440 movdqa 16(%r10),%xmm1 # 00000002000000020000000200000002
441 lea 32-112(%rsp,$num,8),%r10# place the mask after tp[num+4] (+ICache optimization)
443 pshufd \$0,%xmm5,%xmm5 # broadcast index
448 ########################################################################
449 # calculate mask by comparing 0..31 to index and save result to stack
453 pcmpeqd %xmm5,%xmm0 # compare to 1,0
457 for($k=0;$k<$STRIDE/16-4;$k+=4) {
460 pcmpeqd %xmm5,%xmm1 # compare to 3,2
461 movdqa %xmm0,`16*($k+0)+112`(%r10)
465 pcmpeqd %xmm5,%xmm2 # compare to 5,4
466 movdqa %xmm1,`16*($k+1)+112`(%r10)
470 pcmpeqd %xmm5,%xmm3 # compare to 7,6
471 movdqa %xmm2,`16*($k+2)+112`(%r10)
476 movdqa %xmm3,`16*($k+3)+112`(%r10)
480 $code.=<<___; # last iteration can be optimized
483 movdqa %xmm0,`16*($k+0)+112`(%r10)
488 movdqa %xmm1,`16*($k+1)+112`(%r10)
491 movdqa %xmm2,`16*($k+2)+112`(%r10)
492 pand `16*($k+0)-128`($bp),%xmm0 # while it's still in register
494 pand `16*($k+1)-128`($bp),%xmm1
495 pand `16*($k+2)-128`($bp),%xmm2
496 movdqa %xmm3,`16*($k+3)+112`(%r10)
497 pand `16*($k+3)-128`($bp),%xmm3
501 for($k=0;$k<$STRIDE/16-4;$k+=4) {
503 movdqa `16*($k+0)-128`($bp),%xmm4
504 movdqa `16*($k+1)-128`($bp),%xmm5
505 movdqa `16*($k+2)-128`($bp),%xmm2
506 pand `16*($k+0)+112`(%r10),%xmm4
507 movdqa `16*($k+3)-128`($bp),%xmm3
508 pand `16*($k+1)+112`(%r10),%xmm5
510 pand `16*($k+2)+112`(%r10),%xmm2
512 pand `16*($k+3)+112`(%r10),%xmm3
519 pshufd \$0x4e,%xmm0,%xmm1
522 movq %xmm0,$m0 # m0=bp[0]
524 mov ($n0),$n0 # pull n0[0] value
531 mulq $m0 # ap[0]*bp[0]
535 imulq $A[0],$m1 # "tp[0]"*n0
539 add %rax,$A[0] # discarded
562 mulq $m0 # ap[j]*bp[0]
564 mov -16($np,$j,8),%rax
570 mov -8($ap,$j,8),%rax
572 add $A[0],$N[0] # np[j]*m1+ap[j]*bp[0]
574 mov $N[0],-24(%rsp,$j,8) # tp[j-1]
577 mulq $m0 # ap[j]*bp[0]
579 mov -8($np,$j,8),%rax
587 add $A[1],$N[1] # np[j]*m1+ap[j]*bp[0]
589 mov $N[1],-16(%rsp,$j,8) # tp[j-1]
592 mulq $m0 # ap[j]*bp[0]
602 add $A[0],$N[0] # np[j]*m1+ap[j]*bp[0]
604 mov $N[0],-8(%rsp,$j,8) # tp[j-1]
607 mulq $m0 # ap[j]*bp[0]
616 mov -16($ap,$j,8),%rax
618 add $A[1],$N[1] # np[j]*m1+ap[j]*bp[0]
620 mov $N[1],-32(%rsp,$j,8) # tp[j-1]
625 mulq $m0 # ap[j]*bp[0]
627 mov -16($np,$j,8),%rax
633 mov -8($ap,$j,8),%rax
635 add $A[0],$N[0] # np[j]*m1+ap[j]*bp[0]
637 mov $N[0],-24(%rsp,$j,8) # tp[j-1]
640 mulq $m0 # ap[j]*bp[0]
642 mov -8($np,$j,8),%rax
648 mov ($ap),%rax # ap[0]
650 add $A[1],$N[1] # np[j]*m1+ap[j]*bp[0]
652 mov $N[1],-16(%rsp,$j,8) # tp[j-1]
658 mov $N[0],-8(%rsp,$j,8)
659 mov $N[1],(%rsp,$j,8) # store upmost overflow bit
664 lea 32+128(%rsp,$num,8),%rdx # where 256-byte mask is (+size optimization)
668 for($k=0;$k<$STRIDE/16;$k+=4) {
670 movdqa `16*($k+0)-128`($bp),%xmm0
671 movdqa `16*($k+1)-128`($bp),%xmm1
672 movdqa `16*($k+2)-128`($bp),%xmm2
673 movdqa `16*($k+3)-128`($bp),%xmm3
674 pand `16*($k+0)-128`(%rdx),%xmm0
675 pand `16*($k+1)-128`(%rdx),%xmm1
677 pand `16*($k+2)-128`(%rdx),%xmm2
679 pand `16*($k+3)-128`(%rdx),%xmm3
686 pshufd \$0x4e,%xmm4,%xmm0
689 movq %xmm0,$m0 # m0=bp[i]
695 mulq $m0 # ap[0]*bp[i]
696 add %rax,$A[0] # ap[0]*bp[i]+tp[0]
700 imulq $A[0],$m1 # tp[0]*n0
704 add %rax,$A[0] # "$N[0]", discarded
709 mulq $m0 # ap[j]*bp[i]
713 add 8(%rsp),$A[1] # +tp[1]
721 add $A[1],$N[1] # np[j]*m1+ap[j]*bp[i]+tp[j]
728 mulq $m0 # ap[j]*bp[i]
730 mov -16($np,$j,8),%rax
732 add -16(%rsp,$j,8),$A[0] # ap[j]*bp[i]+tp[j]
738 mov -8($ap,$j,8),%rax
742 mov $N[1],-32(%rsp,$j,8) # tp[j-1]
745 mulq $m0 # ap[j]*bp[i]
747 mov -8($np,$j,8),%rax
749 add -8(%rsp,$j,8),$A[1]
759 mov $N[0],-24(%rsp,$j,8) # tp[j-1]
762 mulq $m0 # ap[j]*bp[i]
766 add (%rsp,$j,8),$A[0] # ap[j]*bp[i]+tp[j]
776 mov $N[1],-16(%rsp,$j,8) # tp[j-1]
779 mulq $m0 # ap[j]*bp[i]
783 add 8(%rsp,$j,8),$A[1]
790 mov -16($ap,$j,8),%rax
794 mov $N[0],-40(%rsp,$j,8) # tp[j-1]
799 mulq $m0 # ap[j]*bp[i]
801 mov -16($np,$j,8),%rax
803 add -16(%rsp,$j,8),$A[0] # ap[j]*bp[i]+tp[j]
809 mov -8($ap,$j,8),%rax
813 mov $N[1],-32(%rsp,$j,8) # tp[j-1]
816 mulq $m0 # ap[j]*bp[i]
818 mov -8($np,$j,8),%rax
820 add -8(%rsp,$j,8),$A[1]
827 mov ($ap),%rax # ap[0]
831 mov $N[0],-24(%rsp,$j,8) # tp[j-1]
834 mov $N[1],-16(%rsp,$j,8) # tp[j-1]
839 add (%rsp,$num,8),$N[0] # pull upmost overflow bit
841 mov $N[0],-8(%rsp,$j,8)
842 mov $N[1],(%rsp,$j,8) # store upmost overflow bit
848 my @ri=("%rax","%rdx",$m0,$m1);
850 mov 16(%rsp,$num,8),$rp # restore $rp
851 mov 0(%rsp),@ri[0] # tp[0]
853 mov 8(%rsp),@ri[1] # tp[1]
854 shr \$2,$num # num/=4
855 lea (%rsp),$ap # borrow ap for tp
856 xor $i,$i # i=0 and clear CF!
859 mov 16($ap),@ri[2] # tp[2]
860 mov 24($ap),@ri[3] # tp[3]
862 lea -1($num),$j # j=num/4-1
866 mov @ri[0],0($rp,$i,8) # rp[i]=tp[i]-np[i]
867 mov @ri[1],8($rp,$i,8) # rp[i]=tp[i]-np[i]
868 sbb 16($np,$i,8),@ri[2]
869 mov 32($ap,$i,8),@ri[0] # tp[i+1]
870 mov 40($ap,$i,8),@ri[1]
871 sbb 24($np,$i,8),@ri[3]
872 mov @ri[2],16($rp,$i,8) # rp[i]=tp[i]-np[i]
873 mov @ri[3],24($rp,$i,8) # rp[i]=tp[i]-np[i]
874 sbb 32($np,$i,8),@ri[0]
875 mov 48($ap,$i,8),@ri[2]
876 mov 56($ap,$i,8),@ri[3]
877 sbb 40($np,$i,8),@ri[1]
879 dec $j # doesnn't affect CF!
882 mov @ri[0],0($rp,$i,8) # rp[i]=tp[i]-np[i]
883 mov 32($ap,$i,8),@ri[0] # load overflow bit
884 sbb 16($np,$i,8),@ri[2]
885 mov @ri[1],8($rp,$i,8) # rp[i]=tp[i]-np[i]
886 sbb 24($np,$i,8),@ri[3]
887 mov @ri[2],16($rp,$i,8) # rp[i]=tp[i]-np[i]
889 sbb \$0,@ri[0] # handle upmost overflow bit
890 mov @ri[3],24($rp,$i,8) # rp[i]=tp[i]-np[i]
897 or $np,$ap # ap=borrow?tp:rp
904 .Lcopy4x: # copy or in-place refresh
905 movdqu 16($ap,$i),%xmm2
906 movdqu 32($ap,$i),%xmm1
907 movdqa %xmm0,16(%rsp,$i)
908 movdqu %xmm2,16($rp,$i)
909 movdqa %xmm0,32(%rsp,$i)
910 movdqu %xmm1,32($rp,$i)
916 movdqu 16($ap,$i),%xmm2
917 movdqa %xmm0,16(%rsp,$i)
918 movdqu %xmm2,16($rp,$i)
922 mov 8(%rsp,$num,8),%rsi # restore %rsp
934 .size bn_mul4x_mont_gather5,.-bn_mul4x_mont_gather5
939 my ($inp,$num,$tbl,$idx)=$win64?("%rcx","%rdx","%r8", "%r9d") : # Win64 order
940 ("%rdi","%rsi","%rdx","%ecx"); # Unix order
947 .type bn_scatter5,\@abi-omnipotent
951 jz .Lscatter_epilogue
952 lea ($tbl,$idx,8),$tbl
962 .size bn_scatter5,.-bn_scatter5
965 .type bn_gather5,\@abi-omnipotent
968 .LSEH_begin_bn_gather5: # Win64 thing, but harmless in other cases
969 # I can't trust assembler to use specific encoding:-(
970 .byte 0x4c,0x8d,0x14,0x24 # lea (%rsp),%r10
971 .byte 0x48,0x81,0xec,0x08,0x01,0x00,0x00 # sub $0x108,%rsp
973 and \$-16,%rsp # shouldn't be formally required
976 movdqa 0(%rax),%xmm0 # 00000001000000010000000000000000
977 movdqa 16(%rax),%xmm1 # 00000002000000020000000200000002
978 lea 128($tbl),%r11 # size optimization
979 lea 128(%rsp),%rax # size optimization
981 pshufd \$0,%xmm5,%xmm5 # broadcast $idx
985 ########################################################################
986 # calculate mask by comparing 0..31 to $idx and save result to stack
988 for($i=0;$i<$STRIDE/16;$i+=4) {
991 pcmpeqd %xmm5,%xmm0 # compare to 1,0
993 $code.=<<___ if ($i);
994 movdqa %xmm3,`16*($i-1)-128`(%rax)
1000 pcmpeqd %xmm5,%xmm1 # compare to 3,2
1001 movdqa %xmm0,`16*($i+0)-128`(%rax)
1005 pcmpeqd %xmm5,%xmm2 # compare to 5,4
1006 movdqa %xmm1,`16*($i+1)-128`(%rax)
1010 pcmpeqd %xmm5,%xmm3 # compare to 7,6
1011 movdqa %xmm2,`16*($i+2)-128`(%rax)
1016 movdqa %xmm3,`16*($i-1)-128`(%rax)
1024 for($i=0;$i<$STRIDE/16;$i+=4) {
1026 movdqa `16*($i+0)-128`(%r11),%xmm0
1027 movdqa `16*($i+1)-128`(%r11),%xmm1
1028 movdqa `16*($i+2)-128`(%r11),%xmm2
1029 pand `16*($i+0)-128`(%rax),%xmm0
1030 movdqa `16*($i+3)-128`(%r11),%xmm3
1031 pand `16*($i+1)-128`(%rax),%xmm1
1033 pand `16*($i+2)-128`(%rax),%xmm2
1035 pand `16*($i+3)-128`(%rax),%xmm3
1042 lea $STRIDE(%r11),%r11
1043 pshufd \$0x4e,%xmm4,%xmm0
1045 movq %xmm0,($out) # m0=bp[0]
1052 .LSEH_end_bn_gather5:
1053 .size bn_gather5,.-bn_gather5
1061 .asciz "Montgomery Multiplication with scatter/gather for x86_64, CRYPTOGAMS by <appro\@openssl.org>"
1064 # EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame,
1065 # CONTEXT *context,DISPATCHER_CONTEXT *disp)
1073 .extern __imp_RtlVirtualUnwind
1074 .type mul_handler,\@abi-omnipotent
1088 mov 120($context),%rax # pull context->Rax
1089 mov 248($context),%rbx # pull context->Rip
1091 mov 8($disp),%rsi # disp->ImageBase
1092 mov 56($disp),%r11 # disp->HandlerData
1094 mov 0(%r11),%r10d # HandlerData[0]
1095 lea (%rsi,%r10),%r10 # end of prologue label
1096 cmp %r10,%rbx # context->Rip<end of prologue label
1097 jb .Lcommon_seh_tail
1101 mov 4(%r11),%r10d # HandlerData[1]
1102 lea (%rsi,%r10),%r10 # end of alloca label
1103 cmp %r10,%rbx # context->Rip<end of alloca label
1104 jb .Lcommon_seh_tail
1106 mov 152($context),%rax # pull context->Rsp
1108 mov 8(%r11),%r10d # HandlerData[2]
1109 lea (%rsi,%r10),%r10 # epilogue label
1110 cmp %r10,%rbx # context->Rip>=epilogue label
1111 jae .Lcommon_seh_tail
1113 mov 192($context),%r10 # pull $num
1114 mov 8(%rax,%r10,8),%rax # pull saved stack pointer
1124 mov %rbx,144($context) # restore context->Rbx
1125 mov %rbp,160($context) # restore context->Rbp
1126 mov %r12,216($context) # restore context->R12
1127 mov %r13,224($context) # restore context->R13
1128 mov %r14,232($context) # restore context->R14
1129 mov %r15,240($context) # restore context->R15
1134 mov %rax,152($context) # restore context->Rsp
1135 mov %rsi,168($context) # restore context->Rsi
1136 mov %rdi,176($context) # restore context->Rdi
1138 mov 40($disp),%rdi # disp->ContextRecord
1139 mov $context,%rsi # context
1140 mov \$154,%ecx # sizeof(CONTEXT)
1141 .long 0xa548f3fc # cld; rep movsq
1144 xor %rcx,%rcx # arg1, UNW_FLAG_NHANDLER
1145 mov 8(%rsi),%rdx # arg2, disp->ImageBase
1146 mov 0(%rsi),%r8 # arg3, disp->ControlPc
1147 mov 16(%rsi),%r9 # arg4, disp->FunctionEntry
1148 mov 40(%rsi),%r10 # disp->ContextRecord
1149 lea 56(%rsi),%r11 # &disp->HandlerData
1150 lea 24(%rsi),%r12 # &disp->EstablisherFrame
1151 mov %r10,32(%rsp) # arg5
1152 mov %r11,40(%rsp) # arg6
1153 mov %r12,48(%rsp) # arg7
1154 mov %rcx,56(%rsp) # arg8, (NULL)
1155 call *__imp_RtlVirtualUnwind(%rip)
1157 mov \$1,%eax # ExceptionContinueSearch
1169 .size mul_handler,.-mul_handler
1173 .rva .LSEH_begin_bn_mul_mont_gather5
1174 .rva .LSEH_end_bn_mul_mont_gather5
1175 .rva .LSEH_info_bn_mul_mont_gather5
1177 .rva .LSEH_begin_bn_mul4x_mont_gather5
1178 .rva .LSEH_end_bn_mul4x_mont_gather5
1179 .rva .LSEH_info_bn_mul4x_mont_gather5
1181 .rva .LSEH_begin_bn_gather5
1182 .rva .LSEH_end_bn_gather5
1183 .rva .LSEH_info_bn_gather5
1187 .LSEH_info_bn_mul_mont_gather5:
1190 .rva .Lmul_alloca,.Lmul_body,.Lmul_epilogue # HandlerData[]
1192 .LSEH_info_bn_mul4x_mont_gather5:
1195 .rva .Lmul4x_alloca,.Lmul4x_body,.Lmul4x_epilogue # HandlerData[]
1197 .LSEH_info_bn_gather5:
1198 .byte 0x01,0x0b,0x03,0x0a
1199 .byte 0x0b,0x01,0x21,0x00 # sub rsp,0x108
1200 .byte 0x04,0xa3,0x00,0x00 # lea r10,(rsp), set_frame r10
1205 $code =~ s/\`([^\`]*)\`/eval($1)/gem;