Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation/link fixes for iOS/arm #423

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions 0001-Allow-static-detection-of-NEON-on-non-Android-ARMv7-.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
From 321b79f10adec70f0e3922869668998f34be4326 Mon Sep 17 00:00:00 2001
From: Brian Smith <[email protected]>
Date: Tue, 24 Jan 2017 11:54:54 -1000
Subject: [PATCH] Allow static detection of NEON on non-Android ARMv7 targets.

This should allow armv7-apple-ios targets to use NEON without any
runtime checks.
---
include/openssl/cpu.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/openssl/cpu.h b/include/openssl/cpu.h
index 04926e31c237faa0b4de246abdb7284e39ba5cb9..9583b867eba3cec544762cded826aaf2f77d4cd1 100644
--- a/include/openssl/cpu.h
+++ b/include/openssl/cpu.h
@@ -118,12 +118,12 @@ OPENSSL_EXPORT char GFp_is_NEON_capable_at_runtime(void);
/* GFp_is_NEON_capable returns true if the current CPU has a NEON unit. If
* this is known statically then it returns one immediately. */
static inline int GFp_is_NEON_capable(void) {
- /* Only statically skip the runtime lookup on aarch64. On arm, one CPU is
- * known to have a broken NEON unit which is known to fail with on some
- * hand-written NEON assembly. For now, continue to apply the workaround even
- * when the compiler is instructed to freely emit NEON code. See
- * https://crbug.com/341598 and https://crbug.com/606629. */
-#if defined(__ARM_NEON__) && !defined(OPENSSL_ARM)
+ /* On 32-bit ARM, one CPU is known to have a broken NEON unit which is known
+ * to fail with on some hand-written NEON assembly. Assume that non-Android
+ * applications will not use that buggy CPU but still support Android users
+ * that do, even when the compiler is instructed to freely emit NEON code.
+ * See https://crbug.com/341598 and https://crbug.com/606629. */
+#if defined(__ARM_NEON__) && (!defined(OPENSSL_ARM) || !defined(__ANROID__))
return 1;
#else
return GFp_is_NEON_capable_at_runtime();
--
2.9.3.windows.1

19 changes: 15 additions & 4 deletions crypto/curve25519/asm/x25519-asm-arm.S
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,25 @@
#if !defined(OPENSSL_NO_ASM)
#if defined(__arm__)

#if !defined(__APPLE__)
.fpu neon
#endif
.text
.align 4

.global GFp_x25519_NEON
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the .global directive need to have an underscore prefix added too?


#if defined(__APPLE__)
.private_extern _GFp_x25519_NEON
#ifdef __thumb2__
.thumb_func _GFp_x25519_NEON
#endif
#else
.hidden GFp_x25519_NEON
.type GFp_x25519_NEON, %function
GFp_x25519_NEON:
#endif

_GFp_x25519_NEON:
vpush {q4,q5,q6,q7}
mov r12,sp
sub sp,sp,#736
Expand All @@ -42,8 +53,8 @@ mov r0,r0
mov r1,r1
mov r2,r2
add r3,sp,#32
ldr r4,=0
ldr r5,=254
mov r4, #0
mov r5, #254
vmov.i32 q0,#1
vshr.u64 q1,q0,#7
vshr.u64 q0,q0,#8
Expand All @@ -61,7 +72,7 @@ vst1.8 {d4-d5},[r6,: 128]!
vst1.8 {d4-d5},[r6,: 128]!
vst1.8 d4,[r6,: 64]
add r6,r3,#0
ldr r7,=960
mov r7, #960
sub r7,r7,#2
neg r7,r7
sub r7,r7,r7,LSL #7
Expand Down
12 changes: 6 additions & 6 deletions include/openssl/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ OPENSSL_EXPORT char GFp_is_NEON_capable_at_runtime(void);
/* GFp_is_NEON_capable returns true if the current CPU has a NEON unit. If
* this is known statically then it returns one immediately. */
static inline int GFp_is_NEON_capable(void) {
/* Only statically skip the runtime lookup on aarch64. On arm, one CPU is
* known to have a broken NEON unit which is known to fail with on some
* hand-written NEON assembly. For now, continue to apply the workaround even
* when the compiler is instructed to freely emit NEON code. See
* https://crbug.com/341598 and https://crbug.com/606629. */
#if defined(__ARM_NEON__) && !defined(OPENSSL_ARM)
/* On 32-bit ARM, one CPU is known to have a broken NEON unit which is known
* to fail with on some hand-written NEON assembly. Assume that non-Android
* applications will not use that buggy CPU but still support Android users
* that do, even when the compiler is instructed to freely emit NEON code.
* See https://crbug.com/341598 and https://crbug.com/606629. */
#if defined(__ARM_NEON__) && (!defined(OPENSSL_ARM) || !defined(__ANDROID__))
return 1;
#else
return GFp_is_NEON_capable_at_runtime();
Expand Down
2 changes: 1 addition & 1 deletion src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#[inline(always)]
pub fn init_once() {
#[cfg(not(all(target_arch = "aarch64", target_os = "ios")))]
#[cfg(not(target_os = "ios"))]
{
use std;
extern { fn GFp_cpuid_setup(); }
Expand Down
1 change: 0 additions & 1 deletion src/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
//! documentation for more details.

#[cfg(any(target_os = "linux",
target_os = "ios",
windows,
test))]
use c;
Expand Down