From 769107e1a61ebd6ce6fa46b40aa4566f3803e568 Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Thu, 24 Oct 2019 00:42:43 +0100 Subject: [PATCH] Fixes for some issues on Arm platforms (rhbz 1691430) --- ..._arch-detect-crypto-only-on-arm-vers.patch | 33 +++++++ 0002-Fix-Arm-detection-improvements.patch | 88 +++++++++++++++++++ libdnf.spec | 8 +- 3 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 0001-Revert-hy_detect_arch-detect-crypto-only-on-arm-vers.patch create mode 100644 0002-Fix-Arm-detection-improvements.patch diff --git a/0001-Revert-hy_detect_arch-detect-crypto-only-on-arm-vers.patch b/0001-Revert-hy_detect_arch-detect-crypto-only-on-arm-vers.patch new file mode 100644 index 0000000..ec8ef3c --- /dev/null +++ b/0001-Revert-hy_detect_arch-detect-crypto-only-on-arm-vers.patch @@ -0,0 +1,33 @@ +From d9684b99ed849e11b366ee1e6d98b88daf4b41ba Mon Sep 17 00:00:00 2001 +From: Peter Robinson +Date: Wed, 16 Oct 2019 10:58:03 +0100 +Subject: [PATCH 1/2] Revert "hy_detect_arch(): detect crypto only on arm + version >= 8" + +This reverts commit 6c4f7462b3004e39e82c4ec186175ea4a56035b4. + +The reverts the commit. More details will be in the fixes for commit +73b0de05a4d2. + +Signed-off-by: Peter Robinson +--- + libdnf/hy-util.cpp | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/libdnf/hy-util.cpp b/libdnf/hy-util.cpp +index f6de87d3..61838cc3 100644 +--- a/libdnf/hy-util.cpp ++++ b/libdnf/hy-util.cpp +@@ -118,8 +118,7 @@ hy_detect_arch(char **arch) + modifier++; + if (getauxval(AT_HWCAP) & HWCAP_ARM_VFP) + *modifier++ = 'h'; +- // arm version >= 8 can have crypto extension +- if ((atoi(un.machine+4) >= 8) && (getauxval(AT_HWCAP2) & HWCAP2_AES)) ++ if (getauxval(AT_HWCAP2) & HWCAP2_AES) + *modifier++ = 'c'; + if (getauxval(AT_HWCAP) & HWCAP_ARM_NEON) + *modifier++ = 'n'; +-- +2.23.0 + diff --git a/0002-Fix-Arm-detection-improvements.patch b/0002-Fix-Arm-detection-improvements.patch new file mode 100644 index 0000000..260014a --- /dev/null +++ b/0002-Fix-Arm-detection-improvements.patch @@ -0,0 +1,88 @@ +From f858089c65119500986c6695138590af60a02542 Mon Sep 17 00:00:00 2001 +From: Peter Robinson +Date: Wed, 16 Oct 2019 11:47:43 +0100 +Subject: [PATCH 2/2] Fix Arm detection improvements + +The change in 73b0de05a4d2 has caused a number of real world regressions +on arm32/armhfp/aarch32 users, in particular when running on ARMv8 based +hardware. There's a number of cases where software can't be installed +or the OS can't even be installed due to issues around armv7hcnl and +armv8hcnl. The NEON 'n' extension on ARMv8 hardware is not optional, so +is assumed as part of the armv8hl rpm. The crypto extensions 'c' are +optional and their implementation is widely varied, due to this the +software implementations do run time detection, the detection of this +functionality and subsquent priortisation of the 'c' extension is +incorrect, especially where the software could be running in a VM +or container and hence even in a running instance the underlying +hardware could concievably change so requiring this as a compile time +option has proved to be extremely problematic causing massive issues +with Fedora ARM. + +We adjust the detection of NEON 'n' just to happen on ARMv7 where while +it was implemented it has always been problematic and never really used +and hence is a legacy implementation detail that needs to be supported +but in reality the vast majority of NEON optimisation happens at run +time in libraries where it make a difference. + +In the case of the 'c' crypto extenions we have explicitly not added +this as package management functionality as it's handled effectively +with run time detection as optimisaiton and as in Fefora has just +caused regressions and issues. + +Fixes RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1691430 + +Signed-off-by: Peter Robinson +--- + libdnf/hy-util.cpp | 17 +++++------------ + 1 file changed, 5 insertions(+), 12 deletions(-) + +diff --git a/libdnf/hy-util.cpp b/libdnf/hy-util.cpp +index 61838cc3..295fdc1b 100644 +--- a/libdnf/hy-util.cpp ++++ b/libdnf/hy-util.cpp +@@ -36,20 +36,13 @@ + + #include + +-/* ARM specific HWCAP defines may be missing on non-ARM devices, +- * AT_HWCAP2 is missing on old glibc (<2.18) */ +-#ifndef AT_HWCAP2 +-#define AT_HWCAP2 26 +-#endif ++/* ARM specific HWCAP defines may be missing on non-ARM devices */ + #ifndef HWCAP_ARM_VFP + #define HWCAP_ARM_VFP (1<<6) + #endif + #ifndef HWCAP_ARM_NEON + #define HWCAP_ARM_NEON (1<<12) + #endif +-#ifndef HWCAP2_AES +-#define HWCAP2_AES (1<<0) +-#endif + + const char * + hy_chksum_name(int chksum_type) +@@ -111,16 +104,16 @@ hy_detect_arch(char **arch) + if (!strncmp(un.machine, "armv", 4)) { + /* un.machine is armvXE, where X is version number and E is + * endianness (b or l); we need to add modifiers such as +- * h (hardfloat), n (neon), c (crypto extensions) */ ++ * h (hardfloat), n (neon). Neon is a requirement of armv8 so ++ * as far as rpm is concerned armv8l is the equivilent of armv7hnl ++ * (or 7hnb) so we don't explicitly add 'n' for 8+ as it's expected. */ + char endian = un.machine[strlen(un.machine)-1]; + char *modifier = un.machine + 5; + while(isdigit(*modifier)) /* keep armv7, armv8, armv9, armv10, armv100, ... */ + modifier++; + if (getauxval(AT_HWCAP) & HWCAP_ARM_VFP) + *modifier++ = 'h'; +- if (getauxval(AT_HWCAP2) & HWCAP2_AES) +- *modifier++ = 'c'; +- if (getauxval(AT_HWCAP) & HWCAP_ARM_NEON) ++ if ((atoi(un.machine+4) == 7) && (getauxval(AT_HWCAP) & HWCAP_ARM_NEON)) + *modifier++ = 'n'; + *modifier++ = endian; + *modifier = 0; +-- +2.23.0 + diff --git a/libdnf.spec b/libdnf.spec index 634469c..1127710 100644 --- a/libdnf.spec +++ b/libdnf.spec @@ -44,7 +44,7 @@ Name: libdnf Version: 0.35.5 -Release: 4%{?dist} +Release: 5%{?dist} Summary: Library providing simplified C and Python API to libsolv License: LGPLv2+ URL: https://github.com/rpm-software-management/libdnf @@ -53,6 +53,9 @@ Patch0001: 0001-Revert-9309e92332241ff1113433057c969cebf127734e.patch Patch0002: 0001-Use-POOL_FLAG_WHATPROVIDESWITHDISABLED.patch Patch0003: 0003-Fix-leaking-log-handlers-in-Sack.patch +Patch0005: 0001-Revert-hy_detect_arch-detect-crypto-only-on-arm-vers.patch +Patch0006: 0002-Fix-Arm-detection-improvements.patch + BuildRequires: cmake BuildRequires: gcc BuildRequires: gcc-c++ @@ -285,6 +288,9 @@ popd %endif %changelog +* Wed Oct 23 2019 Peter Robinson 0.35.5-5 +- Fixes for some issues on Arm platforms (rhbz 1691430) + * Tue Oct 22 2019 Ales Matej - 0.35.5-4 - Fix leaking log handlers in Sack that can cause a crash (RhBug:1758737)