Skip to content

Commit 1e6b72e

Browse files
committed
x86/crc32: update prototype for crc32_pclmul_le_16()
- Change the len parameter from unsigned int to size_t, so that the library function which takes a size_t can safely use this code. - Move the crc parameter to the front, as this is the usual convention. Reviewed-by: Ard Biesheuvel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Eric Biggers <[email protected]>
1 parent 64e3586 commit 1e6b72e

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

arch/x86/crypto/crc32-pclmul_asm.S

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,26 +58,25 @@
5858
#define CONSTANT %xmm0
5959

6060
#ifdef __x86_64__
61-
#define BUF %rdi
62-
#define LEN %rsi
63-
#define CRC %edx
61+
#define CRC %edi
62+
#define BUF %rsi
63+
#define LEN %rdx
6464
#else
65-
#define BUF %eax
66-
#define LEN %edx
67-
#define CRC %ecx
65+
#define CRC %eax
66+
#define BUF %edx
67+
#define LEN %ecx
6868
#endif
6969

7070

7171

7272
.text
7373
/**
7474
* Calculate crc32
75-
* BUF - buffer (16 bytes aligned)
76-
* LEN - sizeof buffer (16 bytes aligned), LEN should be grater than 63
7775
* CRC - initial crc32
76+
* BUF - buffer (16 bytes aligned)
77+
* LEN - sizeof buffer (16 bytes aligned), LEN should be greater than 63
7878
* return %eax crc32
79-
* uint crc32_pclmul_le_16(unsigned char const *buffer,
80-
* size_t len, uint crc32)
79+
* u32 crc32_pclmul_le_16(u32 crc, const u8 *buffer, size_t len);
8180
*/
8281

8382
SYM_FUNC_START(crc32_pclmul_le_16) /* buffer and buffer size are 16 bytes aligned */

arch/x86/crypto/crc32-pclmul_glue.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
#define SCALE_F 16L /* size of xmm register */
4747
#define SCALE_F_MASK (SCALE_F - 1)
4848

49-
u32 crc32_pclmul_le_16(unsigned char const *buffer, size_t len, u32 crc32);
49+
u32 crc32_pclmul_le_16(u32 crc, const u8 *buffer, size_t len);
5050

5151
static u32 __attribute__((pure))
5252
crc32_pclmul_le(u32 crc, unsigned char const *p, size_t len)
@@ -71,7 +71,7 @@ static u32 __attribute__((pure))
7171
iremainder = len & SCALE_F_MASK;
7272

7373
kernel_fpu_begin();
74-
crc = crc32_pclmul_le_16(p, iquotient, crc);
74+
crc = crc32_pclmul_le_16(crc, p, iquotient);
7575
kernel_fpu_end();
7676

7777
if (iremainder)

0 commit comments

Comments
 (0)