Skip to content

Commit cc3cc48

Browse files
Ard Biesheuvelherbertx
Ard Biesheuvel
authored andcommitted
crypto: arm64/aes-blk - ensure XTS mask is always loaded
Commit 2e5d2f3 ("crypto: arm64/aes-blk - improve XTS mask handling") optimized away some reloads of the XTS mask vector, but failed to take into account that calls into the XTS en/decrypt routines will take a slightly different code path if a single block of input is split across different buffers. So let's ensure that the first load occurs unconditionally, and move the reload to the end so it doesn't occur needlessly. Fixes: 2e5d2f3 ("crypto: arm64/aes-blk - improve XTS mask handling") Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 22a8118 commit cc3cc48

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/arm64/crypto/aes-modes.S

+4-4
Original file line numberDiff line numberDiff line change
@@ -359,18 +359,17 @@ AES_ENTRY(aes_xts_encrypt)
359359
mov x29, sp
360360

361361
ld1 {v4.16b}, [x6]
362+
xts_load_mask v8
362363
cbz w7, .Lxtsencnotfirst
363364

364365
enc_prepare w3, x5, x8
365366
encrypt_block v4, w3, x5, x8, w7 /* first tweak */
366367
enc_switch_key w3, x2, x8
367-
xts_load_mask v8
368368
b .LxtsencNx
369369

370370
.Lxtsencnotfirst:
371371
enc_prepare w3, x2, x8
372372
.LxtsencloopNx:
373-
xts_reload_mask v8
374373
next_tweak v4, v4, v8
375374
.LxtsencNx:
376375
subs w4, w4, #4
@@ -391,6 +390,7 @@ AES_ENTRY(aes_xts_encrypt)
391390
st1 {v0.16b-v3.16b}, [x0], #64
392391
mov v4.16b, v7.16b
393392
cbz w4, .Lxtsencout
393+
xts_reload_mask v8
394394
b .LxtsencloopNx
395395
.Lxtsenc1x:
396396
adds w4, w4, #4
@@ -417,18 +417,17 @@ AES_ENTRY(aes_xts_decrypt)
417417
mov x29, sp
418418

419419
ld1 {v4.16b}, [x6]
420+
xts_load_mask v8
420421
cbz w7, .Lxtsdecnotfirst
421422

422423
enc_prepare w3, x5, x8
423424
encrypt_block v4, w3, x5, x8, w7 /* first tweak */
424425
dec_prepare w3, x2, x8
425-
xts_load_mask v8
426426
b .LxtsdecNx
427427

428428
.Lxtsdecnotfirst:
429429
dec_prepare w3, x2, x8
430430
.LxtsdecloopNx:
431-
xts_reload_mask v8
432431
next_tweak v4, v4, v8
433432
.LxtsdecNx:
434433
subs w4, w4, #4
@@ -449,6 +448,7 @@ AES_ENTRY(aes_xts_decrypt)
449448
st1 {v0.16b-v3.16b}, [x0], #64
450449
mov v4.16b, v7.16b
451450
cbz w4, .Lxtsdecout
451+
xts_reload_mask v8
452452
b .LxtsdecloopNx
453453
.Lxtsdec1x:
454454
adds w4, w4, #4

0 commit comments

Comments
 (0)