From 4c8f7f2ac6478a1e60eb633ee3cf1c4346228b05 Mon Sep 17 00:00:00 2001 From: hzero1996 Date: Mon, 22 Aug 2022 16:50:18 +0800 Subject: [PATCH] fix the performance degradation on aarch64 --- ...d-performance-degradation-on-aarch64.patch | 146 ++++++++++++++++++ openssl.spec | 6 +- 2 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 Fix-reported-performance-degradation-on-aarch64.patch diff --git a/Fix-reported-performance-degradation-on-aarch64.patch b/Fix-reported-performance-degradation-on-aarch64.patch new file mode 100644 index 0000000..34445aa --- /dev/null +++ b/Fix-reported-performance-degradation-on-aarch64.patch @@ -0,0 +1,146 @@ +From a8f6d73fda64d514171e99a50d1483c0c0b8d968 Mon Sep 17 00:00:00 2001 +From: Bernd Edlinger +Date: Sun, 12 Jun 2022 09:37:26 +0200 +Subject: [PATCH] Fix reported performance degradation on aarch64 + +This restores the implementation prior to +commit 2621751 ("aes/asm/aesv8-armx.pl: avoid 32-bit lane assignment in CTR mode") +for 64bit targets only, since it is reportedly 2-17% slower, +and the silicon errata only affects 32bit targets. +Only for 32bit targets the new algorithm is used. + +Fixes #18445 + +Reviewed-by: Tomas Mraz +Reviewed-by: Paul Dale +Reviewed-by: Hugo Landau +(Merged from https://github.com/openssl/openssl/pull/18539) +--- + crypto/aes/asm/aesv8-armx.pl | 62 ++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 62 insertions(+) + +diff --git a/crypto/aes/asm/aesv8-armx.pl b/crypto/aes/asm/aesv8-armx.pl +index 2b0e982..1856d99 100755 +--- a/crypto/aes/asm/aesv8-armx.pl ++++ b/crypto/aes/asm/aesv8-armx.pl +@@ -740,6 +740,21 @@ $code.=<<___; + #ifndef __ARMEB__ + rev $ctr, $ctr + #endif ++___ ++$code.=<<___ if ($flavour =~ /64/); ++ vorr $dat1,$dat0,$dat0 ++ add $tctr1, $ctr, #1 ++ vorr $dat2,$dat0,$dat0 ++ add $ctr, $ctr, #2 ++ vorr $ivec,$dat0,$dat0 ++ rev $tctr1, $tctr1 ++ vmov.32 ${dat1}[3],$tctr1 ++ b.ls .Lctr32_tail ++ rev $tctr2, $ctr ++ sub $len,$len,#3 // bias ++ vmov.32 ${dat2}[3],$tctr2 ++___ ++$code.=<<___ if ($flavour !~ /64/); + add $tctr1, $ctr, #1 + vorr $ivec,$dat0,$dat0 + rev $tctr1, $tctr1 +@@ -751,6 +766,8 @@ $code.=<<___; + vmov.32 ${ivec}[3],$tctr2 + sub $len,$len,#3 // bias + vorr $dat2,$ivec,$ivec ++___ ++$code.=<<___; + b .Loop3x_ctr32 + + .align 4 +@@ -777,11 +794,25 @@ $code.=<<___; + aese $dat1,q8 + aesmc $tmp1,$dat1 + vld1.8 {$in0},[$inp],#16 ++___ ++$code.=<<___ if ($flavour =~ /64/); ++ vorr $dat0,$ivec,$ivec ++___ ++$code.=<<___ if ($flavour !~ /64/); + add $tctr0,$ctr,#1 ++___ ++$code.=<<___; + aese $dat2,q8 + aesmc $dat2,$dat2 + vld1.8 {$in1},[$inp],#16 ++___ ++$code.=<<___ if ($flavour =~ /64/); ++ vorr $dat1,$ivec,$ivec ++___ ++$code.=<<___ if ($flavour !~ /64/); + rev $tctr0,$tctr0 ++___ ++$code.=<<___; + aese $tmp0,q9 + aesmc $tmp0,$tmp0 + aese $tmp1,q9 +@@ -790,6 +821,12 @@ $code.=<<___; + mov $key_,$key + aese $dat2,q9 + aesmc $tmp2,$dat2 ++___ ++$code.=<<___ if ($flavour =~ /64/); ++ vorr $dat2,$ivec,$ivec ++ add $tctr0,$ctr,#1 ++___ ++$code.=<<___; + aese $tmp0,q12 + aesmc $tmp0,$tmp0 + aese $tmp1,q12 +@@ -805,22 +842,47 @@ $code.=<<___; + aese $tmp1,q13 + aesmc $tmp1,$tmp1 + veor $in2,$in2,$rndlast ++___ ++$code.=<<___ if ($flavour =~ /64/); ++ rev $tctr0,$tctr0 ++ aese $tmp2,q13 ++ aesmc $tmp2,$tmp2 ++ vmov.32 ${dat0}[3], $tctr0 ++___ ++$code.=<<___ if ($flavour !~ /64/); + vmov.32 ${ivec}[3], $tctr0 + aese $tmp2,q13 + aesmc $tmp2,$tmp2 + vorr $dat0,$ivec,$ivec ++___ ++$code.=<<___; + rev $tctr1,$tctr1 + aese $tmp0,q14 + aesmc $tmp0,$tmp0 ++___ ++$code.=<<___ if ($flavour !~ /64/); + vmov.32 ${ivec}[3], $tctr1 + rev $tctr2,$ctr ++___ ++$code.=<<___; + aese $tmp1,q14 + aesmc $tmp1,$tmp1 ++___ ++$code.=<<___ if ($flavour =~ /64/); ++ vmov.32 ${dat1}[3], $tctr1 ++ rev $tctr2,$ctr ++ aese $tmp2,q14 ++ aesmc $tmp2,$tmp2 ++ vmov.32 ${dat2}[3], $tctr2 ++___ ++$code.=<<___ if ($flavour !~ /64/); + vorr $dat1,$ivec,$ivec + vmov.32 ${ivec}[3], $tctr2 + aese $tmp2,q14 + aesmc $tmp2,$tmp2 + vorr $dat2,$ivec,$ivec ++___ ++$code.=<<___; + subs $len,$len,#3 + aese $tmp0,q15 + aese $tmp1,q15 +-- +1.8.3.1 + diff --git a/openssl.spec b/openssl.spec index 623a018..e5bd7c5 100644 --- a/openssl.spec +++ b/openssl.spec @@ -2,7 +2,7 @@ Name: openssl Epoch: 1 Version: 1.1.1m -Release: 8 +Release: 9 Summary: Cryptography and SSL/TLS Toolkit License: OpenSSL and SSLeay URL: https://www.openssl.org/ @@ -18,6 +18,7 @@ Patch7: CVE-2022-2068-Fix-file-operations-in-c_rehash.patch Patch8: CVE-2022-2097-Fix-AES-OCB-encrypt-decrypt-for-x86-AES-NI.patch Patch9: Update-expired-SCT-certificates.patch Patch10: ct_test.c-Update-the-epoch-time.patch +Patch11: Fix-reported-performance-degradation-on-aarch64.patch BuildRequires: gcc perl make lksctp-tools-devel coreutils util-linux zlib-devel Requires: coreutils %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release} @@ -214,6 +215,9 @@ make test || : %ldconfig_scriptlets libs %changelog +* Mon Aug 22 2022 zhujianwei - 1:1.1.1m-9 +- fix proformance degradation on aarch64 + * Tue Jul 26 2022 zhujianwei - 1:1.1.1m-8 - fix expiring-cerificates test case -- Gitee