diff options
author | Andy Polyakov <appro@openssl.org> | 2010-01-19 21:40:58 +0000 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2010-01-19 21:40:58 +0000 |
commit | 3e719c99f588095568c6cd83098c4b1364f2d8e2 (patch) | |
tree | b584c09df048ebc88f1c363da9e8180c5e8fb70a /crypto | |
parent | 2a4d0dcb89499854a51b20c4b80a355f5f34eb55 (diff) |
s390x assembler update: add support for run-time facility detection [from HEAD].
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/aes/asm/aes-s390x.pl | 6 | ||||
-rw-r--r-- | crypto/s390xcap.c | 37 | ||||
-rw-r--r-- | crypto/s390xcpuid.S | 14 | ||||
-rw-r--r-- | crypto/sha/asm/sha1-s390x.pl | 5 | ||||
-rw-r--r-- | crypto/sha/asm/sha512-s390x.pl | 5 |
5 files changed, 60 insertions, 7 deletions
diff --git a/crypto/aes/asm/aes-s390x.pl b/crypto/aes/asm/aes-s390x.pl index 4b27afd92f..7e01889298 100644 --- a/crypto/aes/asm/aes-s390x.pl +++ b/crypto/aes/asm/aes-s390x.pl @@ -765,6 +765,11 @@ $code.=<<___ if (!$softonly); srl %r5,6 ar %r5,%r0 + larl %r1,OPENSSL_s390xcap_P + lg %r0,0(%r1) + tmhl %r0,0x4000 # check for message-security assist + jz .Lekey_internal + lghi %r0,0 # query capability vector la %r1,16($sp) .long 0xb92f0042 # kmc %r4,%r2 @@ -1323,6 +1328,7 @@ $code.=<<___; 4: ex $len,0($s1) j .Lcbc_dec_exit .size AES_cbc_encrypt,.-AES_cbc_encrypt +.comm OPENSSL_s390xcap_P,8,8 ___ } $code.=<<___; diff --git a/crypto/s390xcap.c b/crypto/s390xcap.c new file mode 100644 index 0000000000..ffbe0235f9 --- /dev/null +++ b/crypto/s390xcap.c @@ -0,0 +1,37 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <setjmp.h> +#include <signal.h> + +extern unsigned long OPENSSL_s390xcap_P; + +static sigjmp_buf ill_jmp; +static void ill_handler (int sig) { siglongjmp(ill_jmp,sig); } + +unsigned long OPENSSL_s390x_facilities(void); + +void OPENSSL_cpuid_setup(void) + { + sigset_t oset; + struct sigaction ill_act,oact; + + if (OPENSSL_s390xcap_P) return; + + memset(&ill_act,0,sizeof(ill_act)); + ill_act.sa_handler = ill_handler; + sigfillset(&ill_act.sa_mask); + sigdelset(&ill_act.sa_mask,SIGILL); + sigdelset(&ill_act.sa_mask,SIGTRAP); + sigprocmask(SIG_SETMASK,&ill_act.sa_mask,&oset); + sigaction (SIGILL,&ill_act,&oact); + + /* protection against missing store-facility-list-extended */ + if (sigsetjmp(ill_jmp,0) == 0) + OPENSSL_s390xcap_P = OPENSSL_s390x_facilities(); + else + OPENSSL_s390xcap_P = 1UL<<63; + + sigaction (SIGILL,&oact,NULL); + sigprocmask(SIG_SETMASK,&oset,NULL); + } diff --git a/crypto/s390xcpuid.S b/crypto/s390xcpuid.S index 8500133ad0..aa704c033a 100644 --- a/crypto/s390xcpuid.S +++ b/crypto/s390xcpuid.S @@ -1,12 +1,5 @@ .text -.globl OPENSSL_cpuid_setup -.type OPENSSL_cpuid_setup,@function -.align 16 -OPENSSL_cpuid_setup: - br %r14 # reserved for future -.size OPENSSL_cpuid_setup,.-OPENSSL_cpuid_setup - .globl OPENSSL_s390x_facilities .type OPENSSL_s390x_facilities,@function .align 16 @@ -14,6 +7,8 @@ OPENSSL_s390x_facilities: lghi %r0,0 .long 0xb2b0f010 # stfle 16(%r15) lg %r2,16(%r15) + larl %r1,OPENSSL_s390xcap_P + stg %r2,0(%r1) br %r14 .size OPENSSL_s390x_facilities,.-OPENSSL_s390x_facilities @@ -88,3 +83,8 @@ OPENSSL_cleanse: jnz .Little br %r14 .size OPENSSL_cleanse,.-OPENSSL_cleanse + +.section .init + brasl %r14,OPENSSL_cpuid_setup + +.comm OPENSSL_s390xcap_P,8,8 diff --git a/crypto/sha/asm/sha1-s390x.pl b/crypto/sha/asm/sha1-s390x.pl index eb6f8dfc82..4b17848287 100644 --- a/crypto/sha/asm/sha1-s390x.pl +++ b/crypto/sha/asm/sha1-s390x.pl @@ -143,6 +143,10 @@ Ktable: .long 0x5a827999,0x6ed9eba1,0x8f1bbcdc,0xca62c1d6 sha1_block_data_order: ___ $code.=<<___ if ($kimdfunc); + larl %r1,OPENSSL_s390xcap_P + lg %r0,0(%r1) + tmhl %r0,0x4000 # check for message-security assist + jz .Lsoftware lghi %r0,0 la %r1,16($sp) .long 0xb93e0002 # kimd %r0,%r2 @@ -213,6 +217,7 @@ $code.=<<___; br %r14 .size sha1_block_data_order,.-sha1_block_data_order .string "SHA1 block transform for s390x, CRYPTOGAMS by <appro\@openssl.org>" +.comm OPENSSL_s390xcap_P,8,8 ___ $code =~ s/\`([^\`]*)\`/eval $1/gem; diff --git a/crypto/sha/asm/sha512-s390x.pl b/crypto/sha/asm/sha512-s390x.pl index 5811d74d09..e7ef2d5a9f 100644 --- a/crypto/sha/asm/sha512-s390x.pl +++ b/crypto/sha/asm/sha512-s390x.pl @@ -214,6 +214,10 @@ $code.=<<___; $Func: ___ $code.=<<___ if ($kimdfunc); + larl %r1,OPENSSL_s390xcap_P + lg %r0,0(%r1) + tmhl %r0,0x4000 # check for message-security assist + jz .Lsoftware lghi %r0,0 la %r1,16($sp) .long 0xb93e0002 # kimd %r0,%r2 @@ -286,6 +290,7 @@ $code.=<<___; br %r14 .size $Func,.-$Func .string "SHA${label} block transform for s390x, CRYPTOGAMS by <appro\@openssl.org>" +.comm OPENSSL_s390xcap_P,8,8 ___ $code =~ s/\`([^\`]*)\`/eval $1/gem; |