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