X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fpariscid.pl;h=f82e27ac4c34e8bebd75245f9f097382aecb6aa8;hp=bf470ac510acbd451ab297e43960506d14f27b17;hb=07016a8a3174db5caf07182930533cf88ad9b0ad;hpb=3fc2efd241bdded36dbc099d5d8016ed39311753 diff --git a/crypto/pariscid.pl b/crypto/pariscid.pl index bf470ac510..f82e27ac4c 100644 --- a/crypto/pariscid.pl +++ b/crypto/pariscid.pl @@ -1,4 +1,11 @@ -#!/usr/bin/env perl +#! /usr/bin/env perl +# Copyright 2009-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; $output = shift; @@ -87,8 +94,8 @@ OPENSSL_wipe_cpu .PROCEND ___ { -$inp="%r26"; -$len="%r25"; +my $inp="%r26"; +my $len="%r25"; $code.=<<___; .EXPORT OPENSSL_cleanse,ENTRY,ARGW0=GR,ARGW1=GR @@ -97,40 +104,160 @@ OPENSSL_cleanse .PROC .CALLINFO NO_CALLS .ENTRY - cmpib,*>> 15,$len,Little + cmpib,*= 0,$len,L\$done + nop + cmpib,*>>= 15,$len,L\$ittle ldi $SIZE_T-1,%r1 -Lalign +L\$align and,*<> $inp,%r1,%r28 - b,n Laligned + b,n L\$aligned stb %r0,0($inp) ldo -1($len),$len - b Lalign + b L\$align ldo 1($inp),$inp -Laligned +L\$aligned andcm $len,%r1,%r28 -Loop +L\$ot $ST %r0,0($inp) - addib,*vnz -$SIZE_T,%r28,Loop + addib,*<> -$SIZE_T,%r28,L\$ot ldo $SIZE_T($inp),$inp and,*<> $len,%r1,$len - b,n Ldone -Little + b,n L\$done +L\$ittle stb %r0,0($inp) - addib,*vnz -1,$len,Little + addib,*<> -1,$len,L\$ittle ldo 1($inp),$inp -Ldone +L\$done + bv ($rp) + .EXIT + nop + .PROCEND +___ +} +{ +my ($in1,$in2,$len)=("%r26","%r25","%r24"); + +$code.=<<___; + .EXPORT CRYPTO_memcmp,ENTRY,ARGW0=GR,ARGW1=GR,ARGW1=GR + .ALIGN 8 +CRYPTO_memcmp + .PROC + .CALLINFO NO_CALLS + .ENTRY + cmpib,*= 0,$len,L\$no_data + xor $rv,$rv,$rv + +L\$oop_cmp + ldb 0($in1),%r19 + ldb 0($in2),%r20 + ldo 1($in1),$in1 + ldo 1($in2),$in2 + xor %r19,%r20,%r29 + addib,*<> -1,$len,L\$oop_cmp + or %r29,$rv,$rv + + sub %r0,$rv,%r29 + extru %r29,31,1,$rv +L\$no_data bv ($rp) .EXIT nop .PROCEND ___ } +{ +my ($out,$cnt,$max)=("%r26","%r25","%r24"); +my ($tick,$lasttick)=("%r23","%r22"); +my ($diff,$lastdiff)=("%r21","%r20"); + +$code.=<<___; + .EXPORT OPENSSL_instrument_bus,ENTRY,ARGW0=GR,ARGW1=GR + .ALIGN 8 +OPENSSL_instrument_bus + .PROC + .CALLINFO NO_CALLS + .ENTRY + copy $cnt,$rv + mfctl %cr16,$tick + copy $tick,$lasttick + ldi 0,$diff -$code =~ s/cmpib,\*/comib,/gm if ($SIZE_T==4); -$code =~ s/,\*/,/gm if ($SIZE_T==4); + fdc 0($out) + ldw 0($out),$tick + add $diff,$tick,$tick + stw $tick,0($out) +L\$oop + mfctl %cr16,$tick + sub $tick,$lasttick,$diff + copy $tick,$lasttick + + fdc 0($out) + ldw 0($out),$tick + add $diff,$tick,$tick + stw $tick,0($out) + + addib,<> -1,$cnt,L\$oop + addi 4,$out,$out + + bv ($rp) + .EXIT + sub $rv,$cnt,$rv + .PROCEND + + .EXPORT OPENSSL_instrument_bus2,ENTRY,ARGW0=GR,ARGW1=GR + .ALIGN 8 +OPENSSL_instrument_bus2 + .PROC + .CALLINFO NO_CALLS + .ENTRY + copy $cnt,$rv + sub %r0,$cnt,$cnt + + mfctl %cr16,$tick + copy $tick,$lasttick + ldi 0,$diff + + fdc 0($out) + ldw 0($out),$tick + add $diff,$tick,$tick + stw $tick,0($out) + + mfctl %cr16,$tick + sub $tick,$lasttick,$diff + copy $tick,$lasttick +L\$oop2 + copy $diff,$lastdiff + fdc 0($out) + ldw 0($out),$tick + add $diff,$tick,$tick + stw $tick,0($out) + + addib,= -1,$max,L\$done2 + nop + + mfctl %cr16,$tick + sub $tick,$lasttick,$diff + copy $tick,$lasttick + cmpclr,<> $lastdiff,$diff,$tick + ldi 1,$tick + + ldi 1,%r1 + xor %r1,$tick,$tick + addb,<> $tick,$cnt,L\$oop2 + shladd,l $tick,2,$out,$out +L\$done2 + bv ($rp) + .EXIT + add $rv,$cnt,$rv + .PROCEND +___ +} +$code =~ s/cmpib,\*/comib,/gm if ($SIZE_T==4); +$code =~ s/,\*/,/gm if ($SIZE_T==4); +$code =~ s/\bbv\b/bve/gm if ($SIZE_T==8); print $code; close STDOUT;