2 # Copyright 2009-2018 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
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)
81 lmg
%r2,%r3,S390X_STFLE
(%r4)
82 tmhl
%r2,0x4000 # check for message-security-assist
85 lghi
%r0,S390X_QUERY
# query kimd capabilities
86 la
%r1,S390X_KIMD
(%r4)
87 .long
0xb93e0002 # kimd %r0,%r2
89 lghi
%r0,S390X_QUERY
# query klmd capabilities
90 la
%r1,S390X_KLMD
(%r4)
91 .long
0xb93f0002 # klmd %r0,%r2
93 lghi
%r0,S390X_QUERY
# query km capability vector
95 .long
0xb92e0042 # km %r4,%r2
97 lghi
%r0,S390X_QUERY
# query kmc capability vector
99 .long
0xb92f0042 # kmc %r4,%r2
101 lghi
%r0,S390X_QUERY
# query kmac capability vector
102 la
%r1,S390X_KMAC
(%r4)
103 .long
0xb91e0042 # kmac %r4,%r2
105 tmhh
%r3,0x0004 # check for message-security-assist-4
108 lghi
%r0,S390X_QUERY
# query kmctr capability vector
109 la
%r1,S390X_KMCTR
(%r4)
110 .long
0xb92d2042 # kmctr %r4,%r2,%r2
112 lghi
%r0,S390X_QUERY
# query kmo capability vector
113 la
%r1,S390X_KMO
(%r4)
114 .long
0xb92b0042 # kmo %r4,%r2
116 lghi
%r0,S390X_QUERY
# query kmf capability vector
117 la
%r1,S390X_KMF
(%r4)
118 .long
0xb92a0042 # kmf %r4,%r2
120 tml
%r2,0x40 # check for message-security-assist-5
123 lghi
%r0,S390X_QUERY
# query prno capability vector
124 la
%r1,S390X_PRNO
(%r4)
125 .long
0xb93c0042 # prno %r4,%r2
127 lg
%r2,S390X_STFLE
+16(%r4)
128 tmhl
%r2,0x2000 # check for message-security-assist-8
131 lghi
%r0,S390X_QUERY
# query kma capability vector
132 la
%r1,S390X_KMA
(%r4)
133 .long
0xb9294022 # kma %r2,%r4,%r2
137 .size OPENSSL_s390x_functions
,.-OPENSSL_s390x_functions
140 .type OPENSSL_rdtsc
,\
@function
143 larl
%r4,OPENSSL_s390xcap_P
144 tm S390X_STFLE
+3(%r4),0x40 # check for store-clock-fast facility
147 .long
0xb27cf010 # stckf 16($sp)
154 .size OPENSSL_rdtsc
,.-OPENSSL_rdtsc
156 .globl OPENSSL_atomic_add
157 .type OPENSSL_atomic_add
,\
@function
165 lgfr
%r2,%r0 # OpenSSL expects the new value
167 .size OPENSSL_atomic_add
,.-OPENSSL_atomic_add
169 .globl OPENSSL_wipe_cpu
170 .type OPENSSL_wipe_cpu
,\
@function
187 .size OPENSSL_wipe_cpu
,.-OPENSSL_wipe_cpu
189 .globl OPENSSL_cleanse
190 .type OPENSSL_cleanse
,\
@function
193 #if !defined(__s390x__) && !defined(__s390x)
215 .Loop
: stg
%r0,0(%r2)
222 .size OPENSSL_cleanse
,.-OPENSSL_cleanse
225 .type CRYPTO_memcmp
,\
@function
228 #if !defined(__s390x__) && !defined(__s390x)
249 .size CRYPTO_memcmp
,.-CRYPTO_memcmp
251 .globl OPENSSL_instrument_bus
252 .type OPENSSL_instrument_bus
,\
@function
254 OPENSSL_instrument_bus
:
257 .size OPENSSL_instrument_bus
,.-OPENSSL_instrument_bus
259 .globl OPENSSL_instrument_bus2
260 .type OPENSSL_instrument_bus2
,\
@function
262 OPENSSL_instrument_bus2
:
265 .size OPENSSL_instrument_bus2
,.-OPENSSL_instrument_bus2
267 .globl OPENSSL_vx_probe
268 .type OPENSSL_vx_probe
,\
@function
271 .word
0xe700,0x0000,0x0044 # vzero %v0
273 .size OPENSSL_vx_probe
,.-OPENSSL_vx_probe
278 # void s390x_kimd(const unsigned char *in, size_t len, unsigned int fc,
280 my ($in,$len,$fc,$param) = map("%r$_",(2..5));
283 .type s390x_kimd
,\
@function
289 .long
0xb93e0002 # kimd %r0,%r2
290 brc
1,.-4 # pay attention to "partial completion"
293 .size s390x_kimd
,.-s390x_kimd
299 # void s390x_klmd(const unsigned char *in, size_t inlen, unsigned char *out,
300 # size_t outlen, unsigned int fc, void *param)
301 my ($in,$inlen,$out,$outlen,$fc) = map("%r$_",(2..6));
304 .type s390x_klmd
,\
@function
308 l
${g
} %r1,$stdframe($sp)
310 .long
0xb93f0042 # klmd %r4,%r2
311 brc
1,.-4 # pay attention to "partial completion"
314 .size s390x_klmd
,.-s390x_klmd
319 # void s390x_km(const unsigned char *in, size_t len, unsigned char *out,
320 # unsigned int fc, void *param)
322 my ($in,$len,$out,$fc,$param) = map("%r$_",(2..6));
325 .type s390x_km
,\
@function
331 .long
0xb92e0042 # km $out,$in
332 brc
1,.-4 # pay attention to "partial completion"
335 .size s390x_km
,.-s390x_km
340 # void s390x_kmac(const unsigned char *in, size_t len, unsigned int fc,
343 my ($in,$len,$fc,$param) = map("%r$_",(2..5));
346 .type s390x_kmac
,\
@function
352 .long
0xb91e0002 # kmac %r0,$in
353 brc
1,.-4 # pay attention to "partial completion"
356 .size s390x_kmac
,.-s390x_kmac
361 # void s390x_kmo(const unsigned char *in, size_t len, unsigned char *out,
362 # unsigned int fc, void *param)
364 my ($in,$len,$out,$fc,$param) = map("%r$_",(2..6));
367 .type s390x_kmo
,\
@function
373 .long
0xb92b0042 # kmo $out,$in
374 brc
1,.-4 # pay attention to "partial completion"
377 .size s390x_kmo
,.-s390x_kmo
382 # void s390x_kmf(const unsigned char *in, size_t len, unsigned char *out,
383 # unsigned int fc, void *param)
385 my ($in,$len,$out,$fc,$param) = map("%r$_",(2..6));
388 .type s390x_kmf
,\
@function
394 .long
0xb92a0042 # kmf $out,$in
395 brc
1,.-4 # pay attention to "partial completion"
398 .size s390x_kmf
,.-s390x_kmf
403 # void s390x_kma(const unsigned char *aad, size_t alen,
404 # const unsigned char *in, size_t len,
405 # unsigned char *out, unsigned int fc, void *param)
407 my ($aad,$alen,$in,$len,$out) = map("%r$_",(2..6));
410 .type s390x_kma
,\
@function
413 st
${g
} $out,6*$SIZE_T($sp)
414 lm
${g
} %r0,%r1,$stdframe($sp)
416 .long
0xb9292064 # kma $out,$aad,$in
417 brc
1,.-4 # pay attention to "partial completion"
419 l
${g
} $out,6*$SIZE_T($sp)
421 .size s390x_kma
,.-s390x_kma
427 brasl
$ra,OPENSSL_cpuid_setup
430 $code =~ s/\`([^\`]*)\`/eval $1/gem;
432 close STDOUT
; # force flush