Rich Salz | b132225 | 2016-05-17 14:52:22 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 8 | */ |
| 9 | |
Andy Polyakov | c06b0f3 | 2005-12-15 22:50:36 +0000 | [diff] [blame] | 10 | #include <stdio.h> |
| 11 | #include <stdlib.h> |
| 12 | #include <string.h> |
Andy Polyakov | c32fcca | 2010-07-01 07:34:56 +0000 | [diff] [blame] | 13 | #include <setjmp.h> |
| 14 | #include <signal.h> |
Andy Polyakov | c06b0f3 | 2005-12-15 22:50:36 +0000 | [diff] [blame] | 15 | #include <sys/time.h> |
Andy Polyakov | 68c06bf | 2012-11-17 10:34:11 +0000 | [diff] [blame] | 16 | #include <unistd.h> |
Andy Polyakov | c06b0f3 | 2005-12-15 22:50:36 +0000 | [diff] [blame] | 17 | #include <openssl/bn.h> |
| 18 | |
Andy Polyakov | 1fda639 | 2012-09-23 20:29:03 +0000 | [diff] [blame] | 19 | #include "sparc_arch.h" |
Andy Polyakov | c32fcca | 2010-07-01 07:34:56 +0000 | [diff] [blame] | 20 | |
Andy Polyakov | 1fda639 | 2012-09-23 20:29:03 +0000 | [diff] [blame] | 21 | #if defined(__GNUC__) && defined(__linux) |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 22 | __attribute__ ((visibility("hidden"))) |
Andy Polyakov | 1fda639 | 2012-09-23 20:29:03 +0000 | [diff] [blame] | 23 | #endif |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 24 | unsigned int OPENSSL_sparcv9cap_P[2] = { SPARCV9_TICK_PRIVILEGED, 0 }; |
Andy Polyakov | c06b0f3 | 2005-12-15 22:50:36 +0000 | [diff] [blame] | 25 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 26 | int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, |
| 27 | const BN_ULONG *np, const BN_ULONG *n0, int num) |
| 28 | { |
| 29 | int bn_mul_mont_vis3(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, |
| 30 | const BN_ULONG *np, const BN_ULONG *n0, int num); |
| 31 | int bn_mul_mont_fpu(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, |
| 32 | const BN_ULONG *np, const BN_ULONG *n0, int num); |
| 33 | int bn_mul_mont_int(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, |
| 34 | const BN_ULONG *np, const BN_ULONG *n0, int num); |
Andy Polyakov | c06b0f3 | 2005-12-15 22:50:36 +0000 | [diff] [blame] | 35 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 36 | if (!(num & 1) && num >= 6) { |
| 37 | if ((num & 15) == 0 && num <= 64 && |
| 38 | (OPENSSL_sparcv9cap_P[1] & (CFR_MONTMUL | CFR_MONTSQR)) == |
| 39 | (CFR_MONTMUL | CFR_MONTSQR)) { |
| 40 | typedef int (*bn_mul_mont_f) (BN_ULONG *rp, const BN_ULONG *ap, |
| 41 | const BN_ULONG *bp, |
| 42 | const BN_ULONG *np, |
| 43 | const BN_ULONG *n0); |
| 44 | int bn_mul_mont_t4_8(BN_ULONG *rp, const BN_ULONG *ap, |
| 45 | const BN_ULONG *bp, const BN_ULONG *np, |
| 46 | const BN_ULONG *n0); |
| 47 | int bn_mul_mont_t4_16(BN_ULONG *rp, const BN_ULONG *ap, |
| 48 | const BN_ULONG *bp, const BN_ULONG *np, |
| 49 | const BN_ULONG *n0); |
| 50 | int bn_mul_mont_t4_24(BN_ULONG *rp, const BN_ULONG *ap, |
| 51 | const BN_ULONG *bp, const BN_ULONG *np, |
| 52 | const BN_ULONG *n0); |
| 53 | int bn_mul_mont_t4_32(BN_ULONG *rp, const BN_ULONG *ap, |
| 54 | const BN_ULONG *bp, const BN_ULONG *np, |
| 55 | const BN_ULONG *n0); |
| 56 | static const bn_mul_mont_f funcs[4] = { |
| 57 | bn_mul_mont_t4_8, bn_mul_mont_t4_16, |
| 58 | bn_mul_mont_t4_24, bn_mul_mont_t4_32 |
| 59 | }; |
| 60 | bn_mul_mont_f worker = funcs[num / 16 - 1]; |
Andy Polyakov | 68c06bf | 2012-11-17 10:34:11 +0000 | [diff] [blame] | 61 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 62 | if ((*worker) (rp, ap, bp, np, n0)) |
| 63 | return 1; |
| 64 | /* retry once and fall back */ |
| 65 | if ((*worker) (rp, ap, bp, np, n0)) |
| 66 | return 1; |
| 67 | return bn_mul_mont_vis3(rp, ap, bp, np, n0, num); |
| 68 | } |
| 69 | if ((OPENSSL_sparcv9cap_P[0] & SPARCV9_VIS3)) |
| 70 | return bn_mul_mont_vis3(rp, ap, bp, np, n0, num); |
| 71 | else if (num >= 8 && |
Andy Polyakov | 33ea23d | 2016-04-25 23:17:57 +0200 | [diff] [blame] | 72 | /* |
| 73 | * bn_mul_mont_fpu doesn't use FMADD, we just use the |
| 74 | * flag to detect when FPU path is preferable in cases |
| 75 | * when current heuristics is unreliable. [it works |
| 76 | * out because FMADD-capable processors where FPU |
| 77 | * code path is undesirable are also VIS3-capable and |
| 78 | * VIS3 code path takes precedence.] |
| 79 | */ |
| 80 | ( (OPENSSL_sparcv9cap_P[0] & SPARCV9_FMADD) || |
| 81 | (OPENSSL_sparcv9cap_P[0] & |
| 82 | (SPARCV9_PREFER_FPU | SPARCV9_VIS1)) == |
| 83 | (SPARCV9_PREFER_FPU | SPARCV9_VIS1) )) |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 84 | return bn_mul_mont_fpu(rp, ap, bp, np, n0, num); |
| 85 | } |
| 86 | return bn_mul_mont_int(rp, ap, bp, np, n0, num); |
| 87 | } |
Andy Polyakov | c06b0f3 | 2005-12-15 22:50:36 +0000 | [diff] [blame] | 88 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 89 | unsigned long _sparcv9_rdtick(void); |
| 90 | void _sparcv9_vis1_probe(void); |
| 91 | unsigned long _sparcv9_vis1_instrument(void); |
| 92 | void _sparcv9_vis2_probe(void); |
| 93 | void _sparcv9_fmadd_probe(void); |
| 94 | unsigned long _sparcv9_rdcfr(void); |
| 95 | void _sparcv9_vis3_probe(void); |
Andy Polyakov | d40a13a | 2016-08-11 13:52:44 +0200 | [diff] [blame] | 96 | void _sparcv9_fjaesx_probe(void); |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 97 | unsigned long _sparcv9_random(void); |
| 98 | size_t _sparcv9_vis1_instrument_bus(unsigned int *, size_t); |
| 99 | size_t _sparcv9_vis1_instrument_bus2(unsigned int *, size_t, size_t); |
Andy Polyakov | c32fcca | 2010-07-01 07:34:56 +0000 | [diff] [blame] | 100 | |
Andy Polyakov | c06b0f3 | 2005-12-15 22:50:36 +0000 | [diff] [blame] | 101 | unsigned long OPENSSL_rdtsc(void) |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 102 | { |
| 103 | if (OPENSSL_sparcv9cap_P[0] & SPARCV9_TICK_PRIVILEGED) |
Andy Polyakov | c06b0f3 | 2005-12-15 22:50:36 +0000 | [diff] [blame] | 104 | #if defined(__sun) && defined(__SVR4) |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 105 | return gethrtime(); |
Andy Polyakov | c06b0f3 | 2005-12-15 22:50:36 +0000 | [diff] [blame] | 106 | #else |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 107 | return 0; |
Andy Polyakov | c06b0f3 | 2005-12-15 22:50:36 +0000 | [diff] [blame] | 108 | #endif |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 109 | else |
| 110 | return _sparcv9_rdtick(); |
| 111 | } |
Andy Polyakov | c06b0f3 | 2005-12-15 22:50:36 +0000 | [diff] [blame] | 112 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 113 | size_t OPENSSL_instrument_bus(unsigned int *out, size_t cnt) |
| 114 | { |
| 115 | if ((OPENSSL_sparcv9cap_P[0] & (SPARCV9_TICK_PRIVILEGED | SPARCV9_BLK)) == |
| 116 | SPARCV9_BLK) |
| 117 | return _sparcv9_vis1_instrument_bus(out, cnt); |
| 118 | else |
| 119 | return 0; |
| 120 | } |
Andy Polyakov | 5fabb88 | 2011-04-17 12:46:00 +0000 | [diff] [blame] | 121 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 122 | size_t OPENSSL_instrument_bus2(unsigned int *out, size_t cnt, size_t max) |
| 123 | { |
| 124 | if ((OPENSSL_sparcv9cap_P[0] & (SPARCV9_TICK_PRIVILEGED | SPARCV9_BLK)) == |
| 125 | SPARCV9_BLK) |
| 126 | return _sparcv9_vis1_instrument_bus2(out, cnt, max); |
| 127 | else |
| 128 | return 0; |
| 129 | } |
Andy Polyakov | 5fabb88 | 2011-04-17 12:46:00 +0000 | [diff] [blame] | 130 | |
Andy Polyakov | c32fcca | 2010-07-01 07:34:56 +0000 | [diff] [blame] | 131 | static sigjmp_buf common_jmp; |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 132 | static void common_handler(int sig) |
| 133 | { |
| 134 | siglongjmp(common_jmp, sig); |
| 135 | } |
Andy Polyakov | c32fcca | 2010-07-01 07:34:56 +0000 | [diff] [blame] | 136 | |
Andy Polyakov | 2238e0e | 2015-12-01 12:21:08 +0100 | [diff] [blame] | 137 | #if defined(__sun) && defined(__SVR4) |
| 138 | # if defined(__GNUC__) && __GNUC__>=2 |
| 139 | extern unsigned int getisax(unsigned int vec[], unsigned int sz) __attribute__ ((weak)); |
| 140 | # elif defined(__SUNPRO_C) |
| 141 | #pragma weak getisax |
| 142 | extern unsigned int getisax(unsigned int vec[], unsigned int sz); |
| 143 | # else |
| 144 | static unsigned int (*getisax) (unsigned int vec[], unsigned int sz) = NULL; |
| 145 | # endif |
| 146 | #endif |
| 147 | |
Andy Polyakov | 5d7324e | 2005-12-18 19:13:03 +0000 | [diff] [blame] | 148 | void OPENSSL_cpuid_setup(void) |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 149 | { |
| 150 | char *e; |
| 151 | struct sigaction common_act, ill_oact, bus_oact; |
| 152 | sigset_t all_masked, oset; |
| 153 | static int trigger = 0; |
Andy Polyakov | 4b2603e | 2010-09-05 19:41:41 +0000 | [diff] [blame] | 154 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 155 | if (trigger) |
| 156 | return; |
| 157 | trigger = 1; |
Andy Polyakov | c06b0f3 | 2005-12-15 22:50:36 +0000 | [diff] [blame] | 158 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 159 | if ((e = getenv("OPENSSL_sparcv9cap"))) { |
| 160 | OPENSSL_sparcv9cap_P[0] = strtoul(e, NULL, 0); |
| 161 | if ((e = strchr(e, ':'))) |
| 162 | OPENSSL_sparcv9cap_P[1] = strtoul(e + 1, NULL, 0); |
| 163 | return; |
| 164 | } |
Andy Polyakov | c32fcca | 2010-07-01 07:34:56 +0000 | [diff] [blame] | 165 | |
Andy Polyakov | 2238e0e | 2015-12-01 12:21:08 +0100 | [diff] [blame] | 166 | #if defined(__sun) && defined(__SVR4) |
| 167 | if (getisax != NULL) { |
Andy Polyakov | a5a95f8 | 2016-08-04 21:06:53 +0200 | [diff] [blame] | 168 | unsigned int vec[2] = { 0, 0 }; |
Andy Polyakov | 2238e0e | 2015-12-01 12:21:08 +0100 | [diff] [blame] | 169 | |
Andy Polyakov | a5a95f8 | 2016-08-04 21:06:53 +0200 | [diff] [blame] | 170 | if (getisax (vec,2)) { |
Andy Polyakov | 299ccad | 2016-04-23 19:10:04 +0200 | [diff] [blame] | 171 | if (vec[0]&0x00020) OPENSSL_sparcv9cap_P[0] |= SPARCV9_VIS1; |
| 172 | if (vec[0]&0x00040) OPENSSL_sparcv9cap_P[0] |= SPARCV9_VIS2; |
| 173 | if (vec[0]&0x00080) OPENSSL_sparcv9cap_P[0] |= SPARCV9_BLK; |
| 174 | if (vec[0]&0x00100) OPENSSL_sparcv9cap_P[0] |= SPARCV9_FMADD; |
| 175 | if (vec[0]&0x00400) OPENSSL_sparcv9cap_P[0] |= SPARCV9_VIS3; |
| 176 | if (vec[0]&0x01000) OPENSSL_sparcv9cap_P[0] |= SPARCV9_FJHPCACE; |
| 177 | if (vec[0]&0x02000) OPENSSL_sparcv9cap_P[0] |= SPARCV9_FJDESX; |
| 178 | if (vec[0]&0x08000) OPENSSL_sparcv9cap_P[0] |= SPARCV9_IMA; |
Andy Polyakov | 4400f6c | 2016-04-19 13:08:47 +0200 | [diff] [blame] | 179 | if (vec[0]&0x10000) OPENSSL_sparcv9cap_P[0] |= SPARCV9_FJAESX; |
Andy Polyakov | 299ccad | 2016-04-23 19:10:04 +0200 | [diff] [blame] | 180 | if (vec[1]&0x00008) OPENSSL_sparcv9cap_P[0] |= SPARCV9_VIS4; |
Andy Polyakov | 2238e0e | 2015-12-01 12:21:08 +0100 | [diff] [blame] | 181 | |
| 182 | /* reconstruct %cfr copy */ |
| 183 | OPENSSL_sparcv9cap_P[1] = (vec[0]>>17)&0x3ff; |
| 184 | OPENSSL_sparcv9cap_P[1] |= (OPENSSL_sparcv9cap_P[1]&CFR_MONTMUL)<<1; |
| 185 | if (vec[0]&0x20000000) OPENSSL_sparcv9cap_P[1] |= CFR_CRC32C; |
Andy Polyakov | 299ccad | 2016-04-23 19:10:04 +0200 | [diff] [blame] | 186 | if (vec[1]&0x00000020) OPENSSL_sparcv9cap_P[1] |= CFR_XMPMUL; |
| 187 | if (vec[1]&0x00000040) |
| 188 | OPENSSL_sparcv9cap_P[1] |= CFR_XMONTMUL|CFR_XMONTSQR; |
Andy Polyakov | 2238e0e | 2015-12-01 12:21:08 +0100 | [diff] [blame] | 189 | |
| 190 | /* Some heuristics */ |
| 191 | /* all known VIS2-capable CPUs have unprivileged tick counter */ |
| 192 | if (OPENSSL_sparcv9cap_P[0]&SPARCV9_VIS2) |
| 193 | OPENSSL_sparcv9cap_P[0] &= ~SPARCV9_TICK_PRIVILEGED; |
| 194 | |
| 195 | OPENSSL_sparcv9cap_P[0] |= SPARCV9_PREFER_FPU; |
| 196 | |
| 197 | /* detect UltraSPARC-Tx, see sparccpud.S for details... */ |
| 198 | if ((OPENSSL_sparcv9cap_P[0]&SPARCV9_VIS1) && |
| 199 | _sparcv9_vis1_instrument() >= 12) |
| 200 | OPENSSL_sparcv9cap_P[0] &= ~(SPARCV9_VIS1 | SPARCV9_PREFER_FPU); |
| 201 | } |
| 202 | |
| 203 | if (sizeof(size_t) == 8) |
| 204 | OPENSSL_sparcv9cap_P[0] |= SPARCV9_64BIT_STACK; |
| 205 | |
| 206 | return; |
| 207 | } |
| 208 | #endif |
| 209 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 210 | /* Initial value, fits UltraSPARC-I&II... */ |
| 211 | OPENSSL_sparcv9cap_P[0] = SPARCV9_PREFER_FPU | SPARCV9_TICK_PRIVILEGED; |
Andy Polyakov | c32fcca | 2010-07-01 07:34:56 +0000 | [diff] [blame] | 212 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 213 | sigfillset(&all_masked); |
| 214 | sigdelset(&all_masked, SIGILL); |
| 215 | sigdelset(&all_masked, SIGTRAP); |
| 216 | # ifdef SIGEMT |
| 217 | sigdelset(&all_masked, SIGEMT); |
| 218 | # endif |
| 219 | sigdelset(&all_masked, SIGFPE); |
| 220 | sigdelset(&all_masked, SIGBUS); |
| 221 | sigdelset(&all_masked, SIGSEGV); |
| 222 | sigprocmask(SIG_SETMASK, &all_masked, &oset); |
Andy Polyakov | c32fcca | 2010-07-01 07:34:56 +0000 | [diff] [blame] | 223 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 224 | memset(&common_act, 0, sizeof(common_act)); |
| 225 | common_act.sa_handler = common_handler; |
| 226 | common_act.sa_mask = all_masked; |
Andy Polyakov | 4b2603e | 2010-09-05 19:41:41 +0000 | [diff] [blame] | 227 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 228 | sigaction(SIGILL, &common_act, &ill_oact); |
| 229 | sigaction(SIGBUS, &common_act, &bus_oact); /* T1 fails 16-bit ldda [on |
| 230 | * Linux] */ |
Andy Polyakov | c32fcca | 2010-07-01 07:34:56 +0000 | [diff] [blame] | 231 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 232 | if (sigsetjmp(common_jmp, 1) == 0) { |
| 233 | _sparcv9_rdtick(); |
| 234 | OPENSSL_sparcv9cap_P[0] &= ~SPARCV9_TICK_PRIVILEGED; |
| 235 | } |
Andy Polyakov | 4b2603e | 2010-09-05 19:41:41 +0000 | [diff] [blame] | 236 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 237 | if (sigsetjmp(common_jmp, 1) == 0) { |
| 238 | _sparcv9_vis1_probe(); |
| 239 | OPENSSL_sparcv9cap_P[0] |= SPARCV9_VIS1 | SPARCV9_BLK; |
| 240 | /* detect UltraSPARC-Tx, see sparccpud.S for details... */ |
| 241 | if (_sparcv9_vis1_instrument() >= 12) |
| 242 | OPENSSL_sparcv9cap_P[0] &= ~(SPARCV9_VIS1 | SPARCV9_PREFER_FPU); |
| 243 | else { |
| 244 | _sparcv9_vis2_probe(); |
| 245 | OPENSSL_sparcv9cap_P[0] |= SPARCV9_VIS2; |
| 246 | } |
| 247 | } |
Andy Polyakov | 1fda639 | 2012-09-23 20:29:03 +0000 | [diff] [blame] | 248 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 249 | if (sigsetjmp(common_jmp, 1) == 0) { |
| 250 | _sparcv9_fmadd_probe(); |
| 251 | OPENSSL_sparcv9cap_P[0] |= SPARCV9_FMADD; |
| 252 | } |
Andy Polyakov | 1fda639 | 2012-09-23 20:29:03 +0000 | [diff] [blame] | 253 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 254 | /* |
| 255 | * VIS3 flag is tested independently from VIS1, unlike VIS2 that is, |
| 256 | * because VIS3 defines even integer instructions. |
| 257 | */ |
| 258 | if (sigsetjmp(common_jmp, 1) == 0) { |
| 259 | _sparcv9_vis3_probe(); |
| 260 | OPENSSL_sparcv9cap_P[0] |= SPARCV9_VIS3; |
| 261 | } |
Andy Polyakov | 1fda639 | 2012-09-23 20:29:03 +0000 | [diff] [blame] | 262 | |
Andy Polyakov | 4400f6c | 2016-04-19 13:08:47 +0200 | [diff] [blame] | 263 | if (sigsetjmp(common_jmp, 1) == 0) { |
| 264 | _sparcv9_fjaesx_probe(); |
| 265 | OPENSSL_sparcv9cap_P[0] |= SPARCV9_FJAESX; |
| 266 | } |
| 267 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 268 | /* |
| 269 | * In wait for better solution _sparcv9_rdcfr is masked by |
| 270 | * VIS3 flag, because it goes to uninterruptable endless |
| 271 | * loop on UltraSPARC II running Solaris. Things might be |
| 272 | * different on Linux... |
| 273 | */ |
| 274 | if ((OPENSSL_sparcv9cap_P[0] & SPARCV9_VIS3) && |
| 275 | sigsetjmp(common_jmp, 1) == 0) { |
| 276 | OPENSSL_sparcv9cap_P[1] = (unsigned int)_sparcv9_rdcfr(); |
| 277 | } |
Andy Polyakov | 4b2603e | 2010-09-05 19:41:41 +0000 | [diff] [blame] | 278 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 279 | sigaction(SIGBUS, &bus_oact, NULL); |
| 280 | sigaction(SIGILL, &ill_oact, NULL); |
Andy Polyakov | 7c5889b | 2010-07-08 07:47:35 +0000 | [diff] [blame] | 281 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 282 | sigprocmask(SIG_SETMASK, &oset, NULL); |
Andy Polyakov | 68c06bf | 2012-11-17 10:34:11 +0000 | [diff] [blame] | 283 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 284 | if (sizeof(size_t) == 8) |
| 285 | OPENSSL_sparcv9cap_P[0] |= SPARCV9_64BIT_STACK; |
| 286 | # ifdef __linux |
| 287 | else { |
| 288 | int ret = syscall(340); |
Andy Polyakov | 68c06bf | 2012-11-17 10:34:11 +0000 | [diff] [blame] | 289 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 290 | if (ret >= 0 && ret & 1) |
| 291 | OPENSSL_sparcv9cap_P[0] |= SPARCV9_64BIT_STACK; |
| 292 | } |
| 293 | # endif |
| 294 | } |