2 # This patch was developed in house. |
2 # This patch was developed in house. |
3 # This is Solaris-specific: not suitable for upstream. |
3 # This is Solaris-specific: not suitable for upstream. |
4 # |
4 # |
5 --- openssl-1.0.1g/crypto/sparcv9cap.c.~1~ Thu May 1 13:07:00 2014 |
5 --- openssl-1.0.1g/crypto/sparcv9cap.c.~1~ Thu May 1 13:07:00 2014 |
6 +++ openssl-1.0.1g/crypto/sparcv9cap.c Thu May 1 13:11:33 2014 |
6 +++ openssl-1.0.1g/crypto/sparcv9cap.c Thu May 1 13:11:33 2014 |
7 @@ -2,9 +2,9 @@ |
7 @@ -2,10 +2,10 @@ |
8 #include <stdlib.h> |
8 #include <stdlib.h> |
9 #include <string.h> |
9 #include <string.h> |
10 #include <setjmp.h> |
10 #include <setjmp.h> |
11 -#include <signal.h> |
11 -#include <signal.h> |
12 #include <sys/time.h> |
12 #include <sys/time.h> |
|
13 #include <unistd.h> |
13 #include <openssl/bn.h> |
14 #include <openssl/bn.h> |
14 +#include <sys/auxv.h> |
15 +#include <sys/auxv.h> |
15 |
16 |
16 #define SPARCV9_TICK_PRIVILEGED (1<<0) |
17 #include "sparc_arch.h" |
17 #define SPARCV9_PREFER_FPU (1<<1) |
18 |
18 @@ -11,6 +11,7 @@ |
19 @@ -69,13 +69,8 @@ |
19 #define SPARCV9_VIS1 (1<<2) |
|
20 #define SPARCV9_VIS2 (1<<3) /* reserved */ |
|
21 #define SPARCV9_FMADD (1<<4) /* reserved for SPARC64 V */ |
|
22 +#define SPARCV9_BLK (1<<5) |
|
23 |
|
24 static int OPENSSL_sparcv9cap_P = SPARCV9_TICK_PRIVILEGED; |
|
25 |
|
26 @@ -31,10 +31,7 @@ |
|
27 } |
20 } |
28 |
21 |
29 unsigned long _sparcv9_rdtick(void); |
22 unsigned long _sparcv9_rdtick(void); |
30 -void _sparcv9_vis1_probe(void); |
23 -void _sparcv9_vis1_probe(void); |
31 unsigned long _sparcv9_vis1_instrument(void); |
24 unsigned long _sparcv9_vis1_instrument(void); |
32 -void _sparcv9_vis2_probe(void); |
25 -void _sparcv9_vis2_probe(void); |
33 -void _sparcv9_fmadd_probe(void); |
26 -void _sparcv9_fmadd_probe(void); |
34 |
27 unsigned long _sparcv9_rdcfr(void); |
35 unsigned long OPENSSL_rdtsc(void) |
28 -void _sparcv9_vis3_probe(void); |
36 { |
29 -unsigned long _sparcv9_random(void); |
37 @@ -170,18 +167,11 @@ |
30 size_t _sparcv9_vis1_instrument_bus(unsigned int *, size_t); |
|
31 size_t _sparcv9_vis1_instrument_bus2(unsigned int *, size_t, size_t); |
|
32 |
|
33 @@ -231,18 +227,11 @@ |
38 |
34 |
39 #else |
35 #else |
40 |
36 |
41 -static sigjmp_buf common_jmp; |
37 -static sigjmp_buf common_jmp; |
42 -static void common_handler(int sig) |
38 -static void common_handler(int sig) |
83 - sigaction(SIGBUS, &common_act, &bus_oact); /* T1 fails 16-bit ldda [on |
79 - sigaction(SIGBUS, &common_act, &bus_oact); /* T1 fails 16-bit ldda [on |
84 - * Linux] */ |
80 - * Linux] */ |
85 - |
81 - |
86 - if (sigsetjmp(common_jmp, 1) == 0) { |
82 - if (sigsetjmp(common_jmp, 1) == 0) { |
87 - _sparcv9_rdtick(); |
83 - _sparcv9_rdtick(); |
88 - OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED; |
84 - OPENSSL_sparcv9cap_P[0] &= ~SPARCV9_TICK_PRIVILEGED; |
89 - } |
85 - } |
90 - |
86 - |
91 - if (sigsetjmp(common_jmp, 1) == 0) { |
87 - if (sigsetjmp(common_jmp, 1) == 0) { |
92 - _sparcv9_vis1_probe(); |
88 - _sparcv9_vis1_probe(); |
93 - OPENSSL_sparcv9cap_P |= SPARCV9_VIS1; |
89 - OPENSSL_sparcv9cap_P[0] |= SPARCV9_VIS1 | SPARCV9_BLK; |
94 - /* detect UltraSPARC-Tx, see sparccpud.S for details... */ |
90 - /* detect UltraSPARC-Tx, see sparccpud.S for details... */ |
95 - if (_sparcv9_vis1_instrument() >= 12) |
91 - if (_sparcv9_vis1_instrument() >= 12) |
96 - OPENSSL_sparcv9cap_P &= ~(SPARCV9_VIS1 | SPARCV9_PREFER_FPU); |
92 - OPENSSL_sparcv9cap_P[0] &= ~(SPARCV9_VIS1 | SPARCV9_PREFER_FPU); |
97 - else { |
93 - else { |
98 - _sparcv9_vis2_probe(); |
94 - _sparcv9_vis2_probe(); |
99 - OPENSSL_sparcv9cap_P |= SPARCV9_VIS2; |
95 - OPENSSL_sparcv9cap_P[0] |= SPARCV9_VIS2; |
100 + if (ui & AV_SPARC_VIS) { |
96 + if (ui & AV_SPARC_VIS) { |
101 + /* detect UltraSPARC-Tx, see sparccpuid.S for details... */ |
97 + /* detect UltraSPARC-Tx, see sparccpuid.S for details... */ |
102 + if (_sparcv9_vis1_instrument() < 7) |
98 + if (_sparcv9_vis1_instrument() < 7) |
103 + OPENSSL_sparcv9cap_P |= SPARCV9_TICK_PRIVILEGED; |
99 + OPENSSL_sparcv9cap_P[0] |= SPARCV9_TICK_PRIVILEGED; |
104 + if (_sparcv9_vis1_instrument() < 12) { |
100 + if (_sparcv9_vis1_instrument() < 12) { |
105 + OPENSSL_sparcv9cap_P |= SPARCV9_VIS1|SPARCV9_PREFER_FPU; |
101 + OPENSSL_sparcv9cap_P[0] |= SPARCV9_VIS1|SPARCV9_PREFER_FPU; |
106 + if (ui & AV_SPARC_VIS2) |
102 + if (ui & AV_SPARC_VIS2) |
107 + OPENSSL_sparcv9cap_P |= SPARCV9_VIS2; |
103 + OPENSSL_sparcv9cap_P[0] |= SPARCV9_VIS2; |
108 } |
104 } |
109 } |
105 } |
110 |
106 |
111 - if (sigsetjmp(common_jmp, 1) == 0) { |
107 - if (sigsetjmp(common_jmp, 1) == 0) { |
112 - _sparcv9_fmadd_probe(); |
108 - _sparcv9_fmadd_probe(); |
113 + if (ui & AV_SPARC_FMAF) |
109 + if (ui & AV_SPARC_FMAF) { |
114 OPENSSL_sparcv9cap_P |= SPARCV9_FMADD; |
110 OPENSSL_sparcv9cap_P[0] |= SPARCV9_FMADD; |
|
111 } |
|
112 |
|
113 @@ -303,36 +279,23 @@ |
|
114 * VIS3 flag is tested independently from VIS1, unlike VIS2 that is, |
|
115 * because VIS3 defines even integer instructions. |
|
116 */ |
|
117 - if (sigsetjmp(common_jmp, 1) == 0) { |
|
118 - _sparcv9_vis3_probe(); |
|
119 - OPENSSL_sparcv9cap_P[0] |= SPARCV9_VIS3; |
|
120 + if (ui & AV_SPARC_VIS3) { |
|
121 + OPENSSL_sparcv9cap_P[0] |= SPARCV9_VIS3; |
|
122 } |
|
123 -# if 0 /* was planned at some point but never |
|
124 - * implemented in hardware */ |
|
125 - if (sigsetjmp(common_jmp, 1) == 0) { |
|
126 - (void)_sparcv9_random(); |
|
127 - OPENSSL_sparcv9cap_P[0] |= SPARCV9_RANDOM; |
115 - } |
128 - } |
116 - |
129 -# endif |
|
130 |
|
131 - /* |
|
132 - * In wait for better solution _sparcv9_rdcfr is masked by |
|
133 - * VIS3 flag, because it goes to uninterruptable endless |
|
134 - * loop on UltraSPARC II running Solaris. Things might be |
|
135 - * different on Linux... |
|
136 - */ |
|
137 - if ((OPENSSL_sparcv9cap_P[0] & SPARCV9_VIS3) && |
|
138 - sigsetjmp(common_jmp, 1) == 0) { |
|
139 +#define AV_T4_MECHS (AV_SPARC_AES | AV_SPARC_DES | AV_SPARC_KASUMI | \ |
|
140 + AV_SPARC_CAMELLIA | AV_SPARC_MD5 | AV_SPARC_SHA1 | \ |
|
141 + AV_SPARC_SHA256 | AV_SPARC_SHA512 | AV_SPARC_MPMUL | \ |
|
142 + AV_SPARC_CRC32C) |
|
143 + |
|
144 + if ((OPENSSL_sparcv9cap_P[0]&SPARCV9_VIS3) && (ui & AV_T4_MECHS)) { |
|
145 OPENSSL_sparcv9cap_P[1] = (unsigned int)_sparcv9_rdcfr(); |
|
146 } |
|
147 |
117 - sigaction(SIGBUS, &bus_oact, NULL); |
148 - sigaction(SIGBUS, &bus_oact, NULL); |
118 - sigaction(SIGILL, &ill_oact, NULL); |
149 - sigaction(SIGILL, &ill_oact, NULL); |
119 - |
150 + if (sizeof(size_t) == 8) { |
|
151 + OPENSSL_sparcv9cap_P[0] |= SPARCV9_64BIT_STACK; |
|
152 + } |
|
153 |
120 - sigprocmask(SIG_SETMASK, &oset, NULL); |
154 - sigprocmask(SIG_SETMASK, &oset, NULL); |
121 } |
155 - |
122 |
156 - if (sizeof(size_t) == 8) |
123 #endif |
157 - OPENSSL_sparcv9cap_P[0] |= SPARCV9_64BIT_STACK; |
|
158 # ifdef __linux |
|
159 else { |
|
160 int ret = syscall(340); |
124 --- openssl-1.0.1g/crypto/sparccpuid.S.~1~ Thu May 1 13:07:00 2014 |
161 --- openssl-1.0.1g/crypto/sparccpuid.S.~1~ Thu May 1 13:07:00 2014 |
125 +++ openssl-1.0.1g/crypto/sparccpuid.S Thu May 1 13:11:33 2014 |
162 +++ openssl-1.0.1g/crypto/sparccpuid.S Thu May 1 13:11:33 2014 |
126 @@ -232,16 +232,6 @@ |
163 @@ -232,16 +232,6 @@ |
127 .type _sparcv9_rdtick,#function |
164 .type _sparcv9_rdtick,#function |
128 .size _sparcv9_rdtick,.-_sparcv9_rdtick |
165 .size _sparcv9_rdtick,.-_sparcv9_rdtick |