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