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,16,4 8 9.text 10 11.globl OPENSSL_atomic_add 12.type OPENSSL_atomic_add,@function 13.align 16 14OPENSSL_atomic_add: 15.cfi_startproc 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.cfi_endproc 25.size OPENSSL_atomic_add,.-OPENSSL_atomic_add 26 27.globl OPENSSL_rdtsc 28.type OPENSSL_rdtsc,@function 29.align 16 30OPENSSL_rdtsc: 31.cfi_startproc 32 rdtsc 33 shlq $32,%rdx 34 orq %rdx,%rax 35 .byte 0xf3,0xc3 36.cfi_endproc 37.size OPENSSL_rdtsc,.-OPENSSL_rdtsc 38 39.globl OPENSSL_ia32_cpuid 40.type OPENSSL_ia32_cpuid,@function 41.align 16 42OPENSSL_ia32_cpuid: 43.cfi_startproc 44 movq %rbx,%r8 45.cfi_register %rbx,%r8 46 47 xorl %eax,%eax 48 movq %rax,8(%rdi) 49 cpuid 50 movl %eax,%r11d 51 52 xorl %eax,%eax 53 cmpl $0x756e6547,%ebx 54 setne %al 55 movl %eax,%r9d 56 cmpl $0x49656e69,%edx 57 setne %al 58 orl %eax,%r9d 59 cmpl $0x6c65746e,%ecx 60 setne %al 61 orl %eax,%r9d 62 jz .Lintel 63 64 cmpl $0x68747541,%ebx 65 setne %al 66 movl %eax,%r10d 67 cmpl $0x69746E65,%edx 68 setne %al 69 orl %eax,%r10d 70 cmpl $0x444D4163,%ecx 71 setne %al 72 orl %eax,%r10d 73 jnz .Lintel 74 75 76 movl $0x80000000,%eax 77 cpuid 78 cmpl $0x80000001,%eax 79 jb .Lintel 80 movl %eax,%r10d 81 movl $0x80000001,%eax 82 cpuid 83 orl %ecx,%r9d 84 andl $0x00000801,%r9d 85 86 cmpl $0x80000008,%r10d 87 jb .Lintel 88 89 movl $0x80000008,%eax 90 cpuid 91 movzbq %cl,%r10 92 incq %r10 93 94 movl $1,%eax 95 cpuid 96 btl $28,%edx 97 jnc .Lgeneric 98 shrl $16,%ebx 99 cmpb %r10b,%bl 100 ja .Lgeneric 101 andl $0xefffffff,%edx 102 jmp .Lgeneric 103 104.Lintel: 105 cmpl $4,%r11d 106 movl $-1,%r10d 107 jb .Lnocacheinfo 108 109 movl $4,%eax 110 movl $0,%ecx 111 cpuid 112 movl %eax,%r10d 113 shrl $14,%r10d 114 andl $0xfff,%r10d 115 116.Lnocacheinfo: 117 movl $1,%eax 118 cpuid 119 movd %eax,%xmm0 120 andl $0xbfefffff,%edx 121 cmpl $0,%r9d 122 jne .Lnotintel 123 orl $0x40000000,%edx 124 andb $15,%ah 125 cmpb $15,%ah 126 jne .LnotP4 127 orl $0x00100000,%edx 128.LnotP4: 129 cmpb $6,%ah 130 jne .Lnotintel 131 andl $0x0fff0ff0,%eax 132 cmpl $0x00050670,%eax 133 je .Lknights 134 cmpl $0x00080650,%eax 135 jne .Lnotintel 136.Lknights: 137 andl $0xfbffffff,%ecx 138 139.Lnotintel: 140 btl $28,%edx 141 jnc .Lgeneric 142 andl $0xefffffff,%edx 143 cmpl $0,%r10d 144 je .Lgeneric 145 146 orl $0x10000000,%edx 147 shrl $16,%ebx 148 cmpb $1,%bl 149 ja .Lgeneric 150 andl $0xefffffff,%edx 151.Lgeneric: 152 andl $0x00000800,%r9d 153 andl $0xfffff7ff,%ecx 154 orl %ecx,%r9d 155 156 movl %edx,%r10d 157 158 cmpl $7,%r11d 159 jb .Lno_extended_info 160 movl $7,%eax 161 xorl %ecx,%ecx 162 cpuid 163 btl $26,%r9d 164 jc .Lnotknights 165 andl $0xfff7ffff,%ebx 166.Lnotknights: 167 movd %xmm0,%eax 168 andl $0x0fff0ff0,%eax 169 cmpl $0x00050650,%eax 170 jne .Lnotskylakex 171 andl $0xfffeffff,%ebx 172 173.Lnotskylakex: 174 movl %ebx,8(%rdi) 175 movl %ecx,12(%rdi) 176.Lno_extended_info: 177 178 btl $27,%r9d 179 jnc .Lclear_avx 180 xorl %ecx,%ecx 181.byte 0x0f,0x01,0xd0 182 andl $0xe6,%eax 183 cmpl $0xe6,%eax 184 je .Ldone 185 andl $0x3fdeffff,8(%rdi) 186 187 188 189 190 andl $6,%eax 191 cmpl $6,%eax 192 je .Ldone 193.Lclear_avx: 194 movl $0xefffe7ff,%eax 195 andl %eax,%r9d 196 movl $0x3fdeffdf,%eax 197 andl %eax,8(%rdi) 198.Ldone: 199 shlq $32,%r9 200 movl %r10d,%eax 201 movq %r8,%rbx 202.cfi_restore %rbx 203 orq %r9,%rax 204 .byte 0xf3,0xc3 205.cfi_endproc 206.size OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid 207 208.globl OPENSSL_cleanse 209.type OPENSSL_cleanse,@function 210.align 16 211OPENSSL_cleanse: 212.cfi_startproc 213 xorq %rax,%rax 214 cmpq $15,%rsi 215 jae .Lot 216 cmpq $0,%rsi 217 je .Lret 218.Little: 219 movb %al,(%rdi) 220 subq $1,%rsi 221 leaq 1(%rdi),%rdi 222 jnz .Little 223.Lret: 224 .byte 0xf3,0xc3 225.align 16 226.Lot: 227 testq $7,%rdi 228 jz .Laligned 229 movb %al,(%rdi) 230 leaq -1(%rsi),%rsi 231 leaq 1(%rdi),%rdi 232 jmp .Lot 233.Laligned: 234 movq %rax,(%rdi) 235 leaq -8(%rsi),%rsi 236 testq $-8,%rsi 237 leaq 8(%rdi),%rdi 238 jnz .Laligned 239 cmpq $0,%rsi 240 jne .Little 241 .byte 0xf3,0xc3 242.cfi_endproc 243.size OPENSSL_cleanse,.-OPENSSL_cleanse 244 245.globl CRYPTO_memcmp 246.type CRYPTO_memcmp,@function 247.align 16 248CRYPTO_memcmp: 249.cfi_startproc 250 xorq %rax,%rax 251 xorq %r10,%r10 252 cmpq $0,%rdx 253 je .Lno_data 254 cmpq $16,%rdx 255 jne .Loop_cmp 256 movq (%rdi),%r10 257 movq 8(%rdi),%r11 258 movq $1,%rdx 259 xorq (%rsi),%r10 260 xorq 8(%rsi),%r11 261 orq %r11,%r10 262 cmovnzq %rdx,%rax 263 .byte 0xf3,0xc3 264 265.align 16 266.Loop_cmp: 267 movb (%rdi),%r10b 268 leaq 1(%rdi),%rdi 269 xorb (%rsi),%r10b 270 leaq 1(%rsi),%rsi 271 orb %r10b,%al 272 decq %rdx 273 jnz .Loop_cmp 274 negq %rax 275 shrq $63,%rax 276.Lno_data: 277 .byte 0xf3,0xc3 278.cfi_endproc 279.size CRYPTO_memcmp,.-CRYPTO_memcmp 280.globl OPENSSL_wipe_cpu 281.type OPENSSL_wipe_cpu,@function 282.align 16 283OPENSSL_wipe_cpu: 284.cfi_startproc 285 pxor %xmm0,%xmm0 286 pxor %xmm1,%xmm1 287 pxor %xmm2,%xmm2 288 pxor %xmm3,%xmm3 289 pxor %xmm4,%xmm4 290 pxor %xmm5,%xmm5 291 pxor %xmm6,%xmm6 292 pxor %xmm7,%xmm7 293 pxor %xmm8,%xmm8 294 pxor %xmm9,%xmm9 295 pxor %xmm10,%xmm10 296 pxor %xmm11,%xmm11 297 pxor %xmm12,%xmm12 298 pxor %xmm13,%xmm13 299 pxor %xmm14,%xmm14 300 pxor %xmm15,%xmm15 301 xorq %rcx,%rcx 302 xorq %rdx,%rdx 303 xorq %rsi,%rsi 304 xorq %rdi,%rdi 305 xorq %r8,%r8 306 xorq %r9,%r9 307 xorq %r10,%r10 308 xorq %r11,%r11 309 leaq 8(%rsp),%rax 310 .byte 0xf3,0xc3 311.cfi_endproc 312.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu 313.globl OPENSSL_instrument_bus 314.type OPENSSL_instrument_bus,@function 315.align 16 316OPENSSL_instrument_bus: 317.cfi_startproc 318 movq %rdi,%r10 319 movq %rsi,%rcx 320 movq %rsi,%r11 321 322 rdtsc 323 movl %eax,%r8d 324 movl $0,%r9d 325 clflush (%r10) 326.byte 0xf0 327 addl %r9d,(%r10) 328 jmp .Loop 329.align 16 330.Loop: rdtsc 331 movl %eax,%edx 332 subl %r8d,%eax 333 movl %edx,%r8d 334 movl %eax,%r9d 335 clflush (%r10) 336.byte 0xf0 337 addl %eax,(%r10) 338 leaq 4(%r10),%r10 339 subq $1,%rcx 340 jnz .Loop 341 342 movq %r11,%rax 343 .byte 0xf3,0xc3 344.cfi_endproc 345.size OPENSSL_instrument_bus,.-OPENSSL_instrument_bus 346 347.globl OPENSSL_instrument_bus2 348.type OPENSSL_instrument_bus2,@function 349.align 16 350OPENSSL_instrument_bus2: 351.cfi_startproc 352 movq %rdi,%r10 353 movq %rsi,%rcx 354 movq %rdx,%r11 355 movq %rcx,8(%rsp) 356 357 rdtsc 358 movl %eax,%r8d 359 movl $0,%r9d 360 361 clflush (%r10) 362.byte 0xf0 363 addl %r9d,(%r10) 364 365 rdtsc 366 movl %eax,%edx 367 subl %r8d,%eax 368 movl %edx,%r8d 369 movl %eax,%r9d 370.Loop2: 371 clflush (%r10) 372.byte 0xf0 373 addl %eax,(%r10) 374 375 subq $1,%r11 376 jz .Ldone2 377 378 rdtsc 379 movl %eax,%edx 380 subl %r8d,%eax 381 movl %edx,%r8d 382 cmpl %r9d,%eax 383 movl %eax,%r9d 384 movl $0,%edx 385 setne %dl 386 subq %rdx,%rcx 387 leaq (%r10,%rdx,4),%r10 388 jnz .Loop2 389 390.Ldone2: 391 movq 8(%rsp),%rax 392 subq %rcx,%rax 393 .byte 0xf3,0xc3 394.cfi_endproc 395.size OPENSSL_instrument_bus2,.-OPENSSL_instrument_bus2 396.globl OPENSSL_ia32_rdrand_bytes 397.type OPENSSL_ia32_rdrand_bytes,@function 398.align 16 399OPENSSL_ia32_rdrand_bytes: 400.cfi_startproc 401 xorq %rax,%rax 402 cmpq $0,%rsi 403 je .Ldone_rdrand_bytes 404 405 movq $8,%r11 406.Loop_rdrand_bytes: 407.byte 73,15,199,242 408 jc .Lbreak_rdrand_bytes 409 decq %r11 410 jnz .Loop_rdrand_bytes 411 jmp .Ldone_rdrand_bytes 412 413.align 16 414.Lbreak_rdrand_bytes: 415 cmpq $8,%rsi 416 jb .Ltail_rdrand_bytes 417 movq %r10,(%rdi) 418 leaq 8(%rdi),%rdi 419 addq $8,%rax 420 subq $8,%rsi 421 jz .Ldone_rdrand_bytes 422 movq $8,%r11 423 jmp .Loop_rdrand_bytes 424 425.align 16 426.Ltail_rdrand_bytes: 427 movb %r10b,(%rdi) 428 leaq 1(%rdi),%rdi 429 incq %rax 430 shrq $8,%r10 431 decq %rsi 432 jnz .Ltail_rdrand_bytes 433 434.Ldone_rdrand_bytes: 435 xorq %r10,%r10 436 .byte 0xf3,0xc3 437.cfi_endproc 438.size OPENSSL_ia32_rdrand_bytes,.-OPENSSL_ia32_rdrand_bytes 439.globl OPENSSL_ia32_rdseed_bytes 440.type OPENSSL_ia32_rdseed_bytes,@function 441.align 16 442OPENSSL_ia32_rdseed_bytes: 443.cfi_startproc 444 xorq %rax,%rax 445 cmpq $0,%rsi 446 je .Ldone_rdseed_bytes 447 448 movq $8,%r11 449.Loop_rdseed_bytes: 450.byte 73,15,199,250 451 jc .Lbreak_rdseed_bytes 452 decq %r11 453 jnz .Loop_rdseed_bytes 454 jmp .Ldone_rdseed_bytes 455 456.align 16 457.Lbreak_rdseed_bytes: 458 cmpq $8,%rsi 459 jb .Ltail_rdseed_bytes 460 movq %r10,(%rdi) 461 leaq 8(%rdi),%rdi 462 addq $8,%rax 463 subq $8,%rsi 464 jz .Ldone_rdseed_bytes 465 movq $8,%r11 466 jmp .Loop_rdseed_bytes 467 468.align 16 469.Ltail_rdseed_bytes: 470 movb %r10b,(%rdi) 471 leaq 1(%rdi),%rdi 472 incq %rax 473 shrq $8,%r10 474 decq %rsi 475 jnz .Ltail_rdseed_bytes 476 477.Ldone_rdseed_bytes: 478 xorq %r10,%r10 479 .byte 0xf3,0xc3 480.cfi_endproc 481.size OPENSSL_ia32_rdseed_bytes,.-OPENSSL_ia32_rdseed_bytes 482