diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/libcrypto/aes/asm/aes-sparcv9.pl | 64 | ||||
-rw-r--r-- | lib/libcrypto/arch/sparc64/Makefile.inc | 4 | ||||
-rw-r--r-- | lib/libcrypto/bn/asm/sparcv9-mont.pl | 2 | ||||
-rwxr-xr-x | lib/libcrypto/bn/asm/sparcv9a-mont.pl | 2 | ||||
-rw-r--r-- | lib/libcrypto/modes/asm/ghash-sparcv9.pl | 35 | ||||
-rw-r--r-- | lib/libcrypto/sha/asm/sha1-sparcv9.pl | 1 | ||||
-rw-r--r-- | lib/libcrypto/sha/asm/sha1-sparcv9a.pl | 17 | ||||
-rw-r--r-- | lib/libcrypto/sha/asm/sha512-sparcv9.pl | 25 |
8 files changed, 109 insertions, 41 deletions
diff --git a/lib/libcrypto/aes/asm/aes-sparcv9.pl b/lib/libcrypto/aes/asm/aes-sparcv9.pl index c57b3a2d6d3..08ac9830f14 100755 --- a/lib/libcrypto/aes/asm/aes-sparcv9.pl +++ b/lib/libcrypto/aes/asm/aes-sparcv9.pl @@ -79,7 +79,7 @@ $code.=<<___ if ($bits==64); .register %g3,#scratch ___ $code.=<<___; -.section ".text",#alloc,#execinstr +.section ".rodata",#alloc .align 256 AES_Te: @@ -185,6 +185,7 @@ $code.=<<___; .type AES_Te,#object .size AES_Te,(.-AES_Te) +.section ".text",#alloc,#execinstr .align 64 .skip 16 _sparcv9_AES_encrypt: @@ -512,18 +513,30 @@ _sparcv9_AES_encrypt: .align 32 .globl AES_encrypt AES_encrypt: - or %o0,%o1,%g1 + save %sp,-$frame,%sp +#ifdef __PIC__ + sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %o5 + rd %pc, %o4 + or %o5, %lo(_GLOBAL_OFFSET_TABLE_+4), %o5 + add %o5, %o4, %o5 +#endif + + or %i0,%i1,%g1 andcc %g1,3,%g0 bnz,pn %xcc,.Lunaligned_enc - save %sp,-$frame,%sp + nop ld [%i0+0],%o0 ld [%i0+4],%o1 ld [%i0+8],%o2 ld [%i0+12],%o3 -1: call .+8 - add %o7,AES_Te-1b,%o4 +#ifdef __PIC__ + set AES_Te, %o4 + ldx [%o4+%o5], %o4 +#else + set AES_Te, %o4 +#endif call _sparcv9_AES_encrypt mov %i2,%o5 @@ -582,8 +595,12 @@ AES_encrypt: or %l7,%l6,%l6 or %l4,%l6,%o3 -1: call .+8 - add %o7,AES_Te-1b,%o4 +#ifdef __PIC__ + set AES_Te, %o4 + ldx [%o4+%o5], %o4 +#else + set AES_Te, %o4 +#endif call _sparcv9_AES_encrypt mov %i2,%o5 @@ -627,6 +644,7 @@ AES_encrypt: ___ $code.=<<___; +.section ".rodata",#alloc .align 256 AES_Td: ___ @@ -731,6 +749,7 @@ $code.=<<___; .type AES_Td,#object .size AES_Td,(.-AES_Td) +.section ".text",#alloc,#execinstr .align 64 .skip 16 _sparcv9_AES_decrypt: @@ -1058,18 +1077,30 @@ _sparcv9_AES_decrypt: .align 32 .globl AES_decrypt AES_decrypt: - or %o0,%o1,%g1 + save %sp,-$frame,%sp +#ifdef __PIC__ + sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %o5 + rd %pc, %o4 + or %o5, %lo(_GLOBAL_OFFSET_TABLE_+4), %o5 + add %o5, %o4, %o5 +#endif + + or %i0,%i1,%g1 andcc %g1,3,%g0 bnz,pn %xcc,.Lunaligned_dec - save %sp,-$frame,%sp + nop ld [%i0+0],%o0 ld [%i0+4],%o1 ld [%i0+8],%o2 ld [%i0+12],%o3 -1: call .+8 - add %o7,AES_Td-1b,%o4 +#ifdef __PIC__ + set AES_Td, %o4 + ldx [%o4+%o5], %o4 +#else + set AES_Td, %o4 +#endif call _sparcv9_AES_decrypt mov %i2,%o5 @@ -1128,8 +1159,12 @@ AES_decrypt: or %l7,%l6,%l6 or %l4,%l6,%o3 -1: call .+8 - add %o7,AES_Td-1b,%o4 +#ifdef __PIC__ + set AES_Td, %o4 + ldx [%o4+%o5], %o4 +#else + set AES_Td, %o4 +#endif call _sparcv9_AES_decrypt mov %i2,%o5 @@ -1176,6 +1211,7 @@ ___ # As UltraSPARC T1, a.k.a. Niagara, has shared FPU, FP nops can have # undesired effect, so just omit them and sacrifice some portion of # percent in performance... -$code =~ s/fmovs.*$//gem; +$code =~ s/fmovs.*$//gm; print $code; +close STDOUT; # ensure flush diff --git a/lib/libcrypto/arch/sparc64/Makefile.inc b/lib/libcrypto/arch/sparc64/Makefile.inc index cb502b28a38..223c941f77e 100644 --- a/lib/libcrypto/arch/sparc64/Makefile.inc +++ b/lib/libcrypto/arch/sparc64/Makefile.inc @@ -1,9 +1,7 @@ -# $OpenBSD: Makefile.inc,v 1.5 2023/01/11 16:36:44 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.6 2023/01/13 17:27:26 miod Exp $ # sparc64-specific libcrypto build rules -LDADD+= -Wl,--no-execute-only - # aes SRCS+= aes_core.c aes_cbc.c CFLAGS+= -DAES_ASM diff --git a/lib/libcrypto/bn/asm/sparcv9-mont.pl b/lib/libcrypto/bn/asm/sparcv9-mont.pl index fb44c014431..610ec1a968a 100644 --- a/lib/libcrypto/bn/asm/sparcv9-mont.pl +++ b/lib/libcrypto/bn/asm/sparcv9-mont.pl @@ -598,8 +598,6 @@ $code.=<<___; add $tp,8,$tp .type $fname,#function .size $fname,(.-$fname) -.asciz "Montgomery Multipltication for SPARCv9, CRYPTOGAMS by <appro\@openssl.org>" -.align 32 ___ $code =~ s/\`([^\`]*)\`/eval($1)/gem; print $code; diff --git a/lib/libcrypto/bn/asm/sparcv9a-mont.pl b/lib/libcrypto/bn/asm/sparcv9a-mont.pl index 4ebe15c5c01..7bb1725a0ed 100755 --- a/lib/libcrypto/bn/asm/sparcv9a-mont.pl +++ b/lib/libcrypto/bn/asm/sparcv9a-mont.pl @@ -860,8 +860,6 @@ $fname: restore .type $fname,#function .size $fname,(.-$fname) -.asciz "Montgomery Multipltication for UltraSPARC, CRYPTOGAMS by <appro\@openssl.org>" -.align 32 ___ $code =~ s/\`([^\`]*)\`/eval($1)/gem; diff --git a/lib/libcrypto/modes/asm/ghash-sparcv9.pl b/lib/libcrypto/modes/asm/ghash-sparcv9.pl index 70e7b044a3e..ce75045f096 100644 --- a/lib/libcrypto/modes/asm/ghash-sparcv9.pl +++ b/lib/libcrypto/modes/asm/ghash-sparcv9.pl @@ -67,7 +67,7 @@ $inp="%i2"; $len="%i3"; $code.=<<___; -.section ".text",#alloc,#execinstr +.section ".rodata",#alloc .align 64 rem_4bit: @@ -78,18 +78,30 @@ rem_4bit: .type rem_4bit,#object .size rem_4bit,(.-rem_4bit) +.section ".text",#alloc,#execinstr .globl gcm_ghash_4bit .align 32 gcm_ghash_4bit: save %sp,-$frame,%sp +#ifdef __PIC__ + sethi %hi(_GLOBAL_OFFSET_TABLE_-4), $tmp + rd %pc, $rem + or $tmp, %lo(_GLOBAL_OFFSET_TABLE_+4), $tmp + add $tmp, $rem, $tmp +#endif + ldub [$inp+15],$nlo ldub [$Xi+15],$xi0 ldub [$Xi+14],$xi1 add $len,$inp,$len add $Htbl,8,$Htblo -1: call .+8 - add %o7,rem_4bit-1b,$rem_4bit +#ifdef __PIC__ + set rem_4bit, $rem_4bit + ldx [$rem_4bit+$tmp], $rem_4bit +#else + set rem_4bit, $rem_4bit +#endif .Louter: xor $xi0,$nlo,$nlo @@ -223,11 +235,22 @@ $code.=<<___; .align 32 gcm_gmult_4bit: save %sp,-$frame,%sp +#ifdef __PIC__ + sethi %hi(_GLOBAL_OFFSET_TABLE_-4), $tmp + rd %pc, $rem + or $tmp, %lo(_GLOBAL_OFFSET_TABLE_+4), $tmp + add $tmp, $rem, $tmp +#endif + ldub [$Xi+15],$nlo add $Htbl,8,$Htblo -1: call .+8 - add %o7,rem_4bit-1b,$rem_4bit +#ifdef __PIC__ + set rem_4bit, $rem_4bit + ldx [$rem_4bit+$tmp], $rem_4bit +#else + set rem_4bit, $rem_4bit +#endif and $nlo,0xf0,$nhi and $nlo,0x0f,$nlo @@ -321,8 +344,6 @@ gcm_gmult_4bit: restore .type gcm_gmult_4bit,#function .size gcm_gmult_4bit,(.-gcm_gmult_4bit) -.asciz "GHASH for SPARCv9, CRYPTOGAMS by <appro\@openssl.org>" -.align 4 ___ $code =~ s/\`([^\`]*)\`/eval $1/gem; diff --git a/lib/libcrypto/sha/asm/sha1-sparcv9.pl b/lib/libcrypto/sha/asm/sha1-sparcv9.pl index 8306fc88ccf..5235c59e634 100644 --- a/lib/libcrypto/sha/asm/sha1-sparcv9.pl +++ b/lib/libcrypto/sha/asm/sha1-sparcv9.pl @@ -275,7 +275,6 @@ $code.=<<___; restore .type sha1_block_data_order,#function .size sha1_block_data_order,(.-sha1_block_data_order) -.asciz "SHA1 block transform for SPARCv9, CRYPTOGAMS by <appro\@openssl.org>" ___ $code =~ s/\`([^\`]*)\`/eval $1/gem; diff --git a/lib/libcrypto/sha/asm/sha1-sparcv9a.pl b/lib/libcrypto/sha/asm/sha1-sparcv9a.pl index e81a4dcb053..8e7674e9d23 100644 --- a/lib/libcrypto/sha/asm/sha1-sparcv9a.pl +++ b/lib/libcrypto/sha/asm/sha1-sparcv9a.pl @@ -396,7 +396,7 @@ ___ } $code.=<<___; -.section ".text",#alloc,#execinstr +.section ".rodata",#alloc .align 64 vis_const: @@ -409,13 +409,22 @@ vis_const: .type vis_const,#object .size vis_const,(.-vis_const) +.section ".text",#alloc,#execinstr .globl sha1_block_data_order sha1_block_data_order: save %sp,-$frame,%sp add %fp,$bias-256,$base -1: call .+8 - add %o7,vis_const-1b,$tmp0 +#ifdef __PIC__ + sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %o5 + rd %pc, %o4 + or %o5, %lo(_GLOBAL_OFFSET_TABLE_+4), %o5 + add %o5, %o4, %o5 + set vis_const, %o4 + ldx [%o4+%o5], %o4 +#else + set vis_const, %o4 +#endif ldd [$tmp0+0],$VK_00_19 ldd [$tmp0+8],$VK_20_39 @@ -538,8 +547,6 @@ $code.=<<___; restore .type sha1_block_data_order,#function .size sha1_block_data_order,(.-sha1_block_data_order) -.asciz "SHA1 block transform for SPARCv9a, CRYPTOGAMS by <appro\@openssl.org>" -.align 4 ___ # Purpose of these subroutines is to explicitly encode VIS instructions, diff --git a/lib/libcrypto/sha/asm/sha512-sparcv9.pl b/lib/libcrypto/sha/asm/sha512-sparcv9.pl index 54241aab504..3c93799446a 100644 --- a/lib/libcrypto/sha/asm/sha512-sparcv9.pl +++ b/lib/libcrypto/sha/asm/sha512-sparcv9.pl @@ -305,9 +305,9 @@ $code.=<<___; srlx @X[(($i+9)/2)%8],32,$tmp1 ! X[i+9] xor $tmp0,$tmp2,$tmp2 ! sigma1(X[i+14]) srl @X[($i/2)%8],0,$tmp0 + add $tmp2,$tmp1,$tmp1 add $xi,$T1,$T1 ! +=X[i] xor $tmp0,@X[($i/2)%8],@X[($i/2)%8] - add $tmp2,$T1,$T1 add $tmp1,$T1,$T1 srl $T1,0,$T1 @@ -318,9 +318,9 @@ ___ $code.=<<___; srlx @X[($i/2)%8],32,$tmp1 ! X[i] xor $tmp0,$tmp2,$tmp2 ! sigma1(X[i+14]) - srl @X[($i/2)%8],0,@X[($i/2)%8] add $xi,$T1,$T1 ! +=X[i+9] - add $tmp2,$T1,$T1 + add $tmp2,$tmp1,$tmp1 + srl @X[($i/2)%8],0,@X[($i/2)%8] add $tmp1,$T1,$T1 sllx $T1,32,$tmp0 @@ -386,7 +386,7 @@ $code.=<<___ if ($bits==64); .register %g3,#scratch ___ $code.=<<___; -.section ".text",#alloc,#execinstr +.section ".rodata",#alloc .align 64 K${label}: @@ -457,9 +457,17 @@ ___ } $code.=<<___; .size K${label},.-K${label} + +.section ".text",#alloc,#execinstr .globl sha${label}_block_data_order sha${label}_block_data_order: save %sp,`-$frame-$locals`,%sp +#ifdef __PIC__ + sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %o5 + rd %pc, %o4 + or %o5, %lo(_GLOBAL_OFFSET_TABLE_+4), %o5 + add %o5, %o4, %o5 +#endif and $inp,`$align-1`,$tmp31 sllx $len,`log(16*$SZ)/log(2)`,$len andn $inp,`$align-1`,$inp @@ -471,8 +479,12 @@ $code.=<<___ if ($SZ==8); # SHA512 sub $tmp32,$tmp31,$tmp32 ___ $code.=<<___; -.Lpic: call .+8 - add %o7,K${label}-.Lpic,$Ktbl +#ifdef __PIC__ + set K${label}, $Ktbl + ldx [$Ktbl+%o5], $Ktbl +#else + set K${label}, $Ktbl +#endif $LD [$ctx+`0*$SZ`],$A $LD [$ctx+`1*$SZ`],$B @@ -585,7 +597,6 @@ $code.=<<___; restore .type sha${label}_block_data_order,#function .size sha${label}_block_data_order,(.-sha${label}_block_data_order) -.asciz "SHA${label} block transform for SPARCv9, CRYPTOGAMS by <appro\@openssl.org>" ___ $code =~ s/\`([^\`]*)\`/eval $1/gem; |