kernel: 5.4: import wireguard backport
[openwrt/openwrt.git] / target / linux / generic / backport-5.4 / 080-wireguard-0064-crypto-poly1305-x86_64-Use-XORL-r32-32.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Uros Bizjak <ubizjak@gmail.com>
3 Date: Thu, 27 Aug 2020 19:38:31 +0200
4 Subject: [PATCH] crypto: poly1305-x86_64 - Use XORL r32,32
5
6 commit 7dfd1e01b3dfc13431b1b25720cf2692a7e111ef upstream.
7
8 x86_64 zero extends 32bit operations, so for 64bit operands,
9 XORL r32,r32 is functionally equal to XORQ r64,r64, but avoids
10 a REX prefix byte when legacy registers are used.
11
12 Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
13 Cc: Herbert Xu <herbert@gondor.apana.org.au>
14 Cc: "David S. Miller" <davem@davemloft.net>
15 Acked-by: Jason A. Donenfeld <Jason@zx2c4.com>
16 Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
17 Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
18 ---
19 arch/x86/crypto/poly1305-x86_64-cryptogams.pl | 8 ++++----
20 1 file changed, 4 insertions(+), 4 deletions(-)
21
22 --- a/arch/x86/crypto/poly1305-x86_64-cryptogams.pl
23 +++ b/arch/x86/crypto/poly1305-x86_64-cryptogams.pl
24 @@ -246,7 +246,7 @@ $code.=<<___ if (!$kernel);
25 ___
26 &declare_function("poly1305_init_x86_64", 32, 3);
27 $code.=<<___;
28 - xor %rax,%rax
29 + xor %eax,%eax
30 mov %rax,0($ctx) # initialize hash value
31 mov %rax,8($ctx)
32 mov %rax,16($ctx)
33 @@ -2869,7 +2869,7 @@ $code.=<<___;
34 .type poly1305_init_base2_44,\@function,3
35 .align 32
36 poly1305_init_base2_44:
37 - xor %rax,%rax
38 + xor %eax,%eax
39 mov %rax,0($ctx) # initialize hash value
40 mov %rax,8($ctx)
41 mov %rax,16($ctx)
42 @@ -3963,7 +3963,7 @@ xor128_decrypt_n_pad:
43 mov \$16,$len
44 sub %r10,$len
45 xor %eax,%eax
46 - xor %r11,%r11
47 + xor %r11d,%r11d
48 .Loop_dec_byte:
49 mov ($inp,$otp),%r11b
50 mov ($otp),%al
51 @@ -4101,7 +4101,7 @@ avx_handler:
52 .long 0xa548f3fc # cld; rep movsq
53
54 mov $disp,%rsi
55 - xor %rcx,%rcx # arg1, UNW_FLAG_NHANDLER
56 + xor %ecx,%ecx # arg1, UNW_FLAG_NHANDLER
57 mov 8(%rsi),%rdx # arg2, disp->ImageBase
58 mov 0(%rsi),%r8 # arg3, disp->ControlPc
59 mov 16(%rsi),%r9 # arg4, disp->FunctionEntry