]> git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/s390xcap.c
bn/bn_lib.c: conceal even memmory access pattern in bn2binpad.
[thirdparty/openssl.git] / crypto / s390xcap.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <setjmp.h>
5 #include <signal.h>
6 #include "cryptlib.h"
7
8 extern unsigned long OPENSSL_s390xcap_P[];
9
10 static sigjmp_buf ill_jmp;
11 static void ill_handler(int sig)
12 {
13 siglongjmp(ill_jmp, sig);
14 }
15
16 unsigned long OPENSSL_s390x_facilities(void);
17
18 void OPENSSL_cpuid_setup(void)
19 {
20 sigset_t oset;
21 struct sigaction ill_act, oact;
22
23 if (OPENSSL_s390xcap_P[0])
24 return;
25
26 OPENSSL_s390xcap_P[0] = 1UL << (8 * sizeof(unsigned long) - 1);
27
28 memset(&ill_act, 0, sizeof(ill_act));
29 ill_act.sa_handler = ill_handler;
30 sigfillset(&ill_act.sa_mask);
31 sigdelset(&ill_act.sa_mask, SIGILL);
32 sigdelset(&ill_act.sa_mask, SIGTRAP);
33 sigprocmask(SIG_SETMASK, &ill_act.sa_mask, &oset);
34 sigaction(SIGILL, &ill_act, &oact);
35
36 /* protection against missing store-facility-list-extended */
37 if (sigsetjmp(ill_jmp, 1) == 0)
38 OPENSSL_s390x_facilities();
39
40 sigaction(SIGILL, &oact, NULL);
41 sigprocmask(SIG_SETMASK, &oset, NULL);
42 }