Skip to content

Commit 5e1a646

Browse files
Mikulas Patockaherbertx
authored andcommitted
crypto: crc32-pclmul - remove useless relative addressing
In 32-bit mode, the x86 architecture can hold full 32-bit pointers. Therefore, the code that copies the current address to the %ecx register and uses %ecx-relative addressing is useless, we could just use absolute addressing. The processors have a stack of return addresses for branch prediction. If we use a call instruction and pop the return address, it desynchronizes the return stack and causes branch prediction misses. This patch also moves the data to the .rodata section. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent c07f7c2 commit 5e1a646

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

‎arch/x86/crypto/crc32-pclmul_asm.S‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <asm/inst.h>
4242

4343

44+
.section .rodata
4445
.align 16
4546
/*
4647
* [x4*128+32 mod P(x) << 32)]' << 1 = 0x154442bd4
@@ -111,19 +112,13 @@ ENTRY(crc32_pclmul_le_16) /* buffer and buffer size are 16 bytes aligned */
111112
pxor CONSTANT, %xmm1
112113
sub $0x40, LEN
113114
add $0x40, BUF
114-
#ifndef __x86_64__
115-
/* This is for position independent code(-fPIC) support for 32bit */
116-
call delta
117-
delta:
118-
pop %ecx
119-
#endif
120115
cmp $0x40, LEN
121116
jb less_64
122117

123118
#ifdef __x86_64__
124119
movdqa .Lconstant_R2R1(%rip), CONSTANT
125120
#else
126-
movdqa .Lconstant_R2R1 - delta(%ecx), CONSTANT
121+
movdqa .Lconstant_R2R1, CONSTANT
127122
#endif
128123

129124
loop_64:/* 64 bytes Full cache line folding */
@@ -172,7 +167,7 @@ less_64:/* Folding cache line into 128bit */
172167
#ifdef __x86_64__
173168
movdqa .Lconstant_R4R3(%rip), CONSTANT
174169
#else
175-
movdqa .Lconstant_R4R3 - delta(%ecx), CONSTANT
170+
movdqa .Lconstant_R4R3, CONSTANT
176171
#endif
177172
prefetchnta (BUF)
178173

@@ -220,8 +215,8 @@ fold_64:
220215
movdqa .Lconstant_R5(%rip), CONSTANT
221216
movdqa .Lconstant_mask32(%rip), %xmm3
222217
#else
223-
movdqa .Lconstant_R5 - delta(%ecx), CONSTANT
224-
movdqa .Lconstant_mask32 - delta(%ecx), %xmm3
218+
movdqa .Lconstant_R5, CONSTANT
219+
movdqa .Lconstant_mask32, %xmm3
225220
#endif
226221
psrldq $0x04, %xmm2
227222
pand %xmm3, %xmm1
@@ -232,7 +227,7 @@ fold_64:
232227
#ifdef __x86_64__
233228
movdqa .Lconstant_RUpoly(%rip), CONSTANT
234229
#else
235-
movdqa .Lconstant_RUpoly - delta(%ecx), CONSTANT
230+
movdqa .Lconstant_RUpoly, CONSTANT
236231
#endif
237232
movdqa %xmm1, %xmm2
238233
pand %xmm3, %xmm1

0 commit comments

Comments
 (0)