Merge branch 'vendor/DIFFUTILS'
[dragonfly.git] / crypto / libressl / crypto / cpuid-elf-x86_64.S
1
2 .hidden OPENSSL_cpuid_setup
3 .section        .init
4         call    OPENSSL_cpuid_setup
5
6 .hidden OPENSSL_ia32cap_P
7 .comm   OPENSSL_ia32cap_P,8,4
8
9 .text   
10
11 .globl  OPENSSL_atomic_add
12 .type   OPENSSL_atomic_add,@function
13 .align  16
14 OPENSSL_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_ia32_cpuid
26 .type   OPENSSL_ia32_cpuid,@function
27 .align  16
28 OPENSSL_ia32_cpuid:
29         movq    %rbx,%r8
30
31         xorl    %eax,%eax
32         cpuid
33         movl    %eax,%r11d
34
35         xorl    %eax,%eax
36         cmpl    $1970169159,%ebx
37         setne   %al
38         movl    %eax,%r9d
39         cmpl    $1231384169,%edx
40         setne   %al
41         orl     %eax,%r9d
42         cmpl    $1818588270,%ecx
43         setne   %al
44         orl     %eax,%r9d
45         jz      .Lintel
46
47         cmpl    $1752462657,%ebx
48         setne   %al
49         movl    %eax,%r10d
50         cmpl    $1769238117,%edx
51         setne   %al
52         orl     %eax,%r10d
53         cmpl    $1145913699,%ecx
54         setne   %al
55         orl     %eax,%r10d
56         jnz     .Lintel
57
58
59         movl    $2147483648,%eax
60         cpuid
61         cmpl    $2147483649,%eax
62         jb      .Lintel
63         movl    %eax,%r10d
64         movl    $2147483649,%eax
65         cpuid
66         orl     %ecx,%r9d
67         andl    $2049,%r9d
68
69         cmpl    $2147483656,%r10d
70         jb      .Lintel
71
72         movl    $2147483656,%eax
73         cpuid
74         movzbq  %cl,%r10
75         incq    %r10
76
77         movl    $1,%eax
78         cpuid
79         btl     $28,%edx
80         jnc     .Lgeneric
81         shrl    $16,%ebx
82         cmpb    %r10b,%bl
83         ja      .Lgeneric
84         andl    $4026531839,%edx
85         jmp     .Lgeneric
86
87 .Lintel:
88         cmpl    $4,%r11d
89         movl    $-1,%r10d
90         jb      .Lnocacheinfo
91
92         movl    $4,%eax
93         movl    $0,%ecx
94         cpuid
95         movl    %eax,%r10d
96         shrl    $14,%r10d
97         andl    $4095,%r10d
98
99 .Lnocacheinfo:
100         movl    $1,%eax
101         cpuid
102         andl    $3220176895,%edx
103         cmpl    $0,%r9d
104         jne     .Lnotintel
105         orl     $1073741824,%edx
106         andb    $15,%ah
107         cmpb    $15,%ah
108         jne     .Lnotintel
109         orl     $1048576,%edx
110 .Lnotintel:
111         btl     $28,%edx
112         jnc     .Lgeneric
113         andl    $4026531839,%edx
114         cmpl    $0,%r10d
115         je      .Lgeneric
116
117         orl     $268435456,%edx
118         shrl    $16,%ebx
119         cmpb    $1,%bl
120         ja      .Lgeneric
121         andl    $4026531839,%edx
122 .Lgeneric:
123         andl    $2048,%r9d
124         andl    $4294965247,%ecx
125         orl     %ecx,%r9d
126
127         movl    %edx,%r10d
128         btl     $27,%r9d
129         jnc     .Lclear_avx
130         xorl    %ecx,%ecx
131 .byte   0x0f,0x01,0xd0          
132         andl    $6,%eax
133         cmpl    $6,%eax
134         je      .Ldone
135 .Lclear_avx:
136         movl    $4026525695,%eax
137         andl    %eax,%r9d
138 .Ldone:
139         shlq    $32,%r9
140         movl    %r10d,%eax
141         movq    %r8,%rbx
142         orq     %r9,%rax
143         .byte   0xf3,0xc3
144 .size   OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid
145 .globl  OPENSSL_wipe_cpu
146 .type   OPENSSL_wipe_cpu,@function
147 .align  16
148 OPENSSL_wipe_cpu:
149         pxor    %xmm0,%xmm0
150         pxor    %xmm1,%xmm1
151         pxor    %xmm2,%xmm2
152         pxor    %xmm3,%xmm3
153         pxor    %xmm4,%xmm4
154         pxor    %xmm5,%xmm5
155         pxor    %xmm6,%xmm6
156         pxor    %xmm7,%xmm7
157         pxor    %xmm8,%xmm8
158         pxor    %xmm9,%xmm9
159         pxor    %xmm10,%xmm10
160         pxor    %xmm11,%xmm11
161         pxor    %xmm12,%xmm12
162         pxor    %xmm13,%xmm13
163         pxor    %xmm14,%xmm14
164         pxor    %xmm15,%xmm15
165         xorq    %rcx,%rcx
166         xorq    %rdx,%rdx
167         xorq    %rsi,%rsi
168         xorq    %rdi,%rdi
169         xorq    %r8,%r8
170         xorq    %r9,%r9
171         xorq    %r10,%r10
172         xorq    %r11,%r11
173         leaq    8(%rsp),%rax
174         .byte   0xf3,0xc3
175 .size   OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
176 #if defined(HAVE_GNU_STACK)
177 .section .note.GNU-stack,"",%progbits
178 #endif