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