2 # Copyright 2009-2018 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the Apache License 2.0 (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
11 if ($flavour =~ /3[12]/) {
19 while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
20 open STDOUT
,">$output";
24 $stdframe=16*$SIZE_T+4*8;
27 #include "s390x_arch.h"
31 .globl OPENSSL_s390x_facilities
32 .type OPENSSL_s390x_facilities
,\
@function
34 OPENSSL_s390x_facilities
:
36 larl
%r4,OPENSSL_s390xcap_P
38 stg
%r0,S390X_STFLE
+8(%r4) # wipe capability vectors
39 stg
%r0,S390X_STFLE
+16(%r4)
40 stg
%r0,S390X_STFLE
+24(%r4)
42 .long
0xb2b04000 # stfle 0(%r4)
45 .long
0xb2b04000 # stfle 0(%r4)
48 .long
0xb2b04000 # stfle 0(%r4)
51 .size OPENSSL_s390x_facilities
,.-OPENSSL_s390x_facilities
53 .globl OPENSSL_s390x_functions
54 .type OPENSSL_s390x_functions
,\
@function
56 OPENSSL_s390x_functions
:
58 larl
%r4,OPENSSL_s390xcap_P
60 stg
%r0,S390X_KIMD
(%r4) # wipe capability vectors
61 stg
%r0,S390X_KIMD
+8(%r4)
62 stg
%r0,S390X_KLMD
(%r4)
63 stg
%r0,S390X_KLMD
+8(%r4)
65 stg
%r0,S390X_KM
+8(%r4)
66 stg
%r0,S390X_KMC
(%r4)
67 stg
%r0,S390X_KMC
+8(%r4)
68 stg
%r0,S390X_KMAC
(%r4)
69 stg
%r0,S390X_KMAC
+8(%r4)
70 stg
%r0,S390X_KMCTR
(%r4)
71 stg
%r0,S390X_KMCTR
+8(%r4)
72 stg
%r0,S390X_KMO
(%r4)
73 stg
%r0,S390X_KMO
+8(%r4)
74 stg
%r0,S390X_KMF
(%r4)
75 stg
%r0,S390X_KMF
+8(%r4)
76 stg
%r0,S390X_PRNO
(%r4)
77 stg
%r0,S390X_PRNO
+8(%r4)
78 stg
%r0,S390X_KMA
(%r4)
79 stg
%r0,S390X_KMA
+8(%r4)
80 stg
%r0,S390X_PCC
(%r4)
81 stg
%r0,S390X_PCC
+8(%r4)
82 stg
%r0,S390X_KDSA
(%r4)
83 stg
%r0,S390X_KDSA
+8(%r4)
85 lmg
%r2,%r3,S390X_STFLE
(%r4)
87 tmhl
%r2,0x4000 # check for message-security-assist
90 lghi
%r0,S390X_QUERY
# query kimd capabilities
91 la
%r1,S390X_KIMD
(%r4)
92 .long
0xb93e0002 # kimd %r0,%r2
94 lghi
%r0,S390X_QUERY
# query klmd capabilities
95 la
%r1,S390X_KLMD
(%r4)
96 .long
0xb93f0002 # klmd %r0,%r2
98 lghi
%r0,S390X_QUERY
# query km capability vector
100 .long
0xb92e0042 # km %r4,%r2
102 lghi
%r0,S390X_QUERY
# query kmc capability vector
103 la
%r1,S390X_KMC
(%r4)
104 .long
0xb92f0042 # kmc %r4,%r2
106 lghi
%r0,S390X_QUERY
# query kmac capability vector
107 la
%r1,S390X_KMAC
(%r4)
108 .long
0xb91e0042 # kmac %r4,%r2
110 tmhh
%r3,0x0003 # check for message-security-assist-3
113 lghi
%r0,S390X_QUERY
# query pcc capability vector
114 la
%r1,S390X_PCC
(%r4)
115 .long
0xb92c0000 # pcc
117 tmhh
%r3,0x0004 # check for message-security-assist-4
120 lghi
%r0,S390X_QUERY
# query kmctr capability vector
121 la
%r1,S390X_KMCTR
(%r4)
122 .long
0xb92d2042 # kmctr %r4,%r2,%r2
124 lghi
%r0,S390X_QUERY
# query kmo capability vector
125 la
%r1,S390X_KMO
(%r4)
126 .long
0xb92b0042 # kmo %r4,%r2
128 lghi
%r0,S390X_QUERY
# query kmf capability vector
129 la
%r1,S390X_KMF
(%r4)
130 .long
0xb92a0042 # kmf %r4,%r2
132 tml
%r2,0x40 # check for message-security-assist-5
135 lghi
%r0,S390X_QUERY
# query prno capability vector
136 la
%r1,S390X_PRNO
(%r4)
137 .long
0xb93c0042 # prno %r4,%r2
139 lg
%r2,S390X_STFLE
+16(%r4)
141 tmhl
%r2,0x2000 # check for message-security-assist-8
144 lghi
%r0,S390X_QUERY
# query kma capability vector
145 la
%r1,S390X_KMA
(%r4)
146 .long
0xb9294022 # kma %r2,%r4,%r2
148 tmhl
%r2,0x0010 # check for message-security-assist-9
151 lghi
%r0,S390X_QUERY
# query kdsa capability vector
152 la
%r1,S390X_KDSA
(%r4)
153 .long
0xb93a0002 # kdsa %r0,%r2
157 .size OPENSSL_s390x_functions
,.-OPENSSL_s390x_functions
160 .type OPENSSL_rdtsc
,\
@function
163 larl
%r4,OPENSSL_s390xcap_P
164 tm S390X_STFLE
+3(%r4),0x40 # check for store-clock-fast facility
167 .long
0xb27cf010 # stckf 16($sp)
174 .size OPENSSL_rdtsc
,.-OPENSSL_rdtsc
176 .globl OPENSSL_atomic_add
177 .type OPENSSL_atomic_add
,\
@function
185 lgfr
%r2,%r0 # OpenSSL expects the new value
187 .size OPENSSL_atomic_add
,.-OPENSSL_atomic_add
189 .globl OPENSSL_wipe_cpu
190 .type OPENSSL_wipe_cpu
,\
@function
207 .size OPENSSL_wipe_cpu
,.-OPENSSL_wipe_cpu
209 .globl OPENSSL_cleanse
210 .type OPENSSL_cleanse
,\
@function
213 #if !defined(__s390x__) && !defined(__s390x)
235 .Loop
: stg
%r0,0(%r2)
242 .size OPENSSL_cleanse
,.-OPENSSL_cleanse
245 .type CRYPTO_memcmp
,\
@function
248 #if !defined(__s390x__) && !defined(__s390x)
269 .size CRYPTO_memcmp
,.-CRYPTO_memcmp
271 .globl OPENSSL_instrument_bus
272 .type OPENSSL_instrument_bus
,\
@function
274 OPENSSL_instrument_bus
:
277 .size OPENSSL_instrument_bus
,.-OPENSSL_instrument_bus
279 .globl OPENSSL_instrument_bus2
280 .type OPENSSL_instrument_bus2
,\
@function
282 OPENSSL_instrument_bus2
:
285 .size OPENSSL_instrument_bus2
,.-OPENSSL_instrument_bus2
287 .globl OPENSSL_vx_probe
288 .type OPENSSL_vx_probe
,\
@function
291 .word
0xe700,0x0000,0x0044 # vzero %v0
293 .size OPENSSL_vx_probe
,.-OPENSSL_vx_probe
298 # void s390x_kimd(const unsigned char *in, size_t len, unsigned int fc,
300 my ($in,$len,$fc,$param) = map("%r$_",(2..5));
303 .type s390x_kimd
,\
@function
309 .long
0xb93e0002 # kimd %r0,%r2
310 brc
1,.-4 # pay attention to "partial completion"
313 .size s390x_kimd
,.-s390x_kimd
319 # void s390x_klmd(const unsigned char *in, size_t inlen, unsigned char *out,
320 # size_t outlen, unsigned int fc, void *param)
321 my ($in,$inlen,$out,$outlen,$fc) = map("%r$_",(2..6));
324 .type s390x_klmd
,\
@function
328 l
${g
} %r1,$stdframe($sp)
330 .long
0xb93f0042 # klmd %r4,%r2
331 brc
1,.-4 # pay attention to "partial completion"
334 .size s390x_klmd
,.-s390x_klmd
339 # void s390x_km(const unsigned char *in, size_t len, unsigned char *out,
340 # unsigned int fc, void *param)
342 my ($in,$len,$out,$fc,$param) = map("%r$_",(2..6));
345 .type s390x_km
,\
@function
351 .long
0xb92e0042 # km $out,$in
352 brc
1,.-4 # pay attention to "partial completion"
355 .size s390x_km
,.-s390x_km
360 # void s390x_kmac(const unsigned char *in, size_t len, unsigned int fc,
363 my ($in,$len,$fc,$param) = map("%r$_",(2..5));
366 .type s390x_kmac
,\
@function
372 .long
0xb91e0002 # kmac %r0,$in
373 brc
1,.-4 # pay attention to "partial completion"
376 .size s390x_kmac
,.-s390x_kmac
381 # void s390x_kmo(const unsigned char *in, size_t len, unsigned char *out,
382 # unsigned int fc, void *param)
384 my ($in,$len,$out,$fc,$param) = map("%r$_",(2..6));
387 .type s390x_kmo
,\
@function
393 .long
0xb92b0042 # kmo $out,$in
394 brc
1,.-4 # pay attention to "partial completion"
397 .size s390x_kmo
,.-s390x_kmo
402 # void s390x_kmf(const unsigned char *in, size_t len, unsigned char *out,
403 # unsigned int fc, void *param)
405 my ($in,$len,$out,$fc,$param) = map("%r$_",(2..6));
408 .type s390x_kmf
,\
@function
414 .long
0xb92a0042 # kmf $out,$in
415 brc
1,.-4 # pay attention to "partial completion"
418 .size s390x_kmf
,.-s390x_kmf
423 # void s390x_kma(const unsigned char *aad, size_t alen,
424 # const unsigned char *in, size_t len,
425 # unsigned char *out, unsigned int fc, void *param)
427 my ($aad,$alen,$in,$len,$out) = map("%r$_",(2..6));
430 .type s390x_kma
,\
@function
433 st
${g
} $out,6*$SIZE_T($sp)
434 lm
${g
} %r0,%r1,$stdframe($sp)
436 .long
0xb9292064 # kma $out,$aad,$in
437 brc
1,.-4 # pay attention to "partial completion"
439 l
${g
} $out,6*$SIZE_T($sp)
441 .size s390x_kma
,.-s390x_kma
446 # int s390x_pcc(unsigned int fc, void *param)
448 my ($fc,$param) = map("%r$_",(2..3));
451 .type s390x_pcc
,\
@function
458 .long
0xb92c0000 # pcc
459 brc
1,.-4 # pay attention to "partial completion"
460 brc
7,.Lpcc_err
# if CC==0 return 0, else return 1
466 .size s390x_pcc
,.-s390x_pcc
471 # int s390x_kdsa(unsigned int fc, void *param,
472 # const unsigned char *in, size_t len)
474 my ($fc,$param,$in,$len) = map("%r$_",(2..5));
477 .type s390x_kdsa
,\
@function
484 .long
0xb93a0004 # kdsa %r0,$in
485 brc
1,.-4 # pay attention to "partial completion"
486 brc
7,.Lkdsa_err
# if CC==0 return 0, else return 1
492 .size s390x_kdsa
,.-s390x_kdsa
498 brasl
$ra,OPENSSL_cpuid_setup
501 $code =~ s/\`([^\`]*)\`/eval $1/gem;
503 close STDOUT
; # force flush