]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - secure/lib/libcrypto/i386/x86cpuid.s
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / secure / lib / libcrypto / i386 / x86cpuid.s
1         # $FreeBSD$
2 .file   "x86cpuid.s"
3 .text
4 .globl  OPENSSL_ia32_cpuid
5 .type   OPENSSL_ia32_cpuid,@function
6 .align  16
7 OPENSSL_ia32_cpuid:
8 .L_OPENSSL_ia32_cpuid_begin:
9         pushl   %ebp
10         pushl   %ebx
11         pushl   %esi
12         pushl   %edi
13         xorl    %edx,%edx
14         pushfl
15         popl    %eax
16         movl    %eax,%ecx
17         xorl    $2097152,%eax
18         pushl   %eax
19         popfl
20         pushfl
21         popl    %eax
22         xorl    %eax,%ecx
23         xorl    %eax,%eax
24         btl     $21,%ecx
25         jnc     .L000nocpuid
26         .byte   0x0f,0xa2
27         movl    %eax,%edi
28         xorl    %eax,%eax
29         cmpl    $1970169159,%ebx
30         setne   %al
31         movl    %eax,%ebp
32         cmpl    $1231384169,%edx
33         setne   %al
34         orl     %eax,%ebp
35         cmpl    $1818588270,%ecx
36         setne   %al
37         orl     %eax,%ebp
38         jz      .L001intel
39         cmpl    $1752462657,%ebx
40         setne   %al
41         movl    %eax,%esi
42         cmpl    $1769238117,%edx
43         setne   %al
44         orl     %eax,%esi
45         cmpl    $1145913699,%ecx
46         setne   %al
47         orl     %eax,%esi
48         jnz     .L001intel
49         movl    $2147483648,%eax
50         .byte   0x0f,0xa2
51         cmpl    $2147483649,%eax
52         jb      .L001intel
53         movl    %eax,%esi
54         movl    $2147483649,%eax
55         .byte   0x0f,0xa2
56         orl     %ecx,%ebp
57         andl    $2049,%ebp
58         cmpl    $2147483656,%esi
59         jb      .L001intel
60         movl    $2147483656,%eax
61         .byte   0x0f,0xa2
62         movzbl  %cl,%esi
63         incl    %esi
64         movl    $1,%eax
65         .byte   0x0f,0xa2
66         btl     $28,%edx
67         jnc     .L002generic
68         shrl    $16,%ebx
69         andl    $255,%ebx
70         cmpl    %esi,%ebx
71         ja      .L002generic
72         andl    $4026531839,%edx
73         jmp     .L002generic
74 .L001intel:
75         cmpl    $4,%edi
76         movl    $-1,%edi
77         jb      .L003nocacheinfo
78         movl    $4,%eax
79         movl    $0,%ecx
80         .byte   0x0f,0xa2
81         movl    %eax,%edi
82         shrl    $14,%edi
83         andl    $4095,%edi
84 .L003nocacheinfo:
85         movl    $1,%eax
86         .byte   0x0f,0xa2
87         andl    $3220176895,%edx
88         cmpl    $0,%ebp
89         jne     .L004notintel
90         orl     $1073741824,%edx
91         andb    $15,%ah
92         cmpb    $15,%ah
93         jne     .L004notintel
94         orl     $1048576,%edx
95 .L004notintel:
96         btl     $28,%edx
97         jnc     .L002generic
98         andl    $4026531839,%edx
99         cmpl    $0,%edi
100         je      .L002generic
101         orl     $268435456,%edx
102         shrl    $16,%ebx
103         cmpb    $1,%bl
104         ja      .L002generic
105         andl    $4026531839,%edx
106 .L002generic:
107         andl    $2048,%ebp
108         andl    $4294965247,%ecx
109         movl    %edx,%esi
110         orl     %ecx,%ebp
111         btl     $27,%ecx
112         jnc     .L005clear_avx
113         xorl    %ecx,%ecx
114 .byte   15,1,208
115         andl    $6,%eax
116         cmpl    $6,%eax
117         je      .L006done
118         cmpl    $2,%eax
119         je      .L005clear_avx
120 .L007clear_xmm:
121         andl    $4261412861,%ebp
122         andl    $4278190079,%esi
123 .L005clear_avx:
124         andl    $4026525695,%ebp
125 .L006done:
126         movl    %esi,%eax
127         movl    %ebp,%edx
128 .L000nocpuid:
129         popl    %edi
130         popl    %esi
131         popl    %ebx
132         popl    %ebp
133         ret
134 .size   OPENSSL_ia32_cpuid,.-.L_OPENSSL_ia32_cpuid_begin
135 .globl  OPENSSL_rdtsc
136 .type   OPENSSL_rdtsc,@function
137 .align  16
138 OPENSSL_rdtsc:
139 .L_OPENSSL_rdtsc_begin:
140         xorl    %eax,%eax
141         xorl    %edx,%edx
142         leal    OPENSSL_ia32cap_P,%ecx
143         btl     $4,(%ecx)
144         jnc     .L008notsc
145         .byte   0x0f,0x31
146 .L008notsc:
147         ret
148 .size   OPENSSL_rdtsc,.-.L_OPENSSL_rdtsc_begin
149 .globl  OPENSSL_instrument_halt
150 .type   OPENSSL_instrument_halt,@function
151 .align  16
152 OPENSSL_instrument_halt:
153 .L_OPENSSL_instrument_halt_begin:
154         leal    OPENSSL_ia32cap_P,%ecx
155         btl     $4,(%ecx)
156         jnc     .L009nohalt
157 .long   2421723150
158         andl    $3,%eax
159         jnz     .L009nohalt
160         pushfl
161         popl    %eax
162         btl     $9,%eax
163         jnc     .L009nohalt
164         .byte   0x0f,0x31
165         pushl   %edx
166         pushl   %eax
167         hlt
168         .byte   0x0f,0x31
169         subl    (%esp),%eax
170         sbbl    4(%esp),%edx
171         addl    $8,%esp
172         ret
173 .L009nohalt:
174         xorl    %eax,%eax
175         xorl    %edx,%edx
176         ret
177 .size   OPENSSL_instrument_halt,.-.L_OPENSSL_instrument_halt_begin
178 .globl  OPENSSL_far_spin
179 .type   OPENSSL_far_spin,@function
180 .align  16
181 OPENSSL_far_spin:
182 .L_OPENSSL_far_spin_begin:
183         pushfl
184         popl    %eax
185         btl     $9,%eax
186         jnc     .L010nospin
187         movl    4(%esp),%eax
188         movl    8(%esp),%ecx
189 .long   2430111262
190         xorl    %eax,%eax
191         movl    (%ecx),%edx
192         jmp     .L011spin
193 .align  16
194 .L011spin:
195         incl    %eax
196         cmpl    (%ecx),%edx
197         je      .L011spin
198 .long   529567888
199         ret
200 .L010nospin:
201         xorl    %eax,%eax
202         xorl    %edx,%edx
203         ret
204 .size   OPENSSL_far_spin,.-.L_OPENSSL_far_spin_begin
205 .globl  OPENSSL_wipe_cpu
206 .type   OPENSSL_wipe_cpu,@function
207 .align  16
208 OPENSSL_wipe_cpu:
209 .L_OPENSSL_wipe_cpu_begin:
210         xorl    %eax,%eax
211         xorl    %edx,%edx
212         leal    OPENSSL_ia32cap_P,%ecx
213         movl    (%ecx),%ecx
214         btl     $1,(%ecx)
215         jnc     .L012no_x87
216         andl    $83886080,%ecx
217         cmpl    $83886080,%ecx
218         jne     .L013no_sse2
219         pxor    %xmm0,%xmm0
220         pxor    %xmm1,%xmm1
221         pxor    %xmm2,%xmm2
222         pxor    %xmm3,%xmm3
223         pxor    %xmm4,%xmm4
224         pxor    %xmm5,%xmm5
225         pxor    %xmm6,%xmm6
226         pxor    %xmm7,%xmm7
227 .L013no_sse2:
228 .long   4007259865,4007259865,4007259865,4007259865,2430851995
229 .L012no_x87:
230         leal    4(%esp),%eax
231         ret
232 .size   OPENSSL_wipe_cpu,.-.L_OPENSSL_wipe_cpu_begin
233 .globl  OPENSSL_atomic_add
234 .type   OPENSSL_atomic_add,@function
235 .align  16
236 OPENSSL_atomic_add:
237 .L_OPENSSL_atomic_add_begin:
238         movl    4(%esp),%edx
239         movl    8(%esp),%ecx
240         pushl   %ebx
241         nop
242         movl    (%edx),%eax
243 .L014spin:
244         leal    (%eax,%ecx,1),%ebx
245         nop
246 .long   447811568
247         jne     .L014spin
248         movl    %ebx,%eax
249         popl    %ebx
250         ret
251 .size   OPENSSL_atomic_add,.-.L_OPENSSL_atomic_add_begin
252 .globl  OPENSSL_indirect_call
253 .type   OPENSSL_indirect_call,@function
254 .align  16
255 OPENSSL_indirect_call:
256 .L_OPENSSL_indirect_call_begin:
257         pushl   %ebp
258         movl    %esp,%ebp
259         subl    $28,%esp
260         movl    12(%ebp),%ecx
261         movl    %ecx,(%esp)
262         movl    16(%ebp),%edx
263         movl    %edx,4(%esp)
264         movl    20(%ebp),%eax
265         movl    %eax,8(%esp)
266         movl    24(%ebp),%eax
267         movl    %eax,12(%esp)
268         movl    28(%ebp),%eax
269         movl    %eax,16(%esp)
270         movl    32(%ebp),%eax
271         movl    %eax,20(%esp)
272         movl    36(%ebp),%eax
273         movl    %eax,24(%esp)
274         call    *8(%ebp)
275         movl    %ebp,%esp
276         popl    %ebp
277         ret
278 .size   OPENSSL_indirect_call,.-.L_OPENSSL_indirect_call_begin
279 .globl  OPENSSL_cleanse
280 .type   OPENSSL_cleanse,@function
281 .align  16
282 OPENSSL_cleanse:
283 .L_OPENSSL_cleanse_begin:
284         movl    4(%esp),%edx
285         movl    8(%esp),%ecx
286         xorl    %eax,%eax
287         cmpl    $7,%ecx
288         jae     .L015lot
289         cmpl    $0,%ecx
290         je      .L016ret
291 .L017little:
292         movb    %al,(%edx)
293         subl    $1,%ecx
294         leal    1(%edx),%edx
295         jnz     .L017little
296 .L016ret:
297         ret
298 .align  16
299 .L015lot:
300         testl   $3,%edx
301         jz      .L018aligned
302         movb    %al,(%edx)
303         leal    -1(%ecx),%ecx
304         leal    1(%edx),%edx
305         jmp     .L015lot
306 .L018aligned:
307         movl    %eax,(%edx)
308         leal    -4(%ecx),%ecx
309         testl   $-4,%ecx
310         leal    4(%edx),%edx
311         jnz     .L018aligned
312         cmpl    $0,%ecx
313         jne     .L017little
314         ret
315 .size   OPENSSL_cleanse,.-.L_OPENSSL_cleanse_begin
316 .globl  OPENSSL_ia32_rdrand
317 .type   OPENSSL_ia32_rdrand,@function
318 .align  16
319 OPENSSL_ia32_rdrand:
320 .L_OPENSSL_ia32_rdrand_begin:
321         movl    $8,%ecx
322 .L019loop:
323 .byte   15,199,240
324         jc      .L020break
325         loop    .L019loop
326 .L020break:
327         cmpl    $0,%eax
328         cmovel  %ecx,%eax
329         ret
330 .size   OPENSSL_ia32_rdrand,.-.L_OPENSSL_ia32_rdrand_begin
331 .comm   OPENSSL_ia32cap_P,8,4
332 .section        .init
333         call    OPENSSL_cpuid_setup