crypto: x86/des3 - Use RIP-relative addressing
authorArd Biesheuvel <ardb@kernel.org>
Wed, 12 Apr 2023 11:00:30 +0000 (13:00 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 20 Apr 2023 10:20:04 +0000 (18:20 +0800)
Prefer RIP-relative addressing where possible, which removes the need
for boot time relocation fixups.

Co-developed-by: Thomas Garnier <thgarnie@chromium.org>
Signed-off-by: Thomas Garnier <thgarnie@chromium.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/x86/crypto/des3_ede-asm_64.S

index f4c760f..cf21b99 100644 (file)
        movzbl RW0bl, RT2d; \
        movzbl RW0bh, RT3d; \
        shrq $16, RW0; \
-       movq s8(, RT0, 8), RT0; \
-       xorq s6(, RT1, 8), to; \
+       leaq s8(%rip), RW1; \
+       movq (RW1, RT0, 8), RT0; \
+       leaq s6(%rip), RW1; \
+       xorq (RW1, RT1, 8), to; \
        movzbl RW0bl, RL1d; \
        movzbl RW0bh, RT1d; \
        shrl $16, RW0d; \
-       xorq s4(, RT2, 8), RT0; \
-       xorq s2(, RT3, 8), to; \
+       leaq s4(%rip), RW1; \
+       xorq (RW1, RT2, 8), RT0; \
+       leaq s2(%rip), RW1; \
+       xorq (RW1, RT3, 8), to; \
        movzbl RW0bl, RT2d; \
        movzbl RW0bh, RT3d; \
-       xorq s7(, RL1, 8), RT0; \
-       xorq s5(, RT1, 8), to; \
-       xorq s3(, RT2, 8), RT0; \
+       leaq s7(%rip), RW1; \
+       xorq (RW1, RL1, 8), RT0; \
+       leaq s5(%rip), RW1; \
+       xorq (RW1, RT1, 8), to; \
+       leaq s3(%rip), RW1; \
+       xorq (RW1, RT2, 8), RT0; \
        load_next_key(n, RW0); \
        xorq RT0, to; \
-       xorq s1(, RT3, 8), to; \
+       leaq s1(%rip), RW1; \
+       xorq (RW1, RT3, 8), to; \
 
 #define load_next_key(n, RWx) \
        movq (((n) + 1) * 8)(CTX), RWx;
@@ -355,65 +363,89 @@ SYM_FUNC_END(des3_ede_x86_64_crypt_blk)
        movzbl RW0bl, RT3d; \
        movzbl RW0bh, RT1d; \
        shrq $16, RW0; \
-       xorq s8(, RT3, 8), to##0; \
-       xorq s6(, RT1, 8), to##0; \
+       leaq s8(%rip), RT2; \
+       xorq (RT2, RT3, 8), to##0; \
+       leaq s6(%rip), RT2; \
+       xorq (RT2, RT1, 8), to##0; \
        movzbl RW0bl, RT3d; \
        movzbl RW0bh, RT1d; \
        shrq $16, RW0; \
-       xorq s4(, RT3, 8), to##0; \
-       xorq s2(, RT1, 8), to##0; \
+       leaq s4(%rip), RT2; \
+       xorq (RT2, RT3, 8), to##0; \
+       leaq s2(%rip), RT2; \
+       xorq (RT2, RT1, 8), to##0; \
        movzbl RW0bl, RT3d; \
        movzbl RW0bh, RT1d; \
        shrl $16, RW0d; \
-       xorq s7(, RT3, 8), to##0; \
-       xorq s5(, RT1, 8), to##0; \
+       leaq s7(%rip), RT2; \
+       xorq (RT2, RT3, 8), to##0; \
+       leaq s5(%rip), RT2; \
+       xorq (RT2, RT1, 8), to##0; \
        movzbl RW0bl, RT3d; \
        movzbl RW0bh, RT1d; \
        load_next_key(n, RW0); \
-       xorq s3(, RT3, 8), to##0; \
-       xorq s1(, RT1, 8), to##0; \
+       leaq s3(%rip), RT2; \
+       xorq (RT2, RT3, 8), to##0; \
+       leaq s1(%rip), RT2; \
+       xorq (RT2, RT1, 8), to##0; \
                xorq from##1, RW1; \
                movzbl RW1bl, RT3d; \
                movzbl RW1bh, RT1d; \
                shrq $16, RW1; \
-               xorq s8(, RT3, 8), to##1; \
-               xorq s6(, RT1, 8), to##1; \
+               leaq s8(%rip), RT2; \
+               xorq (RT2, RT3, 8), to##1; \
+               leaq s6(%rip), RT2; \
+               xorq (RT2, RT1, 8), to##1; \
                movzbl RW1bl, RT3d; \
                movzbl RW1bh, RT1d; \
                shrq $16, RW1; \
-               xorq s4(, RT3, 8), to##1; \
-               xorq s2(, RT1, 8), to##1; \
+               leaq s4(%rip), RT2; \
+               xorq (RT2, RT3, 8), to##1; \
+               leaq s2(%rip), RT2; \
+               xorq (RT2, RT1, 8), to##1; \
                movzbl RW1bl, RT3d; \
                movzbl RW1bh, RT1d; \
                shrl $16, RW1d; \
-               xorq s7(, RT3, 8), to##1; \
-               xorq s5(, RT1, 8), to##1; \
+               leaq s7(%rip), RT2; \
+               xorq (RT2, RT3, 8), to##1; \
+               leaq s5(%rip), RT2; \
+               xorq (RT2, RT1, 8), to##1; \
                movzbl RW1bl, RT3d; \
                movzbl RW1bh, RT1d; \
                do_movq(RW0, RW1); \
-               xorq s3(, RT3, 8), to##1; \
-               xorq s1(, RT1, 8), to##1; \
+               leaq s3(%rip), RT2; \
+               xorq (RT2, RT3, 8), to##1; \
+               leaq s1(%rip), RT2; \
+               xorq (RT2, RT1, 8), to##1; \
                        xorq from##2, RW2; \
                        movzbl RW2bl, RT3d; \
                        movzbl RW2bh, RT1d; \
                        shrq $16, RW2; \
-                       xorq s8(, RT3, 8), to##2; \
-                       xorq s6(, RT1, 8), to##2; \
+                       leaq s8(%rip), RT2; \
+                       xorq (RT2, RT3, 8), to##2; \
+                       leaq s6(%rip), RT2; \
+                       xorq (RT2, RT1, 8), to##2; \
                        movzbl RW2bl, RT3d; \
                        movzbl RW2bh, RT1d; \
                        shrq $16, RW2; \
-                       xorq s4(, RT3, 8), to##2; \
-                       xorq s2(, RT1, 8), to##2; \
+                       leaq s4(%rip), RT2; \
+                       xorq (RT2, RT3, 8), to##2; \
+                       leaq s2(%rip), RT2; \
+                       xorq (RT2, RT1, 8), to##2; \
                        movzbl RW2bl, RT3d; \
                        movzbl RW2bh, RT1d; \
                        shrl $16, RW2d; \
-                       xorq s7(, RT3, 8), to##2; \
-                       xorq s5(, RT1, 8), to##2; \
+                       leaq s7(%rip), RT2; \
+                       xorq (RT2, RT3, 8), to##2; \
+                       leaq s5(%rip), RT2; \
+                       xorq (RT2, RT1, 8), to##2; \
                        movzbl RW2bl, RT3d; \
                        movzbl RW2bh, RT1d; \
                        do_movq(RW0, RW2); \
-                       xorq s3(, RT3, 8), to##2; \
-                       xorq s1(, RT1, 8), to##2;
+                       leaq s3(%rip), RT2; \
+                       xorq (RT2, RT3, 8), to##2; \
+                       leaq s1(%rip), RT2; \
+                       xorq (RT2, RT1, 8), to##2;
 
 #define __movq(src, dst) \
        movq src, dst;