1 # |
|
2 # This patch was developed in house. |
|
3 # This is Solaris-specific: not suitable for upstream. |
|
4 # |
|
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 |
|
7 @@ -2,10 +2,10 @@ |
|
8 #include <stdlib.h> |
|
9 #include <string.h> |
|
10 #include <setjmp.h> |
|
11 -#include <signal.h> |
|
12 #include <sys/time.h> |
|
13 #include <unistd.h> |
|
14 #include <openssl/bn.h> |
|
15 +#include <sys/auxv.h> |
|
16 |
|
17 #include "sparc_arch.h" |
|
18 |
|
19 @@ -59,13 +59,8 @@ |
|
20 } |
|
21 |
|
22 unsigned long _sparcv9_rdtick(void); |
|
23 -void _sparcv9_vis1_probe(void); |
|
24 unsigned long _sparcv9_vis1_instrument(void); |
|
25 -void _sparcv9_vis2_probe(void); |
|
26 -void _sparcv9_fmadd_probe(void); |
|
27 unsigned long _sparcv9_rdcfr(void); |
|
28 -void _sparcv9_vis3_probe(void); |
|
29 -unsigned long _sparcv9_random(void); |
|
30 #ifndef _BOOT |
|
31 size_t _sparcv9_vis1_instrument_bus(unsigned int *,size_t); |
|
32 size_t _sparcv9_vis1_instrument_bus2(unsigned int *,size_t,size_t); |
|
33 @@ -235,18 +235,11 @@ |
|
34 |
|
35 #else |
|
36 |
|
37 -static sigjmp_buf common_jmp; |
|
38 -static void common_handler(int sig) |
|
39 -{ |
|
40 - siglongjmp(common_jmp, sig); |
|
41 -} |
|
42 - |
|
43 void OPENSSL_cpuid_setup(void) |
|
44 { |
|
45 char *e; |
|
46 - struct sigaction common_act, ill_oact, bus_oact; |
|
47 - sigset_t all_masked, oset; |
|
48 static int trigger = 0; |
|
49 + uint_t ui = 0; |
|
50 |
|
51 if (trigger) |
|
52 return; |
|
53 @@ -259,80 +247,40 @@ |
|
54 return; |
|
55 } |
|
56 |
|
57 + (void) getisax(&ui, 1); |
|
58 + |
|
59 /* Initial value, fits UltraSPARC-I&II... */ |
|
60 - OPENSSL_sparcv9cap_P[0] = SPARCV9_PREFER_FPU | SPARCV9_TICK_PRIVILEGED; |
|
61 + OPENSSL_sparcv9cap_P[0] = SPARCV9_BLK; |
|
62 |
|
63 - sigfillset(&all_masked); |
|
64 - sigdelset(&all_masked, SIGILL); |
|
65 - sigdelset(&all_masked, SIGTRAP); |
|
66 -# ifdef SIGEMT |
|
67 - sigdelset(&all_masked, SIGEMT); |
|
68 -# endif |
|
69 - sigdelset(&all_masked, SIGFPE); |
|
70 - sigdelset(&all_masked, SIGBUS); |
|
71 - sigdelset(&all_masked, SIGSEGV); |
|
72 - sigprocmask(SIG_SETMASK, &all_masked, &oset); |
|
73 - |
|
74 - memset(&common_act, 0, sizeof(common_act)); |
|
75 - common_act.sa_handler = common_handler; |
|
76 - common_act.sa_mask = all_masked; |
|
77 - |
|
78 - sigaction(SIGILL, &common_act, &ill_oact); |
|
79 - sigaction(SIGBUS, &common_act, &bus_oact); /* T1 fails 16-bit ldda [on |
|
80 - * Linux] */ |
|
81 - |
|
82 - if (sigsetjmp(common_jmp, 1) == 0) { |
|
83 - _sparcv9_rdtick(); |
|
84 - OPENSSL_sparcv9cap_P[0] &= ~SPARCV9_TICK_PRIVILEGED; |
|
85 - } |
|
86 - |
|
87 - if (sigsetjmp(common_jmp, 1) == 0) { |
|
88 - _sparcv9_vis1_probe(); |
|
89 - OPENSSL_sparcv9cap_P[0] |= SPARCV9_VIS1 | SPARCV9_BLK; |
|
90 + if (ui & AV_SPARC_VIS) { |
|
91 /* detect UltraSPARC-Tx, see sparccpud.S for details... */ |
|
92 - if (_sparcv9_vis1_instrument() >= 12) |
|
93 - OPENSSL_sparcv9cap_P[0] &= ~(SPARCV9_VIS1 | SPARCV9_PREFER_FPU); |
|
94 - else { |
|
95 - _sparcv9_vis2_probe(); |
|
96 - OPENSSL_sparcv9cap_P[0] |= SPARCV9_VIS2; |
|
97 - } |
|
98 + if (_sparcv9_vis1_instrument() < 7) |
|
99 + OPENSSL_sparcv9cap_P[0] |= SPARCV9_TICK_PRIVILEGED; |
|
100 + if (_sparcv9_vis1_instrument() < 12) { |
|
101 + OPENSSL_sparcv9cap_P[0] |= (SPARCV9_VIS1 | SPARCV9_PREFER_FPU); |
|
102 + if (ui & AV_SPARC_VIS2) |
|
103 + OPENSSL_sparcv9cap_P[0] |= SPARCV9_VIS2; |
|
104 + } |
|
105 } |
|
106 |
|
107 - if (sigsetjmp(common_jmp, 1) == 0) { |
|
108 - _sparcv9_fmadd_probe(); |
|
109 + if (ui & AV_SPARC_FMAF) |
|
110 OPENSSL_sparcv9cap_P[0] |= SPARCV9_FMADD; |
|
111 - } |
|
112 |
|
113 /* |
|
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 - } |
|
121 + if (ui & AV_SPARC_VIS3) |
|
122 + OPENSSL_sparcv9cap_P[0] |= SPARCV9_VIS3; |
|
123 |
|
124 - if (sigsetjmp(common_jmp,1) == 0) { |
|
125 - (void)_sparcv9_random(); |
|
126 - OPENSSL_sparcv9cap_P[0] |= SPARCV9_RANDOM; |
|
127 - } |
|
128 +#define AV_T4_MECHS (AV_SPARC_AES | AV_SPARC_DES | AV_SPARC_KASUMI | \ |
|
129 + AV_SPARC_CAMELLIA | AV_SPARC_MD5 | AV_SPARC_SHA1 | \ |
|
130 + AV_SPARC_SHA256 | AV_SPARC_SHA512 | AV_SPARC_MPMUL | \ |
|
131 + AV_SPARC_CRC32C) |
|
132 |
|
133 - /* |
|
134 - * In wait for better solution _sparcv9_rdcfr is masked by |
|
135 - * VIS3 flag, because it goes to uninterruptable endless |
|
136 - * loop on UltraSPARC II running Solaris. Things might be |
|
137 - * different on Linux... |
|
138 - */ |
|
139 - if ((OPENSSL_sparcv9cap_P[0]&SPARCV9_VIS3) && |
|
140 - sigsetjmp(common_jmp, 1) == 0) { |
|
141 + if ((OPENSSL_sparcv9cap_P[0]&SPARCV9_VIS3) && (ui & AV_T4_MECHS)) |
|
142 OPENSSL_sparcv9cap_P[1] = (unsigned int)_sparcv9_rdcfr(); |
|
143 - } |
|
144 |
|
145 - sigaction(SIGBUS, &bus_oact, NULL); |
|
146 - sigaction(SIGILL, &ill_oact, NULL); |
|
147 - |
|
148 - sigprocmask(SIG_SETMASK, &oset, NULL); |
|
149 - |
|
150 if (sizeof(size_t) == 8) |
|
151 OPENSSL_sparcv9cap_P[0] |= SPARCV9_64BIT_STACK; |
|
152 #ifdef __linux |
|
153 --- openssl-1.0.1g/crypto/sparccpuid.S.~1~ Thu May 1 13:07:00 2014 |
|
154 +++ openssl-1.0.1g/crypto/sparccpuid.S Thu May 1 13:11:33 2014 |
|
155 @@ -236,16 +236,6 @@ |
|
156 .type _sparcv9_rdtick,#function |
|
157 .size _sparcv9_rdtick,.-_sparcv9_rdtick |
|
158 |
|
159 -.global _sparcv9_vis1_probe |
|
160 -.align 8 |
|
161 -_sparcv9_vis1_probe: |
|
162 - .word 0x81b00d80 !fxor %f0,%f0,%f0 |
|
163 - add %sp,BIAS+2,%o1 |
|
164 - retl |
|
165 - .word 0xc19a5a40 !ldda [%o1]ASI_FP16_P,%f0 |
|
166 -.type _sparcv9_vis1_probe,#function |
|
167 -.size _sparcv9_vis1_probe,.-_sparcv9_vis1_probe |
|
168 - |
|
169 ! Probe and instrument VIS1 instruction. Output is number of cycles it |
|
170 ! takes to execute rdtick and pair of VIS1 instructions. US-Tx VIS unit |
|
171 ! is slow (documented to be 6 cycles on T2) and the core is in-order |
|
172 @@ -307,24 +297,6 @@ |
|
173 .type _sparcv9_vis1_instrument,#function |
|
174 .size _sparcv9_vis1_instrument,.-_sparcv9_vis1_instrument |
|
175 |
|
176 -.global _sparcv9_vis2_probe |
|
177 -.align 8 |
|
178 -_sparcv9_vis2_probe: |
|
179 - retl |
|
180 - .word 0x81b00980 !bshuffle %f0,%f0,%f0 |
|
181 -.type _sparcv9_vis2_probe,#function |
|
182 -.size _sparcv9_vis2_probe,.-_sparcv9_vis2_probe |
|
183 - |
|
184 -.global _sparcv9_fmadd_probe |
|
185 -.align 8 |
|
186 -_sparcv9_fmadd_probe: |
|
187 - .word 0x81b00d80 !fxor %f0,%f0,%f0 |
|
188 - .word 0x85b08d82 !fxor %f2,%f2,%f2 |
|
189 - retl |
|
190 - .word 0x81b80440 !fmaddd %f0,%f0,%f2,%f0 |
|
191 -.type _sparcv9_fmadd_probe,#function |
|
192 -.size _sparcv9_fmadd_probe,.-_sparcv9_fmadd_probe |
|
193 - |
|
194 .global _sparcv9_rdcfr |
|
195 .align 8 |
|
196 _sparcv9_rdcfr: |
|
197 @@ -333,22 +305,6 @@ |
|
198 .type _sparcv9_rdcfr,#function |
|
199 .size _sparcv9_rdcfr,.-_sparcv9_rdcfr |
|
200 |
|
201 -.global _sparcv9_vis3_probe |
|
202 -.align 8 |
|
203 -_sparcv9_vis3_probe: |
|
204 - retl |
|
205 - .word 0x81b022a0 !xmulx %g0,%g0,%g0 |
|
206 -.type _sparcv9_vis3_probe,#function |
|
207 -.size _sparcv9_vis3_probe,.-_sparcv9_vis3_probe |
|
208 - |
|
209 -.global _sparcv9_random |
|
210 -.align 8 |
|
211 -_sparcv9_random: |
|
212 - retl |
|
213 - .word 0x91b002a0 !random %o0 |
|
214 -.type _sparcv9_random,#function |
|
215 -.size _sparcv9_random,.-_sparcv9_vis3_probe |
|
216 - |
|
217 .global OPENSSL_cleanse |
|
218 .align 32 |
|
219 OPENSSL_cleanse: |
|