1%ifidn __OUTPUT_FORMAT__,obj 2section code use32 class=code align=64 3%elifidn __OUTPUT_FORMAT__,win32 4$@feat.00 equ 1 5section .text code align=64 6%else 7section .text code 8%endif 9global _OPENSSL_ia32_cpuid 10align 16 11_OPENSSL_ia32_cpuid: 12L$_OPENSSL_ia32_cpuid_begin: 13 push ebp 14 push ebx 15 push esi 16 push edi 17 xor edx,edx 18 pushfd 19 pop eax 20 mov ecx,eax 21 xor eax,2097152 22 push eax 23 popfd 24 pushfd 25 pop eax 26 xor ecx,eax 27 xor eax,eax 28 mov esi,DWORD [20+esp] 29 mov DWORD [8+esi],eax 30 bt ecx,21 31 jnc NEAR L$000nocpuid 32 cpuid 33 mov edi,eax 34 xor eax,eax 35 cmp ebx,1970169159 36 setne al 37 mov ebp,eax 38 cmp edx,1231384169 39 setne al 40 or ebp,eax 41 cmp ecx,1818588270 42 setne al 43 or ebp,eax 44 jz NEAR L$001intel 45 cmp ebx,1752462657 46 setne al 47 mov esi,eax 48 cmp edx,1769238117 49 setne al 50 or esi,eax 51 cmp ecx,1145913699 52 setne al 53 or esi,eax 54 jnz NEAR L$001intel 55 mov eax,2147483648 56 cpuid 57 cmp eax,2147483649 58 jb NEAR L$001intel 59 mov esi,eax 60 mov eax,2147483649 61 cpuid 62 or ebp,ecx 63 and ebp,2049 64 cmp esi,2147483656 65 jb NEAR L$001intel 66 mov eax,2147483656 67 cpuid 68 movzx esi,cl 69 inc esi 70 mov eax,1 71 xor ecx,ecx 72 cpuid 73 bt edx,28 74 jnc NEAR L$002generic 75 shr ebx,16 76 and ebx,255 77 cmp ebx,esi 78 ja NEAR L$002generic 79 and edx,4026531839 80 jmp NEAR L$002generic 81L$001intel: 82 cmp edi,4 83 mov esi,-1 84 jb NEAR L$003nocacheinfo 85 mov eax,4 86 mov ecx,0 87 cpuid 88 mov esi,eax 89 shr esi,14 90 and esi,4095 91L$003nocacheinfo: 92 mov eax,1 93 xor ecx,ecx 94 cpuid 95 and edx,3220176895 96 cmp ebp,0 97 jne NEAR L$004notintel 98 or edx,1073741824 99 and ah,15 100 cmp ah,15 101 jne NEAR L$004notintel 102 or edx,1048576 103L$004notintel: 104 bt edx,28 105 jnc NEAR L$002generic 106 and edx,4026531839 107 cmp esi,0 108 je NEAR L$002generic 109 or edx,268435456 110 shr ebx,16 111 cmp bl,1 112 ja NEAR L$002generic 113 and edx,4026531839 114L$002generic: 115 and ebp,2048 116 and ecx,4294965247 117 mov esi,edx 118 or ebp,ecx 119 cmp edi,7 120 mov edi,DWORD [20+esp] 121 jb NEAR L$005no_extended_info 122 mov eax,7 123 xor ecx,ecx 124 cpuid 125 mov DWORD [8+edi],ebx 126L$005no_extended_info: 127 bt ebp,27 128 jnc NEAR L$006clear_avx 129 xor ecx,ecx 130db 15,1,208 131 and eax,6 132 cmp eax,6 133 je NEAR L$007done 134 cmp eax,2 135 je NEAR L$006clear_avx 136L$008clear_xmm: 137 and ebp,4261412861 138 and esi,4278190079 139L$006clear_avx: 140 and ebp,4026525695 141 and DWORD [8+edi],4294967263 142L$007done: 143 mov eax,esi 144 mov edx,ebp 145L$000nocpuid: 146 pop edi 147 pop esi 148 pop ebx 149 pop ebp 150 ret 151;extern _OPENSSL_ia32cap_P 152global _OPENSSL_rdtsc 153align 16 154_OPENSSL_rdtsc: 155L$_OPENSSL_rdtsc_begin: 156 xor eax,eax 157 xor edx,edx 158 lea ecx,[_OPENSSL_ia32cap_P] 159 bt DWORD [ecx],4 160 jnc NEAR L$009notsc 161 rdtsc 162L$009notsc: 163 ret 164global _OPENSSL_instrument_halt 165align 16 166_OPENSSL_instrument_halt: 167L$_OPENSSL_instrument_halt_begin: 168 lea ecx,[_OPENSSL_ia32cap_P] 169 bt DWORD [ecx],4 170 jnc NEAR L$010nohalt 171dd 2421723150 172 and eax,3 173 jnz NEAR L$010nohalt 174 pushfd 175 pop eax 176 bt eax,9 177 jnc NEAR L$010nohalt 178 rdtsc 179 push edx 180 push eax 181 hlt 182 rdtsc 183 sub eax,DWORD [esp] 184 sbb edx,DWORD [4+esp] 185 add esp,8 186 ret 187L$010nohalt: 188 xor eax,eax 189 xor edx,edx 190 ret 191global _OPENSSL_far_spin 192align 16 193_OPENSSL_far_spin: 194L$_OPENSSL_far_spin_begin: 195 pushfd 196 pop eax 197 bt eax,9 198 jnc NEAR L$011nospin 199 mov eax,DWORD [4+esp] 200 mov ecx,DWORD [8+esp] 201dd 2430111262 202 xor eax,eax 203 mov edx,DWORD [ecx] 204 jmp NEAR L$012spin 205align 16 206L$012spin: 207 inc eax 208 cmp edx,DWORD [ecx] 209 je NEAR L$012spin 210dd 529567888 211 ret 212L$011nospin: 213 xor eax,eax 214 xor edx,edx 215 ret 216global _OPENSSL_wipe_cpu 217align 16 218_OPENSSL_wipe_cpu: 219L$_OPENSSL_wipe_cpu_begin: 220 xor eax,eax 221 xor edx,edx 222 lea ecx,[_OPENSSL_ia32cap_P] 223 mov ecx,DWORD [ecx] 224 bt DWORD [ecx],1 225 jnc NEAR L$013no_x87 226 and ecx,83886080 227 cmp ecx,83886080 228 jne NEAR L$014no_sse2 229 pxor xmm0,xmm0 230 pxor xmm1,xmm1 231 pxor xmm2,xmm2 232 pxor xmm3,xmm3 233 pxor xmm4,xmm4 234 pxor xmm5,xmm5 235 pxor xmm6,xmm6 236 pxor xmm7,xmm7 237L$014no_sse2: 238dd 4007259865,4007259865,4007259865,4007259865,2430851995 239L$013no_x87: 240 lea eax,[4+esp] 241 ret 242global _OPENSSL_atomic_add 243align 16 244_OPENSSL_atomic_add: 245L$_OPENSSL_atomic_add_begin: 246 mov edx,DWORD [4+esp] 247 mov ecx,DWORD [8+esp] 248 push ebx 249 nop 250 mov eax,DWORD [edx] 251L$015spin: 252 lea ebx,[ecx*1+eax] 253 nop 254dd 447811568 255 jne NEAR L$015spin 256 mov eax,ebx 257 pop ebx 258 ret 259global _OPENSSL_cleanse 260align 16 261_OPENSSL_cleanse: 262L$_OPENSSL_cleanse_begin: 263 mov edx,DWORD [4+esp] 264 mov ecx,DWORD [8+esp] 265 xor eax,eax 266 cmp ecx,7 267 jae NEAR L$016lot 268 cmp ecx,0 269 je NEAR L$017ret 270L$018little: 271 mov BYTE [edx],al 272 sub ecx,1 273 lea edx,[1+edx] 274 jnz NEAR L$018little 275L$017ret: 276 ret 277align 16 278L$016lot: 279 test edx,3 280 jz NEAR L$019aligned 281 mov BYTE [edx],al 282 lea ecx,[ecx-1] 283 lea edx,[1+edx] 284 jmp NEAR L$016lot 285L$019aligned: 286 mov DWORD [edx],eax 287 lea ecx,[ecx-4] 288 test ecx,-4 289 lea edx,[4+edx] 290 jnz NEAR L$019aligned 291 cmp ecx,0 292 jne NEAR L$018little 293 ret 294global _CRYPTO_memcmp 295align 16 296_CRYPTO_memcmp: 297L$_CRYPTO_memcmp_begin: 298 push esi 299 push edi 300 mov esi,DWORD [12+esp] 301 mov edi,DWORD [16+esp] 302 mov ecx,DWORD [20+esp] 303 xor eax,eax 304 xor edx,edx 305 cmp ecx,0 306 je NEAR L$020no_data 307L$021loop: 308 mov dl,BYTE [esi] 309 lea esi,[1+esi] 310 xor dl,BYTE [edi] 311 lea edi,[1+edi] 312 or al,dl 313 dec ecx 314 jnz NEAR L$021loop 315 neg eax 316 shr eax,31 317L$020no_data: 318 pop edi 319 pop esi 320 ret 321global _OPENSSL_instrument_bus 322align 16 323_OPENSSL_instrument_bus: 324L$_OPENSSL_instrument_bus_begin: 325 push ebp 326 push ebx 327 push esi 328 push edi 329 mov eax,0 330 lea edx,[_OPENSSL_ia32cap_P] 331 bt DWORD [edx],4 332 jnc NEAR L$022nogo 333 bt DWORD [edx],19 334 jnc NEAR L$022nogo 335 mov edi,DWORD [20+esp] 336 mov ecx,DWORD [24+esp] 337 rdtsc 338 mov esi,eax 339 mov ebx,0 340 clflush [edi] 341db 240 342 add DWORD [edi],ebx 343 jmp NEAR L$023loop 344align 16 345L$023loop: 346 rdtsc 347 mov edx,eax 348 sub eax,esi 349 mov esi,edx 350 mov ebx,eax 351 clflush [edi] 352db 240 353 add DWORD [edi],eax 354 lea edi,[4+edi] 355 sub ecx,1 356 jnz NEAR L$023loop 357 mov eax,DWORD [24+esp] 358L$022nogo: 359 pop edi 360 pop esi 361 pop ebx 362 pop ebp 363 ret 364global _OPENSSL_instrument_bus2 365align 16 366_OPENSSL_instrument_bus2: 367L$_OPENSSL_instrument_bus2_begin: 368 push ebp 369 push ebx 370 push esi 371 push edi 372 mov eax,0 373 lea edx,[_OPENSSL_ia32cap_P] 374 bt DWORD [edx],4 375 jnc NEAR L$024nogo 376 bt DWORD [edx],19 377 jnc NEAR L$024nogo 378 mov edi,DWORD [20+esp] 379 mov ecx,DWORD [24+esp] 380 mov ebp,DWORD [28+esp] 381 rdtsc 382 mov esi,eax 383 mov ebx,0 384 clflush [edi] 385db 240 386 add DWORD [edi],ebx 387 rdtsc 388 mov edx,eax 389 sub eax,esi 390 mov esi,edx 391 mov ebx,eax 392 jmp NEAR L$025loop2 393align 16 394L$025loop2: 395 clflush [edi] 396db 240 397 add DWORD [edi],eax 398 sub ebp,1 399 jz NEAR L$026done2 400 rdtsc 401 mov edx,eax 402 sub eax,esi 403 mov esi,edx 404 cmp eax,ebx 405 mov ebx,eax 406 mov edx,0 407 setne dl 408 sub ecx,edx 409 lea edi,[edx*4+edi] 410 jnz NEAR L$025loop2 411L$026done2: 412 mov eax,DWORD [24+esp] 413 sub eax,ecx 414L$024nogo: 415 pop edi 416 pop esi 417 pop ebx 418 pop ebp 419 ret 420global _OPENSSL_ia32_rdrand_bytes 421align 16 422_OPENSSL_ia32_rdrand_bytes: 423L$_OPENSSL_ia32_rdrand_bytes_begin: 424 push edi 425 push ebx 426 xor eax,eax 427 mov edi,DWORD [12+esp] 428 mov ebx,DWORD [16+esp] 429 cmp ebx,0 430 je NEAR L$027done 431 mov ecx,8 432L$028loop: 433db 15,199,242 434 jc NEAR L$029break 435 loop L$028loop 436 jmp NEAR L$027done 437align 16 438L$029break: 439 cmp ebx,4 440 jb NEAR L$030tail 441 mov DWORD [edi],edx 442 lea edi,[4+edi] 443 add eax,4 444 sub ebx,4 445 jz NEAR L$027done 446 mov ecx,8 447 jmp NEAR L$028loop 448align 16 449L$030tail: 450 mov BYTE [edi],dl 451 lea edi,[1+edi] 452 inc eax 453 shr edx,8 454 dec ebx 455 jnz NEAR L$030tail 456L$027done: 457 xor edx,edx 458 pop ebx 459 pop edi 460 ret 461global _OPENSSL_ia32_rdseed_bytes 462align 16 463_OPENSSL_ia32_rdseed_bytes: 464L$_OPENSSL_ia32_rdseed_bytes_begin: 465 push edi 466 push ebx 467 xor eax,eax 468 mov edi,DWORD [12+esp] 469 mov ebx,DWORD [16+esp] 470 cmp ebx,0 471 je NEAR L$031done 472 mov ecx,8 473L$032loop: 474db 15,199,250 475 jc NEAR L$033break 476 loop L$032loop 477 jmp NEAR L$031done 478align 16 479L$033break: 480 cmp ebx,4 481 jb NEAR L$034tail 482 mov DWORD [edi],edx 483 lea edi,[4+edi] 484 add eax,4 485 sub ebx,4 486 jz NEAR L$031done 487 mov ecx,8 488 jmp NEAR L$032loop 489align 16 490L$034tail: 491 mov BYTE [edi],dl 492 lea edi,[1+edi] 493 inc eax 494 shr edx,8 495 dec ebx 496 jnz NEAR L$034tail 497L$031done: 498 xor edx,edx 499 pop ebx 500 pop edi 501 ret 502segment .bss 503common _OPENSSL_ia32cap_P 16 504segment .CRT$XCU data align=4 505extern _OPENSSL_cpuid_setup 506dd _OPENSSL_cpuid_setup 507