VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.7/crypto/genasm-nasm/x86_64cpuid.S@ 98024

Last change on this file since 98024 was 94083, checked in by vboxsync, 3 years ago

libs/openssl-3.0.1: Recreate asm files, bugref:10128

File size: 6.5 KB
Line 
1default rel
2%define XMMWORD
3%define YMMWORD
4%define ZMMWORD
5EXTERN OPENSSL_cpuid_setup
6
7section .CRT$XCU rdata align=8
8 DQ OPENSSL_cpuid_setup
9
10
11common OPENSSL_ia32cap_P 16
12
13section .text code align=64
14
15
16global OPENSSL_atomic_add
17
18ALIGN 16
19OPENSSL_atomic_add:
20
21DB 243,15,30,250
22 mov eax,DWORD[rcx]
23$L$spin: lea r8,[rax*1+rdx]
24DB 0xf0
25 cmpxchg DWORD[rcx],r8d
26 jne NEAR $L$spin
27 mov eax,r8d
28DB 0x48,0x98
29 DB 0F3h,0C3h ;repret
30
31
32
33global OPENSSL_rdtsc
34
35ALIGN 16
36OPENSSL_rdtsc:
37
38DB 243,15,30,250
39 rdtsc
40 shl rdx,32
41 or rax,rdx
42 DB 0F3h,0C3h ;repret
43
44
45
46global OPENSSL_ia32_cpuid
47
48ALIGN 16
49OPENSSL_ia32_cpuid:
50 mov QWORD[8+rsp],rdi ;WIN64 prologue
51 mov QWORD[16+rsp],rsi
52 mov rax,rsp
53$L$SEH_begin_OPENSSL_ia32_cpuid:
54 mov rdi,rcx
55
56
57
58DB 243,15,30,250
59 mov r8,rbx
60
61
62 xor eax,eax
63 mov QWORD[8+rdi],rax
64 cpuid
65 mov r11d,eax
66
67 xor eax,eax
68 cmp ebx,0x756e6547
69 setne al
70 mov r9d,eax
71 cmp edx,0x49656e69
72 setne al
73 or r9d,eax
74 cmp ecx,0x6c65746e
75 setne al
76 or r9d,eax
77 jz NEAR $L$intel
78
79 cmp ebx,0x68747541
80 setne al
81 mov r10d,eax
82 cmp edx,0x69746E65
83 setne al
84 or r10d,eax
85 cmp ecx,0x444D4163
86 setne al
87 or r10d,eax
88 jnz NEAR $L$intel
89
90
91 mov eax,0x80000000
92 cpuid
93 cmp eax,0x80000001
94 jb NEAR $L$intel
95 mov r10d,eax
96 mov eax,0x80000001
97 cpuid
98 or r9d,ecx
99 and r9d,0x00000801
100
101 cmp r10d,0x80000008
102 jb NEAR $L$intel
103
104 mov eax,0x80000008
105 cpuid
106 movzx r10,cl
107 inc r10
108
109 mov eax,1
110 cpuid
111 bt edx,28
112 jnc NEAR $L$generic
113 shr ebx,16
114 cmp bl,r10b
115 ja NEAR $L$generic
116 and edx,0xefffffff
117 jmp NEAR $L$generic
118
119$L$intel:
120 cmp r11d,4
121 mov r10d,-1
122 jb NEAR $L$nocacheinfo
123
124 mov eax,4
125 mov ecx,0
126 cpuid
127 mov r10d,eax
128 shr r10d,14
129 and r10d,0xfff
130
131$L$nocacheinfo:
132 mov eax,1
133 cpuid
134 movd xmm0,eax
135 and edx,0xbfefffff
136 cmp r9d,0
137 jne NEAR $L$notintel
138 or edx,0x40000000
139 and ah,15
140 cmp ah,15
141 jne NEAR $L$notP4
142 or edx,0x00100000
143$L$notP4:
144 cmp ah,6
145 jne NEAR $L$notintel
146 and eax,0x0fff0ff0
147 cmp eax,0x00050670
148 je NEAR $L$knights
149 cmp eax,0x00080650
150 jne NEAR $L$notintel
151$L$knights:
152 and ecx,0xfbffffff
153
154$L$notintel:
155 bt edx,28
156 jnc NEAR $L$generic
157 and edx,0xefffffff
158 cmp r10d,0
159 je NEAR $L$generic
160
161 or edx,0x10000000
162 shr ebx,16
163 cmp bl,1
164 ja NEAR $L$generic
165 and edx,0xefffffff
166$L$generic:
167 and r9d,0x00000800
168 and ecx,0xfffff7ff
169 or r9d,ecx
170
171 mov r10d,edx
172
173 cmp r11d,7
174 jb NEAR $L$no_extended_info
175 mov eax,7
176 xor ecx,ecx
177 cpuid
178 bt r9d,26
179 jc NEAR $L$notknights
180 and ebx,0xfff7ffff
181$L$notknights:
182 movd eax,xmm0
183 and eax,0x0fff0ff0
184 cmp eax,0x00050650
185 jne NEAR $L$notskylakex
186 and ebx,0xfffeffff
187
188$L$notskylakex:
189 mov DWORD[8+rdi],ebx
190 mov DWORD[12+rdi],ecx
191$L$no_extended_info:
192
193 bt r9d,27
194 jnc NEAR $L$clear_avx
195 xor ecx,ecx
196DB 0x0f,0x01,0xd0
197 and eax,0xe6
198 cmp eax,0xe6
199 je NEAR $L$done
200 and DWORD[8+rdi],0x3fdeffff
201
202
203
204
205 and eax,6
206 cmp eax,6
207 je NEAR $L$done
208$L$clear_avx:
209 mov eax,0xefffe7ff
210 and r9d,eax
211 mov eax,0x3fdeffdf
212 and DWORD[8+rdi],eax
213$L$done:
214 shl r9,32
215 mov eax,r10d
216 mov rbx,r8
217
218 or rax,r9
219 mov rdi,QWORD[8+rsp] ;WIN64 epilogue
220 mov rsi,QWORD[16+rsp]
221 DB 0F3h,0C3h ;repret
222
223$L$SEH_end_OPENSSL_ia32_cpuid:
224
225global OPENSSL_cleanse
226
227ALIGN 16
228OPENSSL_cleanse:
229
230DB 243,15,30,250
231 xor rax,rax
232 cmp rdx,15
233 jae NEAR $L$ot
234 cmp rdx,0
235 je NEAR $L$ret
236$L$ittle:
237 mov BYTE[rcx],al
238 sub rdx,1
239 lea rcx,[1+rcx]
240 jnz NEAR $L$ittle
241$L$ret:
242 DB 0F3h,0C3h ;repret
243ALIGN 16
244$L$ot:
245 test rcx,7
246 jz NEAR $L$aligned
247 mov BYTE[rcx],al
248 lea rdx,[((-1))+rdx]
249 lea rcx,[1+rcx]
250 jmp NEAR $L$ot
251$L$aligned:
252 mov QWORD[rcx],rax
253 lea rdx,[((-8))+rdx]
254 test rdx,-8
255 lea rcx,[8+rcx]
256 jnz NEAR $L$aligned
257 cmp rdx,0
258 jne NEAR $L$ittle
259 DB 0F3h,0C3h ;repret
260
261
262
263global CRYPTO_memcmp
264
265ALIGN 16
266CRYPTO_memcmp:
267
268DB 243,15,30,250
269 xor rax,rax
270 xor r10,r10
271 cmp r8,0
272 je NEAR $L$no_data
273 cmp r8,16
274 jne NEAR $L$oop_cmp
275 mov r10,QWORD[rcx]
276 mov r11,QWORD[8+rcx]
277 mov r8,1
278 xor r10,QWORD[rdx]
279 xor r11,QWORD[8+rdx]
280 or r10,r11
281 cmovnz rax,r8
282 DB 0F3h,0C3h ;repret
283
284ALIGN 16
285$L$oop_cmp:
286 mov r10b,BYTE[rcx]
287 lea rcx,[1+rcx]
288 xor r10b,BYTE[rdx]
289 lea rdx,[1+rdx]
290 or al,r10b
291 dec r8
292 jnz NEAR $L$oop_cmp
293 neg rax
294 shr rax,63
295$L$no_data:
296 DB 0F3h,0C3h ;repret
297
298
299global OPENSSL_wipe_cpu
300
301ALIGN 16
302OPENSSL_wipe_cpu:
303 pxor xmm0,xmm0
304 pxor xmm1,xmm1
305 pxor xmm2,xmm2
306 pxor xmm3,xmm3
307 pxor xmm4,xmm4
308 pxor xmm5,xmm5
309 xor rcx,rcx
310 xor rdx,rdx
311 xor r8,r8
312 xor r9,r9
313 xor r10,r10
314 xor r11,r11
315 lea rax,[8+rsp]
316 DB 0F3h,0C3h ;repret
317
318global OPENSSL_instrument_bus
319
320ALIGN 16
321OPENSSL_instrument_bus:
322
323DB 243,15,30,250
324 mov r10,rcx
325 mov rcx,rdx
326 mov r11,rdx
327
328 rdtsc
329 mov r8d,eax
330 mov r9d,0
331 clflush [r10]
332DB 0xf0
333 add DWORD[r10],r9d
334 jmp NEAR $L$oop
335ALIGN 16
336$L$oop: rdtsc
337 mov edx,eax
338 sub eax,r8d
339 mov r8d,edx
340 mov r9d,eax
341 clflush [r10]
342DB 0xf0
343 add DWORD[r10],eax
344 lea r10,[4+r10]
345 sub rcx,1
346 jnz NEAR $L$oop
347
348 mov rax,r11
349 DB 0F3h,0C3h ;repret
350
351
352
353global OPENSSL_instrument_bus2
354
355ALIGN 16
356OPENSSL_instrument_bus2:
357
358DB 243,15,30,250
359 mov r10,rcx
360 mov rcx,rdx
361 mov r11,r8
362 mov QWORD[8+rsp],rcx
363
364 rdtsc
365 mov r8d,eax
366 mov r9d,0
367
368 clflush [r10]
369DB 0xf0
370 add DWORD[r10],r9d
371
372 rdtsc
373 mov edx,eax
374 sub eax,r8d
375 mov r8d,edx
376 mov r9d,eax
377$L$oop2:
378 clflush [r10]
379DB 0xf0
380 add DWORD[r10],eax
381
382 sub r11,1
383 jz NEAR $L$done2
384
385 rdtsc
386 mov edx,eax
387 sub eax,r8d
388 mov r8d,edx
389 cmp eax,r9d
390 mov r9d,eax
391 mov edx,0
392 setne dl
393 sub rcx,rdx
394 lea r10,[rdx*4+r10]
395 jnz NEAR $L$oop2
396
397$L$done2:
398 mov rax,QWORD[8+rsp]
399 sub rax,rcx
400 DB 0F3h,0C3h ;repret
401
402
403global OPENSSL_ia32_rdrand_bytes
404
405ALIGN 16
406OPENSSL_ia32_rdrand_bytes:
407
408DB 243,15,30,250
409 xor rax,rax
410 cmp rdx,0
411 je NEAR $L$done_rdrand_bytes
412
413 mov r11,8
414$L$oop_rdrand_bytes:
415DB 73,15,199,242
416 jc NEAR $L$break_rdrand_bytes
417 dec r11
418 jnz NEAR $L$oop_rdrand_bytes
419 jmp NEAR $L$done_rdrand_bytes
420
421ALIGN 16
422$L$break_rdrand_bytes:
423 cmp rdx,8
424 jb NEAR $L$tail_rdrand_bytes
425 mov QWORD[rcx],r10
426 lea rcx,[8+rcx]
427 add rax,8
428 sub rdx,8
429 jz NEAR $L$done_rdrand_bytes
430 mov r11,8
431 jmp NEAR $L$oop_rdrand_bytes
432
433ALIGN 16
434$L$tail_rdrand_bytes:
435 mov BYTE[rcx],r10b
436 lea rcx,[1+rcx]
437 inc rax
438 shr r10,8
439 dec rdx
440 jnz NEAR $L$tail_rdrand_bytes
441
442$L$done_rdrand_bytes:
443 xor r10,r10
444 DB 0F3h,0C3h ;repret
445
446
447global OPENSSL_ia32_rdseed_bytes
448
449ALIGN 16
450OPENSSL_ia32_rdseed_bytes:
451
452DB 243,15,30,250
453 xor rax,rax
454 cmp rdx,0
455 je NEAR $L$done_rdseed_bytes
456
457 mov r11,8
458$L$oop_rdseed_bytes:
459DB 73,15,199,250
460 jc NEAR $L$break_rdseed_bytes
461 dec r11
462 jnz NEAR $L$oop_rdseed_bytes
463 jmp NEAR $L$done_rdseed_bytes
464
465ALIGN 16
466$L$break_rdseed_bytes:
467 cmp rdx,8
468 jb NEAR $L$tail_rdseed_bytes
469 mov QWORD[rcx],r10
470 lea rcx,[8+rcx]
471 add rax,8
472 sub rdx,8
473 jz NEAR $L$done_rdseed_bytes
474 mov r11,8
475 jmp NEAR $L$oop_rdseed_bytes
476
477ALIGN 16
478$L$tail_rdseed_bytes:
479 mov BYTE[rcx],r10b
480 lea rcx,[1+rcx]
481 inc rax
482 shr r10,8
483 dec rdx
484 jnz NEAR $L$tail_rdseed_bytes
485
486$L$done_rdseed_bytes:
487 xor r10,r10
488 DB 0F3h,0C3h ;repret
489
490
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette