xref: /freebsd/sys/crypto/openssl/aarch64/arm64cpuid.S (revision 4757b351ea9d59d71d4a38b82506d2d16fcd560d)
1/* Do not modify. This file is auto-generated from arm64cpuid.pl. */
2#include "arm_arch.h"
3
4.text
5.arch	armv8-a+crypto
6
7.align	5
8.globl	_armv7_neon_probe
9.type	_armv7_neon_probe,%function
10_armv7_neon_probe:
11	AARCH64_VALID_CALL_TARGET
12	orr	v15.16b, v15.16b, v15.16b
13	ret
14.size	_armv7_neon_probe,.-_armv7_neon_probe
15
16.globl	_armv7_tick
17.type	_armv7_tick,%function
18_armv7_tick:
19	AARCH64_VALID_CALL_TARGET
20#ifdef	__APPLE__
21	mrs	x0, CNTPCT_EL0
22#else
23	mrs	x0, CNTVCT_EL0
24#endif
25	ret
26.size	_armv7_tick,.-_armv7_tick
27
28.globl	_armv8_aes_probe
29.type	_armv8_aes_probe,%function
30_armv8_aes_probe:
31	AARCH64_VALID_CALL_TARGET
32	aese	v0.16b, v0.16b
33	ret
34.size	_armv8_aes_probe,.-_armv8_aes_probe
35
36.globl	_armv8_sha1_probe
37.type	_armv8_sha1_probe,%function
38_armv8_sha1_probe:
39	AARCH64_VALID_CALL_TARGET
40	sha1h	s0, s0
41	ret
42.size	_armv8_sha1_probe,.-_armv8_sha1_probe
43
44.globl	_armv8_sha256_probe
45.type	_armv8_sha256_probe,%function
46_armv8_sha256_probe:
47	AARCH64_VALID_CALL_TARGET
48	sha256su0	v0.4s, v0.4s
49	ret
50.size	_armv8_sha256_probe,.-_armv8_sha256_probe
51
52.globl	_armv8_pmull_probe
53.type	_armv8_pmull_probe,%function
54_armv8_pmull_probe:
55	AARCH64_VALID_CALL_TARGET
56	pmull	v0.1q, v0.1d, v0.1d
57	ret
58.size	_armv8_pmull_probe,.-_armv8_pmull_probe
59
60.globl	_armv8_sm4_probe
61.type	_armv8_sm4_probe,%function
62_armv8_sm4_probe:
63	AARCH64_VALID_CALL_TARGET
64.inst	0xcec08400	// sm4e	v0.4s, v0.4s
65	ret
66.size	_armv8_sm4_probe,.-_armv8_sm4_probe
67
68.globl	_armv8_sha512_probe
69.type	_armv8_sha512_probe,%function
70_armv8_sha512_probe:
71	AARCH64_VALID_CALL_TARGET
72.inst	0xcec08000	// sha512su0	v0.2d,v0.2d
73	ret
74.size	_armv8_sha512_probe,.-_armv8_sha512_probe
75
76.globl	_armv8_eor3_probe
77.type	_armv8_eor3_probe,%function
78_armv8_eor3_probe:
79	AARCH64_VALID_CALL_TARGET
80.inst	0xce010800	// eor3	v0.16b, v0.16b, v1.16b, v2.16b
81	ret
82.size	_armv8_eor3_probe,.-_armv8_eor3_probe
83
84.globl	_armv8_sve_probe
85.type	_armv8_sve_probe,%function
86_armv8_sve_probe:
87	AARCH64_VALID_CALL_TARGET
88.inst	0x04a03000	// eor z0.d,z0.d,z0.d
89	ret
90.size	_armv8_sve_probe,.-_armv8_sve_probe
91
92.globl	_armv8_sve2_probe
93.type	_armv8_sve2_probe,%function
94_armv8_sve2_probe:
95	AARCH64_VALID_CALL_TARGET
96.inst	0x04e03400	// xar z0.d,z0.d,z0.d
97	ret
98.size	_armv8_sve2_probe,.-_armv8_sve2_probe
99
100.globl	_armv8_cpuid_probe
101.type	_armv8_cpuid_probe,%function
102_armv8_cpuid_probe:
103	AARCH64_VALID_CALL_TARGET
104	mrs	x0, midr_el1
105	ret
106.size	_armv8_cpuid_probe,.-_armv8_cpuid_probe
107
108.globl	_armv8_sm3_probe
109.type	_armv8_sm3_probe,%function
110_armv8_sm3_probe:
111	AARCH64_VALID_CALL_TARGET
112.inst	0xce63c004	// sm3partw1 v4.4s, v0.4s, v3.4s
113	ret
114.size	_armv8_sm3_probe,.-_armv8_sm3_probe
115
116.globl	OPENSSL_cleanse
117.type	OPENSSL_cleanse,%function
118.align	5
119OPENSSL_cleanse:
120	AARCH64_VALID_CALL_TARGET
121	cbz	x1,.Lret	// len==0?
122	cmp	x1,#15
123	b.hi	.Lot		// len>15
124	nop
125.Little:
126	strb	wzr,[x0],#1	// store byte-by-byte
127	subs	x1,x1,#1
128	b.ne	.Little
129.Lret:	ret
130
131.align	4
132.Lot:	tst	x0,#7
133	b.eq	.Laligned	// inp is aligned
134	strb	wzr,[x0],#1	// store byte-by-byte
135	sub	x1,x1,#1
136	b	.Lot
137
138.align	4
139.Laligned:
140	str	xzr,[x0],#8	// store word-by-word
141	sub	x1,x1,#8
142	tst	x1,#-8
143	b.ne	.Laligned	// len>=8
144	cbnz	x1,.Little	// len!=0?
145	ret
146.size	OPENSSL_cleanse,.-OPENSSL_cleanse
147
148.globl	CRYPTO_memcmp
149.type	CRYPTO_memcmp,%function
150.align	4
151CRYPTO_memcmp:
152	AARCH64_VALID_CALL_TARGET
153	eor	w3,w3,w3
154	cbz	x2,.Lno_data	// len==0?
155	cmp	x2,#16
156	b.ne	.Loop_cmp
157	ldp	x8,x9,[x0]
158	ldp	x10,x11,[x1]
159	eor	x8,x8,x10
160	eor	x9,x9,x11
161	orr	x8,x8,x9
162	mov	x0,#1
163	cmp	x8,#0
164	csel	x0,xzr,x0,eq
165	ret
166
167.align	4
168.Loop_cmp:
169	ldrb	w4,[x0],#1
170	ldrb	w5,[x1],#1
171	eor	w4,w4,w5
172	orr	w3,w3,w4
173	subs	x2,x2,#1
174	b.ne	.Loop_cmp
175
176.Lno_data:
177	neg	w0,w3
178	lsr	w0,w0,#31
179	ret
180.size	CRYPTO_memcmp,.-CRYPTO_memcmp
181
182.globl	_armv8_rng_probe
183.type	_armv8_rng_probe,%function
184_armv8_rng_probe:
185	AARCH64_VALID_CALL_TARGET
186	mrs	x0, s3_3_c2_c4_0	// rndr
187	mrs	x0, s3_3_c2_c4_1	// rndrrs
188	ret
189.size	_armv8_rng_probe,.-_armv8_rng_probe
190// Fill buffer with Randomly Generated Bytes
191// inputs:  char * in x0 - Pointer to buffer
192//          size_t in x1 - Number of bytes to write to buffer
193// outputs: size_t in x0 - Number of bytes successfully written to buffer
194.globl	OPENSSL_rndr_asm
195.type	OPENSSL_rndr_asm,%function
196.align	4
197OPENSSL_rndr_asm:
198	AARCH64_VALID_CALL_TARGET
199	mov	x2,xzr
200	mov	x3,xzr
201
202.align	4
203.Loop_rndr:
204	cmp	x1,#0
205	b.eq	.rndr_done
206	mov	x3,xzr
207	mrs	x3,s3_3_c2_c4_0
208	b.eq	.rndr_done
209
210	cmp	x1,#8
211	b.lt	.Loop_single_byte_rndr
212
213	str	x3,[x0]
214	add	x0,x0,#8
215	add	x2,x2,#8
216	subs	x1,x1,#8
217	b.ge	.Loop_rndr
218
219.align	4
220.Loop_single_byte_rndr:
221	strb	w3,[x0]
222	lsr	x3,x3,#8
223	add	x2,x2,#1
224	add	x0,x0,#1
225	subs	x1,x1,#1
226	b.gt	.Loop_single_byte_rndr
227
228.align	4
229.rndr_done:
230	mov	x0,x2
231	ret
232.size	OPENSSL_rndr_asm,.-OPENSSL_rndr_asm
233// Fill buffer with Randomly Generated Bytes
234// inputs:  char * in x0 - Pointer to buffer
235//          size_t in x1 - Number of bytes to write to buffer
236// outputs: size_t in x0 - Number of bytes successfully written to buffer
237.globl	OPENSSL_rndrrs_asm
238.type	OPENSSL_rndrrs_asm,%function
239.align	4
240OPENSSL_rndrrs_asm:
241	AARCH64_VALID_CALL_TARGET
242	mov	x2,xzr
243	mov	x3,xzr
244
245.align	4
246.Loop_rndrrs:
247	cmp	x1,#0
248	b.eq	.rndrrs_done
249	mov	x3,xzr
250	mrs	x3,s3_3_c2_c4_1
251	b.eq	.rndrrs_done
252
253	cmp	x1,#8
254	b.lt	.Loop_single_byte_rndrrs
255
256	str	x3,[x0]
257	add	x0,x0,#8
258	add	x2,x2,#8
259	subs	x1,x1,#8
260	b.ge	.Loop_rndrrs
261
262.align	4
263.Loop_single_byte_rndrrs:
264	strb	w3,[x0]
265	lsr	x3,x3,#8
266	add	x2,x2,#1
267	add	x0,x0,#1
268	subs	x1,x1,#1
269	b.gt	.Loop_single_byte_rndrrs
270
271.align	4
272.rndrrs_done:
273	mov	x0,x2
274	ret
275.size	OPENSSL_rndrrs_asm,.-OPENSSL_rndrrs_asm
276