aarch64: fix branch target indications in arm64cpuid.pl and keccak1600
authorTom Cosgrove <tom.cosgrove@arm.com>
Mon, 7 Feb 2022 14:44:56 +0000 (14:44 +0000)
committerPauli <pauli@openssl.org>
Wed, 9 Feb 2022 02:24:31 +0000 (13:24 +1100)
Add missing AARCH64_VALID_CALL_TARGET to armv8_rng_probe(). Also add
these to the functions defined by gen_random(), and note that this Perl
sub prints the assembler out directly, not going via the $code xlate
mechanism (and therefore coming before the include of arm_arch.h). So
fix this too.

In KeccakF1600_int, AARCH64_SIGN_LINK_REGISTER functions as
AARCH64_VALID_CALL_TARGET on BTI-only builds, so it needs to come before
the 'adr' line.

Change-Id: If241efe71591c88253a3e36647ced00300c3c1a3

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17653)

crypto/arm64cpuid.pl
crypto/sha/asm/keccak1600-armv8.pl

index ebea4be59c3a939356f19793ebae914e2c4b38af..3ba593a4885d1ccc17c9dc3a132e4f7208a7453a 100755 (executable)
@@ -189,6 +189,7 @@ CRYPTO_memcmp:
 .globl _armv8_rng_probe
 .type  _armv8_rng_probe,%function
 _armv8_rng_probe:
+       AARCH64_VALID_CALL_TARGET
        mrs     x0, s3_3_c2_c4_0        // rndr
        mrs     x0, s3_3_c2_c4_1        // rndrrs
        ret
@@ -199,7 +200,7 @@ sub gen_random {
 my $rdop = shift;
 my $rand_reg = $rdop eq "rndr" ? "s3_3_c2_c4_0" : "s3_3_c2_c4_1";
 
-print<<___;
+return <<___;
 // Fill buffer with Randomly Generated Bytes
 // inputs:  char * in x0 - Pointer to buffer
 //          size_t in x1 - Number of bytes to write to buffer
@@ -208,6 +209,7 @@ print<<___;
 .type  OPENSSL_${rdop}_asm,%function
 .align 4
 OPENSSL_${rdop}_asm:
+       AARCH64_VALID_CALL_TARGET
        mov     x2,xzr
        mov     x3,xzr
 
@@ -244,8 +246,9 @@ OPENSSL_${rdop}_asm:
 .size  OPENSSL_${rdop}_asm,.-OPENSSL_${rdop}_asm
 ___
 }
-gen_random("rndr");
-gen_random("rndrrs");
+
+$code .= gen_random("rndr");
+$code .= gen_random("rndrrs");
 
 print $code;
 close STDOUT or die "error closing STDOUT: $!";
index cf54b62c636a010b0d0156ce4680c5f25b961505..40f7aa7a695a63faf123cff3ff56f50a4e7d2d4e 100755 (executable)
@@ -126,8 +126,8 @@ $code.=<<___;
 .type  KeccakF1600_int,%function
 .align 5
 KeccakF1600_int:
-       adr     $C[2],iotas
        AARCH64_SIGN_LINK_REGISTER
+       adr     $C[2],iotas
        stp     $C[2],x30,[sp,#16]              // 32 bytes on top are mine
        b       .Loop
 .align 4