2 # Copyright 2012-2016 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the OpenSSL license (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
9 while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
10 open STDOUT,">$output";
15 .if .ASSEMBLER_VERSION<7000000
19 .asg OPENSSL_rdtsc,_OPENSSL_rdtsc
20 .asg OPENSSL_cleanse,_OPENSSL_cleanse
21 .asg OPENSSL_atomic_add,_OPENSSL_atomic_add
22 .asg OPENSSL_wipe_cpu,_OPENSSL_wipe_cpu
23 .asg OPENSSL_instrument_bus,_OPENSSL_instrument_bus
24 .asg OPENSSL_instrument_bus2,_OPENSSL_instrument_bus2
29 .global _OPENSSL_rdtsc
35 [!B0] MVC B0,TSCL ; start TSC
40 .global _OPENSSL_cleanse
45 || SHRU B4,3,B0 ; is length >= 8
54 || [B1] STB B2,*B6++[2]
58 || [B1] STB B2,*B6++[2]
62 || [B1] STB B2,*B6++[2]
71 MV B4,B0 ; remaining bytes
77 || [B1] STB B2,*B6++[2]
81 || [B1] STB B2,*B6++[2]
85 || [B1] STB B2,*B6++[2]
90 .global _OPENSSL_atomic_add
106 .global _OPENSSL_wipe_cpu
152 CLFLUSH .macro CONTROL,ADDR,LEN
154 || STW ADDR,*CONTROL[0]
161 [A0] BNOP spinlock?,5
164 .global _OPENSSL_instrument_bus
165 _OPENSSL_instrument_bus:
167 MV B4,B0 ; reassign sizeof(output)
168 || MV A4,B4 ; reassign output
170 MV B0,A4 ; return value
172 || MVKH 0x01840000,A3 ; L1DWIBAR
173 MVC TSCL,B8 ; collect 1st tick
175 MV B8,B9 ; lasttick = tick
176 || MVK 0,B7 ; lastdiff = 0
177 || MVKH 0x01840000,A5 ; L2WIBAR
178 CLFLUSH A3,B4,A1 ; write-back and invalidate L1D line
179 CLFLUSH A5,B4,A1 ; write-back and invalidate L2 line
190 SUB B8,B9,B7 ; lastdiff = tick - lasttick
191 || MV B8,B9 ; lasttick = tick
192 CLFLUSH A3,B4,A1 ; write-back and invalidate L1D line
193 CLFLUSH A5,B4,A1 ; write-back and invalidate L2 line
199 STW B5,*B4 ; [!B1] is removed to flatten samples
201 || [B0] BNOP bus_loop1?,5
206 .global _OPENSSL_instrument_bus2
207 _OPENSSL_instrument_bus2:
209 MV A6,B0 ; reassign max
210 || MV B4,A6 ; reassing sizeof(output)
212 MV A4,B4 ; reassign output
213 || MVK 0,A4 ; return value
215 || MVKH 0x01840000,A3 ; L1DWIBAR
217 MVC TSCL,B8 ; collect 1st tick
219 MV B8,B9 ; lasttick = tick
220 || MVK 0,B7 ; lastdiff = 0
221 || MVKH 0x01840000,A5 ; L2WIBAR
222 CLFLUSH A3,B4,A1 ; write-back and invalidate L1D line
223 CLFLUSH A5,B4,A1 ; write-back and invalidate L2 line
232 MVC TSCL,B8 ; collect 1st diff
233 SUB B8,B9,B7 ; lastdiff = tick - lasttick
234 || MV B8,B9 ; lasttick = tick
237 CLFLUSH A3,B4,A1 ; write-back and invalidate L1D line
238 CLFLUSH A5,B4,A1 ; write-back and invalidate L2 line
244 STW B5,*B4 ; [!B1] is removed to flatten samples
245 ||[!B0] BNOP bus_loop2_done?,2
255 [!A2] BNOP bus_loop2?,5