Fix segfault in RSA_free() (and DSA/DH/EC_KEY)
[openssl.git] / crypto / ppccpuid.pl
index 3bdfff39d8b9b92bbc2710a36b2f185f0352deeb..9d1cada4dc4c9177552f1abdd2bd4151c1e73296 100755 (executable)
@@ -1,4 +1,11 @@
-#!/usr/bin/env perl
+#! /usr/bin/env perl
+# Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the OpenSSL license (the "License").  You may not use
+# 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
+
 
 $flavour = shift;
 
@@ -23,6 +30,14 @@ $code=<<___;
 .machine       "any"
 .text
 
+.globl .OPENSSL_fpu_probe
+.align 4
+.OPENSSL_fpu_probe:
+       fmr     f0,f0
+       blr
+       .long   0
+       .byte   0,12,0x14,0,0,0,0,0
+.size  .OPENSSL_fpu_probe,.-.OPENSSL_fpu_probe
 .globl .OPENSSL_ppc64_probe
 .align 4
 .OPENSSL_ppc64_probe:
@@ -31,6 +46,7 @@ $code=<<___;
        blr
        .long   0
        .byte   0,12,0x14,0,0,0,0,0
+.size  .OPENSSL_ppc64_probe,.-.OPENSSL_ppc64_probe
 
 .globl .OPENSSL_altivec_probe
 .align 4
@@ -39,6 +55,27 @@ $code=<<___;
        blr
        .long   0
        .byte   0,12,0x14,0,0,0,0,0
+.size  .OPENSSL_altivec_probe,.-..OPENSSL_altivec_probe
+
+.globl .OPENSSL_crypto207_probe
+.align 4
+.OPENSSL_crypto207_probe:
+       lvx_u   v0,0,r1
+       vcipher v0,v0,v0
+       blr
+       .long   0
+       .byte   0,12,0x14,0,0,0,0,0
+.size  .OPENSSL_crypto207_probe,.-.OPENSSL_crypto207_probe
+
+.globl .OPENSSL_madd300_probe
+.align 4
+.OPENSSL_madd300_probe:
+       xor     r0,r0,r0
+       maddld  r3,r0,r0,r0
+       maddhdu r3,r0,r0,r0
+       blr
+       .long   0
+       .byte   0,12,0x14,0,0,0,0,0
 
 .globl .OPENSSL_wipe_cpu
 .align 4
@@ -71,6 +108,7 @@ $code=<<___;
        blr
        .long   0
        .byte   0,12,0x14,0,0,0,0,0
+.size  .OPENSSL_wipe_cpu,.-.OPENSSL_wipe_cpu
 
 .globl .OPENSSL_atomic_add
 .align 4
@@ -84,15 +122,28 @@ Ladd:      lwarx   r5,0,r3
        .long   0
        .byte   0,12,0x14,0,0,0,2,0
        .long   0
+.size  .OPENSSL_atomic_add,.-.OPENSSL_atomic_add
 
 .globl .OPENSSL_rdtsc
 .align 4
 .OPENSSL_rdtsc:
+___
+$code.=<<___   if ($flavour =~ /64/);
+       mftb    r3
+___
+$code.=<<___   if ($flavour !~ /64/);
+Loop_rdtsc:
+       mftbu   r5
        mftb    r3
        mftbu   r4
+       cmplw   r4,r5
+       bne     Loop_rdtsc
+___
+$code.=<<___;
        blr
        .long   0
        .byte   0,12,0x14,0,0,0,0,0
+.size  .OPENSSL_rdtsc,.-.OPENSSL_rdtsc
 
 .globl .OPENSSL_cleanse
 .align 4
@@ -105,7 +156,7 @@ Ladd:       lwarx   r5,0,r3
 Little:        mtctr   r4
        stb     r0,0(r3)
        addi    r3,r3,1
-       bdnz-   \$-8
+       bdnz    \$-8
        blr
 Lot:   andi.   r5,r3,3
        beq     Laligned
@@ -118,13 +169,40 @@ Laligned:
        mtctr   r5
        stw     r0,0(r3)
        addi    r3,r3,4
-       bdnz-   \$-8
+       bdnz    \$-8
        andi.   r4,r4,3
        bne     Little
        blr
        .long   0
        .byte   0,12,0x14,0,0,0,2,0
        .long   0
+.size  .OPENSSL_cleanse,.-.OPENSSL_cleanse
+
+globl  .CRYPTO_memcmp
+.align 4
+.CRYPTO_memcmp:
+       $CMPLI  r5,0
+       li      r0,0
+       beq     Lno_data
+       mtctr   r5
+Loop_cmp:
+       lbz     r6,0(r3)
+       addi    r3,r3,1
+       lbz     r7,0(r4)
+       addi    r4,r4,1
+       xor     r6,r6,r7
+       or      r0,r0,r6
+       bdnz    Loop_cmp
+
+Lno_data:
+       li      r3,0
+       sub     r3,r3,r0
+       extrwi  r3,r3,1,0
+       blr
+       .long   0
+       .byte   0,12,0x14,0,0,0,3,0
+       .long   0
+.size  .CRYPTO_memcmp,.-.CRYPTO_memcmp
 ___
 {
 my ($out,$cnt,$max)=("r3","r4","r5");
@@ -162,6 +240,7 @@ Loop:       mftb    $tick
        .long   0
        .byte   0,12,0x14,0,0,0,2,0
        .long   0
+.size  .OPENSSL_instrument_bus,.-.OPENSSL_instrument_bus
 
 .globl .OPENSSL_instrument_bus2
 .align 4
@@ -213,6 +292,7 @@ Ldone2:
        .long   0
        .byte   0,12,0x14,0,0,0,3,0
        .long   0
+.size  .OPENSSL_instrument_bus2,.-.OPENSSL_instrument_bus2
 ___
 }