Update files for OpenSSL-1.0.1 update.
[dragonfly.git] / secure / lib / libcrypto / asm / x86_64cpuid.s
CommitLineData
aa1f3630 1
ca7b1aff 2.hidden OPENSSL_cpuid_setup
aa1f3630
PA
3.section .init
4 call OPENSSL_cpuid_setup
5
ca7b1aff
PA
6.hidden OPENSSL_ia32cap_P
7.comm OPENSSL_ia32cap_P,8,4
8
aa1f3630
PA
9.text
10
11.globl OPENSSL_atomic_add
12.type OPENSSL_atomic_add,@function
13.align 16
14OPENSSL_atomic_add:
15 movl (%rdi),%eax
16.Lspin: leaq (%rsi,%rax,1),%r8
17.byte 0xf0
18 cmpxchgl %r8d,(%rdi)
19 jne .Lspin
20 movl %r8d,%eax
21.byte 0x48,0x98
22 .byte 0xf3,0xc3
23.size OPENSSL_atomic_add,.-OPENSSL_atomic_add
24
25.globl OPENSSL_rdtsc
26.type OPENSSL_rdtsc,@function
27.align 16
28OPENSSL_rdtsc:
29 rdtsc
30 shlq $32,%rdx
31 orq %rdx,%rax
32 .byte 0xf3,0xc3
33.size OPENSSL_rdtsc,.-OPENSSL_rdtsc
34
35.globl OPENSSL_ia32_cpuid
36.type OPENSSL_ia32_cpuid,@function
37.align 16
38OPENSSL_ia32_cpuid:
39 movq %rbx,%r8
40
41 xorl %eax,%eax
42 cpuid
43 movl %eax,%r11d
44
45 xorl %eax,%eax
46 cmpl $1970169159,%ebx
47 setne %al
48 movl %eax,%r9d
49 cmpl $1231384169,%edx
50 setne %al
51 orl %eax,%r9d
52 cmpl $1818588270,%ecx
53 setne %al
54 orl %eax,%r9d
55 jz .Lintel
56
57 cmpl $1752462657,%ebx
58 setne %al
59 movl %eax,%r10d
60 cmpl $1769238117,%edx
61 setne %al
62 orl %eax,%r10d
63 cmpl $1145913699,%ecx
64 setne %al
65 orl %eax,%r10d
66 jnz .Lintel
67
68
69 movl $2147483648,%eax
70 cpuid
ca7b1aff
PA
71 cmpl $2147483649,%eax
72 jb .Lintel
73 movl %eax,%r10d
74 movl $2147483649,%eax
75 cpuid
76 orl %ecx,%r9d
77 andl $2049,%r9d
78
79 cmpl $2147483656,%r10d
aa1f3630
PA
80 jb .Lintel
81
82 movl $2147483656,%eax
83 cpuid
84 movzbq %cl,%r10
85 incq %r10
86
87 movl $1,%eax
88 cpuid
89 btl $28,%edx
ca7b1aff 90 jnc .Lgeneric
aa1f3630
PA
91 shrl $16,%ebx
92 cmpb %r10b,%bl
ca7b1aff 93 ja .Lgeneric
aa1f3630 94 andl $4026531839,%edx
ca7b1aff 95 jmp .Lgeneric
aa1f3630
PA
96
97.Lintel:
98 cmpl $4,%r11d
99 movl $-1,%r10d
100 jb .Lnocacheinfo
101
102 movl $4,%eax
103 movl $0,%ecx
104 cpuid
105 movl %eax,%r10d
106 shrl $14,%r10d
107 andl $4095,%r10d
108
109.Lnocacheinfo:
110 movl $1,%eax
111 cpuid
ca7b1aff 112 andl $3220176895,%edx
aa1f3630
PA
113 cmpl $0,%r9d
114 jne .Lnotintel
ca7b1aff 115 orl $1073741824,%edx
aa1f3630
PA
116 andb $15,%ah
117 cmpb $15,%ah
ca7b1aff
PA
118 jne .Lnotintel
119 orl $1048576,%edx
aa1f3630
PA
120.Lnotintel:
121 btl $28,%edx
ca7b1aff 122 jnc .Lgeneric
aa1f3630
PA
123 andl $4026531839,%edx
124 cmpl $0,%r10d
ca7b1aff 125 je .Lgeneric
aa1f3630
PA
126
127 orl $268435456,%edx
128 shrl $16,%ebx
129 cmpb $1,%bl
ca7b1aff 130 ja .Lgeneric
aa1f3630 131 andl $4026531839,%edx
ca7b1aff
PA
132.Lgeneric:
133 andl $2048,%r9d
134 andl $4294965247,%ecx
135 orl %ecx,%r9d
136
137 movl %edx,%r10d
138 btl $27,%r9d
139 jnc .Lclear_avx
140 xorl %ecx,%ecx
141.byte 0x0f,0x01,0xd0
142 andl $6,%eax
143 cmpl $6,%eax
144 je .Ldone
145.Lclear_avx:
146 movl $4026525695,%eax
147 andl %eax,%r9d
aa1f3630 148.Ldone:
ca7b1aff
PA
149 shlq $32,%r9
150 movl %r10d,%eax
aa1f3630 151 movq %r8,%rbx
ca7b1aff 152 orq %r9,%rax
aa1f3630
PA
153 .byte 0xf3,0xc3
154.size OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid
155
156.globl OPENSSL_cleanse
157.type OPENSSL_cleanse,@function
158.align 16
159OPENSSL_cleanse:
160 xorq %rax,%rax
161 cmpq $15,%rsi
162 jae .Lot
163 cmpq $0,%rsi
164 je .Lret
165.Little:
166 movb %al,(%rdi)
167 subq $1,%rsi
168 leaq 1(%rdi),%rdi
169 jnz .Little
170.Lret:
171 .byte 0xf3,0xc3
172.align 16
173.Lot:
174 testq $7,%rdi
175 jz .Laligned
176 movb %al,(%rdi)
177 leaq -1(%rsi),%rsi
178 leaq 1(%rdi),%rdi
179 jmp .Lot
180.Laligned:
181 movq %rax,(%rdi)
182 leaq -8(%rsi),%rsi
183 testq $-8,%rsi
184 leaq 8(%rdi),%rdi
185 jnz .Laligned
186 cmpq $0,%rsi
187 jne .Little
188 .byte 0xf3,0xc3
189.size OPENSSL_cleanse,.-OPENSSL_cleanse
190.globl OPENSSL_wipe_cpu
191.type OPENSSL_wipe_cpu,@function
192.align 16
193OPENSSL_wipe_cpu:
194 pxor %xmm0,%xmm0
195 pxor %xmm1,%xmm1
196 pxor %xmm2,%xmm2
197 pxor %xmm3,%xmm3
198 pxor %xmm4,%xmm4
199 pxor %xmm5,%xmm5
200 pxor %xmm6,%xmm6
201 pxor %xmm7,%xmm7
202 pxor %xmm8,%xmm8
203 pxor %xmm9,%xmm9
204 pxor %xmm10,%xmm10
205 pxor %xmm11,%xmm11
206 pxor %xmm12,%xmm12
207 pxor %xmm13,%xmm13
208 pxor %xmm14,%xmm14
209 pxor %xmm15,%xmm15
210 xorq %rcx,%rcx
211 xorq %rdx,%rdx
212 xorq %rsi,%rsi
213 xorq %rdi,%rdi
214 xorq %r8,%r8
215 xorq %r9,%r9
216 xorq %r10,%r10
217 xorq %r11,%r11
218 leaq 8(%rsp),%rax
219 .byte 0xf3,0xc3
220.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
ca7b1aff
PA
221.globl OPENSSL_ia32_rdrand
222.type OPENSSL_ia32_rdrand,@function
223.align 16
224OPENSSL_ia32_rdrand:
225 movl $8,%ecx
226.Loop_rdrand:
227.byte 72,15,199,240
228 jc .Lbreak_rdrand
229 loop .Loop_rdrand
230.Lbreak_rdrand:
231 cmpq $0,%rax
232 cmoveq %rcx,%rax
233 .byte 0xf3,0xc3
234.size OPENSSL_ia32_rdrand,.-OPENSSL_ia32_rdrand