mirror of
https://github.com/openbsd/ports.git
synced 2026-06-18 23:44:01 +02:00
Apply upstream fixes to use AT_HWCAP with elf_aux_info() correctly.
from Brad Smith
This commit is contained in:
@@ -3,7 +3,7 @@ COMMENT = crypto and TLS for C++11
|
||||
VERSION = 2.19.5
|
||||
DISTNAME = Botan-${VERSION}
|
||||
PKGNAME = botan2-${VERSION}
|
||||
REVISION = 0
|
||||
REVISION = 1
|
||||
|
||||
SHARED_LIBS = botan-2 19.1
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
Use OpenBSD numbering for shared library.
|
||||
|
||||
Enable elf_aux_info() support.
|
||||
Provides auxiliary vector support for OpenBSD
|
||||
69ad604ff8ba35860cfb22be3ed4e763ea07ba2c
|
||||
|
||||
Index: src/build-data/os/openbsd.txt
|
||||
--- src/build-data/os/openbsd.txt.orig
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
Fix aarch64/armv7/ppc64 feature detection for systems with AT_HWCAP != 16
|
||||
c0697e73a19b46fb389aeb5fe14a92b2275b5301
|
||||
|
||||
Index: src/lib/utils/cpuid/cpuid_arm.cpp
|
||||
--- src/lib/utils/cpuid/cpuid_arm.cpp.orig
|
||||
+++ src/lib/utils/cpuid/cpuid_arm.cpp
|
||||
@@ -153,7 +153,7 @@ uint64_t CPUID::CPUID_Data::detect_cpu_features(size_t
|
||||
*cache_line_size = static_cast<size_t>(dcache_line);
|
||||
#endif
|
||||
|
||||
- const unsigned long hwcap_neon = OS::get_auxval(ARM_hwcap_bit::ARCH_hwcap_neon);
|
||||
+ const unsigned long hwcap_neon = OS::get_auxval(OS::auxval_hwcap());
|
||||
if(hwcap_neon & ARM_hwcap_bit::NEON_bit)
|
||||
detected_features |= CPUID::CPUID_ARM_NEON_BIT;
|
||||
|
||||
@@ -162,7 +162,11 @@ uint64_t CPUID::CPUID_Data::detect_cpu_features(size_t
|
||||
It doesn't seem worth optimizing this out, since getauxval is
|
||||
just reading a field in the ELF header.
|
||||
*/
|
||||
- const unsigned long hwcap_crypto = OS::get_auxval(ARM_hwcap_bit::ARCH_hwcap_crypto);
|
||||
+#if defined(BOTAN_TARGET_ARCH_IS_ARM32)
|
||||
+ const unsigned long hwcap_crypto = OS::get_auxval(OS::auxval_hwcap2());
|
||||
+#elif defined(BOTAN_TARGET_ARCH_IS_ARM64)
|
||||
+ const unsigned long hwcap_crypto = OS::get_auxval(OS::auxval_hwcap());
|
||||
+#endif
|
||||
if(hwcap_crypto & ARM_hwcap_bit::AES_bit)
|
||||
detected_features |= CPUID::CPUID_ARM_AES_BIT;
|
||||
if(hwcap_crypto & ARM_hwcap_bit::PMULL_bit)
|
||||
@@ -0,0 +1,20 @@
|
||||
Fix aarch64/armv7/ppc64 feature detection for systems with AT_HWCAP != 16
|
||||
c0697e73a19b46fb389aeb5fe14a92b2275b5301
|
||||
|
||||
Index: src/lib/utils/cpuid/cpuid_ppc.cpp
|
||||
--- src/lib/utils/cpuid/cpuid_ppc.cpp.orig
|
||||
+++ src/lib/utils/cpuid/cpuid_ppc.cpp
|
||||
@@ -66,11 +66,11 @@ uint64_t CPUID::CPUID_Data::detect_cpu_features(size_t
|
||||
|
||||
uint64_t detected_features = 0;
|
||||
|
||||
- const unsigned long hwcap_altivec = OS::get_auxval(PPC_hwcap_bit::ARCH_hwcap_altivec);
|
||||
+ const unsigned long hwcap_altivec = OS::get_auxval(OS::auxval_hwcap());
|
||||
if(hwcap_altivec & PPC_hwcap_bit::ALTIVEC_bit)
|
||||
detected_features |= CPUID::CPUID_ALTIVEC_BIT;
|
||||
|
||||
- const unsigned long hwcap_crypto = OS::get_auxval(PPC_hwcap_bit::ARCH_hwcap_crypto);
|
||||
+ const unsigned long hwcap_crypto = OS::get_auxval(OS::auxval_hwcap2());
|
||||
if(hwcap_crypto & PPC_hwcap_bit::CRYPTO_bit)
|
||||
detected_features |= CPUID::CPUID_POWER_CRYPTO_BIT;
|
||||
if(hwcap_crypto & PPC_hwcap_bit::DARN_bit)
|
||||
@@ -0,0 +1,33 @@
|
||||
Fix aarch64/armv7/ppc64 feature detection for systems with AT_HWCAP != 16
|
||||
c0697e73a19b46fb389aeb5fe14a92b2275b5301
|
||||
|
||||
Index: src/lib/utils/os_utils.cpp
|
||||
--- src/lib/utils/os_utils.cpp.orig
|
||||
+++ src/lib/utils/os_utils.cpp
|
||||
@@ -106,6 +106,26 @@ uint32_t OS::get_process_id()
|
||||
#endif
|
||||
}
|
||||
|
||||
+unsigned long OS::auxval_hwcap() {
|
||||
+#if defined(AT_HWCAP)
|
||||
+ return AT_HWCAP;
|
||||
+#else
|
||||
+ // If the value is not defined in a header we can see,
|
||||
+ // but auxval is supported, return the Linux/Android value
|
||||
+ return (OS::has_auxval()) ? 16 : 0;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+unsigned long OS::auxval_hwcap2() {
|
||||
+#if defined(AT_HWCAP2)
|
||||
+ return AT_HWCAP2;
|
||||
+#else
|
||||
+ // If the value is not defined in a header we can see,
|
||||
+ // but auxval is supported, return the Linux/Android value
|
||||
+ return (OS::has_auxval()) ? 26 : 0;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
unsigned long OS::get_auxval(unsigned long id)
|
||||
{
|
||||
#if defined(BOTAN_TARGET_OS_HAS_GETAUXVAL)
|
||||
@@ -0,0 +1,27 @@
|
||||
Fix aarch64/armv7/ppc64 feature detection for systems with AT_HWCAP != 16
|
||||
c0697e73a19b46fb389aeb5fe14a92b2275b5301
|
||||
|
||||
Index: src/lib/utils/os_utils.h
|
||||
--- src/lib/utils/os_utils.h.orig
|
||||
+++ src/lib/utils/os_utils.h
|
||||
@@ -54,6 +54,20 @@ size_t BOTAN_TEST_API get_cpu_total();
|
||||
size_t BOTAN_TEST_API get_cpu_available();
|
||||
|
||||
/**
|
||||
+* If get_auxval is supported, returns the relevant value for AT_HWCAP
|
||||
+*
|
||||
+* If get_auxval is not supported on this system, arbitrarily returns 0
|
||||
+*/
|
||||
+unsigned long auxval_hwcap();
|
||||
+
|
||||
+/**
|
||||
+* If get_auxval is supported, returns the relevant value for AT_HWCAP2
|
||||
+*
|
||||
+* If get_auxval is not supported on this system, arbitrarily returns 0
|
||||
+*/
|
||||
+unsigned long auxval_hwcap2();
|
||||
+
|
||||
+/**
|
||||
* Return the ELF auxiliary vector cooresponding to the given ID.
|
||||
* This only makes sense on Unix-like systems and is currently
|
||||
* only supported on Linux, Android, and FreeBSD.
|
||||
Reference in New Issue
Block a user