4 while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
5 open STDOUT,">$output";
10 .asg OPENSSL_rdtsc,_OPENSSL_rdtsc
11 .asg OPENSSL_cleanse,_OPENSSL_cleanse
12 .asg OPENSSL_atomic_add,_OPENSSL_atomic_add
13 .asg OPENSSL_wipe_cpu,_OPENSSL_wipe_cpu
14 .asg OPENSSL_instrument_bus,_OPENSSL_instrument_bus
15 .asg OPENSSL_instrument_bus2,_OPENSSL_instrument_bus2
20 .global _OPENSSL_rdtsc
26 [!B0] MVC B0,TSCL ; start TSC
31 .global _OPENSSL_cleanse
36 || SHRU B4,3,B0 ; is length >= 8
45 || [B1] STB B2,*B6++[2]
49 || [B1] STB B2,*B6++[2]
53 || [B1] STB B2,*B6++[2]
62 MV B4,B0 ; remaining bytes
68 || [B1] STB B2,*B6++[2]
72 || [B1] STB B2,*B6++[2]
76 || [B1] STB B2,*B6++[2]
81 .global _OPENSSL_atomic_add
97 .global _OPENSSL_wipe_cpu
143 CLFLUSH .macro CONTROL,ADDR,LEN
145 || STW ADDR,*CONTROL[0]
152 [A0] BNOP spinlock?,5
155 .global _OPENSSL_instrument_bus
156 _OPENSSL_instrument_bus:
158 MV B4,B0 ; reassign sizeof(output)
159 || MV A4,B4 ; reassign output
161 MV B0,A4 ; return value
163 || MVKH 0x01840000,A3 ; L1DWIBAR
164 MVC TSCL,B8 ; collect 1st tick
166 MV B8,B9 ; lasttick = tick
167 || MVK 0,B7 ; lastdiff = 0
168 || MVKH 0x01840000,A5 ; L2WIBAR
169 CLFLUSH A3,B4,A1 ; write-back and invalidate L1D line
170 CLFLUSH A5,B4,A1 ; write-back and invalidate L2 line
181 SUB B8,B9,B7 ; lastdiff = tick - lasttick
182 || MV B8,B9 ; lasttick = tick
183 CLFLUSH A3,B4,A1 ; write-back and invalidate L1D line
184 CLFLUSH A5,B4,A1 ; write-back and invalidate L2 line
190 STW B5,*B4 ; [!B1] is removed to flatten samples
192 || [B0] BNOP bus_loop1?,5
197 .global _OPENSSL_instrument_bus2
198 _OPENSSL_instrument_bus2:
200 MV A6,B0 ; reassign max
201 || MV B4,A6 ; reassing sizeof(output)
203 MV A4,B4 ; reassign output
204 || MVK 0,A4 ; return value
206 || MVKH 0x01840000,A3 ; L1DWIBAR
208 MVC TSCL,B8 ; collect 1st tick
210 MV B8,B9 ; lasttick = tick
211 || MVK 0,B7 ; lastdiff = 0
212 || MVKH 0x01840000,A5 ; L2WIBAR
213 CLFLUSH A3,B4,A1 ; write-back and invalidate L1D line
214 CLFLUSH A5,B4,A1 ; write-back and invalidate L2 line
223 MVC TSCL,B8 ; collect 1st diff
224 SUB B8,B9,B7 ; lastdiff = tick - lasttick
225 || MV B8,B9 ; lasttick = tick
228 CLFLUSH A3,B4,A1 ; write-back and invalidate L1D line
229 CLFLUSH A5,B4,A1 ; write-back and invalidate L2 line
235 STW B5,*B4 ; [!B1] is removed to flatten samples
236 ||[!B0] BNOP bus_loop2_done?,2
246 [!A2] BNOP bus_loop2?,5