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