external/openssl/UnpackedTarball_openssl.mk | 1 external/openssl/openssl-no-_umul128-on-aarch64.patch.1 | 58 ++++++++++++++++ 2 files changed, 59 insertions(+)
New commits: commit 30c252f83bbd2b43a1bc3261e1837cd66870f6db Author: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> AuthorDate: Sun Feb 12 19:36:25 2023 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Wed Feb 15 11:11:30 2023 +0000 fix openssl build on aarch64 - _umul128 is not available on non x64 adding upstream patch that uses __umulh as a fallback Change-Id: Ib95de30d3f7208c38421df0c63eb1ceafccd9354 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146839 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> (cherry picked from commit 821f4d6f0987450233e4f63e01f89484ec737258) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146916 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit ae24dd7bf521c960b7d03a19f9e64396ceaafdcc) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146979 Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/external/openssl/UnpackedTarball_openssl.mk b/external/openssl/UnpackedTarball_openssl.mk index 2a8f3bb3f905..58e3a93352e1 100644 --- a/external/openssl/UnpackedTarball_openssl.mk +++ b/external/openssl/UnpackedTarball_openssl.mk @@ -16,6 +16,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,openssl,\ external/openssl/configurable-z-option.patch.0 \ external/openssl/openssl-no-ipc-cmd.patch.0 \ external/openssl/system-cannot-find-path-for-move.patch.0 \ + external/openssl/openssl-no-_umul128-on-aarch64.patch.1 \ )) # vim: set noet sw=4 ts=4: diff --git a/external/openssl/openssl-no-_umul128-on-aarch64.patch.1 b/external/openssl/openssl-no-_umul128-on-aarch64.patch.1 new file mode 100644 index 000000000000..c7ca53bc574c --- /dev/null +++ b/external/openssl/openssl-no-_umul128-on-aarch64.patch.1 @@ -0,0 +1,58 @@ +From 98f9a401c3964c7ff0e6ca048685e28a2a6401d4 Mon Sep 17 00:00:00 2001 +From: Hubert Kario <hka...@redhat.com> +Date: Wed, 8 Feb 2023 14:13:24 +0100 +Subject: [PATCH] rsa: add msvc intrinsic for non x64 platforms + +_umul128() is x86_64 (x64) only, while __umulh() works everywhere, but +doesn't generate optimal code on x64 + +Reviewed-by: Dmitry Belyavskiy <beld...@gmail.com> +Reviewed-by: Paul Dale <pa...@openssl.org> +Reviewed-by: Tomas Mraz <to...@openssl.org> +(Merged from https://github.com/openssl/openssl/pull/20244) + +(cherry picked from commit 075652f224479dad2e64b92e791b296177af8705) +--- + crypto/bn/rsa_sup_mul.c | 24 +++++++++++++++++++++++- + 1 file changed, 23 insertions(+), 1 deletion(-) + +diff --git a/crypto/bn/rsa_sup_mul.c b/crypto/bn/rsa_sup_mul.c +index 0e0d02e1946e..3b57161b4589 100644 +--- a/crypto/bn/rsa_sup_mul.c ++++ b/crypto/bn/rsa_sup_mul.c +@@ -110,12 +110,34 @@ static ossl_inline void _mul_limb(limb_t *hi, limb_t *lo, limb_t a, limb_t b) + *lo = (limb_t)t; + } + #elif (BN_BYTES == 8) && (defined _MSC_VER) +-/* https://learn.microsoft.com/en-us/cpp/intrinsics/umul128?view=msvc-170 */ ++# if defined(_M_X64) ++/* ++ * on x86_64 (x64) we can use the _umul128 intrinsic to get one `mul` ++ * instruction to get both high and low 64 bits of the multiplication. ++ * https://learn.microsoft.com/en-us/cpp/intrinsics/umul128?view=msvc-140 ++ */ ++#include <intrin.h> + #pragma intrinsic(_umul128) + static ossl_inline void _mul_limb(limb_t *hi, limb_t *lo, limb_t a, limb_t b) + { + *lo = _umul128(a, b, hi); + } ++# elif defined(_M_ARM64) || defined (_M_IA64) ++/* ++ * We can't use the __umulh() on x86_64 as then msvc generates two `mul` ++ * instructions; so use this more portable intrinsic on platforms that ++ * don't support _umul128 (like aarch64 (ARM64) or ia64) ++ * https://learn.microsoft.com/en-us/cpp/intrinsics/umulh?view=msvc-140 ++ */ ++#include <intrin.h> ++static ossl_inline void _mul_limb(limb_t *hi, limb_t *lo, limb_t a, limb_t b) ++{ ++ *lo = a * b; ++ *hi = __umulh(a, b); ++} ++# else ++# error Only x64, ARM64 and IA64 supported. ++# endif /* defined(_M_X64) */ + #else + /* + * if the compiler doesn't have either a 128bit data type nor a "return