From 5e5e5b44cc91a5ea6597e5a0af0b986a1fc72e58 Mon Sep 17 00:00:00 2001 From: swcompiler Date: Mon, 25 Aug 2025 10:59:45 +0800 Subject: [PATCH] fix sw_64 _libdir --- ...> add-support-for-sw_64-architecture.patch | 706 ++++++++++-------- openssl.spec | 11 +- 2 files changed, 392 insertions(+), 325 deletions(-) rename add-sw_64-support.patch => add-support-for-sw_64-architecture.patch (68%) mode change 100644 => 100755 mode change 100644 => 100755 openssl.spec diff --git a/add-sw_64-support.patch b/add-support-for-sw_64-architecture.patch old mode 100644 new mode 100755 similarity index 68% rename from add-sw_64-support.patch rename to add-support-for-sw_64-architecture.patch index 6eccddb..c671abf --- a/add-sw_64-support.patch +++ b/add-support-for-sw_64-architecture.patch @@ -1,55 +1,89 @@ -From dfb837f21d55b9cf0bf78e6b3d5dc02567672400 Mon Sep 17 00:00:00 2001 -From: mahailiang -Date: Sun, 29 Sep 2024 17:26:05 +0800 -Subject: [PATCH] to support sw_64 +From d0640e594ea3a135519f77bfd4fcb334a77c2831 Mon Sep 17 00:00:00 2001 +From: funnyaaa +Date: Thu, 3 Apr 2025 11:08:31 +0800 +Subject: [PATCH 1/1] add support for sw_64 architecture --- - Configurations/10-main.conf | 12 + - crypto/bn/asm/sw_64-mont.pl | 328 ++++++++++++++++++++++ - crypto/bn/bn_local.h | 2 +- - crypto/bn/build.info | 2 +- - crypto/modes/asm/ghash-sw_64.pl | 467 ++++++++++++++++++++++++++++++++ - crypto/sha/asm/sha1-sw_64.pl | 329 ++++++++++++++++++++++ - crypto/sha/build.info | 2 +- - crypto/sw_64cpuid.pl | 273 +++++++++++++++++++ - include/crypto/md32_common.h | 2 +- - 9 files changed, 1413 insertions(+), 4 deletions(-) + Configurations/10-main.conf | 7 + + apps/lib/vms_term_sock.c | 6 +- + crypto/bn/asm/sw_64-mont.pl | 331 +++++++++++++ + crypto/bn/bn_local.h | 2 +- + crypto/bn/build.info | 5 + + crypto/build.info | 3 + + crypto/modes/asm/ghash-sw_64.pl | 467 ++++++++++++++++++ + crypto/modes/build.info | 4 + + crypto/sha/asm/sha1-sw_64.pl | 329 ++++++++++++ + crypto/sha/build.info | 5 + + crypto/sw64cap.c | 15 + + crypto/sw_64cpuid.pl | 149 ++++++ + include/crypto/md32_common.h | 2 +- + providers/fips.module.sources | 4 + + .../implementations/rands/seeding/rand_unix.c | 2 +- + util/perl/OpenSSL/config.pm | 1 + + 16 files changed, 1326 insertions(+), 6 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/sw64cap.c create mode 100644 crypto/sw_64cpuid.pl diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf -index 915e7dd..33fd760 100644 +index 280a75b..ae2bba5 100644 --- a/Configurations/10-main.conf +++ b/Configurations/10-main.conf -@@ -984,6 +984,18 @@ my %targets = ( +@@ -976,6 +976,13 @@ my %targets = ( asm_arch => 'alpha', perlasm_scheme => "void", }, -+ "linux-sw_64-gcc" => { -+ inherit_from => [ "linux-generic64" ], -+ lib_cppflags => add("-DL_ENDIAN"), -+ bn_ops => "SIXTY_FOUR_BIT_LONG", -+ }, + "linux-sw_64" => { + inherit_from => [ "linux-generic64" ], -+ cflags => add("-DL_ENDIAN"), ++ lib_cppflags => add("-DL_ENDIAN"), + bn_ops => "SIXTY_FOUR_BIT_LONG", -+ perlasm_scheme => "elf", -+ multilib => "64", ++ asm_arch => 'sw_64', ++ perlasm_scheme => "linux64", + }, "linux-c64xplus" => { inherit_from => [ "BASE_unix" ], # TI_CGT_C6000_7.3.x is a requirement +diff --git a/apps/lib/vms_term_sock.c b/apps/lib/vms_term_sock.c +index 97fb394..8a8b0b3 100644 +--- a/apps/lib/vms_term_sock.c ++++ b/apps/lib/vms_term_sock.c +@@ -36,7 +36,7 @@ + # include + # include + # include +-# ifdef __alpha ++# ifdef __alpha || defined(__sw_64) + # include + # else + typedef struct _iosb { /* Copied from IOSBDEF.H for Alpha */ +@@ -91,7 +91,7 @@ typedef struct _iosb { /* Copied from IOSBDEF.H for Alpha */ + + # include "vms_term_sock.h" + +-# ifdef __alpha ++# ifdef __alpha || defined(__sw_64) + static struct _iosb TerminalDeviceIosb; + # else + IOSB TerminalDeviceIosb; +@@ -295,7 +295,7 @@ static int CreateSocketPair (int SocketFamily, + int status; + unsigned int slen; + +-# ifdef __alpha ++# ifdef __alpha || defined(__sw_64) + struct _iosb iosb; + # else + IOSB iosb; diff --git a/crypto/bn/asm/sw_64-mont.pl b/crypto/bn/asm/sw_64-mont.pl new file mode 100644 -index 0000000..348b903 +index 0000000..3ed821e --- /dev/null +++ b/crypto/bn/asm/sw_64-mont.pl -@@ -0,0 +1,328 @@ +@@ -0,0 +1,331 @@ +#! /usr/bin/env perl -+# Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved. ++# Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the OpenSSL license (the "License"). You may not use +# this file except in compliance with the License. You can obtain a copy @@ -58,7 +92,7 @@ index 0000000..348b903 + +# +# ==================================================================== -+# Written by Andy Polyakov for the OpenSSL ++# Written by Andy Polyakov for the OpenSSL +# project. The module is, however, dual licensed under OpenSSL and +# CRYPTOGAMS licenses depending on where you obtain it. For further +# details see http://www.openssl.org/~appro/cryptogams/. @@ -171,7 +205,7 @@ index 0000000..348b903 +.L1st: + .set noreorder + ldl $aj,0($aj) -+ addw $j,1,$j ++ addl $j,1,$j + ldl $nj,0($nj) + ldi $tp,8($tp) + @@ -270,7 +304,7 @@ index 0000000..348b903 + mull $aj,$bi,$alo #U1 + cmpult $lo0,$hi0,AT #L0 + addl $nlo,$hi1,$lo1 #L1 -+ addw $j,1,$j ++ addl $j,1,$j + + mull $nj,$m1,$nlo #U1 + addl $ahi,AT,$hi0 #L0 @@ -315,7 +349,7 @@ index 0000000..348b903 + cmpult $lo1,$hi0,$hi1 + addl $lo1,$tj,$lo1 + cmpult $lo1,$tj,AT -+ addw $i,1,$i ++ addl $i,1,$i + addl $hi1,AT,$hi1 + stl $lo1,8($tp) + cmplt $i,$num,$tj # borrow $tj @@ -347,12 +381,15 @@ index 0000000..348b903 + mov sp,$tp + mov $bp,$rp # restore rp + ++ and sp,$hi0,$ap ++ bic $bp,$hi0,$bp ++ bis $bp,$ap,$ap # ap=borrow?tp:rp ++ +.align 4 -+.Lcopy: ldl $aj,0($tp) # conditional copy -+ ldl $nj,0($rp) ++.Lcopy: ldl $aj,0($ap) # copy or in-place refresh + ldi $tp,8($tp) + ldi $rp,8($rp) -+ seleq $hi0,$nj,$aj ++ ldi $ap,8($ap) + stl zero,-8($tp) # zap tp + cmpult $tp,$tj,AT + stl $aj,-8($rp) @@ -370,14 +407,14 @@ index 0000000..348b903 + ldi sp,48(sp) + ret (ra) +.end bn_mul_mont -+.ascii "Montgomery Multiplication for Sw_64, CRYPTOGAMS by " ++.ascii "Montgomery Multiplication for sw_64, CRYPTOGAMS by " +.align 2 +___ + +print $code; -+close STDOUT or die "error closing STDOUT: $!"; ++close STDOUT; diff --git a/crypto/bn/bn_local.h b/crypto/bn/bn_local.h -index 50e9d26..e73bd3f 100644 +index 50e9d26..a6275c1 100644 --- a/crypto/bn/bn_local.h +++ b/crypto/bn/bn_local.h @@ -387,7 +387,7 @@ struct bn_gencb_st { @@ -390,26 +427,57 @@ index 50e9d26..e73bd3f 100644 # include # define BN_UMULT_HIGH(a,b) (BN_ULONG)asm("umulh %a0,%a1,%v0",(a),(b)) diff --git a/crypto/bn/build.info b/crypto/bn/build.info -index c4ba51b..b598423 100644 +index c4ba51b..9eab5d8 100644 --- a/crypto/bn/build.info +++ b/crypto/bn/build.info -@@ -168,7 +168,7 @@ GENERATE[ppc-mont.s]=asm/ppc-mont.pl - GENERATE[ppc64-mont.s]=asm/ppc64-mont.pl +@@ -50,6 +50,9 @@ IF[{- !$disabled{asm} -}] + $BNASM_alpha=bn_asm.c alpha-mont.S + $BNDEF_alpha=OPENSSL_BN_ASM_MONT + ++ $BNASM_sw_64=bn_asm.c sw_64-mont.S ++ $BNDEF_sw_64=OPENSSL_BN_ASM_MONT ++ + $BNASM_mips32=bn-mips.S mips-mont.S + $BNDEF_mips32=OPENSSL_BN_ASM_MONT + $BNASM_mips64=$BNASM_mips32 +@@ -169,6 +172,8 @@ GENERATE[ppc64-mont.s]=asm/ppc64-mont.pl GENERATE[alpha-mont.S]=asm/alpha-mont.pl -- + +GENERATE[sw_64-mont.S]=asm/sw_64-mont.pl ++ GENERATE[armv4-mont.S]=asm/armv4-mont.pl INCLUDE[armv4-mont.o]=.. GENERATE[armv4-gf2m.S]=asm/armv4-gf2m.pl +diff --git a/crypto/build.info b/crypto/build.info +index c04db55..070ef08 100644 +--- a/crypto/build.info ++++ b/crypto/build.info +@@ -37,6 +37,8 @@ IF[{- !$disabled{asm} && $config{processor} ne '386' -}] + + $CPUIDASM_alpha=alphacpuid.s + ++ $CPUIDASM_sw_64=sw64cap.c sw_64cpuid.s ++ + $CPUIDASM_s390x=s390xcap.c s390xcpuid.S + + $CPUIDASM_armv4=armcap.c armv4cpuid.S +@@ -124,6 +126,7 @@ GENERATE[ia64cpuid.s]=ia64cpuid.S + GENERATE[ppccpuid.s]=ppccpuid.pl + GENERATE[pariscid.s]=pariscid.pl + GENERATE[alphacpuid.s]=alphacpuid.pl ++GENERATE[sw_64cpuid.s]=sw_64cpuid.pl + GENERATE[arm64cpuid.S]=arm64cpuid.pl + INCLUDE[arm64cpuid.o]=. + GENERATE[armv4cpuid.S]=armv4cpuid.pl diff --git a/crypto/modes/asm/ghash-sw_64.pl b/crypto/modes/asm/ghash-sw_64.pl new file mode 100644 -index 0000000..59b5596 +index 0000000..42838a8 --- /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. ++# Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the OpenSSL license (the "License"). You may not use +# this file except in compliance with the License. You can obtain a copy @@ -467,7 +535,7 @@ index 0000000..59b5596 + $N++; +$code.=<<___; +.align 4 -+ extlb $Xlo,7,$nlo ++ ext0b $Xlo,7,$nlo + and $nlo,0xf0,$nhi + sll $nlo,4,$nlo + and $nlo,0xf0,$nlo @@ -480,7 +548,7 @@ index 0000000..59b5596 + and $Zlo,0x0f,$remp + sll $Zhi,60,$t0 + ldi $cnt,6(zero) -+ extlb $Xlo,6,$nlo ++ ext0b $Xlo,6,$nlo + + ldl $Tlo1,8($nhi) + s8addl $remp,$rem_4bit,$remp @@ -516,7 +584,7 @@ index 0000000..59b5596 + ldl $rem,0($remp) + srl $Zhi,4,$Zhi + xor $t0,$Zlo,$Zlo -+ extlb $Xlo,$cnt,$nlo ++ ext0b $Xlo,$cnt,$nlo + + and $nlo,0xf0,$nhi + xor $Thi0,$Zhi,$Zhi @@ -558,7 +626,7 @@ index 0000000..59b5596 + ldl $rem,0($remp) + srl $Zhi,4,$Zhi + xor $t0,$Zlo,$Zlo -+ extlb $Xhi,$cnt,$nlo ++ ext0b $Xhi,$cnt,$nlo + + and $nlo,0xf0,$nhi + xor $Thi0,$Zhi,$Zhi @@ -600,7 +668,7 @@ index 0000000..59b5596 + ldl $rem,0($remp) + srl $Zhi,4,$Zhi + xor $t0,$Zlo,$Zlo -+ extlb $Xhi,$cnt,$nlo ++ ext0b $Xhi,$cnt,$nlo + + and $nlo,0xf0,$nhi + xor $Thi0,$Zhi,$Zhi @@ -762,13 +830,13 @@ index 0000000..59b5596 + nop + +.Louter: -+ extll $inhi,$inp,$inhi -+ exthl $Thi0,$inp,$Thi0 ++ ext3b $inhi,$inp,$inhi ++ ext7b $Thi0,$inp,$Thi0 + or $inhi,$Thi0,$inhi + ldi $inp,16($inp) + -+ extll $inlo,$inp,$inlo -+ exthl $Tlo0,$inp,$Tlo0 ++ ext3b $inlo,$inp,$inlo ++ ext7b $Tlo0,$inp,$Tlo0 + or $inlo,$Tlo0,$inlo + subl $len,16,$len + @@ -867,22 +935,44 @@ index 0000000..59b5596 + .long 0,0x7080<<16, 0,0x6CA0<<16, 0,0x48C0<<16, 0,0x54E0<<16 + .long 0,0xE100<<16, 0,0xFD20<<16, 0,0xD940<<16, 0,0xC560<<16 + .long 0,0x9180<<16, 0,0x8DA0<<16, 0,0xA9C0<<16, 0,0xB5E0<<16 -+.ascii "GHASH for Sw_64, CRYPTOGAMS by " ++.ascii "GHASH for sw_64, CRYPTOGAMS by " +.align 4 + +___ +$output=pop and open STDOUT,">$output"; +print $code; -+close STDOUT or die "error closing STDOUT: $!"; ++close STDOUT; ++ +diff --git a/crypto/modes/build.info b/crypto/modes/build.info +index f3558fa..d642539 100644 +--- a/crypto/modes/build.info ++++ b/crypto/modes/build.info +@@ -19,6 +19,9 @@ IF[{- !$disabled{asm} -}] + $MODESASM_alpha=ghash-alpha.S + $MODESDEF_alpha=GHASH_ASM + ++ $MODESASM_sw_64=ghash-sw_64.S ++ $MODESDEF_sw_64=GHASH_ASM + + $MODESASM_s390x=ghash-s390x.S + $MODESDEF_s390x=GHASH_ASM + +@@ -69,6 +72,7 @@ GENERATE[aesni-gcm-x86_64.s]=asm/aesni-gcm-x86_64.pl + GENERATE[ghash-sparcv9.S]=asm/ghash-sparcv9.pl + INCLUDE[ghash-sparcv9.o]=.. + GENERATE[ghash-alpha.S]=asm/ghash-alpha.pl ++GENERATE[ghash-sw_64.S]=asm/ghash-sw_64.pl + GENERATE[ghash-parisc.s]=asm/ghash-parisc.pl + GENERATE[ghashp8-ppc.s]=asm/ghashp8-ppc.pl + GENERATE[ghash-armv4.S]=asm/ghash-armv4.pl diff --git a/crypto/sha/asm/sha1-sw_64.pl b/crypto/sha/asm/sha1-sw_64.pl new file mode 100644 -index 0000000..cce4015 +index 0000000..08b9150 --- /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. ++# Copyright 2009-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the OpenSSL license (the "License"). You may not use +# this file except in compliance with the License. You can obtain a copy @@ -891,13 +981,13 @@ index 0000000..cce4015 + + +# ==================================================================== -+# Written by Andy Polyakov for the OpenSSL ++# Written by Andy Polyakov for the OpenSSL +# project. The module is, however, dual licensed under OpenSSL and +# CRYPTOGAMS licenses depending on where you obtain it. For further +# details see http://www.openssl.org/~appro/cryptogams/. +# ==================================================================== + -+# SHA1 block procedure for Sw_64. ++# SHA1 block procedure for sw_64. + +# On 21264 performance is 33% better than code generated by vendor +# compiler, and 75% better than GCC [3.4], and in absolute terms is @@ -932,8 +1022,8 @@ index 0000000..cce4015 + ldl_u @X[$i+3],($i+2)*4+7($inp) +___ +$code.=<<___ if (!($i&1) && $i<15); -+ extll @X[$i],$inp,@X[$i] -+ exthl @X[$i+1],$inp,@X[$i+1] ++ ext3b @X[$i],$inp,@X[$i] ++ ext7b @X[$i+1],$inp,@X[$i+1] + + or @X[$i+1],@X[$i],@X[$i] # pair of 32-bit values are fetched + @@ -960,7 +1050,7 @@ index 0000000..cce4015 + 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 + @@ -1204,304 +1294,213 @@ index 0000000..cce4015 + ldi sp,64(sp) + ret (ra) +.end sha1_block_data_order -+.ascii "SHA1 block transform for Sw_64, CRYPTOGAMS by " ++.ascii "SHA1 block transform for sw_64, CRYPTOGAMS by " +.align 2 +___ +$output=pop and open STDOUT,">$output"; +print $code; -+close STDOUT or die "error closing STDOUT: $!"; ++close STDOUT; diff --git a/crypto/sha/build.info b/crypto/sha/build.info -index 556a658..9c29460 100644 +index d61f7de..b6a031b 100644 --- a/crypto/sha/build.info +++ b/crypto/sha/build.info -@@ -103,7 +103,7 @@ GENERATE[sha256-ia64.s]=asm/sha512-ia64.pl - GENERATE[sha512-ia64.s]=asm/sha512-ia64.pl +@@ -18,6 +18,9 @@ IF[{- !$disabled{asm} -}] + $SHA1ASM_alpha=sha1-alpha.S + $SHA1DEF_alpha=SHA1_ASM + ++ $SHA1ASM_sw_64=sha1-sw_64.S ++ $SHA1DEF_sw_64=SHA1_ASM ++ + $SHA1ASM_mips32=sha1-mips.S sha256-mips.S + $SHA1DEF_mips32=SHA1_ASM SHA256_ASM + $SHA1ASM_mips64=$SHA1ASM_mips32 sha512-mips.S +@@ -104,6 +107,8 @@ GENERATE[sha512-ia64.s]=asm/sha512-ia64.pl GENERATE[sha1-alpha.S]=asm/sha1-alpha.pl -- + +GENERATE[sha1-sw_64.S]=asm/sha1-sw_64.pl ++ GENERATE[sha1-x86_64.s]=asm/sha1-x86_64.pl GENERATE[sha1-mb-x86_64.s]=asm/sha1-mb-x86_64.pl GENERATE[sha256-x86_64.s]=asm/sha512-x86_64.pl +diff --git a/crypto/sw64cap.c b/crypto/sw64cap.c +new file mode 100644 +index 0000000..a720174 +--- /dev/null ++++ b/crypto/sw64cap.c +@@ -0,0 +1,15 @@ ++#include ++#include ++ ++int CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len) ++{ ++ size_t i; ++ const volatile unsigned char *a = in_a; ++ const volatile unsigned char *b = in_b; ++ unsigned char x = 0; ++ ++ for (i = 0; i < len; i++) ++ x |= a[i] ^ b[i]; ++ ++ return x; ++} +\ No newline at end of file diff --git a/crypto/sw_64cpuid.pl b/crypto/sw_64cpuid.pl new file mode 100644 -index 0000000..0f2d44a +index 0000000..791b530 --- /dev/null +++ b/crypto/sw_64cpuid.pl -@@ -0,0 +1,273 @@ -+#! /usr/bin/env perl -+# Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved. -+# -+# Licensed under the OpenSSL license (the "License"). You may not use -+# this file except in compliance with the License. You can obtain a copy -+# in the file LICENSE in the source distribution or at -+# https://www.openssl.org/source/license.html +@@ -0,0 +1,149 @@ ++#!/usr/bin/env perl + ++$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef; ++$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef; + -+$output = pop; -+open STDOUT,">$output"; ++$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; ++( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or ++( $xlate="${dir}perlasm/arm-xlate.pl" and -f $xlate) or ++die "can't locate arm-xlate.pl"; ++ ++open OUT,"| \"$^X\" $xlate $flavour \"$output\"" ++ or die "can't call $xlate: $!"; ++*STDOUT=*OUT; + -+print <<'___'; ++$code .=<<___; +.text + -+.set noat ++.set noat + -+.globl OPENSSL_cpuid_setup -+.ent OPENSSL_cpuid_setup ++.globl OPENSSL_cpuid_setup ++.ent OPENSSL_cpuid_setup +OPENSSL_cpuid_setup: -+ .frame $30,0,$26 -+ .prologue 0 -+ ret ($26) -+.end OPENSSL_cpuid_setup ++ .frame \$30,0,\$26 ++ .prologue 0 ++ ret (\$26) ++.end OPENSSL_cpuid_setup + -+.globl OPENSSL_wipe_cpu -+.ent OPENSSL_wipe_cpu ++.globl OPENSSL_wipe_cpu ++.ent OPENSSL_wipe_cpu +OPENSSL_wipe_cpu: -+ .frame $30,0,$26 -+ .prologue 0 -+ clr $1 -+ clr $2 -+ clr $3 -+ clr $4 -+ clr $5 -+ clr $6 -+ clr $7 -+ clr $8 -+ clr $16 -+ clr $17 -+ clr $18 -+ clr $19 -+ clr $20 -+ clr $21 -+ clr $22 -+ clr $23 -+ clr $24 -+ clr $25 -+ clr $27 -+ clr $at -+ clr $29 -+ fclr $f0 -+ fclr $f1 -+ fclr $f10 -+ fclr $f11 -+ fclr $f12 -+ fclr $f13 -+ fclr $f14 -+ fclr $f15 -+ fclr $f16 -+ fclr $f17 -+ fclr $f18 -+ fclr $f19 -+ fclr $f20 -+ fclr $f21 -+ fclr $f22 -+ fclr $f23 -+ fclr $f24 -+ fclr $f25 -+ fclr $f26 -+ fclr $f27 -+ fclr $f28 -+ fclr $f29 -+ fclr $f30 -+ mov $sp,$0 -+ ret ($26) -+.end OPENSSL_wipe_cpu -+ -+.globl OPENSSL_atomic_add -+.ent OPENSSL_atomic_add ++ .frame \$30,0,\$26 ++ .prologue 0 ++ clr \$1 ++ clr \$2 ++ clr \$3 ++ clr \$4 ++ clr \$5 ++ clr \$6 ++ clr \$7 ++ clr \$8 ++ clr \$16 ++ clr \$17 ++ clr \$18 ++ clr \$19 ++ clr \$20 ++ clr \$21 ++ clr \$22 ++ clr \$23 ++ clr \$24 ++ clr \$25 ++ clr \$27 ++ clr \$at ++ clr \$29 ++ fclr \$f0 ++ fclr \$f1 ++ fclr \$f10 ++ fclr \$f11 ++ fclr \$f12 ++ fclr \$f13 ++ fclr \$f14 ++ fclr \$f15 ++ fclr \$f16 ++ fclr \$f17 ++ fclr \$f18 ++ fclr \$f19 ++ fclr \$f20 ++ fclr \$f21 ++ fclr \$f22 ++ fclr \$f23 ++ fclr \$f24 ++ fclr \$f25 ++ fclr \$f26 ++ fclr \$f27 ++ fclr \$f28 ++ fclr \$f29 ++ fclr \$f30 ++ mov \$sp,\$0 ++ ret (\$26) ++.end OPENSSL_wipe_cpu ++ ++.globl OPENSSL_atomic_add ++.ent OPENSSL_atomic_add +OPENSSL_atomic_add: -+ .frame $30,0,$26 -+ .prologue 0 -+1: lldw $0,0($16) -+ ldi $1,1 -+ wr_f $1 -+ addw $0,$17,$1 -+ lstw $1,0($16) -+ rd_f $1 -+ beq $1,1b -+ addw $0,$17,$0 -+ ret ($26) -+.end OPENSSL_atomic_add -+ -+.globl OPENSSL_rdtsc -+.ent OPENSSL_rdtsc ++ .frame \$30,0,\$26 ++ .prologue 0 ++1: lldw \$0,0(\$16) ++ ldi \$1,1 ++ wr_f \$1 ++ addw \$0,\$17,\$1 ++ lstw \$1,0(\$16) ++ rd_f \$1 ++ beq \$1,1b ++ addw \$0,\$17,\$0 ++ ret (\$26) ++.end OPENSSL_atomic_add ++ ++.globl OPENSSL_rdtsc ++.ent OPENSSL_rdtsc +OPENSSL_rdtsc: -+ .frame $30,0,$26 -+ .prologue 0 -+ rtc $0 -+ ret ($26) -+.end OPENSSL_rdtsc -+ -+.globl OPENSSL_cleanse -+.ent OPENSSL_cleanse ++ .frame \$30,0,\$26 ++ .prologue 0 ++ rtc \$0 ++ ret (\$26) ++.end OPENSSL_rdtsc ++ ++.globl OPENSSL_cleanse ++.ent OPENSSL_cleanse +OPENSSL_cleanse: -+ .frame $30,0,$26 -+ .prologue 0 -+ beq $17,.Ldone -+ and $16,7,$0 -+ bic $17,7,$at -+ beq $at,.Little -+ beq $0,.Laligned ++ .frame \$30,0,\$26 ++ .prologue 0 ++ beq \$17,.Ldone ++ and \$16,7,\$0 ++ bic \$17,7,\$at ++ beq \$at,.Little ++ beq \$0,.Laligned + +.Little: -+ subl $0,8,$0 -+ ldl_u $1,0($16) -+ mov $16,$2 ++ subl \$0,8,\$0 ++ ldl_u \$1,0(\$16) ++ mov \$16,\$2 +.Lalign: -+ masklb $1,$16,$1 -+ ldi $16,1($16) -+ subl $17,1,$17 -+ addl $0,1,$0 -+ beq $17,.Lout -+ bne $0,.Lalign -+.Lout: stl_u $1,0($2) -+ beq $17,.Ldone -+ bic $17,7,$at -+ beq $at,.Little ++ masklb \$1,\$16,\$1 ++ ldi \$16,1(\$16) ++ subl \$17,1,\$17 ++ addl \$0,1,\$0 ++ beq \$17,.Lout ++ bne \$0,.Lalign ++.Lout: ++ stl_u \$1,0(\$2) ++ beq \$17,.Ldone ++ bic \$17,7,\$at ++ beq \$at,.Little + +.Laligned: -+ stl $31,0($16) -+ subl $17,8,$17 -+ ldi $16,8($16) -+ bic $17,7,$at -+ bne $at,.Laligned -+ bne $17,.Little -+.Ldone: ret ($26) -+.end OPENSSL_cleanse -+ -+.globl CRYPTO_memcmp -+.ent CRYPTO_memcmp -+CRYPTO_memcmp: -+ .frame $30,0,$26 -+ .prologue 0 -+ xor $0,$0,$0 -+ beq $18,.Lno_data ++ stl \$31,0(\$16) ++ subl \$17,8,\$17 ++ ldi \$16,8(\$16) ++ bic \$17,7,\$at ++ bne \$at,.Laligned ++ bne \$17,.Little ++.Ldone: ++ ret (\$26) ++.end OPENSSL_cleanse + -+ xor $1,$1,$1 -+ nop -+.Loop_cmp: -+ ldl_u $2,0($16) -+ subl $18,1,$18 -+ ldl_u $3,0($17) -+ extlb $2,$16,$2 -+ ldi $16,1($16) -+ extlb $3,$17,$3 -+ ldi $17,1($17) -+ xor $3,$2,$2 -+ or $2,$0,$0 -+ bne $18,.Loop_cmp -+ -+ subl $31,$0,$0 -+ srl $0,63,$0 -+.Lno_data: -+ ret ($26) -+.end CRYPTO_memcmp +___ -+{ -+my ($out,$cnt,$max)=("\$16","\$17","\$18"); -+my ($tick,$lasttick)=("\$19","\$20"); -+my ($diff,$lastdiff)=("\$21","\$22"); -+my ($lock1,$lock2)=("\$23","\$24"); -+my ($v0,$ra,$sp,$zero)=("\$0","\$26","\$30","\$31"); -+ -+print <<___; -+.globl OPENSSL_instrument_bus -+.ent OPENSSL_instrument_bus -+OPENSSL_instrument_bus: -+ .frame $sp,0,$ra -+ .prologue 0 -+ mov $cnt,$v0 -+ -+ rtc $lasttick -+ mov 0,$diff -+ -+ #ecb ($out) -+ lldw $tick,0($out) -+ ldi $lock1,1 -+ wr_f $lock1 -+ addw $diff,$tick,$tick -+ mov $tick,$diff -+ lstw $tick,0($out) -+ rd_f $tick -+ stw $diff,0($out) -+ -+.Loop: rtc $tick -+ subl $tick,$lasttick,$diff -+ mov $tick,$lasttick -+ -+ #ecb ($out) -+ lldw $tick,0($out) -+ ldi $lock1,1 -+ wr_f $lock1 -+ addw $diff,$tick,$tick -+ mov $tick,$diff -+ lstw $tick,0($out) -+ rd_f $tick -+ stw $diff,0($out) -+ -+ subw $cnt,1,$cnt -+ ldi $out,4($out) -+ bne $cnt,.Loop -+ -+ ret ($ra) -+.end OPENSSL_instrument_bus -+ -+.globl OPENSSL_instrument_bus2 -+.ent OPENSSL_instrument_bus2 -+OPENSSL_instrument_bus2: -+ .frame $sp,0,$ra -+ .prologue 0 -+ mov $cnt,$v0 -+ -+ rtc $lasttick -+ mov 0,$diff -+ -+ #ecb ($out) -+ lldw $tick,0($out) -+ ldi $lock1,1 -+ wr_f $lock1 -+ addw $diff,$tick,$tick -+ mov $tick,$diff -+ lstw $tick,0($out) -+ rd_f $tick -+ stw $diff,0($out) -+ -+ rtc $tick -+ subl $tick,$lasttick,$diff -+ mov $tick,$lasttick -+ mov $diff,$lastdiff -+.Loop2: -+ #ecb ($out) -+ lldw $tick,0($out) -+ ldi $lock1,1 -+ wr_f $lock1 -+ addw $diff,$tick,$tick -+ mov $tick,$diff -+ lstw $tick,0($out) -+ rd_f $tick -+ stw $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 -+ subw $cnt,$tick,$cnt -+ s4addl $tick,$out,$out -+ bne $cnt,.Loop2 -+ -+.Ldone2: -+ subw $v0,$cnt,$v0 -+ ret ($ra) -+.end OPENSSL_instrument_bus2 -+___ -+} + -+close STDOUT; ++print $code; ++close STDOUT or die "error closing STDOUT: $!"; ++ +\ No newline at end of file diff --git a/include/crypto/md32_common.h b/include/crypto/md32_common.h index 3b16f1b..84dc45a 100644 --- a/include/crypto/md32_common.h @@ -1515,6 +1514,67 @@ index 3b16f1b..84dc45a 100644 # define MD32_REG_T long /* * This comment was originally written for MD5, which is why it +diff --git a/providers/fips.module.sources b/providers/fips.module.sources +index 88e9188..8ab4683 100644 +--- a/providers/fips.module.sources ++++ b/providers/fips.module.sources +@@ -61,6 +61,7 @@ crypto/bn/asm/sparcv8plus.S + crypto/bn/asm/sparcv9-gf2m.pl + crypto/bn/asm/sparcv9-mont.pl + crypto/bn/asm/sparcv9a-mont.pl ++crypto/bn/asm/sw_64-mont.pl + crypto/bn/asm/via-mont.pl + crypto/bn/asm/vis3-mont.pl + crypto/bn/asm/x86-gf2m.pl +@@ -237,6 +238,7 @@ crypto/modes/asm/ghash-ia64.pl + crypto/modes/asm/ghash-parisc.pl + crypto/modes/asm/ghash-s390x.pl + crypto/modes/asm/ghash-sparcv9.pl ++crypto/modes/asm/ghash-sw_64.pl + crypto/modes/asm/ghash-x86.pl + crypto/modes/asm/ghash-x86_64.pl + crypto/modes/asm/ghashp8-ppc.pl +@@ -314,6 +316,7 @@ crypto/sha/asm/sha1-ppc.pl + crypto/sha/asm/sha1-s390x.pl + crypto/sha/asm/sha1-sparcv9.pl + crypto/sha/asm/sha1-sparcv9a.pl ++crypto/sha/asm/sha1-sw_64.pl + crypto/sha/asm/sha1-thumb.pl + crypto/sha/asm/sha1-x86_64.pl + crypto/sha/asm/sha256-586.pl +@@ -342,6 +345,7 @@ crypto/sparccpuid.S + crypto/sparcv9cap.c + crypto/sparse_array.c + crypto/stack/stack.c ++crypto/sw_64cpuid.pl + crypto/threads_lib.c + crypto/threads_none.c + crypto/threads_pthread.c +diff --git a/providers/implementations/rands/seeding/rand_unix.c b/providers/implementations/rands/seeding/rand_unix.c +index 750afca..e894e97 100644 +--- a/providers/implementations/rands/seeding/rand_unix.c ++++ b/providers/implementations/rands/seeding/rand_unix.c +@@ -304,7 +304,7 @@ static ssize_t sysctl_random(char *buf, size_t buflen) + # define __NR_getrandom 347 + # elif defined(__ia64__) + # define __NR_getrandom 1339 +-# elif defined(__alpha__) ++# elif defined(__alpha__) || defined(__sw_64__) + # define __NR_getrandom 511 + # elif defined(__sh__) + # if defined(__SH5__) +diff --git a/util/perl/OpenSSL/config.pm b/util/perl/OpenSSL/config.pm +index 1aa6768..6540fcd 100755 +--- a/util/perl/OpenSSL/config.pm ++++ b/util/perl/OpenSSL/config.pm +@@ -570,6 +570,7 @@ EOF + %config }; + } + ], ++ [ 'sw_64-.*-linux2.*', { target => "linux-sw_64" } ], + [ 'ppc64-.*-linux2', + sub { + my $KERNEL_BITS = $ENV{KERNEL_BITS} // ''; -- -2.27.0 +2.33.0 diff --git a/openssl.spec b/openssl.spec old mode 100644 new mode 100755 index 2127bfa..0ae848d --- a/openssl.spec +++ b/openssl.spec @@ -2,7 +2,7 @@ Name: openssl Epoch: 1 Version: 3.0.12 -Release: 18 +Release: 19 Summary: Cryptography and SSL/TLS Toolkit License: OpenSSL and SSLeay URL: https://www.openssl.org/ @@ -81,7 +81,7 @@ Patch67: backport-CVE-2024-41996.patch Patch9000: add-FIPS_mode_set-support.patch Patch9001: backport-CVE-2024-9143-Harden-BN_GF2m_poly2arr-against-misuse.patch Patch9002: Fix-build-error-for-ppc64le.patch -Patch9003: add-sw_64-support.patch +Patch9003: add-support-for-sw_64-architecture.patch BuildRequires: gcc gcc-c++ perl make lksctp-tools-devel coreutils util-linux zlib-devel Requires: coreutils %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release} @@ -142,6 +142,10 @@ sslarch=%{_os}64-%{_target_cpu} sslflags="--libdir=%{_libdir}" %endif +%ifarch sw_64 +sslflags="--libdir=%{_libdir}" +%endif + %ifarch x86_64 aarch64 sslflags=enable-ec_nistp_64_gcc_128 %endif @@ -282,6 +286,9 @@ make test || : %ldconfig_scriptlets libs %changelog +* Mon Aug 25 2025 swcompiler - 1:3.0.12-19 +- fix sw_64 _libdir + * Fri Aug 15 2025 yanglongkang - 1:3.0.12-18 - fix CVE-2024-41996 -- Gitee