summaryrefslogtreecommitdiffstats
path: root/CryptoPkg/Library/OpensslLib/X64Gcc/crypto/aes/aesni-mb-x86_64.S
blob: 7749fd685a27551c45d2c5a0bf970e5380dc8571 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
# WARNING: do not edit!
# Generated from openssl/crypto/aes/asm/aesni-mb-x86_64.pl
#
# Copyright 2013-2020 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License").  You may not use
# this file except in compliance with the License.  You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html

.text



.globl  aesni_multi_cbc_encrypt
.type   aesni_multi_cbc_encrypt,@function
.align  32
aesni_multi_cbc_encrypt:
.cfi_startproc
        movq    %rsp,%rax
.cfi_def_cfa_register   %rax
        pushq   %rbx
.cfi_offset     %rbx,-16
        pushq   %rbp
.cfi_offset     %rbp,-24
        pushq   %r12
.cfi_offset     %r12,-32
        pushq   %r13
.cfi_offset     %r13,-40
        pushq   %r14
.cfi_offset     %r14,-48
        pushq   %r15
.cfi_offset     %r15,-56






        subq    $48,%rsp
        andq    $-64,%rsp
        movq    %rax,16(%rsp)
.cfi_escape     0x0f,0x05,0x77,0x10,0x06,0x23,0x08

.Lenc4x_body:
        movdqu  (%rsi),%xmm12
        leaq    120(%rsi),%rsi
        leaq    80(%rdi),%rdi

.Lenc4x_loop_grande:
        movl    %edx,24(%rsp)
        xorl    %edx,%edx
        movl    -64(%rdi),%ecx
        movq    -80(%rdi),%r8
        cmpl    %edx,%ecx
        movq    -72(%rdi),%r12
        cmovgl  %ecx,%edx
        testl   %ecx,%ecx
        movdqu  -56(%rdi),%xmm2
        movl    %ecx,32(%rsp)
        cmovleq %rsp,%r8
        movl    -24(%rdi),%ecx
        movq    -40(%rdi),%r9
        cmpl    %edx,%ecx
        movq    -32(%rdi),%r13
        cmovgl  %ecx,%edx
        testl   %ecx,%ecx
        movdqu  -16(%rdi),%xmm3
        movl    %ecx,36(%rsp)
        cmovleq %rsp,%r9
        movl    16(%rdi),%ecx
        movq    0(%rdi),%r10
        cmpl    %edx,%ecx
        movq    8(%rdi),%r14
        cmovgl  %ecx,%edx
        testl   %ecx,%ecx
        movdqu  24(%rdi),%xmm4
        movl    %ecx,40(%rsp)
        cmovleq %rsp,%r10
        movl    56(%rdi),%ecx
        movq    40(%rdi),%r11
        cmpl    %edx,%ecx
        movq    48(%rdi),%r15
        cmovgl  %ecx,%edx
        testl   %ecx,%ecx
        movdqu  64(%rdi),%xmm5
        movl    %ecx,44(%rsp)
        cmovleq %rsp,%r11
        testl   %edx,%edx
        jz      .Lenc4x_done

        movups  16-120(%rsi),%xmm1
        pxor    %xmm12,%xmm2
        movups  32-120(%rsi),%xmm0
        pxor    %xmm12,%xmm3
        movl    240-120(%rsi),%eax
        pxor    %xmm12,%xmm4
        movdqu  (%r8),%xmm6
        pxor    %xmm12,%xmm5
        movdqu  (%r9),%xmm7
        pxor    %xmm6,%xmm2
        movdqu  (%r10),%xmm8
        pxor    %xmm7,%xmm3
        movdqu  (%r11),%xmm9
        pxor    %xmm8,%xmm4
        pxor    %xmm9,%xmm5
        movdqa  32(%rsp),%xmm10
        xorq    %rbx,%rbx
        jmp     .Loop_enc4x

.align  32
.Loop_enc4x:
        addq    $16,%rbx
        leaq    16(%rsp),%rbp
        movl    $1,%ecx
        subq    %rbx,%rbp

.byte   102,15,56,220,209
        prefetcht0      31(%r8,%rbx,1)
        prefetcht0      31(%r9,%rbx,1)
.byte   102,15,56,220,217
        prefetcht0      31(%r10,%rbx,1)
        prefetcht0      31(%r10,%rbx,1)
.byte   102,15,56,220,225
.byte   102,15,56,220,233
        movups  48-120(%rsi),%xmm1
        cmpl    32(%rsp),%ecx
.byte   102,15,56,220,208
.byte   102,15,56,220,216
.byte   102,15,56,220,224
        cmovgeq %rbp,%r8
        cmovgq  %rbp,%r12
.byte   102,15,56,220,232
        movups  -56(%rsi),%xmm0
        cmpl    36(%rsp),%ecx
.byte   102,15,56,220,209
.byte   102,15,56,220,217
.byte   102,15,56,220,225
        cmovgeq %rbp,%r9
        cmovgq  %rbp,%r13
.byte   102,15,56,220,233
        movups  -40(%rsi),%xmm1
        cmpl    40(%rsp),%ecx
.byte   102,15,56,220,208
.byte   102,15,56,220,216
.byte   102,15,56,220,224
        cmovgeq %rbp,%r10
        cmovgq  %rbp,%r14
.byte   102,15,56,220,232
        movups  -24(%rsi),%xmm0
        cmpl    44(%rsp),%ecx
.byte   102,15,56,220,209
.byte   102,15,56,220,217
.byte   102,15,56,220,225
        cmovgeq %rbp,%r11
        cmovgq  %rbp,%r15
.byte   102,15,56,220,233
        movups  -8(%rsi),%xmm1
        movdqa  %xmm10,%xmm11
.byte   102,15,56,220,208
        prefetcht0      15(%r12,%rbx,1)
        prefetcht0      15(%r13,%rbx,1)
.byte   102,15,56,220,216
        prefetcht0      15(%r14,%rbx,1)
        prefetcht0      15(%r15,%rbx,1)
.byte   102,15,56,220,224
.byte   102,15,56,220,232
        movups  128-120(%rsi),%xmm0
        pxor    %xmm12,%xmm12

.byte   102,15,56,220,209
        pcmpgtd %xmm12,%xmm11
        movdqu  -120(%rsi),%xmm12
.byte   102,15,56,220,217
        paddd   %xmm11,%xmm10
        movdqa  %xmm10,32(%rsp)
.byte   102,15,56,220,225
.byte   102,15,56,220,233
        movups  144-120(%rsi),%xmm1

        cmpl    $11,%eax

.byte   102,15,56,220,208
.byte   102,15,56,220,216
.byte   102,15,56,220,224
.byte   102,15,56,220,232
        movups  160-120(%rsi),%xmm0

        jb      .Lenc4x_tail

.byte   102,15,56,220,209
.byte   102,15,56,220,217
.byte   102,15,56,220,225
.byte   102,15,56,220,233
        movups  176-120(%rsi),%xmm1

.byte   102,15,56,220,208
.byte   102,15,56,220,216
.byte   102,15,56,220,224
.byte   102,15,56,220,232
        movups  192-120(%rsi),%xmm0

        je      .Lenc4x_tail

.byte   102,15,56,220,209
.byte   102,15,56,220,217
.byte   102,15,56,220,225
.byte   102,15,56,220,233
        movups  208-120(%rsi),%xmm1

.byte   102,15,56,220,208
.byte   102,15,56,220,216
.byte   102,15,56,220,224
.byte   102,15,56,220,232
        movups  224-120(%rsi),%xmm0
        jmp     .Lenc4x_tail

.align  32
.Lenc4x_tail:
.byte   102,15,56,220,209
.byte   102,15,56,220,217
.byte   102,15,56,220,225
.byte   102,15,56,220,233
        movdqu  (%r8,%rbx,1),%xmm6
        movdqu  16-120(%rsi),%xmm1

.byte   102,15,56,221,208
        movdqu  (%r9,%rbx,1),%xmm7
        pxor    %xmm12,%xmm6
.byte   102,15,56,221,216
        movdqu  (%r10,%rbx,1),%xmm8
        pxor    %xmm12,%xmm7
.byte   102,15,56,221,224
        movdqu  (%r11,%rbx,1),%xmm9
        pxor    %xmm12,%xmm8
.byte   102,15,56,221,232
        movdqu  32-120(%rsi),%xmm0
        pxor    %xmm12,%xmm9

        movups  %xmm2,-16(%r12,%rbx,1)
        pxor    %xmm6,%xmm2
        movups  %xmm3,-16(%r13,%rbx,1)
        pxor    %xmm7,%xmm3
        movups  %xmm4,-16(%r14,%rbx,1)
        pxor    %xmm8,%xmm4
        movups  %xmm5,-16(%r15,%rbx,1)
        pxor    %xmm9,%xmm5

        decl    %edx
        jnz     .Loop_enc4x

        movq    16(%rsp),%rax
.cfi_def_cfa    %rax,8
        movl    24(%rsp),%edx










        leaq    160(%rdi),%rdi
        decl    %edx
        jnz     .Lenc4x_loop_grande

.Lenc4x_done:
        movq    -48(%rax),%r15
.cfi_restore    %r15
        movq    -40(%rax),%r14
.cfi_restore    %r14
        movq    -32(%rax),%r13
.cfi_restore    %r13
        movq    -24(%rax),%r12
.cfi_restore    %r12
        movq    -16(%rax),%rbp
.cfi_restore    %rbp
        movq    -8(%rax),%rbx
.cfi_restore    %rbx
        leaq    (%rax),%rsp
.cfi_def_cfa_register   %rsp
.Lenc4x_epilogue:
        .byte   0xf3,0xc3
.cfi_endproc
.size   aesni_multi_cbc_encrypt,.-aesni_multi_cbc_encrypt

.globl  aesni_multi_cbc_decrypt
.type   aesni_multi_cbc_decrypt,@function
.align  32
aesni_multi_cbc_decrypt:
.cfi_startproc
        movq    %rsp,%rax
.cfi_def_cfa_register   %rax
        pushq   %rbx
.cfi_offset     %rbx,-16
        pushq   %rbp
.cfi_offset     %rbp,-24
        pushq   %r12
.cfi_offset     %r12,-32
        pushq   %r13
.cfi_offset     %r13,-40
        pushq   %r14
.cfi_offset     %r14,-48
        pushq   %r15
.cfi_offset     %r15,-56






        subq    $48,%rsp
        andq    $-64,%rsp
        movq    %rax,16(%rsp)
.cfi_escape     0x0f,0x05,0x77,0x10,0x06,0x23,0x08

.Ldec4x_body:
        movdqu  (%rsi),%xmm12
        leaq    120(%rsi),%rsi
        leaq    80(%rdi),%rdi

.Ldec4x_loop_grande:
        movl    %edx,24(%rsp)
        xorl    %edx,%edx
        movl    -64(%rdi),%ecx
        movq    -80(%rdi),%r8
        cmpl    %edx,%ecx
        movq    -72(%rdi),%r12
        cmovgl  %ecx,%edx
        testl   %ecx,%ecx
        movdqu  -56(%rdi),%xmm6
        movl    %ecx,32(%rsp)
        cmovleq %rsp,%r8
        movl    -24(%rdi),%ecx
        movq    -40(%rdi),%r9
        cmpl    %edx,%ecx
        movq    -32(%rdi),%r13
        cmovgl  %ecx,%edx
        testl   %ecx,%ecx
        movdqu  -16(%rdi),%xmm7
        movl    %ecx,36(%rsp)
        cmovleq %rsp,%r9
        movl    16(%rdi),%ecx
        movq    0(%rdi),%r10
        cmpl    %edx,%ecx
        movq    8(%rdi),%r14
        cmovgl  %ecx,%edx
        testl   %ecx,%ecx
        movdqu  24(%rdi),%xmm8
        movl    %ecx,40(%rsp)
        cmovleq %rsp,%r10
        movl    56(%rdi),%ecx
        movq    40(%rdi),%r11
        cmpl    %edx,%ecx
        movq    48(%rdi),%r15
        cmovgl  %ecx,%edx
        testl   %ecx,%ecx
        movdqu  64(%rdi),%xmm9
        movl    %ecx,44(%rsp)
        cmovleq %rsp,%r11
        testl   %edx,%edx
        jz      .Ldec4x_done

        movups  16-120(%rsi),%xmm1
        movups  32-120(%rsi),%xmm0
        movl    240-120(%rsi),%eax
        movdqu  (%r8),%xmm2
        movdqu  (%r9),%xmm3
        pxor    %xmm12,%xmm2
        movdqu  (%r10),%xmm4
        pxor    %xmm12,%xmm3
        movdqu  (%r11),%xmm5
        pxor    %xmm12,%xmm4
        pxor    %xmm12,%xmm5
        movdqa  32(%rsp),%xmm10
        xorq    %rbx,%rbx
        jmp     .Loop_dec4x

.align  32
.Loop_dec4x:
        addq    $16,%rbx
        leaq    16(%rsp),%rbp
        movl    $1,%ecx
        subq    %rbx,%rbp

.byte   102,15,56,222,209
        prefetcht0      31(%r8,%rbx,1)
        prefetcht0      31(%r9,%rbx,1)
.byte   102,15,56,222,217
        prefetcht0      31(%r10,%rbx,1)
        prefetcht0      31(%r11,%rbx,1)
.byte   102,15,56,222,225
.byte   102,15,56,222,233
        movups  48-120(%rsi),%xmm1
        cmpl    32(%rsp),%ecx
.byte   102,15,56,222,208
.byte   102,15,56,222,216
.byte   102,15,56,222,224
        cmovgeq %rbp,%r8
        cmovgq  %rbp,%r12
.byte   102,15,56,222,232
        movups  -56(%rsi),%xmm0
        cmpl    36(%rsp),%ecx
.byte   102,15,56,222,209
.byte   102,15,56,222,217
.byte   102,15,56,222,225
        cmovgeq %rbp,%r9
        cmovgq  %rbp,%r13
.byte   102,15,56,222,233
        movups  -40(%rsi),%xmm1
        cmpl    40(%rsp),%ecx
.byte   102,15,56,222,208
.byte   102,15,56,222,216
.byte   102,15,56,222,224
        cmovgeq %rbp,%r10
        cmovgq  %rbp,%r14
.byte   102,15,56,222,232
        movups  -24(%rsi),%xmm0
        cmpl    44(%rsp),%ecx
.byte   102,15,56,222,209
.byte   102,15,56,222,217
.byte   102,15,56,222,225
        cmovgeq %rbp,%r11
        cmovgq  %rbp,%r15
.byte   102,15,56,222,233
        movups  -8(%rsi),%xmm1
        movdqa  %xmm10,%xmm11
.byte   102,15,56,222,208
        prefetcht0      15(%r12,%rbx,1)
        prefetcht0      15(%r13,%rbx,1)
.byte   102,15,56,222,216
        prefetcht0      15(%r14,%rbx,1)
        prefetcht0      15(%r15,%rbx,1)
.byte   102,15,56,222,224
.byte   102,15,56,222,232
        movups  128-120(%rsi),%xmm0
        pxor    %xmm12,%xmm12

.byte   102,15,56,222,209
        pcmpgtd %xmm12,%xmm11
        movdqu  -120(%rsi),%xmm12
.byte   102,15,56,222,217
        paddd   %xmm11,%xmm10
        movdqa  %xmm10,32(%rsp)
.byte   102,15,56,222,225
.byte   102,15,56,222,233
        movups  144-120(%rsi),%xmm1

        cmpl    $11,%eax

.byte   102,15,56,222,208
.byte   102,15,56,222,216
.byte   102,15,56,222,224
.byte   102,15,56,222,232
        movups  160-120(%rsi),%xmm0

        jb      .Ldec4x_tail

.byte   102,15,56,222,209
.byte   102,15,56,222,217
.byte   102,15,56,222,225
.byte   102,15,56,222,233
        movups  176-120(%rsi),%xmm1

.byte   102,15,56,222,208
.byte   102,15,56,222,216
.byte   102,15,56,222,224
.byte   102,15,56,222,232
        movups  192-120(%rsi),%xmm0

        je      .Ldec4x_tail

.byte   102,15,56,222,209
.byte   102,15,56,222,217
.byte   102,15,56,222,225
.byte   102,15,56,222,233
        movups  208-120(%rsi),%xmm1

.byte   102,15,56,222,208
.byte   102,15,56,222,216
.byte   102,15,56,222,224
.byte   102,15,56,222,232
        movups  224-120(%rsi),%xmm0
        jmp     .Ldec4x_tail

.align  32
.Ldec4x_tail:
.byte   102,15,56,222,209
.byte   102,15,56,222,217
.byte   102,15,56,222,225
        pxor    %xmm0,%xmm6
        pxor    %xmm0,%xmm7
.byte   102,15,56,222,233
        movdqu  16-120(%rsi),%xmm1
        pxor    %xmm0,%xmm8
        pxor    %xmm0,%xmm9
        movdqu  32-120(%rsi),%xmm0

.byte   102,15,56,223,214
.byte   102,15,56,223,223
        movdqu  -16(%r8,%rbx,1),%xmm6
        movdqu  -16(%r9,%rbx,1),%xmm7
.byte   102,65,15,56,223,224
.byte   102,65,15,56,223,233
        movdqu  -16(%r10,%rbx,1),%xmm8
        movdqu  -16(%r11,%rbx,1),%xmm9

        movups  %xmm2,-16(%r12,%rbx,1)
        movdqu  (%r8,%rbx,1),%xmm2
        movups  %xmm3,-16(%r13,%rbx,1)
        movdqu  (%r9,%rbx,1),%xmm3
        pxor    %xmm12,%xmm2
        movups  %xmm4,-16(%r14,%rbx,1)
        movdqu  (%r10,%rbx,1),%xmm4
        pxor    %xmm12,%xmm3
        movups  %xmm5,-16(%r15,%rbx,1)
        movdqu  (%r11,%rbx,1),%xmm5
        pxor    %xmm12,%xmm4
        pxor    %xmm12,%xmm5

        decl    %edx
        jnz     .Loop_dec4x

        movq    16(%rsp),%rax
.cfi_def_cfa    %rax,8
        movl    24(%rsp),%edx

        leaq    160(%rdi),%rdi
        decl    %edx
        jnz     .Ldec4x_loop_grande

.Ldec4x_done:
        movq    -48(%rax),%r15
.cfi_restore    %r15
        movq    -40(%rax),%r14
.cfi_restore    %r14
        movq    -32(%rax),%r13
.cfi_restore    %r13
        movq    -24(%rax),%r12
.cfi_restore    %r12
        movq    -16(%rax),%rbp
.cfi_restore    %rbp
        movq    -8(%rax),%rbx
.cfi_restore    %rbx
        leaq    (%rax),%rsp
.cfi_def_cfa_register   %rsp
.Ldec4x_epilogue:
        .byte   0xf3,0xc3
.cfi_endproc
.size   aesni_multi_cbc_decrypt,.-aesni_multi_cbc_decrypt