1#include <machine/asm.h> 2.text 3.globl OPENSSL_ia32_cpuid 4.type OPENSSL_ia32_cpuid,@function 5.align 16 6OPENSSL_ia32_cpuid: 7.L_OPENSSL_ia32_cpuid_begin: 8 #ifdef __CET__ 9 10.byte 243,15,30,251 11 #endif 12 13 pushl %ebp 14 pushl %ebx 15 pushl %esi 16 pushl %edi 17 xorl %edx,%edx 18 pushfl 19 popl %eax 20 movl %eax,%ecx 21 xorl $2097152,%eax 22 pushl %eax 23 popfl 24 pushfl 25 popl %eax 26 xorl %eax,%ecx 27 xorl %eax,%eax 28 movl 20(%esp),%esi 29 movl %eax,8(%esi) 30 btl $21,%ecx 31 jnc .L000nocpuid 32 .byte 0x0f,0xa2 33 movl %eax,%edi 34 xorl %eax,%eax 35 cmpl $1970169159,%ebx 36 setne %al 37 movl %eax,%ebp 38 cmpl $1231384169,%edx 39 setne %al 40 orl %eax,%ebp 41 cmpl $1818588270,%ecx 42 setne %al 43 orl %eax,%ebp 44 jz .L001intel 45 cmpl $1752462657,%ebx 46 setne %al 47 movl %eax,%esi 48 cmpl $1769238117,%edx 49 setne %al 50 orl %eax,%esi 51 cmpl $1145913699,%ecx 52 setne %al 53 orl %eax,%esi 54 jnz .L001intel 55 movl $2147483648,%eax 56 .byte 0x0f,0xa2 57 cmpl $2147483649,%eax 58 jb .L001intel 59 movl %eax,%esi 60 movl $2147483649,%eax 61 .byte 0x0f,0xa2 62 orl %ecx,%ebp 63 andl $2049,%ebp 64 cmpl $2147483656,%esi 65 jb .L001intel 66 movl $2147483656,%eax 67 .byte 0x0f,0xa2 68 movzbl %cl,%esi 69 incl %esi 70 movl $1,%eax 71 xorl %ecx,%ecx 72 .byte 0x0f,0xa2 73 btl $28,%edx 74 jnc .L002generic 75 shrl $16,%ebx 76 andl $255,%ebx 77 cmpl %esi,%ebx 78 ja .L002generic 79 andl $4026531839,%edx 80 jmp .L002generic 81.L001intel: 82 cmpl $4,%edi 83 movl $-1,%esi 84 jb .L003nocacheinfo 85 movl $4,%eax 86 movl $0,%ecx 87 .byte 0x0f,0xa2 88 movl %eax,%esi 89 shrl $14,%esi 90 andl $4095,%esi 91.L003nocacheinfo: 92 movl $1,%eax 93 xorl %ecx,%ecx 94 .byte 0x0f,0xa2 95 andl $3220176895,%edx 96 cmpl $0,%ebp 97 jne .L004notintel 98 orl $1073741824,%edx 99 andb $15,%ah 100 cmpb $15,%ah 101 jne .L004notintel 102 orl $1048576,%edx 103.L004notintel: 104 btl $28,%edx 105 jnc .L002generic 106 andl $4026531839,%edx 107 cmpl $0,%esi 108 je .L002generic 109 orl $268435456,%edx 110 shrl $16,%ebx 111 cmpb $1,%bl 112 ja .L002generic 113 andl $4026531839,%edx 114.L002generic: 115 andl $2048,%ebp 116 andl $4294965247,%ecx 117 movl %edx,%esi 118 orl %ecx,%ebp 119 cmpl $7,%edi 120 movl 20(%esp),%edi 121 jb .L005no_extended_info 122 movl $7,%eax 123 xorl %ecx,%ecx 124 .byte 0x0f,0xa2 125 movl %ebx,8(%edi) 126.L005no_extended_info: 127 btl $27,%ebp 128 jnc .L006clear_avx 129 xorl %ecx,%ecx 130.byte 15,1,208 131 andl $6,%eax 132 cmpl $6,%eax 133 je .L007done 134 cmpl $2,%eax 135 je .L006clear_avx 136.L008clear_xmm: 137 andl $4261412861,%ebp 138 andl $4278190079,%esi 139.L006clear_avx: 140 andl $4026525695,%ebp 141 andl $4294967263,8(%edi) 142.L007done: 143 movl %esi,%eax 144 movl %ebp,%edx 145.L000nocpuid: 146 popl %edi 147 popl %esi 148 popl %ebx 149 popl %ebp 150 ret 151.size OPENSSL_ia32_cpuid,.-.L_OPENSSL_ia32_cpuid_begin 152.globl OPENSSL_rdtsc 153.type OPENSSL_rdtsc,@function 154.align 16 155OPENSSL_rdtsc: 156.L_OPENSSL_rdtsc_begin: 157 #ifdef __CET__ 158 159.byte 243,15,30,251 160 #endif 161 162 xorl %eax,%eax 163 xorl %edx,%edx 164 call .L009PIC_me_up 165.L009PIC_me_up: 166 popl %ecx 167 leal OPENSSL_ia32cap_P-.L009PIC_me_up(%ecx),%ecx 168 btl $4,(%ecx) 169 jnc .L010notsc 170 .byte 0x0f,0x31 171.L010notsc: 172 ret 173.size OPENSSL_rdtsc,.-.L_OPENSSL_rdtsc_begin 174.globl OPENSSL_instrument_halt 175.type OPENSSL_instrument_halt,@function 176.align 16 177OPENSSL_instrument_halt: 178.L_OPENSSL_instrument_halt_begin: 179 #ifdef __CET__ 180 181.byte 243,15,30,251 182 #endif 183 184 call .L011PIC_me_up 185.L011PIC_me_up: 186 popl %ecx 187 leal OPENSSL_ia32cap_P-.L011PIC_me_up(%ecx),%ecx 188 btl $4,(%ecx) 189 jnc .L012nohalt 190.long 2421723150 191 andl $3,%eax 192 jnz .L012nohalt 193 pushfl 194 popl %eax 195 btl $9,%eax 196 jnc .L012nohalt 197 .byte 0x0f,0x31 198 pushl %edx 199 pushl %eax 200 hlt 201 .byte 0x0f,0x31 202 subl (%esp),%eax 203 sbbl 4(%esp),%edx 204 addl $8,%esp 205 ret 206.L012nohalt: 207 xorl %eax,%eax 208 xorl %edx,%edx 209 ret 210.size OPENSSL_instrument_halt,.-.L_OPENSSL_instrument_halt_begin 211.globl OPENSSL_far_spin 212.type OPENSSL_far_spin,@function 213.align 16 214OPENSSL_far_spin: 215.L_OPENSSL_far_spin_begin: 216 #ifdef __CET__ 217 218.byte 243,15,30,251 219 #endif 220 221 pushfl 222 popl %eax 223 btl $9,%eax 224 jnc .L013nospin 225 movl 4(%esp),%eax 226 movl 8(%esp),%ecx 227.long 2430111262 228 xorl %eax,%eax 229 movl (%ecx),%edx 230 jmp .L014spin 231.align 16 232.L014spin: 233 incl %eax 234 cmpl (%ecx),%edx 235 je .L014spin 236.long 529567888 237 ret 238.L013nospin: 239 xorl %eax,%eax 240 xorl %edx,%edx 241 ret 242.size OPENSSL_far_spin,.-.L_OPENSSL_far_spin_begin 243.globl OPENSSL_wipe_cpu 244.type OPENSSL_wipe_cpu,@function 245.align 16 246OPENSSL_wipe_cpu: 247.L_OPENSSL_wipe_cpu_begin: 248 #ifdef __CET__ 249 250.byte 243,15,30,251 251 #endif 252 253 xorl %eax,%eax 254 xorl %edx,%edx 255 call .L015PIC_me_up 256.L015PIC_me_up: 257 popl %ecx 258 leal OPENSSL_ia32cap_P-.L015PIC_me_up(%ecx),%ecx 259 movl (%ecx),%ecx 260 btl $1,(%ecx) 261 jnc .L016no_x87 262 andl $83886080,%ecx 263 cmpl $83886080,%ecx 264 jne .L017no_sse2 265 pxor %xmm0,%xmm0 266 pxor %xmm1,%xmm1 267 pxor %xmm2,%xmm2 268 pxor %xmm3,%xmm3 269 pxor %xmm4,%xmm4 270 pxor %xmm5,%xmm5 271 pxor %xmm6,%xmm6 272 pxor %xmm7,%xmm7 273.L017no_sse2: 274.long 4007259865,4007259865,4007259865,4007259865,2430851995 275.L016no_x87: 276 leal 4(%esp),%eax 277 ret 278.size OPENSSL_wipe_cpu,.-.L_OPENSSL_wipe_cpu_begin 279.globl OPENSSL_atomic_add 280.type OPENSSL_atomic_add,@function 281.align 16 282OPENSSL_atomic_add: 283.L_OPENSSL_atomic_add_begin: 284 #ifdef __CET__ 285 286.byte 243,15,30,251 287 #endif 288 289 movl 4(%esp),%edx 290 movl 8(%esp),%ecx 291 pushl %ebx 292 nop 293 movl (%edx),%eax 294.L018spin: 295 leal (%eax,%ecx,1),%ebx 296 nop 297.long 447811568 298 jne .L018spin 299 movl %ebx,%eax 300 popl %ebx 301 ret 302.size OPENSSL_atomic_add,.-.L_OPENSSL_atomic_add_begin 303.globl OPENSSL_cleanse 304.type OPENSSL_cleanse,@function 305.align 16 306OPENSSL_cleanse: 307.L_OPENSSL_cleanse_begin: 308 #ifdef __CET__ 309 310.byte 243,15,30,251 311 #endif 312 313 movl 4(%esp),%edx 314 movl 8(%esp),%ecx 315 xorl %eax,%eax 316 cmpl $7,%ecx 317 jae .L019lot 318 cmpl $0,%ecx 319 je .L020ret 320.L021little: 321 movb %al,(%edx) 322 subl $1,%ecx 323 leal 1(%edx),%edx 324 jnz .L021little 325.L020ret: 326 ret 327.align 16 328.L019lot: 329 testl $3,%edx 330 jz .L022aligned 331 movb %al,(%edx) 332 leal -1(%ecx),%ecx 333 leal 1(%edx),%edx 334 jmp .L019lot 335.L022aligned: 336 movl %eax,(%edx) 337 leal -4(%ecx),%ecx 338 testl $-4,%ecx 339 leal 4(%edx),%edx 340 jnz .L022aligned 341 cmpl $0,%ecx 342 jne .L021little 343 ret 344.size OPENSSL_cleanse,.-.L_OPENSSL_cleanse_begin 345.globl CRYPTO_memcmp 346.type CRYPTO_memcmp,@function 347.align 16 348CRYPTO_memcmp: 349.L_CRYPTO_memcmp_begin: 350 #ifdef __CET__ 351 352.byte 243,15,30,251 353 #endif 354 355 pushl %esi 356 pushl %edi 357 movl 12(%esp),%esi 358 movl 16(%esp),%edi 359 movl 20(%esp),%ecx 360 xorl %eax,%eax 361 xorl %edx,%edx 362 cmpl $0,%ecx 363 je .L023no_data 364.L024loop: 365 movb (%esi),%dl 366 leal 1(%esi),%esi 367 xorb (%edi),%dl 368 leal 1(%edi),%edi 369 orb %dl,%al 370 decl %ecx 371 jnz .L024loop 372 negl %eax 373 shrl $31,%eax 374.L023no_data: 375 popl %edi 376 popl %esi 377 ret 378.size CRYPTO_memcmp,.-.L_CRYPTO_memcmp_begin 379.globl OPENSSL_instrument_bus 380.type OPENSSL_instrument_bus,@function 381.align 16 382OPENSSL_instrument_bus: 383.L_OPENSSL_instrument_bus_begin: 384 #ifdef __CET__ 385 386.byte 243,15,30,251 387 #endif 388 389 pushl %ebp 390 pushl %ebx 391 pushl %esi 392 pushl %edi 393 movl $0,%eax 394 call .L025PIC_me_up 395.L025PIC_me_up: 396 popl %edx 397 leal OPENSSL_ia32cap_P-.L025PIC_me_up(%edx),%edx 398 btl $4,(%edx) 399 jnc .L026nogo 400 btl $19,(%edx) 401 jnc .L026nogo 402 movl 20(%esp),%edi 403 movl 24(%esp),%ecx 404 .byte 0x0f,0x31 405 movl %eax,%esi 406 movl $0,%ebx 407 clflush (%edi) 408.byte 240 409 addl %ebx,(%edi) 410 jmp .L027loop 411.align 16 412.L027loop: 413 .byte 0x0f,0x31 414 movl %eax,%edx 415 subl %esi,%eax 416 movl %edx,%esi 417 movl %eax,%ebx 418 clflush (%edi) 419.byte 240 420 addl %eax,(%edi) 421 leal 4(%edi),%edi 422 subl $1,%ecx 423 jnz .L027loop 424 movl 24(%esp),%eax 425.L026nogo: 426 popl %edi 427 popl %esi 428 popl %ebx 429 popl %ebp 430 ret 431.size OPENSSL_instrument_bus,.-.L_OPENSSL_instrument_bus_begin 432.globl OPENSSL_instrument_bus2 433.type OPENSSL_instrument_bus2,@function 434.align 16 435OPENSSL_instrument_bus2: 436.L_OPENSSL_instrument_bus2_begin: 437 #ifdef __CET__ 438 439.byte 243,15,30,251 440 #endif 441 442 pushl %ebp 443 pushl %ebx 444 pushl %esi 445 pushl %edi 446 movl $0,%eax 447 call .L028PIC_me_up 448.L028PIC_me_up: 449 popl %edx 450 leal OPENSSL_ia32cap_P-.L028PIC_me_up(%edx),%edx 451 btl $4,(%edx) 452 jnc .L029nogo 453 btl $19,(%edx) 454 jnc .L029nogo 455 movl 20(%esp),%edi 456 movl 24(%esp),%ecx 457 movl 28(%esp),%ebp 458 .byte 0x0f,0x31 459 movl %eax,%esi 460 movl $0,%ebx 461 clflush (%edi) 462.byte 240 463 addl %ebx,(%edi) 464 .byte 0x0f,0x31 465 movl %eax,%edx 466 subl %esi,%eax 467 movl %edx,%esi 468 movl %eax,%ebx 469 jmp .L030loop2 470.align 16 471.L030loop2: 472 clflush (%edi) 473.byte 240 474 addl %eax,(%edi) 475 subl $1,%ebp 476 jz .L031done2 477 .byte 0x0f,0x31 478 movl %eax,%edx 479 subl %esi,%eax 480 movl %edx,%esi 481 cmpl %ebx,%eax 482 movl %eax,%ebx 483 movl $0,%edx 484 setne %dl 485 subl %edx,%ecx 486 leal (%edi,%edx,4),%edi 487 jnz .L030loop2 488.L031done2: 489 movl 24(%esp),%eax 490 subl %ecx,%eax 491.L029nogo: 492 popl %edi 493 popl %esi 494 popl %ebx 495 popl %ebp 496 ret 497.size OPENSSL_instrument_bus2,.-.L_OPENSSL_instrument_bus2_begin 498.globl OPENSSL_ia32_rdrand_bytes 499.type OPENSSL_ia32_rdrand_bytes,@function 500.align 16 501OPENSSL_ia32_rdrand_bytes: 502.L_OPENSSL_ia32_rdrand_bytes_begin: 503 #ifdef __CET__ 504 505.byte 243,15,30,251 506 #endif 507 508 pushl %edi 509 pushl %ebx 510 xorl %eax,%eax 511 movl 12(%esp),%edi 512 movl 16(%esp),%ebx 513 cmpl $0,%ebx 514 je .L032done 515 movl $8,%ecx 516.L033loop: 517.byte 15,199,242 518 jc .L034break 519 loop .L033loop 520 jmp .L032done 521.align 16 522.L034break: 523 cmpl $4,%ebx 524 jb .L035tail 525 movl %edx,(%edi) 526 leal 4(%edi),%edi 527 addl $4,%eax 528 subl $4,%ebx 529 jz .L032done 530 movl $8,%ecx 531 jmp .L033loop 532.align 16 533.L035tail: 534 movb %dl,(%edi) 535 leal 1(%edi),%edi 536 incl %eax 537 shrl $8,%edx 538 decl %ebx 539 jnz .L035tail 540.L032done: 541 xorl %edx,%edx 542 popl %ebx 543 popl %edi 544 ret 545.size OPENSSL_ia32_rdrand_bytes,.-.L_OPENSSL_ia32_rdrand_bytes_begin 546.globl OPENSSL_ia32_rdseed_bytes 547.type OPENSSL_ia32_rdseed_bytes,@function 548.align 16 549OPENSSL_ia32_rdseed_bytes: 550.L_OPENSSL_ia32_rdseed_bytes_begin: 551 #ifdef __CET__ 552 553.byte 243,15,30,251 554 #endif 555 556 pushl %edi 557 pushl %ebx 558 xorl %eax,%eax 559 movl 12(%esp),%edi 560 movl 16(%esp),%ebx 561 cmpl $0,%ebx 562 je .L036done 563 movl $8,%ecx 564.L037loop: 565.byte 15,199,250 566 jc .L038break 567 loop .L037loop 568 jmp .L036done 569.align 16 570.L038break: 571 cmpl $4,%ebx 572 jb .L039tail 573 movl %edx,(%edi) 574 leal 4(%edi),%edi 575 addl $4,%eax 576 subl $4,%ebx 577 jz .L036done 578 movl $8,%ecx 579 jmp .L037loop 580.align 16 581.L039tail: 582 movb %dl,(%edi) 583 leal 1(%edi),%edi 584 incl %eax 585 shrl $8,%edx 586 decl %ebx 587 jnz .L039tail 588.L036done: 589 xorl %edx,%edx 590 popl %ebx 591 popl %edi 592 ret 593.size OPENSSL_ia32_rdseed_bytes,.-.L_OPENSSL_ia32_rdseed_bytes_begin 594.hidden OPENSSL_cpuid_setup 595.hidden OPENSSL_ia32cap_P 596.comm OPENSSL_ia32cap_P,16,4 597.section .init 598 PIC_PROLOGUE 599 call PIC_PLT(OPENSSL_cpuid_setup) 600 PIC_EPILOGUE 601 602 .section ".note.gnu.property", "a" 603 .p2align 2 604 .long 1f - 0f 605 .long 4f - 1f 606 .long 5 6070: 608 .asciz "GNU" 6091: 610 .p2align 2 611 .long 0xc0000002 612 .long 3f - 2f 6132: 614 .long 3 6153: 616 .p2align 2 6174: 618