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