76 Index: crypto/sparcv9cap.c |
76 Index: crypto/sparcv9cap.c |
77 =================================================================== |
77 =================================================================== |
78 diff -ru openssl-1.0.1e/crypto/sparcv9cap.c openssl-1.0.1e/crypto/sparcv9cap.c |
78 diff -ru openssl-1.0.1e/crypto/sparcv9cap.c openssl-1.0.1e/crypto/sparcv9cap.c |
79 --- openssl-1.0.1e/crypto/sparcv9cap.c 2011-05-24 17:02:24.000000000 -0700 |
79 --- openssl-1.0.1e/crypto/sparcv9cap.c 2011-05-24 17:02:24.000000000 -0700 |
80 +++ openssl-1.0.1e/crypto/sparcv9cap.c 2011-07-27 10:48:17.817470000 -0700 |
80 +++ openssl-1.0.1e/crypto/sparcv9cap.c 2011-07-27 10:48:17.817470000 -0700 |
81 @@ -6,17 +6,12 @@ |
81 @@ -6,16 +6,15 @@ |
82 #include <sys/time.h> |
82 #include <sys/time.h> |
83 #include <openssl/bn.h> |
83 #include <openssl/bn.h> |
84 |
84 |
85 -#define SPARCV9_TICK_PRIVILEGED (1<<0) |
85 -#define SPARCV9_TICK_PRIVILEGED (1<<0) |
86 -#define SPARCV9_PREFER_FPU (1<<1) |
86 -#define SPARCV9_PREFER_FPU (1<<1) |
87 -#define SPARCV9_VIS1 (1<<2) |
87 -#define SPARCV9_VIS1 (1<<2) |
88 -#define SPARCV9_VIS2 (1<<3) /* reserved */ |
88 -#define SPARCV9_VIS2 (1<<3) /* reserved */ |
89 -#define SPARCV9_FMADD (1<<4) /* reserved for SPARC64 V */ |
89 -#define SPARCV9_FMADD (1<<4) /* reserved for SPARC64 V */ |
90 +#include "sparc_arch.h" |
90 +#include "sparc_arch.h" |
91 |
91 |
92 -#ifndef _BOOT |
|
93 -static int OPENSSL_sparcv9cap_P=SPARCV9_TICK_PRIVILEGED; |
|
94 -#else |
|
95 -static int OPENSSL_sparcv9cap_P = SPARCV9_VIS1; |
|
96 +#if defined(__GNUC__) && defined(__linux) |
92 +#if defined(__GNUC__) && defined(__linux) |
97 +__attribute__((visibility("hidden"))) |
93 +__attribute__((visibility("hidden"))) |
|
94 +#endif |
|
95 #ifndef _BOOT |
|
96 -static int OPENSSL_sparcv9cap_P=SPARCV9_TICK_PRIVILEGED; |
|
97 +unsigned int OPENSSL_sparcv9cap_P[2]={SPARCV9_TICK_PRIVILEGED,0}; |
|
98 #else |
|
99 -static int OPENSSL_sparcv9cap_P = SPARCV9_VIS1; |
|
100 +unsigned int OPENSSL_sparcv9cap_P[2]={SPARCV9_VIS1,0}; |
98 #endif |
101 #endif |
99 +unsigned int OPENSSL_sparcv9cap_P[2]={SPARCV9_TICK_PRIVILEGED,0}; |
|
100 |
102 |
101 int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num) |
103 int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num) |
102 { |
104 @@ -24,7 +23,7 @@ |
103 @@ -24,7 +19,7 @@ |
|
104 int bn_mul_mont_int(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num); |
105 int bn_mul_mont_int(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num); |
105 |
106 |
106 if (num>=8 && !(num&1) && |
107 if (num>=8 && !(num&1) && |
107 - (OPENSSL_sparcv9cap_P&(SPARCV9_PREFER_FPU|SPARCV9_VIS1)) == |
108 - (OPENSSL_sparcv9cap_P&(SPARCV9_PREFER_FPU|SPARCV9_VIS1)) == |
108 + (OPENSSL_sparcv9cap_P[0]&(SPARCV9_PREFER_FPU|SPARCV9_VIS1)) == |
109 + (OPENSSL_sparcv9cap_P[0]&(SPARCV9_PREFER_FPU|SPARCV9_VIS1)) == |
109 (SPARCV9_PREFER_FPU|SPARCV9_VIS1)) |
110 (SPARCV9_PREFER_FPU|SPARCV9_VIS1)) |
110 return bn_mul_mont_fpu(rp,ap,bp,np,n0,num); |
111 return bn_mul_mont_fpu(rp,ap,bp,np,n0,num); |
111 else |
112 else |
112 @@ -36,11 +31,15 @@ |
113 @@ -36,11 +35,16 @@ |
113 unsigned long _sparcv9_vis1_instrument(void); |
114 unsigned long _sparcv9_vis1_instrument(void); |
114 void _sparcv9_vis2_probe(void); |
115 void _sparcv9_vis2_probe(void); |
115 void _sparcv9_fmadd_probe(void); |
116 void _sparcv9_fmadd_probe(void); |
116 +unsigned long _sparcv9_rdcfr(void); |
117 +unsigned long _sparcv9_rdcfr(void); |
117 +void _sparcv9_vis3_probe(void); |
118 +void _sparcv9_vis3_probe(void); |
118 +unsigned long _sparcv9_random(void); |
119 +unsigned long _sparcv9_random(void); |
119 +size_t _sparcv9_vis1_instrument_bus(unsigned int *,size_t); |
120 +size_t _sparcv9_vis1_instrument_bus(unsigned int *,size_t); |
120 +size_t _sparcv8_vis1_instrument_bus2(unsigned int *,size_t,size_t); |
121 +size_t _sparcv9_vis1_instrument_bus2(unsigned int *,size_t,size_t); |
121 |
122 |
122 -#ifndef _BOOT |
123 #ifndef _BOOT |
123 unsigned long OPENSSL_rdtsc(void) |
124 unsigned long OPENSSL_rdtsc(void) |
124 { |
125 { |
125 - if (OPENSSL_sparcv9cap_P&SPARCV9_TICK_PRIVILEGED) |
126 - if (OPENSSL_sparcv9cap_P&SPARCV9_TICK_PRIVILEGED) |
126 + if (OPENSSL_sparcv9cap_P[0]&SPARCV9_TICK_PRIVILEGED) |
127 + if (OPENSSL_sparcv9cap_P[0]&SPARCV9_TICK_PRIVILEGED) |
127 #if defined(__sun) && defined(__SVR4) |
128 #if defined(__sun) && defined(__SVR4) |
128 return gethrtime(); |
129 return gethrtime(); |
129 #else |
130 #else |
130 @@ -49,19 +48,26 @@ |
131 @@ -51,6 +55,25 @@ |
131 else |
|
132 return _sparcv9_rdtick(); |
|
133 } |
132 } |
134 -#endif |
133 #endif |
135 |
134 |
136 -#if defined(_BOOT) |
|
137 -/* |
|
138 - * Hardcoding sparc capabilities for wanboot. |
|
139 - * Older CPUs are EOLed anyway. |
|
140 - */ |
|
141 -void OPENSSL_cpuid_setup(void) |
|
142 +size_t OPENSSL_instrument_bus(unsigned int *out,size_t cnt) |
135 +size_t OPENSSL_instrument_bus(unsigned int *out,size_t cnt) |
143 { |
136 + { |
144 - OPENSSL_sparcv9cap_P = SPARCV9_VIS1; |
|
145 + if (OPENSSL_sparcv9cap_P[0]&(SPARCV9_TICK_PRIVILEGED|SPARCV9_BLK) == |
137 + if (OPENSSL_sparcv9cap_P[0]&(SPARCV9_TICK_PRIVILEGED|SPARCV9_BLK) == |
146 + SPARCV9_BLK) |
138 + SPARCV9_BLK) |
147 + return _sparcv9_vis1_instrument_bus(out,cnt); |
139 + return _sparcv9_vis1_instrument_bus(out,cnt); |
148 + else |
140 + else |
149 + return 0; |
141 + return 0; |
150 } |
142 + } |
151 |
143 + |
152 -#elif 0 && defined(__sun) && defined(__SVR4) |
|
153 +size_t OPENSSL_instrument_bus2(unsigned int *out,size_t cnt,size_t max) |
144 +size_t OPENSSL_instrument_bus2(unsigned int *out,size_t cnt,size_t max) |
154 + { |
145 + { |
155 + if (OPENSSL_sparcv9cap_P[0]&(SPARCV9_TICK_PRIVILEGED|SPARCV9_BLK) == |
146 + if (OPENSSL_sparcv9cap_P[0]&(SPARCV9_TICK_PRIVILEGED|SPARCV9_BLK) == |
156 + SPARCV9_BLK) |
147 + SPARCV9_BLK) |
157 + return _sparcv9_vis1_instrument_bus2(out,cnt,max); |
148 + return _sparcv9_vis1_instrument_bus2(out,cnt,max); |
158 + else |
149 + else |
159 + return 0; |
150 + return 0; |
160 + } |
151 + } |
161 + |
152 + |
162 +#if 0 && defined(__sun) && defined(__SVR4) |
153 + |
163 /* This code path is disabled, because of incompatibility of |
154 #if defined(_BOOT) |
164 * libdevinfo.so.1 and libmalloc.so.1 (see below for details) |
155 /* |
|
156 * Hardcoding sparc capabilities for wanboot. |
|
157 @@ -58,7 +81,7 @@ |
165 */ |
158 */ |
166 @@ -85,11 +91,11 @@ |
159 void OPENSSL_cpuid_setup(void) |
|
160 { |
|
161 - OPENSSL_sparcv9cap_P = SPARCV9_VIS1; |
|
162 + OPENSSL_sparcv9cap_P[0] = SPARCV9_VIS1; |
|
163 } |
|
164 |
|
165 #elif 0 && defined(__sun) && defined(__SVR4) |
|
166 @@ -85,11 +108,11 @@ |
167 if (!strcmp (name,"SUNW,UltraSPARC") || |
167 if (!strcmp (name,"SUNW,UltraSPARC") || |
168 !strncmp(name,"SUNW,UltraSPARC-I",17)) /* covers II,III,IV */ |
168 !strncmp(name,"SUNW,UltraSPARC-I",17)) /* covers II,III,IV */ |
169 { |
169 { |
170 - OPENSSL_sparcv9cap_P |= SPARCV9_PREFER_FPU|SPARCV9_VIS1; |
170 - OPENSSL_sparcv9cap_P |= SPARCV9_PREFER_FPU|SPARCV9_VIS1; |
171 + OPENSSL_sparcv9cap_P[0] |= SPARCV9_PREFER_FPU|SPARCV9_VIS1; |
171 + OPENSSL_sparcv9cap_P[0] |= SPARCV9_PREFER_FPU|SPARCV9_VIS1; |
175 - OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED; |
175 - OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED; |
176 + OPENSSL_sparcv9cap_P[0] &= ~SPARCV9_TICK_PRIVILEGED; |
176 + OPENSSL_sparcv9cap_P[0] &= ~SPARCV9_TICK_PRIVILEGED; |
177 |
177 |
178 return DI_WALK_TERMINATE; |
178 return DI_WALK_TERMINATE; |
179 } |
179 } |
180 @@ -96,7 +102,7 @@ |
180 @@ -96,7 +119,7 @@ |
181 /* This is expected to catch remaining UltraSPARCs, such as T1 */ |
181 /* This is expected to catch remaining UltraSPARCs, such as T1 */ |
182 else if (!strncmp(name,"SUNW,UltraSPARC",15)) |
182 else if (!strncmp(name,"SUNW,UltraSPARC",15)) |
183 { |
183 { |
184 - OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED; |
184 - OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED; |
185 + OPENSSL_sparcv9cap_P[0] &= ~SPARCV9_TICK_PRIVILEGED; |
185 + OPENSSL_sparcv9cap_P[0] &= ~SPARCV9_TICK_PRIVILEGED; |
186 |
186 |
187 return DI_WALK_TERMINATE; |
187 return DI_WALK_TERMINATE; |
188 } |
188 } |
189 @@ -115,7 +121,7 @@ |
189 @@ -115,7 +138,7 @@ |
190 |
190 |
191 if ((e=getenv("OPENSSL_sparcv9cap"))) |
191 if ((e=getenv("OPENSSL_sparcv9cap"))) |
192 { |
192 { |
193 - OPENSSL_sparcv9cap_P=strtoul(e,NULL,0); |
193 - OPENSSL_sparcv9cap_P=strtoul(e,NULL,0); |
194 + OPENSSL_sparcv9cap_P[0]=strtoul(e,NULL,0); |
194 + OPENSSL_sparcv9cap_P[0]=strtoul(e,NULL,0); |
195 return; |
195 return; |
196 } |
196 } |
197 |
197 |
198 @@ -123,17 +129,17 @@ |
198 @@ -123,17 +146,17 @@ |
199 { |
199 { |
200 if (strcmp(si,"sun4v")) |
200 if (strcmp(si,"sun4v")) |
201 /* FPU is preferred for all CPUs, but US-T1/2 */ |
201 /* FPU is preferred for all CPUs, but US-T1/2 */ |
202 - OPENSSL_sparcv9cap_P |= SPARCV9_PREFER_FPU; |
202 - OPENSSL_sparcv9cap_P |= SPARCV9_PREFER_FPU; |
203 + OPENSSL_sparcv9cap_P[0] |= SPARCV9_PREFER_FPU; |
203 + OPENSSL_sparcv9cap_P[0] |= SPARCV9_PREFER_FPU; |