|
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~ Fri May 2 15:08:47 2014 |
|
6 +++ openssl-1.0.1g/crypto/sparcv9cap.c Fri May 2 15:08:32 2014 |
|
7 @@ -2,9 +2,9 @@ |
|
8 #include <stdlib.h> |
|
9 #include <string.h> |
|
10 #include <setjmp.h> |
|
11 -#include <signal.h> |
|
12 #include <sys/time.h> |
|
13 #include <openssl/bn.h> |
|
14 +#include <sys/auxv.h> |
|
15 |
|
16 #define SPARCV9_TICK_PRIVILEGED (1<<0) |
|
17 #define SPARCV9_PREFER_FPU (1<<1) |
|
18 @@ -11,6 +11,7 @@ |
|
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 @@ -28,10 +29,7 @@ |
|
27 } |
|
28 |
|
29 unsigned long _sparcv9_rdtick(void); |
|
30 -void _sparcv9_vis1_probe(void); |
|
31 unsigned long _sparcv9_vis1_instrument(void); |
|
32 -void _sparcv9_vis2_probe(void); |
|
33 -void _sparcv9_fmadd_probe(void); |
|
34 |
|
35 unsigned long OPENSSL_rdtsc(void) |
|
36 { |
|
37 @@ -162,15 +160,11 @@ |
|
38 |
|
39 #else |
|
40 |
|
41 -static sigjmp_buf common_jmp; |
|
42 -static void common_handler(int sig) { siglongjmp(common_jmp,sig); } |
|
43 - |
|
44 void OPENSSL_cpuid_setup(void) |
|
45 { |
|
46 char *e; |
|
47 - struct sigaction common_act,ill_oact,bus_oact; |
|
48 - sigset_t all_masked,oset; |
|
49 static int trigger=0; |
|
50 + uint_t ui = 0; |
|
51 |
|
52 if (trigger) return; |
|
53 trigger=1; |
|
54 @@ -181,57 +175,27 @@ |
|
55 return; |
|
56 } |
|
57 |
|
58 + (void) getisax(&ui, 1); |
|
59 + |
|
60 /* Initial value, fits UltraSPARC-I&II... */ |
|
61 - OPENSSL_sparcv9cap_P = SPARCV9_PREFER_FPU|SPARCV9_TICK_PRIVILEGED; |
|
62 + OPENSSL_sparcv9cap_P = SPARCV9_BLK; |
|
63 |
|
64 - sigfillset(&all_masked); |
|
65 - sigdelset(&all_masked,SIGILL); |
|
66 - sigdelset(&all_masked,SIGTRAP); |
|
67 -#ifdef SIGEMT |
|
68 - sigdelset(&all_masked,SIGEMT); |
|
69 -#endif |
|
70 - sigdelset(&all_masked,SIGFPE); |
|
71 - sigdelset(&all_masked,SIGBUS); |
|
72 - sigdelset(&all_masked,SIGSEGV); |
|
73 - sigprocmask(SIG_SETMASK,&all_masked,&oset); |
|
74 - |
|
75 - memset(&common_act,0,sizeof(common_act)); |
|
76 - common_act.sa_handler = common_handler; |
|
77 - common_act.sa_mask = all_masked; |
|
78 - |
|
79 - sigaction(SIGILL,&common_act,&ill_oact); |
|
80 - sigaction(SIGBUS,&common_act,&bus_oact);/* T1 fails 16-bit ldda [on Linux] */ |
|
81 - |
|
82 - if (sigsetjmp(common_jmp,1) == 0) |
|
83 + if (ui & AV_SPARC_VIS) |
|
84 { |
|
85 - _sparcv9_rdtick(); |
|
86 - OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED; |
|
87 - } |
|
88 - |
|
89 - if (sigsetjmp(common_jmp,1) == 0) |
|
90 - { |
|
91 - _sparcv9_vis1_probe(); |
|
92 - OPENSSL_sparcv9cap_P |= SPARCV9_VIS1; |
|
93 - /* detect UltraSPARC-Tx, see sparccpud.S for details... */ |
|
94 - if (_sparcv9_vis1_instrument() >= 12) |
|
95 - OPENSSL_sparcv9cap_P &= ~(SPARCV9_VIS1|SPARCV9_PREFER_FPU); |
|
96 - else |
|
97 + /* detect UltraSPARC-Tx, see sparccpuid.S for details... */ |
|
98 + if (_sparcv9_vis1_instrument() < 7) |
|
99 + OPENSSL_sparcv9cap_P |= SPARCV9_TICK_PRIVILEGED; |
|
100 + if (_sparcv9_vis1_instrument() < 12) |
|
101 { |
|
102 - _sparcv9_vis2_probe(); |
|
103 - OPENSSL_sparcv9cap_P |= SPARCV9_VIS2; |
|
104 + OPENSSL_sparcv9cap_P |= SPARCV9_VIS1|SPARCV9_PREFER_FPU; |
|
105 + if (ui & AV_SPARC_VIS2) |
|
106 + OPENSSL_sparcv9cap_P |= SPARCV9_VIS2; |
|
107 } |
|
108 } |
|
109 |
|
110 - if (sigsetjmp(common_jmp,1) == 0) |
|
111 - { |
|
112 - _sparcv9_fmadd_probe(); |
|
113 + if (ui & AV_SPARC_FMAF) |
|
114 OPENSSL_sparcv9cap_P |= SPARCV9_FMADD; |
|
115 - } |
|
116 |
|
117 - sigaction(SIGBUS,&bus_oact,NULL); |
|
118 - sigaction(SIGILL,&ill_oact,NULL); |
|
119 - |
|
120 - sigprocmask(SIG_SETMASK,&oset,NULL); |
|
121 } |
|
122 |
|
123 #endif |
|
124 --- openssl-1.0.1g/crypto/sparccpuid.S.~1~ Fri May 2 11:23:54 2014 |
|
125 +++ openssl-1.0.1g/crypto/sparccpuid.S Fri May 2 11:24:23 2014 |
|
126 @@ -232,16 +232,6 @@ |
|
127 .type _sparcv9_rdtick,#function |
|
128 .size _sparcv9_rdtick,.-_sparcv9_rdtick |
|
129 |
|
130 -.global _sparcv9_vis1_probe |
|
131 -.align 8 |
|
132 -_sparcv9_vis1_probe: |
|
133 - add %sp,BIAS+2,%o1 |
|
134 - .word 0xc19a5a40 !ldda [%o1]ASI_FP16_P,%f0 |
|
135 - retl |
|
136 - .word 0x81b00d80 !fxor %f0,%f0,%f0 |
|
137 -.type _sparcv9_vis1_probe,#function |
|
138 -.size _sparcv9_vis1_probe,.-_sparcv9_vis1_probe |
|
139 - |
|
140 ! Probe and instrument VIS1 instruction. Output is number of cycles it |
|
141 ! takes to execute rdtick and pair of VIS1 instructions. US-Tx VIS unit |
|
142 ! is slow (documented to be 6 cycles on T2) and the core is in-order |
|
143 @@ -296,24 +286,6 @@ |
|
144 .type _sparcv9_vis1_instrument,#function |
|
145 .size _sparcv9_vis1_instrument,.-_sparcv9_vis1_instrument |
|
146 |
|
147 -.global _sparcv9_vis2_probe |
|
148 -.align 8 |
|
149 -_sparcv9_vis2_probe: |
|
150 - retl |
|
151 - .word 0x81b00980 !bshuffle %f0,%f0,%f0 |
|
152 -.type _sparcv9_vis2_probe,#function |
|
153 -.size _sparcv9_vis2_probe,.-_sparcv9_vis2_probe |
|
154 - |
|
155 -.global _sparcv9_fmadd_probe |
|
156 -.align 8 |
|
157 -_sparcv9_fmadd_probe: |
|
158 - .word 0x81b00d80 !fxor %f0,%f0,%f0 |
|
159 - .word 0x85b08d82 !fxor %f2,%f2,%f2 |
|
160 - retl |
|
161 - .word 0x81b80440 !fmaddd %f0,%f0,%f2,%f0 |
|
162 -.type _sparcv9_fmadd_probe,#function |
|
163 -.size _sparcv9_fmadd_probe,.-_sparcv9_fmadd_probe |
|
164 - |
|
165 .global OPENSSL_cleanse |
|
166 .align 32 |
|
167 OPENSSL_cleanse: |