Skip to content

Commit 3695536

Browse files
ardbiesheuvelherbertx
authored andcommitted
crypto: x86/des3 - Use RIP-relative addressing
Prefer RIP-relative addressing where possible, which removes the need for boot time relocation fixups. Co-developed-by: Thomas Garnier <[email protected]> Signed-off-by: Thomas Garnier <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 3b519dc commit 3695536

File tree

1 file changed

+64
-32
lines changed

1 file changed

+64
-32
lines changed

arch/x86/crypto/des3_ede-asm_64.S

Lines changed: 64 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -129,21 +129,29 @@
129129
movzbl RW0bl, RT2d; \
130130
movzbl RW0bh, RT3d; \
131131
shrq $16, RW0; \
132-
movq s8(, RT0, 8), RT0; \
133-
xorq s6(, RT1, 8), to; \
132+
leaq s8(%rip), RW1; \
133+
movq (RW1, RT0, 8), RT0; \
134+
leaq s6(%rip), RW1; \
135+
xorq (RW1, RT1, 8), to; \
134136
movzbl RW0bl, RL1d; \
135137
movzbl RW0bh, RT1d; \
136138
shrl $16, RW0d; \
137-
xorq s4(, RT2, 8), RT0; \
138-
xorq s2(, RT3, 8), to; \
139+
leaq s4(%rip), RW1; \
140+
xorq (RW1, RT2, 8), RT0; \
141+
leaq s2(%rip), RW1; \
142+
xorq (RW1, RT3, 8), to; \
139143
movzbl RW0bl, RT2d; \
140144
movzbl RW0bh, RT3d; \
141-
xorq s7(, RL1, 8), RT0; \
142-
xorq s5(, RT1, 8), to; \
143-
xorq s3(, RT2, 8), RT0; \
145+
leaq s7(%rip), RW1; \
146+
xorq (RW1, RL1, 8), RT0; \
147+
leaq s5(%rip), RW1; \
148+
xorq (RW1, RT1, 8), to; \
149+
leaq s3(%rip), RW1; \
150+
xorq (RW1, RT2, 8), RT0; \
144151
load_next_key(n, RW0); \
145152
xorq RT0, to; \
146-
xorq s1(, RT3, 8), to; \
153+
leaq s1(%rip), RW1; \
154+
xorq (RW1, RT3, 8), to; \
147155

148156
#define load_next_key(n, RWx) \
149157
movq (((n) + 1) * 8)(CTX), RWx;
@@ -355,65 +363,89 @@ SYM_FUNC_END(des3_ede_x86_64_crypt_blk)
355363
movzbl RW0bl, RT3d; \
356364
movzbl RW0bh, RT1d; \
357365
shrq $16, RW0; \
358-
xorq s8(, RT3, 8), to##0; \
359-
xorq s6(, RT1, 8), to##0; \
366+
leaq s8(%rip), RT2; \
367+
xorq (RT2, RT3, 8), to##0; \
368+
leaq s6(%rip), RT2; \
369+
xorq (RT2, RT1, 8), to##0; \
360370
movzbl RW0bl, RT3d; \
361371
movzbl RW0bh, RT1d; \
362372
shrq $16, RW0; \
363-
xorq s4(, RT3, 8), to##0; \
364-
xorq s2(, RT1, 8), to##0; \
373+
leaq s4(%rip), RT2; \
374+
xorq (RT2, RT3, 8), to##0; \
375+
leaq s2(%rip), RT2; \
376+
xorq (RT2, RT1, 8), to##0; \
365377
movzbl RW0bl, RT3d; \
366378
movzbl RW0bh, RT1d; \
367379
shrl $16, RW0d; \
368-
xorq s7(, RT3, 8), to##0; \
369-
xorq s5(, RT1, 8), to##0; \
380+
leaq s7(%rip), RT2; \
381+
xorq (RT2, RT3, 8), to##0; \
382+
leaq s5(%rip), RT2; \
383+
xorq (RT2, RT1, 8), to##0; \
370384
movzbl RW0bl, RT3d; \
371385
movzbl RW0bh, RT1d; \
372386
load_next_key(n, RW0); \
373-
xorq s3(, RT3, 8), to##0; \
374-
xorq s1(, RT1, 8), to##0; \
387+
leaq s3(%rip), RT2; \
388+
xorq (RT2, RT3, 8), to##0; \
389+
leaq s1(%rip), RT2; \
390+
xorq (RT2, RT1, 8), to##0; \
375391
xorq from##1, RW1; \
376392
movzbl RW1bl, RT3d; \
377393
movzbl RW1bh, RT1d; \
378394
shrq $16, RW1; \
379-
xorq s8(, RT3, 8), to##1; \
380-
xorq s6(, RT1, 8), to##1; \
395+
leaq s8(%rip), RT2; \
396+
xorq (RT2, RT3, 8), to##1; \
397+
leaq s6(%rip), RT2; \
398+
xorq (RT2, RT1, 8), to##1; \
381399
movzbl RW1bl, RT3d; \
382400
movzbl RW1bh, RT1d; \
383401
shrq $16, RW1; \
384-
xorq s4(, RT3, 8), to##1; \
385-
xorq s2(, RT1, 8), to##1; \
402+
leaq s4(%rip), RT2; \
403+
xorq (RT2, RT3, 8), to##1; \
404+
leaq s2(%rip), RT2; \
405+
xorq (RT2, RT1, 8), to##1; \
386406
movzbl RW1bl, RT3d; \
387407
movzbl RW1bh, RT1d; \
388408
shrl $16, RW1d; \
389-
xorq s7(, RT3, 8), to##1; \
390-
xorq s5(, RT1, 8), to##1; \
409+
leaq s7(%rip), RT2; \
410+
xorq (RT2, RT3, 8), to##1; \
411+
leaq s5(%rip), RT2; \
412+
xorq (RT2, RT1, 8), to##1; \
391413
movzbl RW1bl, RT3d; \
392414
movzbl RW1bh, RT1d; \
393415
do_movq(RW0, RW1); \
394-
xorq s3(, RT3, 8), to##1; \
395-
xorq s1(, RT1, 8), to##1; \
416+
leaq s3(%rip), RT2; \
417+
xorq (RT2, RT3, 8), to##1; \
418+
leaq s1(%rip), RT2; \
419+
xorq (RT2, RT1, 8), to##1; \
396420
xorq from##2, RW2; \
397421
movzbl RW2bl, RT3d; \
398422
movzbl RW2bh, RT1d; \
399423
shrq $16, RW2; \
400-
xorq s8(, RT3, 8), to##2; \
401-
xorq s6(, RT1, 8), to##2; \
424+
leaq s8(%rip), RT2; \
425+
xorq (RT2, RT3, 8), to##2; \
426+
leaq s6(%rip), RT2; \
427+
xorq (RT2, RT1, 8), to##2; \
402428
movzbl RW2bl, RT3d; \
403429
movzbl RW2bh, RT1d; \
404430
shrq $16, RW2; \
405-
xorq s4(, RT3, 8), to##2; \
406-
xorq s2(, RT1, 8), to##2; \
431+
leaq s4(%rip), RT2; \
432+
xorq (RT2, RT3, 8), to##2; \
433+
leaq s2(%rip), RT2; \
434+
xorq (RT2, RT1, 8), to##2; \
407435
movzbl RW2bl, RT3d; \
408436
movzbl RW2bh, RT1d; \
409437
shrl $16, RW2d; \
410-
xorq s7(, RT3, 8), to##2; \
411-
xorq s5(, RT1, 8), to##2; \
438+
leaq s7(%rip), RT2; \
439+
xorq (RT2, RT3, 8), to##2; \
440+
leaq s5(%rip), RT2; \
441+
xorq (RT2, RT1, 8), to##2; \
412442
movzbl RW2bl, RT3d; \
413443
movzbl RW2bh, RT1d; \
414444
do_movq(RW0, RW2); \
415-
xorq s3(, RT3, 8), to##2; \
416-
xorq s1(, RT1, 8), to##2;
445+
leaq s3(%rip), RT2; \
446+
xorq (RT2, RT3, 8), to##2; \
447+
leaq s1(%rip), RT2; \
448+
xorq (RT2, RT1, 8), to##2;
417449

418450
#define __movq(src, dst) \
419451
movq src, dst;

0 commit comments

Comments
 (0)