2016-04-20 10:10:43 +08:00
|
|
|
#! /usr/bin/env perl
|
2023-09-07 16:59:15 +08:00
|
|
|
# Copyright 2015-2023 The OpenSSL Project Authors. All Rights Reserved.
|
2016-04-20 10:10:43 +08:00
|
|
|
#
|
2018-12-06 21:03:01 +08:00
|
|
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-04-20 10:10:43 +08:00
|
|
|
# this file except in compliance with the License. You can obtain a copy
|
|
|
|
# in the file LICENSE in the source distribution or at
|
|
|
|
# https://www.openssl.org/source/license.html
|
|
|
|
|
2015-04-02 16:17:42 +08:00
|
|
|
|
Unify all assembler file generators
They now generally conform to the following argument sequence:
script.pl "$(PERLASM_SCHEME)" [ C preprocessor arguments ... ] \
$(PROCESSOR) <output file>
However, in the spirit of being able to use these scripts manually,
they also allow for no argument, or for only the flavour, or for only
the output file. This is done by only using the last argument as
output file if it's a file (it has an extension), and only using the
first argument as flavour if it isn't a file (it doesn't have an
extension).
While we're at it, we make all $xlate calls the same, i.e. the $output
argument is always quoted, and we always die on error when trying to
start $xlate.
There's a perl lesson in this, regarding operator priority...
This will always succeed, even when it fails:
open FOO, "something" || die "ERR: $!";
The reason is that '||' has higher priority than list operators (a
function is essentially a list operator and gobbles up everything
following it that isn't lower priority), and since a non-empty string
is always true, so that ends up being exactly the same as:
open FOO, "something";
This, however, will fail if "something" can't be opened:
open FOO, "something" or die "ERR: $!";
The reason is that 'or' has lower priority that list operators,
i.e. it's performed after the 'open' call.
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9884)
2019-09-13 06:06:46 +08:00
|
|
|
# $output is the last argument if it looks like a file (it has an extension)
|
|
|
|
# $flavour is the first argument if it doesn't look like a file
|
|
|
|
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
|
|
|
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
2015-04-02 16:17:42 +08:00
|
|
|
|
|
|
|
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
|
|
|
( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or
|
|
|
|
( $xlate="${dir}perlasm/arm-xlate.pl" and -f $xlate) or
|
|
|
|
die "can't locate arm-xlate.pl";
|
|
|
|
|
Unify all assembler file generators
They now generally conform to the following argument sequence:
script.pl "$(PERLASM_SCHEME)" [ C preprocessor arguments ... ] \
$(PROCESSOR) <output file>
However, in the spirit of being able to use these scripts manually,
they also allow for no argument, or for only the flavour, or for only
the output file. This is done by only using the last argument as
output file if it's a file (it has an extension), and only using the
first argument as flavour if it isn't a file (it doesn't have an
extension).
While we're at it, we make all $xlate calls the same, i.e. the $output
argument is always quoted, and we always die on error when trying to
start $xlate.
There's a perl lesson in this, regarding operator priority...
This will always succeed, even when it fails:
open FOO, "something" || die "ERR: $!";
The reason is that '||' has higher priority than list operators (a
function is essentially a list operator and gobbles up everything
following it that isn't lower priority), and since a non-empty string
is always true, so that ends up being exactly the same as:
open FOO, "something";
This, however, will fail if "something" can't be opened:
open FOO, "something" or die "ERR: $!";
The reason is that 'or' has lower priority that list operators,
i.e. it's performed after the 'open' call.
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9884)
2019-09-13 06:06:46 +08:00
|
|
|
open OUT,"| \"$^X\" $xlate $flavour \"$output\""
|
|
|
|
or die "can't call $xlate: $!";
|
2015-04-02 16:17:42 +08:00
|
|
|
*STDOUT=*OUT;
|
|
|
|
|
|
|
|
$code.=<<___;
|
2011-07-18 01:40:29 +08:00
|
|
|
#include "arm_arch.h"
|
|
|
|
|
2015-09-24 00:41:27 +08:00
|
|
|
#if defined(__thumb2__) && !defined(__APPLE__)
|
|
|
|
.syntax unified
|
|
|
|
.thumb
|
|
|
|
#else
|
2011-07-18 01:40:29 +08:00
|
|
|
.code 32
|
2017-02-14 01:16:16 +08:00
|
|
|
#undef __thumb2__
|
2015-09-24 00:41:27 +08:00
|
|
|
#endif
|
2011-07-18 01:40:29 +08:00
|
|
|
|
2019-02-15 16:44:39 +08:00
|
|
|
.text
|
|
|
|
|
2014-05-04 16:55:49 +08:00
|
|
|
.align 5
|
2011-07-18 01:40:29 +08:00
|
|
|
.global OPENSSL_atomic_add
|
|
|
|
.type OPENSSL_atomic_add,%function
|
|
|
|
OPENSSL_atomic_add:
|
|
|
|
#if __ARM_ARCH__>=6
|
|
|
|
.Ladd: ldrex r2,[r0]
|
|
|
|
add r3,r2,r1
|
|
|
|
strex r2,r3,[r0]
|
|
|
|
cmp r2,#0
|
|
|
|
bne .Ladd
|
|
|
|
mov r0,r3
|
2014-06-07 03:27:18 +08:00
|
|
|
bx lr
|
2011-07-18 01:40:29 +08:00
|
|
|
#else
|
|
|
|
stmdb sp!,{r4-r6,lr}
|
|
|
|
ldr r2,.Lspinlock
|
|
|
|
adr r3,.Lspinlock
|
|
|
|
mov r4,r0
|
|
|
|
mov r5,r1
|
|
|
|
add r6,r3,r2 @ &spinlock
|
|
|
|
b .+8
|
|
|
|
.Lspin: bl sched_yield
|
|
|
|
mov r0,#-1
|
|
|
|
swp r0,r0,[r6]
|
|
|
|
cmp r0,#0
|
|
|
|
bne .Lspin
|
|
|
|
|
|
|
|
ldr r2,[r4]
|
2011-11-05 21:07:18 +08:00
|
|
|
add r2,r2,r5
|
2011-07-18 01:40:29 +08:00
|
|
|
str r2,[r4]
|
|
|
|
str r0,[r6] @ release spinlock
|
|
|
|
ldmia sp!,{r4-r6,lr}
|
|
|
|
tst lr,#1
|
|
|
|
moveq pc,lr
|
|
|
|
.word 0xe12fff1e @ bx lr
|
|
|
|
#endif
|
|
|
|
.size OPENSSL_atomic_add,.-OPENSSL_atomic_add
|
|
|
|
|
|
|
|
.global OPENSSL_cleanse
|
|
|
|
.type OPENSSL_cleanse,%function
|
|
|
|
OPENSSL_cleanse:
|
|
|
|
eor ip,ip,ip
|
|
|
|
cmp r1,#7
|
2015-09-24 00:41:27 +08:00
|
|
|
#ifdef __thumb2__
|
|
|
|
itt hs
|
|
|
|
#endif
|
2011-11-05 21:07:18 +08:00
|
|
|
subhs r1,r1,#4
|
2011-07-18 01:40:29 +08:00
|
|
|
bhs .Lot
|
|
|
|
cmp r1,#0
|
|
|
|
beq .Lcleanse_done
|
|
|
|
.Little:
|
|
|
|
strb ip,[r0],#1
|
2011-11-05 21:07:18 +08:00
|
|
|
subs r1,r1,#1
|
2011-07-18 01:40:29 +08:00
|
|
|
bhi .Little
|
|
|
|
b .Lcleanse_done
|
|
|
|
|
|
|
|
.Lot: tst r0,#3
|
|
|
|
beq .Laligned
|
|
|
|
strb ip,[r0],#1
|
2011-11-05 21:07:18 +08:00
|
|
|
sub r1,r1,#1
|
2011-07-18 01:40:29 +08:00
|
|
|
b .Lot
|
|
|
|
.Laligned:
|
|
|
|
str ip,[r0],#4
|
2011-11-05 21:07:18 +08:00
|
|
|
subs r1,r1,#4
|
2011-07-18 01:40:29 +08:00
|
|
|
bhs .Laligned
|
2011-11-05 21:07:18 +08:00
|
|
|
adds r1,r1,#4
|
2011-07-18 01:40:29 +08:00
|
|
|
bne .Little
|
|
|
|
.Lcleanse_done:
|
2014-06-07 03:27:18 +08:00
|
|
|
#if __ARM_ARCH__>=5
|
|
|
|
bx lr
|
|
|
|
#else
|
2011-07-18 01:40:29 +08:00
|
|
|
tst lr,#1
|
|
|
|
moveq pc,lr
|
|
|
|
.word 0xe12fff1e @ bx lr
|
2014-06-07 03:27:18 +08:00
|
|
|
#endif
|
2011-07-18 01:40:29 +08:00
|
|
|
.size OPENSSL_cleanse,.-OPENSSL_cleanse
|
|
|
|
|
2016-05-15 23:01:15 +08:00
|
|
|
.global CRYPTO_memcmp
|
|
|
|
.type CRYPTO_memcmp,%function
|
|
|
|
.align 4
|
|
|
|
CRYPTO_memcmp:
|
|
|
|
eor ip,ip,ip
|
|
|
|
cmp r2,#0
|
|
|
|
beq .Lno_data
|
|
|
|
stmdb sp!,{r4,r5}
|
|
|
|
|
|
|
|
.Loop_cmp:
|
|
|
|
ldrb r4,[r0],#1
|
|
|
|
ldrb r5,[r1],#1
|
|
|
|
eor r4,r4,r5
|
|
|
|
orr ip,ip,r4
|
|
|
|
subs r2,r2,#1
|
|
|
|
bne .Loop_cmp
|
|
|
|
|
|
|
|
ldmia sp!,{r4,r5}
|
|
|
|
.Lno_data:
|
2018-04-22 22:09:56 +08:00
|
|
|
rsb r0,ip,#0
|
2016-05-15 23:01:15 +08:00
|
|
|
mov r0,r0,lsr#31
|
|
|
|
#if __ARM_ARCH__>=5
|
|
|
|
bx lr
|
|
|
|
#else
|
|
|
|
tst lr,#1
|
|
|
|
moveq pc,lr
|
|
|
|
.word 0xe12fff1e @ bx lr
|
|
|
|
#endif
|
|
|
|
.size CRYPTO_memcmp,.-CRYPTO_memcmp
|
|
|
|
|
2014-11-08 05:48:22 +08:00
|
|
|
#if __ARM_MAX_ARCH__>=7
|
|
|
|
.arch armv7-a
|
|
|
|
.fpu neon
|
|
|
|
|
|
|
|
.align 5
|
|
|
|
.global _armv7_neon_probe
|
|
|
|
.type _armv7_neon_probe,%function
|
|
|
|
_armv7_neon_probe:
|
|
|
|
vorr q0,q0,q0
|
|
|
|
bx lr
|
|
|
|
.size _armv7_neon_probe,.-_armv7_neon_probe
|
|
|
|
|
|
|
|
.global _armv7_tick
|
|
|
|
.type _armv7_tick,%function
|
|
|
|
_armv7_tick:
|
2015-04-02 16:17:42 +08:00
|
|
|
#ifdef __APPLE__
|
|
|
|
mrrc p15,0,r0,r1,c14 @ CNTPCT
|
|
|
|
#else
|
2014-11-08 05:48:22 +08:00
|
|
|
mrrc p15,1,r0,r1,c14 @ CNTVCT
|
2015-04-02 16:17:42 +08:00
|
|
|
#endif
|
2014-11-08 05:48:22 +08:00
|
|
|
bx lr
|
|
|
|
.size _armv7_tick,.-_armv7_tick
|
|
|
|
|
|
|
|
.global _armv8_aes_probe
|
|
|
|
.type _armv8_aes_probe,%function
|
|
|
|
_armv8_aes_probe:
|
2015-09-24 00:41:27 +08:00
|
|
|
#if defined(__thumb2__) && !defined(__APPLE__)
|
|
|
|
.byte 0xb0,0xff,0x00,0x03 @ aese.8 q0,q0
|
|
|
|
#else
|
2014-11-08 05:48:22 +08:00
|
|
|
.byte 0x00,0x03,0xb0,0xf3 @ aese.8 q0,q0
|
2015-09-24 00:41:27 +08:00
|
|
|
#endif
|
2014-11-08 05:48:22 +08:00
|
|
|
bx lr
|
|
|
|
.size _armv8_aes_probe,.-_armv8_aes_probe
|
|
|
|
|
|
|
|
.global _armv8_sha1_probe
|
|
|
|
.type _armv8_sha1_probe,%function
|
|
|
|
_armv8_sha1_probe:
|
2015-09-24 00:41:27 +08:00
|
|
|
#if defined(__thumb2__) && !defined(__APPLE__)
|
|
|
|
.byte 0x00,0xef,0x40,0x0c @ sha1c.32 q0,q0,q0
|
|
|
|
#else
|
2014-11-08 05:48:22 +08:00
|
|
|
.byte 0x40,0x0c,0x00,0xf2 @ sha1c.32 q0,q0,q0
|
2015-09-24 00:41:27 +08:00
|
|
|
#endif
|
2014-11-08 05:48:22 +08:00
|
|
|
bx lr
|
|
|
|
.size _armv8_sha1_probe,.-_armv8_sha1_probe
|
|
|
|
|
|
|
|
.global _armv8_sha256_probe
|
|
|
|
.type _armv8_sha256_probe,%function
|
|
|
|
_armv8_sha256_probe:
|
2015-09-24 00:41:27 +08:00
|
|
|
#if defined(__thumb2__) && !defined(__APPLE__)
|
|
|
|
.byte 0x00,0xff,0x40,0x0c @ sha256h.32 q0,q0,q0
|
|
|
|
#else
|
2014-11-08 05:48:22 +08:00
|
|
|
.byte 0x40,0x0c,0x00,0xf3 @ sha256h.32 q0,q0,q0
|
2015-09-24 00:41:27 +08:00
|
|
|
#endif
|
2014-11-08 05:48:22 +08:00
|
|
|
bx lr
|
|
|
|
.size _armv8_sha256_probe,.-_armv8_sha256_probe
|
|
|
|
.global _armv8_pmull_probe
|
|
|
|
.type _armv8_pmull_probe,%function
|
|
|
|
_armv8_pmull_probe:
|
2015-09-24 00:41:27 +08:00
|
|
|
#if defined(__thumb2__) && !defined(__APPLE__)
|
|
|
|
.byte 0xa0,0xef,0x00,0x0e @ vmull.p64 q0,d0,d0
|
|
|
|
#else
|
2014-11-08 05:48:22 +08:00
|
|
|
.byte 0x00,0x0e,0xa0,0xf2 @ vmull.p64 q0,d0,d0
|
2015-09-24 00:41:27 +08:00
|
|
|
#endif
|
2014-11-08 05:48:22 +08:00
|
|
|
bx lr
|
|
|
|
.size _armv8_pmull_probe,.-_armv8_pmull_probe
|
|
|
|
#endif
|
|
|
|
|
2011-07-18 01:40:29 +08:00
|
|
|
.global OPENSSL_wipe_cpu
|
|
|
|
.type OPENSSL_wipe_cpu,%function
|
|
|
|
OPENSSL_wipe_cpu:
|
2014-11-08 05:48:22 +08:00
|
|
|
#if __ARM_MAX_ARCH__>=7
|
2011-07-18 01:40:29 +08:00
|
|
|
ldr r0,.LOPENSSL_armcap
|
|
|
|
adr r1,.LOPENSSL_armcap
|
|
|
|
ldr r0,[r1,r0]
|
2015-04-02 16:17:42 +08:00
|
|
|
#ifdef __APPLE__
|
|
|
|
ldr r0,[r0]
|
|
|
|
#endif
|
2014-11-08 05:48:22 +08:00
|
|
|
#endif
|
2011-07-18 01:40:29 +08:00
|
|
|
eor r2,r2,r2
|
|
|
|
eor r3,r3,r3
|
|
|
|
eor ip,ip,ip
|
2014-11-08 05:48:22 +08:00
|
|
|
#if __ARM_MAX_ARCH__>=7
|
2011-07-18 01:40:29 +08:00
|
|
|
tst r0,#1
|
|
|
|
beq .Lwipe_done
|
2014-11-08 05:48:22 +08:00
|
|
|
veor q0, q0, q0
|
|
|
|
veor q1, q1, q1
|
|
|
|
veor q2, q2, q2
|
|
|
|
veor q3, q3, q3
|
|
|
|
veor q8, q8, q8
|
|
|
|
veor q9, q9, q9
|
|
|
|
veor q10, q10, q10
|
|
|
|
veor q11, q11, q11
|
|
|
|
veor q12, q12, q12
|
|
|
|
veor q13, q13, q13
|
|
|
|
veor q14, q14, q14
|
|
|
|
veor q15, q15, q15
|
2011-07-18 01:40:29 +08:00
|
|
|
.Lwipe_done:
|
2014-11-08 05:48:22 +08:00
|
|
|
#endif
|
2011-07-18 01:40:29 +08:00
|
|
|
mov r0,sp
|
2014-06-07 03:27:18 +08:00
|
|
|
#if __ARM_ARCH__>=5
|
|
|
|
bx lr
|
|
|
|
#else
|
2011-07-18 01:40:29 +08:00
|
|
|
tst lr,#1
|
|
|
|
moveq pc,lr
|
|
|
|
.word 0xe12fff1e @ bx lr
|
2014-06-07 03:27:18 +08:00
|
|
|
#endif
|
2011-07-18 01:40:29 +08:00
|
|
|
.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
|
|
|
|
|
|
|
|
.global OPENSSL_instrument_bus
|
|
|
|
.type OPENSSL_instrument_bus,%function
|
|
|
|
OPENSSL_instrument_bus:
|
|
|
|
eor r0,r0,r0
|
2014-06-07 03:27:18 +08:00
|
|
|
#if __ARM_ARCH__>=5
|
|
|
|
bx lr
|
|
|
|
#else
|
2011-07-18 01:40:29 +08:00
|
|
|
tst lr,#1
|
|
|
|
moveq pc,lr
|
|
|
|
.word 0xe12fff1e @ bx lr
|
2014-06-07 03:27:18 +08:00
|
|
|
#endif
|
2011-07-18 01:40:29 +08:00
|
|
|
.size OPENSSL_instrument_bus,.-OPENSSL_instrument_bus
|
|
|
|
|
|
|
|
.global OPENSSL_instrument_bus2
|
|
|
|
.type OPENSSL_instrument_bus2,%function
|
|
|
|
OPENSSL_instrument_bus2:
|
|
|
|
eor r0,r0,r0
|
2014-06-07 03:27:18 +08:00
|
|
|
#if __ARM_ARCH__>=5
|
|
|
|
bx lr
|
|
|
|
#else
|
2011-07-18 01:40:29 +08:00
|
|
|
tst lr,#1
|
|
|
|
moveq pc,lr
|
|
|
|
.word 0xe12fff1e @ bx lr
|
2014-06-07 03:27:18 +08:00
|
|
|
#endif
|
2011-07-18 01:40:29 +08:00
|
|
|
.size OPENSSL_instrument_bus2,.-OPENSSL_instrument_bus2
|
|
|
|
|
|
|
|
.align 5
|
2014-11-08 05:48:22 +08:00
|
|
|
#if __ARM_MAX_ARCH__>=7
|
2011-07-18 01:40:29 +08:00
|
|
|
.LOPENSSL_armcap:
|
2015-04-02 16:17:42 +08:00
|
|
|
.word OPENSSL_armcap_P-.
|
2014-11-08 05:48:22 +08:00
|
|
|
#endif
|
2011-07-18 01:40:29 +08:00
|
|
|
#if __ARM_ARCH__>=6
|
|
|
|
.align 5
|
|
|
|
#else
|
|
|
|
.Lspinlock:
|
|
|
|
.word atomic_add_spinlock-.Lspinlock
|
|
|
|
.align 5
|
|
|
|
|
|
|
|
.data
|
|
|
|
.align 2
|
|
|
|
atomic_add_spinlock:
|
|
|
|
.word 0
|
|
|
|
#endif
|
|
|
|
|
2023-03-28 05:05:13 +08:00
|
|
|
.extern OPENSSL_armcap_P
|
2015-04-02 16:17:42 +08:00
|
|
|
___
|
|
|
|
|
|
|
|
print $code;
|
2020-02-17 10:17:53 +08:00
|
|
|
close STDOUT or die "error closing STDOUT: $!";
|