VirtualBox

source: vbox/trunk/src/libs/openssl-1.1.1g/crypto/genasm-nasm/x86_64cpuid.S@ 86352

最後變更 在這個檔案從86352是 83531,由 vboxsync 提交於 5 年 前

setting svn:sync-process=export for openssl-1.1.1f, all files except tests

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

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