xref: /isa-l_crypto/include/reg_sizes.asm (revision 99d3b44924279c4f82108a035dc8d91062a54446)
1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2;  Copyright(c) 2011-2019 Intel Corporation All rights reserved.
3;
4;  Redistribution and use in source and binary forms, with or without
5;  modification, are permitted provided that the following conditions
6;  are met:
7;    * Redistributions of source code must retain the above copyright
8;      notice, this list of conditions and the following disclaimer.
9;    * Redistributions in binary form must reproduce the above copyright
10;      notice, this list of conditions and the following disclaimer in
11;      the documentation and/or other materials provided with the
12;      distribution.
13;    * Neither the name of Intel Corporation nor the names of its
14;      contributors may be used to endorse or promote products derived
15;      from this software without specific prior written permission.
16;
17;  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18;  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19;  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20;  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21;  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22;  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23;  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24;  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25;  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26;  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27;  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
29
30%ifndef _REG_SIZES_ASM_
31%define _REG_SIZES_ASM_
32
33%ifndef AS_FEATURE_LEVEL
34%define AS_FEATURE_LEVEL 4
35%endif
36
37%define EFLAGS_HAS_CPUID        (1<<21)
38%define FLAG_CPUID1_ECX_CLMUL   (1<<1)
39%define FLAG_CPUID1_EDX_SSE2    (1<<26)
40%define FLAG_CPUID1_ECX_SSE3	(1)
41%define FLAG_CPUID1_ECX_SSE4_1  (1<<19)
42%define FLAG_CPUID1_ECX_SSE4_2  (1<<20)
43%define FLAG_CPUID1_ECX_POPCNT  (1<<23)
44%define FLAG_CPUID1_ECX_AESNI   (1<<25)
45%define FLAG_CPUID1_ECX_OSXSAVE (1<<27)
46%define FLAG_CPUID1_ECX_AVX     (1<<28)
47%define FLAG_CPUID1_EBX_AVX2    (1<<5)
48
49%define FLAG_CPUID7_EBX_AVX2           (1<<5)
50%define FLAG_CPUID7_EBX_AVX512F        (1<<16)
51%define FLAG_CPUID7_EBX_AVX512DQ       (1<<17)
52%define FLAG_CPUID7_EBX_AVX512IFMA     (1<<21)
53%define FLAG_CPUID7_EBX_AVX512PF       (1<<26)
54%define FLAG_CPUID7_EBX_AVX512ER       (1<<27)
55%define FLAG_CPUID7_EBX_AVX512CD       (1<<28)
56%define FLAG_CPUID7_EBX_SHA            (1<<29)
57%define FLAG_CPUID7_EBX_AVX512BW       (1<<30)
58%define FLAG_CPUID7_EBX_AVX512VL       (1<<31)
59
60%define FLAG_CPUID7_ECX_AVX512VBMI     (1<<1)
61%define FLAG_CPUID7_ECX_AVX512VBMI2    (1 << 6)
62%define FLAG_CPUID7_ECX_GFNI           (1 << 8)
63%define FLAG_CPUID7_ECX_VAES           (1 << 9)
64%define FLAG_CPUID7_ECX_VPCLMULQDQ     (1 << 10)
65%define FLAG_CPUID7_ECX_VNNI           (1 << 11)
66%define FLAG_CPUID7_ECX_BITALG         (1 << 12)
67%define FLAG_CPUID7_ECX_VPOPCNTDQ      (1 << 14)
68
69%define FLAGS_CPUID7_EBX_AVX512_G1 (FLAG_CPUID7_EBX_AVX512F | FLAG_CPUID7_EBX_AVX512VL | FLAG_CPUID7_EBX_AVX512BW | FLAG_CPUID7_EBX_AVX512CD | FLAG_CPUID7_EBX_AVX512DQ)
70%define FLAGS_CPUID7_ECX_AVX512_G2 (FLAG_CPUID7_ECX_AVX512VBMI2 | FLAG_CPUID7_ECX_GFNI | FLAG_CPUID7_ECX_VAES | FLAG_CPUID7_ECX_VPCLMULQDQ | FLAG_CPUID7_ECX_VNNI | FLAG_CPUID7_ECX_BITALG | FLAG_CPUID7_ECX_VPOPCNTDQ)
71
72%define FLAG_XGETBV_EAX_XMM            (1<<1)
73%define FLAG_XGETBV_EAX_YMM            (1<<2)
74%define FLAG_XGETBV_EAX_XMM_YMM        0x6
75%define FLAG_XGETBV_EAX_ZMM_OPM        0xe0
76
77%define FLAG_CPUID1_EAX_AVOTON     0x000406d0
78%define FLAG_CPUID1_EAX_STEP_MASK  0xfffffff0
79
80; define d and w variants for registers
81
82%define	raxd	eax
83%define raxw	ax
84%define raxb	al
85
86%define	rbxd	ebx
87%define rbxw	bx
88%define rbxb	bl
89
90%define	rcxd	ecx
91%define rcxw	cx
92%define rcxb	cl
93
94%define	rdxd	edx
95%define rdxw	dx
96%define rdxb	dl
97
98%define	rsid	esi
99%define rsiw	si
100%define rsib	sil
101
102%define	rdid	edi
103%define rdiw	di
104%define rdib	dil
105
106%define	rbpd	ebp
107%define rbpw	bp
108%define rbpb	bpl
109
110%define zmm0x xmm0
111%define zmm1x xmm1
112%define zmm2x xmm2
113%define zmm3x xmm3
114%define zmm4x xmm4
115%define zmm5x xmm5
116%define zmm6x xmm6
117%define zmm7x xmm7
118%define zmm8x xmm8
119%define zmm9x xmm9
120%define zmm10x xmm10
121%define zmm11x xmm11
122%define zmm12x xmm12
123%define zmm13x xmm13
124%define zmm14x xmm14
125%define zmm15x xmm15
126%define zmm16x xmm16
127%define zmm17x xmm17
128%define zmm18x xmm18
129%define zmm19x xmm19
130%define zmm20x xmm20
131%define zmm21x xmm21
132%define zmm22x xmm22
133%define zmm23x xmm23
134%define zmm24x xmm24
135%define zmm25x xmm25
136%define zmm26x xmm26
137%define zmm27x xmm27
138%define zmm28x xmm28
139%define zmm29x xmm29
140%define zmm30x xmm30
141%define zmm31x xmm31
142
143%define ymm0x xmm0
144%define ymm1x xmm1
145%define ymm2x xmm2
146%define ymm3x xmm3
147%define ymm4x xmm4
148%define ymm5x xmm5
149%define ymm6x xmm6
150%define ymm7x xmm7
151%define ymm8x xmm8
152%define ymm9x xmm9
153%define ymm10x xmm10
154%define ymm11x xmm11
155%define ymm12x xmm12
156%define ymm13x xmm13
157%define ymm14x xmm14
158%define ymm15x xmm15
159%define ymm16x xmm16
160%define ymm17x xmm17
161%define ymm18x xmm18
162%define ymm19x xmm19
163%define ymm20x xmm20
164%define ymm21x xmm21
165%define ymm22x xmm22
166%define ymm23x xmm23
167%define ymm24x xmm24
168%define ymm25x xmm25
169%define ymm26x xmm26
170%define ymm27x xmm27
171%define ymm28x xmm28
172%define ymm29x xmm29
173%define ymm30x xmm30
174%define ymm31x xmm31
175
176%define xmm0x xmm0
177%define xmm1x xmm1
178%define xmm2x xmm2
179%define xmm3x xmm3
180%define xmm4x xmm4
181%define xmm5x xmm5
182%define xmm6x xmm6
183%define xmm7x xmm7
184%define xmm8x xmm8
185%define xmm9x xmm9
186%define xmm10x xmm10
187%define xmm11x xmm11
188%define xmm12x xmm12
189%define xmm13x xmm13
190%define xmm14x xmm14
191%define xmm15x xmm15
192%define xmm16x xmm16
193%define xmm17x xmm17
194%define xmm18x xmm18
195%define xmm19x xmm19
196%define xmm20x xmm20
197%define xmm21x xmm21
198%define xmm22x xmm22
199%define xmm23x xmm23
200%define xmm24x xmm24
201%define xmm25x xmm25
202%define xmm26x xmm26
203%define xmm27x xmm27
204%define xmm28x xmm28
205%define xmm29x xmm29
206%define xmm30x xmm30
207%define xmm31x xmm31
208
209%define zmm0y ymm0
210%define zmm1y ymm1
211%define zmm2y ymm2
212%define zmm3y ymm3
213%define zmm4y ymm4
214%define zmm5y ymm5
215%define zmm6y ymm6
216%define zmm7y ymm7
217%define zmm8y ymm8
218%define zmm9y ymm9
219%define zmm10y ymm10
220%define zmm11y ymm11
221%define zmm12y ymm12
222%define zmm13y ymm13
223%define zmm14y ymm14
224%define zmm15y ymm15
225%define zmm16y ymm16
226%define zmm17y ymm17
227%define zmm18y ymm18
228%define zmm19y ymm19
229%define zmm20y ymm20
230%define zmm21y ymm21
231%define zmm22y ymm22
232%define zmm23y ymm23
233%define zmm24y ymm24
234%define zmm25y ymm25
235%define zmm26y ymm26
236%define zmm27y ymm27
237%define zmm28y ymm28
238%define zmm29y ymm29
239%define zmm30y ymm30
240%define zmm31y ymm31
241
242%define xmm0y ymm0
243%define xmm1y ymm1
244%define xmm2y ymm2
245%define xmm3y ymm3
246%define xmm4y ymm4
247%define xmm5y ymm5
248%define xmm6y ymm6
249%define xmm7y ymm7
250%define xmm8y ymm8
251%define xmm9y ymm9
252%define xmm10y ymm10
253%define xmm11y ymm11
254%define xmm12y ymm12
255%define xmm13y ymm13
256%define xmm14y ymm14
257%define xmm15y ymm15
258%define xmm16y ymm16
259%define xmm17y ymm17
260%define xmm18y ymm18
261%define xmm19y ymm19
262%define xmm20y ymm20
263%define xmm21y ymm21
264%define xmm22y ymm22
265%define xmm23y ymm23
266%define xmm24y ymm24
267%define xmm25y ymm25
268%define xmm26y ymm26
269%define xmm27y ymm27
270%define xmm28y ymm28
271%define xmm29y ymm29
272%define xmm30y ymm30
273%define xmm31y ymm31
274
275%define xmm0z zmm0
276%define xmm1z zmm1
277%define xmm2z zmm2
278%define xmm3z zmm3
279%define xmm4z zmm4
280%define xmm5z zmm5
281%define xmm6z zmm6
282%define xmm7z zmm7
283%define xmm8z zmm8
284%define xmm9z zmm9
285%define xmm10z zmm10
286%define xmm11z zmm11
287%define xmm12z zmm12
288%define xmm13z zmm13
289%define xmm14z zmm14
290%define xmm15z zmm15
291%define xmm16z zmm16
292%define xmm17z zmm17
293%define xmm18z zmm18
294%define xmm19z zmm19
295%define xmm20z zmm20
296%define xmm21z zmm21
297%define xmm22z zmm22
298%define xmm23z zmm23
299%define xmm24z zmm24
300%define xmm25z zmm25
301%define xmm26z zmm26
302%define xmm27z zmm27
303%define xmm28z zmm28
304%define xmm29z zmm29
305%define xmm30z zmm30
306%define xmm31z zmm31
307
308%define ymm0z zmm0
309%define ymm1z zmm1
310%define ymm2z zmm2
311%define ymm3z zmm3
312%define ymm4z zmm4
313%define ymm5z zmm5
314%define ymm6z zmm6
315%define ymm7z zmm7
316%define ymm8z zmm8
317%define ymm9z zmm9
318%define ymm10z zmm10
319%define ymm11z zmm11
320%define ymm12z zmm12
321%define ymm13z zmm13
322%define ymm14z zmm14
323%define ymm15z zmm15
324%define ymm16z zmm16
325%define ymm17z zmm17
326%define ymm18z zmm18
327%define ymm19z zmm19
328%define ymm20z zmm20
329%define ymm21z zmm21
330%define ymm22z zmm22
331%define ymm23z zmm23
332%define ymm24z zmm24
333%define ymm25z zmm25
334%define ymm26z zmm26
335%define ymm27z zmm27
336%define ymm28z zmm28
337%define ymm29z zmm29
338%define ymm30z zmm30
339%define ymm31z zmm31
340
341%define DWORD(reg) reg %+ d
342%define WORD(reg)  reg %+ w
343%define BYTE(reg)  reg %+ b
344
345%define XWORD(reg) reg %+ x
346%define YWORD(reg) reg %+ y
347%define ZWORD(reg) reg %+ z
348
349%ifdef INTEL_CET_ENABLED
350 %ifdef __NASM_VER__
351  %if AS_FEATURE_LEVEL >= 10
352   %ifidn __OUTPUT_FORMAT__,elf32
353section .note.gnu.property  note  alloc noexec align=4
354DD 0x00000004,0x0000000c,0x00000005,0x00554e47
355DD 0xc0000002,0x00000004,0x00000003
356   %endif
357   %ifidn __OUTPUT_FORMAT__,elf64
358section .note.gnu.property  note  alloc noexec align=8
359DD 0x00000004,0x00000010,0x00000005,0x00554e47
360DD 0xc0000002,0x00000004,0x00000003,0x00000000
361   %endif
362  %endif
363 %endif
364%endif
365
366%ifidn __OUTPUT_FORMAT__,elf32
367section .note.GNU-stack noalloc noexec nowrite progbits
368section .text
369%endif
370%ifidn __OUTPUT_FORMAT__,elf64
371 %define __x86_64__
372section .note.GNU-stack noalloc noexec nowrite progbits
373section .text
374%endif
375%ifidn __OUTPUT_FORMAT__,win64
376 %define __x86_64__
377%endif
378%ifidn __OUTPUT_FORMAT__,macho64
379 %define __x86_64__
380%endif
381
382%ifdef __x86_64__
383 %define endbranch db 0xf3, 0x0f, 0x1e, 0xfa
384%else
385 %define endbranch db 0xf3, 0x0f, 0x1e, 0xfb
386%endif
387
388%ifdef REL_TEXT
389 %define WRT_OPT
390%elifidn __OUTPUT_FORMAT__, elf64
391 %define WRT_OPT        wrt ..plt
392%else
393 %define WRT_OPT
394%endif
395
396%macro mk_global 1-3
397  %ifdef __NASM_VER__
398    %ifidn __OUTPUT_FORMAT__, macho64
399	global %1
400    %elifidn __OUTPUT_FORMAT__, win64
401	global %1
402    %else
403	global %1:%2 %3
404    %endif
405  %else
406	global %1:%2 %3
407  %endif
408%endmacro
409
410
411; Fixes for nasm lack of MS proc helpers
412%ifdef __NASM_VER__
413  %ifidn __OUTPUT_FORMAT__, win64
414    %macro alloc_stack 1
415	sub	rsp, %1
416    %endmacro
417
418    %macro proc_frame 1
419	%1:
420    %endmacro
421
422    %macro save_xmm128 2
423	movdqa	[rsp + %2], %1
424    %endmacro
425
426    %macro save_reg 2
427	mov	[rsp + %2], %1
428    %endmacro
429
430    %macro rex_push_reg	1
431	push	%1
432    %endmacro
433
434    %macro push_reg 1
435	push	%1
436    %endmacro
437
438    %define end_prolog
439  %endif
440
441  %define endproc_frame
442%endif
443
444%ifidn __OUTPUT_FORMAT__, macho64
445 %define elf64 macho64
446 mac_equ equ 1
447%endif
448
449%macro slversion 4
450	section .text
451	global %1_slver_%2%3%4
452	global %1_slver
453	%1_slver:
454	%1_slver_%2%3%4:
455		dw 0x%4
456		db 0x%3, 0x%2
457%endmacro
458
459%endif ; ifndef _REG_SIZES_ASM_
460