diff --git a/openssl-1.1.1k-sw.patch b/openssl-1.1.1k-sw.patch index aff91ae2d80ced01d52bad214f107b8d29c9550f..efa7d1c8dec92b2f9fc0b87abf1d900f7a49c265 100644 --- a/openssl-1.1.1k-sw.patch +++ b/openssl-1.1.1k-sw.patch @@ -1,60 +1,91 @@ -diff -Naur openssl-1.1.1k.org/config openssl-1.1.1k.sw/config ---- openssl-1.1.1k.org/config 2021-03-25 21:28:38.000000000 +0800 -+++ openssl-1.1.1k.sw/config 2023-05-16 14:20:22.039496272 +0800 -@@ -521,6 +521,17 @@ - esac - fi - ;; -+ sw_64-*-linux2) -+ ISA=`awk '/cpu model/{print$4;exit(0);}' /proc/cpuinfo` -+ OUT="linux-sw_64-$CC" -+ if [ "$CC" = "gcc" ]; then -+ case ${ISA:-generic} in -+ *sw*) __CNF_CFLAGS="$__CNF_CFLAGS -mcpu=sw6b" -+ __CNF_CXXFLAGS="$__CNF_CFLAGS -mcpu=sw6b";; -+ esac -+ fi -+ ;; -+ - ppc64-*-linux2) - if [ -z "$KERNEL_BITS" ]; then - echo "WARNING! If you wish to build 64-bit library, then you have to" -diff -Naur openssl-1.1.1k.org/Configurations/00-base-templates.conf openssl-1.1.1k.sw/Configurations/00-base-templates.conf ---- openssl-1.1.1k.org/Configurations/00-base-templates.conf 2023-05-16 14:08:10.157785868 +0800 -+++ openssl-1.1.1k.sw/Configurations/00-base-templates.conf 2023-05-16 14:22:55.091873469 +0800 -@@ -273,6 +273,14 @@ - modes_asm_src => "ghash-alpha.S", +From b9a4924e2d662b555caf7c9872462891b33baa3f Mon Sep 17 00:00:00 2001 +From: wxiat +Date: Thu, 13 Jul 2023 10:55:18 +0800 +Subject: [PATCH] add sw + +Signed-off-by: wxiat +--- + Configurations/00-base-templates.conf | 8 + + Configurations/10-main.conf | 5 + + config | 10 + + crypto/bn/asm/sw_64-mont.pl | 328 ++++++++++++++++++ + crypto/bn/bn_local.h | 2 +- + crypto/bn/build.info | 1 + + crypto/build.info | 3 +- + crypto/modes/asm/ghash-sw_64.pl | 467 ++++++++++++++++++++++++++ + crypto/modes/build.info | 1 + + crypto/rand/rand_unix.c | 2 + + crypto/sha/asm/sha1-sw_64.pl | 329 ++++++++++++++++++ + crypto/sha/build.info | 1 + + crypto/sw_64cpuid.pl | 270 +++++++++++++++ + include/crypto/md32_common.h | 2 +- + 14 files changed, 1426 insertions(+), 3 deletions(-) + create mode 100644 crypto/bn/asm/sw_64-mont.pl + create mode 100644 crypto/modes/asm/ghash-sw_64.pl + create mode 100644 crypto/sha/asm/sha1-sw_64.pl + create mode 100644 crypto/sw_64cpuid.pl + +diff --git a/Configurations/00-base-templates.conf b/Configurations/00-base-templates.conf +index 9add1cd..528a19c 100644 +--- a/Configurations/00-base-templates.conf ++++ b/Configurations/00-base-templates.conf +@@ -265,6 +265,14 @@ my %targets=( + des_asm_src => "des_enc-sparc.S fcrypt_b.c", perlasm_scheme => "void" }, + sw_64_asm => { -+ template => 1, -+ cpuid_asm_src => "sw_64cpuid.s", -+ bn_asm_src => "bn_asm.c sw_64-mont.S", -+ sha1_asm_src => "sha1-sw_64.S", -+ modes_asm_src => "ghash-sw_64.S", -+ perlasm_scheme => "void" ++ template => 1, ++ cpuid_asm_src => "sw_64cpuid.s", ++ bn_asm_src => "bn_asm.c sw_64-mont.S", ++ sha1_asm_src => "sha1-sw_64.S", ++ modes_asm_src => "ghash-sw_64.S", ++ perlasm_scheme => "void" + }, - mips32_asm => { + alpha_asm => { template => 1, - bn_asm_src => "bn-mips.S mips-mont.S", -diff -Naur openssl-1.1.1k.org/Configurations/10-main.conf openssl-1.1.1k.sw/Configurations/10-main.conf ---- openssl-1.1.1k.org/Configurations/10-main.conf 2023-05-16 14:08:10.074782953 +0800 -+++ openssl-1.1.1k.sw/Configurations/10-main.conf 2023-05-16 14:23:48.071735635 +0800 -@@ -885,6 +885,11 @@ - lib_cppflags => add("-DL_ENDIAN"), - bn_ops => "SIXTY_FOUR_BIT_LONG", + cpuid_asm_src => "alphacpuid.s", +diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf +index bf69df7..264b8e4 100644 +--- a/Configurations/10-main.conf ++++ b/Configurations/10-main.conf +@@ -880,6 +880,11 @@ my %targets = ( + multilib => "64", }, + + "linux-sw_64-gcc" => { + inherit_from => [ "linux-generic64", asm("sw_64_asm") ], + lib_cppflags => add("-DL_ENDIAN"), + bn_ops => "SIXTY_FOUR_BIT_LONG", + }, - "linux-c64xplus" => { - inherit_from => [ "BASE_unix" ], - # TI_CGT_C6000_7.3.x is a requirement -diff -Naur openssl-1.1.1k.org/crypto/bn/asm/sw_64-mont.pl openssl-1.1.1k.sw/crypto/bn/asm/sw_64-mont.pl ---- openssl-1.1.1k.org/crypto/bn/asm/sw_64-mont.pl 1970-01-01 08:00:00.000000000 +0800 -+++ openssl-1.1.1k.sw/crypto/bn/asm/sw_64-mont.pl 2023-05-16 14:32:44.381586191 +0800 + "linux-alpha-gcc" => { + inherit_from => [ "linux-generic64", asm("alpha_asm") ], + lib_cppflags => add("-DL_ENDIAN"), +diff --git a/config b/config +index 26225ca..fbe39d6 100755 +--- a/config ++++ b/config +@@ -507,6 +507,16 @@ case "$GUESSOS" in + OUT="iphoneos-cross" ;; + arm64-*-iphoneos|*-*-ios64) + OUT="ios64-cross" ;; ++ sw_64-*-linux2) ++ ISA=`awk '/cpu model/{print$4;exit(0);}' /proc/cpuinfo` ++ OUT="linux-sw_64-$CC" ++ if [ "$CC" = "gcc" ]; then ++ case ${ISA:-generic} in ++ *sw*) __CNF_CFLAGS="$__CNF_CFLAGS -mcpu=sw6b" ++ __CNF_CXXFLAGS="$__CNF_CFLAGS -mcpu=sw6b";; ++ esac ++ fi ++ ;; + alpha-*-linux2) + ISA=`awk '/cpu model/{print$4;exit(0);}' /proc/cpuinfo` + OUT="linux-alpha-$CC" +diff --git a/crypto/bn/asm/sw_64-mont.pl b/crypto/bn/asm/sw_64-mont.pl +new file mode 100644 +index 0000000..c2208f5 +--- /dev/null ++++ b/crypto/bn/asm/sw_64-mont.pl @@ -0,0 +1,328 @@ +#! /usr/bin/env perl +# Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved. @@ -144,7 +175,7 @@ diff -Naur openssl-1.1.1k.org/crypto/bn/asm/sw_64-mont.pl openssl-1.1.1k.sw/cryp + bne AT,.Lexit + + ldl $hi0,0($ap) # ap[0] -+ s8addql$num,16,AT ++ s8addl $num,16,AT + ldl $aj,8($ap) + subl sp,AT,sp + ldl $bi,0($bp) # bp[0] @@ -203,7 +234,7 @@ diff -Naur openssl-1.1.1k.org/crypto/bn/asm/sw_64-mont.pl openssl-1.1.1k.sw/cryp + addl $hi1,v0,$hi1 + s8addl $j,$np,$nj + -+ stq $lo1,-8($tp) ++ stl $lo1,-8($tp) + nop + unop + bne $tj,.L1st @@ -220,7 +251,7 @@ diff -Naur openssl-1.1.1k.org/crypto/bn/asm/sw_64-mont.pl openssl-1.1.1k.sw/cryp + cmpult $lo1,$lo0,v0 + addl $hi1,v0,$hi1 + -+ stq $lo1,0($tp) ++ stl $lo1,0($tp) + + addl $hi1,$hi0,$hi1 + cmpult $hi1,$hi0,AT @@ -257,7 +288,7 @@ diff -Naur openssl-1.1.1k.org/crypto/bn/asm/sw_64-mont.pl openssl-1.1.1k.sw/cryp + + mull $aj,$bi,$alo + mov sp,$tp -+ umull $aj,$bi,$ahi ++ umulh $aj,$bi,$ahi + + mull $nj,$m1,$nlo + s8addl $j,$ap,$aj @@ -278,7 +309,7 @@ diff -Naur openssl-1.1.1k.org/crypto/bn/asm/sw_64-mont.pl openssl-1.1.1k.sw/cryp + mull $aj,$bi,$alo #U1 + cmpult $lo0,$hi0,AT #L0 + addl $nlo,$hi1,$lo1 #L1 -+ addi $j,1,$j ++ addw $j,1,$j + + mull $nj,$m1,$nlo #U1 + addl $ahi,AT,$hi0 #L0 @@ -323,7 +354,7 @@ diff -Naur openssl-1.1.1k.org/crypto/bn/asm/sw_64-mont.pl openssl-1.1.1k.sw/cryp + cmpult $lo1,$hi0,$hi1 + addl $lo1,$tj,$lo1 + cmpult $lo1,$tj,AT -+ addi $i,1,$i ++ addw $i,1,$i + addl $hi1,AT,$hi1 + stl $lo1,8($tp) + cmplt $i,$num,$tj # borrow $tj @@ -351,7 +382,7 @@ diff -Naur openssl-1.1.1k.org/crypto/bn/asm/sw_64-mont.pl openssl-1.1.1k.sw/cryp + ldi $rp,8($rp) + bne v0,.Lsub + -+ subq $hi1,$hi0,$hi0 # handle upmost overflow bit ++ subl $hi1,$hi0,$hi0 # handle upmost overflow bit + mov sp,$tp + mov $bp,$rp # restore rp + @@ -360,7 +391,7 @@ diff -Naur openssl-1.1.1k.org/crypto/bn/asm/sw_64-mont.pl openssl-1.1.1k.sw/cryp + ldl $nj,0($rp) + ldi $tp,8($tp) + ldi $rp,8($rp) -+ cmoveq $hi0,$nj,$aj ++ seleq $hi0,$nj,$aj,$aj + stl zero,-8($tp) # zap tp + cmpult $tp,$tj,AT + stl $aj,-8($rp) @@ -384,22 +415,24 @@ diff -Naur openssl-1.1.1k.org/crypto/bn/asm/sw_64-mont.pl openssl-1.1.1k.sw/cryp + +print $code; +close STDOUT or die "error closing STDOUT: $!"; -diff -Naur openssl-1.1.1k.org/crypto/bn/bn_local.h openssl-1.1.1k.sw/crypto/bn/bn_local.h ---- openssl-1.1.1k.org/crypto/bn/bn_local.h 2023-05-16 14:08:10.228788363 +0800 -+++ openssl-1.1.1k.sw/crypto/bn/bn_local.h 2023-05-16 14:34:20.571967144 +0800 -@@ -392,7 +392,7 @@ +diff --git a/crypto/bn/bn_local.h b/crypto/bn/bn_local.h +index 0965135..1d96339 100644 +--- a/crypto/bn/bn_local.h ++++ b/crypto/bn/bn_local.h +@@ -392,7 +392,7 @@ struct bn_blinding_st { # define BN_UMULT_LOHI(low,high,a,b) ({ \ __uint128_t ret=(__uint128_t)(a)*(b); \ (high)=ret>>64; (low)=ret; }) -# elif defined(__alpha) && (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT)) -+# elif (defined(__alpha) || defined(__sw_64)) && (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT)) ++# elif (defined(__alpha) || defined(__sw_64)) && (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT)) # if defined(__DECC) # include # define BN_UMULT_HIGH(a,b) (BN_ULONG)asm("umulh %a0,%a1,%v0",(a),(b)) -diff -Naur openssl-1.1.1k.org/crypto/bn/build.info openssl-1.1.1k.sw/crypto/bn/build.info ---- openssl-1.1.1k.org/crypto/bn/build.info 2023-05-16 14:08:10.228788363 +0800 -+++ openssl-1.1.1k.sw/crypto/bn/build.info 2023-05-16 14:34:44.790818401 +0800 -@@ -59,6 +59,7 @@ +diff --git a/crypto/bn/build.info b/crypto/bn/build.info +index c9fe2fd..52f1898 100644 +--- a/crypto/bn/build.info ++++ b/crypto/bn/build.info +@@ -59,6 +59,7 @@ GENERATE[ppc-mont.s]=asm/ppc-mont.pl $(PERLASM_SCHEME) GENERATE[ppc64-mont.s]=asm/ppc64-mont.pl $(PERLASM_SCHEME) GENERATE[alpha-mont.S]=asm/alpha-mont.pl $(PERLASM_SCHEME) @@ -407,10 +440,11 @@ diff -Naur openssl-1.1.1k.org/crypto/bn/build.info openssl-1.1.1k.sw/crypto/bn/b GENERATE[armv4-mont.S]=asm/armv4-mont.pl $(PERLASM_SCHEME) INCLUDE[armv4-mont.o]=.. -diff -Naur openssl-1.1.1k.org/crypto/build.info openssl-1.1.1k.sw/crypto/build.info ---- openssl-1.1.1k.org/crypto/build.info 2021-03-25 21:28:38.000000000 +0800 -+++ openssl-1.1.1k.sw/crypto/build.info 2023-05-16 14:35:30.211414878 +0800 -@@ -7,7 +7,7 @@ +diff --git a/crypto/build.info b/crypto/build.info +index 2c619c6..bf15def 100644 +--- a/crypto/build.info ++++ b/crypto/build.info +@@ -7,7 +7,7 @@ SOURCE[../libcrypto]=\ {- $target{uplink_aux_src} -} EXTRA= ../ms/uplink-x86.pl ../ms/uplink.c ../ms/applink.c \ x86cpuid.pl x86_64cpuid.pl ia64cpuid.S \ @@ -419,7 +453,7 @@ diff -Naur openssl-1.1.1k.org/crypto/build.info openssl-1.1.1k.sw/crypto/build.i DEPEND[cversion.o]=buildinf.h GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(CC) $(LIB_CFLAGS) $(CPPFLAGS_Q)" "$(PLATFORM)" -@@ -27,6 +27,7 @@ +@@ -27,6 +27,7 @@ GENERATE[ia64cpuid.s]=ia64cpuid.S GENERATE[ppccpuid.s]=ppccpuid.pl $(PERLASM_SCHEME) GENERATE[pariscid.s]=pariscid.pl $(PERLASM_SCHEME) GENERATE[alphacpuid.s]=alphacpuid.pl @@ -427,9 +461,11 @@ diff -Naur openssl-1.1.1k.org/crypto/build.info openssl-1.1.1k.sw/crypto/build.i GENERATE[arm64cpuid.S]=arm64cpuid.pl $(PERLASM_SCHEME) INCLUDE[arm64cpuid.o]=. GENERATE[armv4cpuid.S]=armv4cpuid.pl $(PERLASM_SCHEME) -diff -Naur openssl-1.1.1k.org/crypto/modes/asm/ghash-sw_64.pl openssl-1.1.1k.sw/crypto/modes/asm/ghash-sw_64.pl ---- openssl-1.1.1k.org/crypto/modes/asm/ghash-sw_64.pl 1970-01-01 08:00:00.000000000 +0800 -+++ openssl-1.1.1k.sw/crypto/modes/asm/ghash-sw_64.pl 2023-05-16 15:45:57.032040583 +0800 +diff --git a/crypto/modes/asm/ghash-sw_64.pl b/crypto/modes/asm/ghash-sw_64.pl +new file mode 100644 +index 0000000..de36b01 +--- /dev/null ++++ b/crypto/modes/asm/ghash-sw_64.pl @@ -0,0 +1,467 @@ +#! /usr/bin/env perl +# Copyright 2010-2020 The OpenSSL Project Authors. All Rights Reserved. @@ -623,7 +659,7 @@ diff -Naur openssl-1.1.1k.org/crypto/modes/asm/ghash-sw_64.pl openssl-1.1.1k.sw/ + ldl $rem,0($remp) + srl $Zhi,4,$Zhi + xor $t0,$Zlo,$Zlo -+ ext0b $Xhi,$cnt,$nlo ++ ext0b $Xhi,$cnt,$nlo + + and $nlo,0xf0,$nhi + xor $Thi0,$Zhi,$Zhi @@ -793,7 +829,7 @@ diff -Naur openssl-1.1.1k.org/crypto/modes/asm/ghash-sw_64.pl openssl-1.1.1k.sw/ + ext3b $inlo,$inp,$inlo + ext7b $Tlo0,$inp,$Tlo0 + or $inlo,$Tlo0,$inlo -+ subi $len,16,$len ++ subl $len,16,$len + + xor $Xlo,$inlo,$Xlo + xor $Xhi,$inhi,$Xhi @@ -898,10 +934,11 @@ diff -Naur openssl-1.1.1k.org/crypto/modes/asm/ghash-sw_64.pl openssl-1.1.1k.sw/ +print $code; +close STDOUT or die "error closing STDOUT: $!"; + -diff -Naur openssl-1.1.1k.org/crypto/modes/build.info openssl-1.1.1k.sw/crypto/modes/build.info ---- openssl-1.1.1k.org/crypto/modes/build.info 2021-03-25 21:28:38.000000000 +0800 -+++ openssl-1.1.1k.sw/crypto/modes/build.info 2023-05-16 15:46:55.493096136 +0800 -@@ -14,6 +14,7 @@ +diff --git a/crypto/modes/build.info b/crypto/modes/build.info +index 821340e..cbb9083 100644 +--- a/crypto/modes/build.info ++++ b/crypto/modes/build.info +@@ -14,6 +14,7 @@ GENERATE[aesni-gcm-x86_64.s]=asm/aesni-gcm-x86_64.pl $(PERLASM_SCHEME) GENERATE[ghash-sparcv9.S]=asm/ghash-sparcv9.pl $(PERLASM_SCHEME) INCLUDE[ghash-sparcv9.o]=.. GENERATE[ghash-alpha.S]=asm/ghash-alpha.pl $(PERLASM_SCHEME) @@ -909,10 +946,11 @@ diff -Naur openssl-1.1.1k.org/crypto/modes/build.info openssl-1.1.1k.sw/crypto/m GENERATE[ghash-parisc.s]=asm/ghash-parisc.pl $(PERLASM_SCHEME) GENERATE[ghashp8-ppc.s]=asm/ghashp8-ppc.pl $(PERLASM_SCHEME) GENERATE[ghash-armv4.S]=asm/ghash-armv4.pl $(PERLASM_SCHEME) -diff -Naur openssl-1.1.1k.org/crypto/rand/rand_unix.c openssl-1.1.1k.sw/crypto/rand/rand_unix.c ---- openssl-1.1.1k.org/crypto/rand/rand_unix.c 2023-05-16 14:08:10.178786606 +0800 -+++ openssl-1.1.1k.sw/crypto/rand/rand_unix.c 2023-05-16 15:47:22.414042703 +0800 -@@ -319,6 +319,8 @@ +diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c +index 5ed97cb..c34a183 100644 +--- a/crypto/rand/rand_unix.c ++++ b/crypto/rand/rand_unix.c +@@ -319,6 +319,8 @@ static ssize_t sysctl_random(char *buf, size_t buflen) # define __NR_getrandom 347 # elif defined(__ia64__) # define __NR_getrandom 1339 @@ -921,9 +959,11 @@ diff -Naur openssl-1.1.1k.org/crypto/rand/rand_unix.c openssl-1.1.1k.sw/crypto/r # elif defined(__alpha__) # define __NR_getrandom 511 # elif defined(__sh__) -diff -Naur openssl-1.1.1k.org/crypto/sha/asm/sha1-sw_64.pl openssl-1.1.1k.sw/crypto/sha/asm/sha1-sw_64.pl ---- openssl-1.1.1k.org/crypto/sha/asm/sha1-sw_64.pl 1970-01-01 08:00:00.000000000 +0800 -+++ openssl-1.1.1k.sw/crypto/sha/asm/sha1-sw_64.pl 2023-05-16 16:31:13.767449198 +0800 +diff --git a/crypto/sha/asm/sha1-sw_64.pl b/crypto/sha/asm/sha1-sw_64.pl +new file mode 100644 +index 0000000..313478b +--- /dev/null ++++ b/crypto/sha/asm/sha1-sw_64.pl @@ -0,0 +1,329 @@ +#! /usr/bin/env perl +# Copyright 2009-2020 The OpenSSL Project Authors. All Rights Reserved. @@ -1004,7 +1044,7 @@ diff -Naur openssl-1.1.1k.org/crypto/sha/asm/sha1-sw_64.pl openssl-1.1.1k.sw/cry + bic $d,$b,$t3 + sll $b,30,$b + -+ extll @X[$i],4,@X[$i+1] # extract upper half ++ ext2b @X[$i],4,@X[$i+1] # extract upper half + or $t2,$t3,$t2 + addw @X[$i],$e,$e + @@ -1197,7 +1237,7 @@ diff -Naur openssl-1.1.1k.org/crypto/sha/asm/sha1-sw_64.pl openssl-1.1.1k.sw/cry + +.Lloop: + .set noreorder -+ ldah $K,23170(zero) ++ ldih $K,23170(zero) + zapnot $B,0xf,$B + ldi $K,31129($K) # K_00_19 +___ @@ -1254,10 +1294,11 @@ diff -Naur openssl-1.1.1k.org/crypto/sha/asm/sha1-sw_64.pl openssl-1.1.1k.sw/cry +$output=pop and open STDOUT,">$output"; +print $code; +close STDOUT or die "error closing STDOUT: $!"; -diff -Naur openssl-1.1.1k.org/crypto/sha/build.info openssl-1.1.1k.sw/crypto/sha/build.info ---- openssl-1.1.1k.org/crypto/sha/build.info 2021-03-25 21:28:38.000000000 +0800 -+++ openssl-1.1.1k.sw/crypto/sha/build.info 2023-05-16 16:31:32.989124428 +0800 -@@ -18,6 +18,7 @@ +diff --git a/crypto/sha/build.info b/crypto/sha/build.info +index 5dd5a99..1608477 100644 +--- a/crypto/sha/build.info ++++ b/crypto/sha/build.info +@@ -18,6 +18,7 @@ GENERATE[sha256-ia64.s]=asm/sha512-ia64.pl $(LIB_CFLAGS) $(LIB_CPPFLAGS) GENERATE[sha512-ia64.s]=asm/sha512-ia64.pl $(LIB_CFLAGS) $(LIB_CPPFLAGS) GENERATE[sha1-alpha.S]=asm/sha1-alpha.pl $(PERLASM_SCHEME) @@ -1265,10 +1306,12 @@ diff -Naur openssl-1.1.1k.org/crypto/sha/build.info openssl-1.1.1k.sw/crypto/sha GENERATE[sha1-x86_64.s]=asm/sha1-x86_64.pl $(PERLASM_SCHEME) GENERATE[sha1-mb-x86_64.s]=asm/sha1-mb-x86_64.pl $(PERLASM_SCHEME) -diff -Naur openssl-1.1.1k.org/crypto/sw_64cpuid.pl openssl-1.1.1k.sw/crypto/sw_64cpuid.pl ---- openssl-1.1.1k.org/crypto/sw_64cpuid.pl 1970-01-01 08:00:00.000000000 +0800 -+++ openssl-1.1.1k.sw/crypto/sw_64cpuid.pl 2023-05-16 16:44:11.228748777 +0800 -@@ -0,0 +1,269 @@ +diff --git a/crypto/sw_64cpuid.pl b/crypto/sw_64cpuid.pl +new file mode 100644 +index 0000000..6b6b6a3 +--- /dev/null ++++ b/crypto/sw_64cpuid.pl +@@ -0,0 +1,270 @@ +#! /usr/bin/env perl +# Copyright 2010-2020 The OpenSSL Project Authors. All Rights Reserved. +# @@ -1352,16 +1395,16 @@ diff -Naur openssl-1.1.1k.org/crypto/sw_64cpuid.pl openssl-1.1.1k.sw/crypto/sw_6 +OPENSSL_atomic_add: + .frame $30,0,$26 + .prologue 0 -+1: ldi $2,0($16) -+ lldw $0,0($2) -+ ldi $3,1 -+ rd_f $3 -+ addw $0,$17,$1 -+ lstw $1,0($2) -+ rd_f $1 -+ beq $1,1b -+ addw $0,$17,$0 -+ ret ($26) ++1: ldi $2,0($16) ++ lldw $0,0($2) ++ ldi $3,1 ++ rd_f $3 ++ addw $0,$17,$1 ++ lstw $1,0($2) ++ rd_f $1 ++ beq $1,1b ++ addw $0,$17,$0 ++ ret ($26) +.end OPENSSL_atomic_add + +.globl OPENSSL_rdtsc @@ -1369,7 +1412,7 @@ diff -Naur openssl-1.1.1k.org/crypto/sw_64cpuid.pl openssl-1.1.1k.sw/crypto/sw_6 +OPENSSL_rdtsc: + .frame $30,0,$26 + .prologue 0 -+ rpcc $0 ++ rtc $0 + ret ($26) +.end OPENSSL_rdtsc + @@ -1389,7 +1432,7 @@ diff -Naur openssl-1.1.1k.org/crypto/sw_64cpuid.pl openssl-1.1.1k.sw/crypto/sw_6 + ldl_u $1,0($16) + mov $16,$2 +.Lalign: -+ msk0b $1,$16,$1 ++ mask0b $1,$16,$1 + ldi $16,1($16) + subl $17,1,$17 + addl $0,1,$0 @@ -1443,6 +1486,7 @@ diff -Naur openssl-1.1.1k.org/crypto/sw_64cpuid.pl openssl-1.1.1k.sw/crypto/sw_6 +my ($tick,$lasttick)=("\$19","\$20"); +my ($diff,$lastdiff)=("\$21","\$22"); +my ($v0,$ra,$sp,$zero)=("\$0","\$26","\$30","\$31"); ++my ($tmp)=("\$4"); + +print <<___; +.globl OPENSSL_instrument_bus @@ -1452,33 +1496,33 @@ diff -Naur openssl-1.1.1k.org/crypto/sw_64cpuid.pl openssl-1.1.1k.sw/crypto/sw_6 + .prologue 0 + mov $cnt,$v0 + -+ rpcc $lasttick ++ rtc $lasttick + mov 0,$diff + -+ lldw $tick,0($out) -+ ldi $tmp,1 -+ wr_f $tmp -+ addw $diff,$tick,$tick -+ mov $tick,$diff -+ lstw $tick,0($out) -+ rd_f $tick -+ stl $diff,0($out) ++ lldw $tick,0($out) ++ ldi $tmp,1 ++ wr_f $tmp ++ addw $diff,$tick,$tick ++ mov $tick,$diff ++ lstw $tick,0($out) ++ rd_f $tick ++ stl $diff,0($out) + -+.Loop: rpcc $tick ++.Loop: rtc $tick + subl $tick,$lasttick,$diff + mov $tick,$lasttick + -+ lldw $tick,0($out) -+ ldi $tmp,1 -+ wr_f $tmp -+ addw $diff,$tick,$tick -+ mov $tick,$diff -+ lstw $tick,0($out) -+ rd_f $tick -+ stl $diff,0($out) ++ lldw $tick,0($out) ++ ldi $tmp,1 ++ wr_f $tmp ++ addw $diff,$tick,$tick ++ mov $tick,$diff ++ lstw $tick,0($out) ++ rd_f $tick ++ stl $diff,0($out) + + subw $cnt,1,$cnt -+ lda $out,4($out) ++ ldi $out,4($out) + bne $cnt,.Loop + + ret ($ra) @@ -1491,44 +1535,44 @@ diff -Naur openssl-1.1.1k.org/crypto/sw_64cpuid.pl openssl-1.1.1k.sw/crypto/sw_6 + .prologue 0 + mov $cnt,$v0 + -+ rpcc $lasttick ++ rtc $lasttick + mov 0,$diff + -+ lldw $tick,0($out) -+ ldi $tmp,1 -+ wr_f $tmp -+ addw $diff,$tick,$tick -+ mov $tick,$diff -+ lstw $tick,0($out) -+ rd_f $tick -+ stl $diff,0($out) ++ lldw $tick,0($out) ++ ldi $tmp,1 ++ wr_f $tmp ++ addw $diff,$tick,$tick ++ mov $tick,$diff ++ lstw $tick,0($out) ++ rd_f $tick ++ stl $diff,0($out) + -+ rpcc $tick ++ rtc $tick + subl $tick,$lasttick,$diff + mov $tick,$lasttick + mov $diff,$lastdiff +.Loop2: -+ lldw $tick,0($out) -+ ldi $tmp,1 -+ wr_f $tmp -+ addw $diff,$tick,$tick -+ mov $tick,$diff -+ lstw $tick,0($out) -+ rd_f $tick -+ stl $diff,0($out) ++ lldw $tick,0($out) ++ ldi $tmp,1 ++ wr_f $tmp ++ addw $diff,$tick,$tick ++ mov $tick,$diff ++ lstw $tick,0($out) ++ rd_f $tick ++ stl $diff,0($out) + + subw $max,1,$max + beq $max,.Ldone2 + -+ rtc $tick -+ subl $tick,$lasttick,$diff -+ mov $tick,$lasttick -+ subl $lastdiff,$diff,$tick -+ mov $diff,$lastdiff -+ selne $tick,1,$tick,$tick -+ subw $cnt,$tick,$cnt -+ s4addl $tick,$out,$out -+ bne $cnt,.Loop2 ++ rtc $tick ++ subl $tick,$lasttick,$diff ++ mov $tick,$lasttick ++ subl $lastdiff,$diff,$tick ++ mov $diff,$lastdiff ++ selne $tick,1,$tick,$tick ++ subw $cnt,$tick,$cnt ++ s4addl $tick,$out,$out ++ bne $cnt,.Loop2 + +.Ldone2: + subw $v0,$cnt,$v0 @@ -1538,15 +1582,19 @@ diff -Naur openssl-1.1.1k.org/crypto/sw_64cpuid.pl openssl-1.1.1k.sw/crypto/sw_6 +} + +close STDOUT or die "error closing STDOUT: $!"; -diff -Naur openssl-1.1.1k.org/include/crypto/md32_common.h openssl-1.1.1k.sw/include/crypto/md32_common.h ---- openssl-1.1.1k.org/include/crypto/md32_common.h 2021-03-25 21:28:38.000000000 +0800 -+++ openssl-1.1.1k.sw/include/crypto/md32_common.h 2023-05-16 16:44:44.705923066 +0800 -@@ -226,7 +226,7 @@ +diff --git a/include/crypto/md32_common.h b/include/crypto/md32_common.h +index 1124e9c..31fd740 100644 +--- a/include/crypto/md32_common.h ++++ b/include/crypto/md32_common.h +@@ -226,7 +226,7 @@ int HASH_FINAL(unsigned char *md, HASH_CTX *c) } #ifndef MD32_REG_T -# if defined(__alpha) || defined(__sparcv9) || defined(__mips) -+# if defined(__alpha) || defined(__sw_64) || defined(__sparcv9) || defined(__mips) ++# if defined(__alpha) || defined(__sw_64) || defined(__sparcv9) || defined(__mips) # define MD32_REG_T long /* * This comment was originally written for MD5, which is why it +-- +2.31.1 + diff --git a/openssl.spec b/openssl.spec index 2cfbffe407345dd083583ff9d0148a6f277c0458..63d03102cfab347a32704e3c361170fa21b94d64 100644 --- a/openssl.spec +++ b/openssl.spec @@ -1,4 +1,4 @@ -%define anolis_release .0.2 +%define anolis_release .0.3 # For the curious: # 0.9.5a soversion = 0 # 0.9.6 soversion = 1 @@ -250,7 +250,8 @@ sslarch=linux64-sparcv9 sslflags=no-asm %endif %ifarch sw_64 -sslarch=linux-sunway-gcc +sslarch=linux-sw_64-gcc +sslflags=enable-ec_nistp_64_gcc_128 %endif %ifarch alpha alphaev56 alphaev6 alphaev67 sslarch=linux-alpha-gcc @@ -518,6 +519,9 @@ export LD_LIBRARY_PATH %postun libs -p /sbin/ldconfig %changelog +* Thu Jul 13 2023 wxiat - 1:1.1.1k-9.0.3 +- change sw arch + * Tue May 16 2023 wxiat - 1:1.1.1k-9.0.2 - add sw patch