Skip to content

Commit 41022ef

Browse files
pcercueitsbogend
authored andcommitted
MIPS: crypto: Fix CRC32 code
Commit 67512a8 ("MIPS: Avoid macro redefinitions") changed how the MIPS register macros were defined, in order to allow the code to compile under LLVM/Clang. The MIPS CRC32 code however wasn't updated accordingly, causing a build bug when using a MIPS32r6 toolchain without CRC support. Update the CRC32 code to use the macros correctly, to fix the build failures. Fixes: 67512a8 ("MIPS: Avoid macro redefinitions") Cc: <[email protected]> Signed-off-by: Paul Cercueil <[email protected]> Reported-by: kernel test robot <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent bf64f7f commit 41022ef

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

arch/mips/crypto/crc32-mips.c

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ enum crc_type {
2828
};
2929

3030
#ifndef TOOLCHAIN_SUPPORTS_CRC
31-
#define _ASM_MACRO_CRC32(OP, SZ, TYPE) \
31+
#define _ASM_SET_CRC(OP, SZ, TYPE) \
3232
_ASM_MACRO_3R(OP, rt, rs, rt2, \
3333
".ifnc \\rt, \\rt2\n\t" \
3434
".error \"invalid operands \\\"" #OP " \\rt,\\rs,\\rt2\\\"\"\n\t" \
@@ -37,30 +37,36 @@ _ASM_MACRO_3R(OP, rt, rs, rt2, \
3737
((SZ) << 6) | ((TYPE) << 8)) \
3838
_ASM_INSN32_IF_MM(0x00000030 | (__rs << 16) | (__rt << 21) | \
3939
((SZ) << 14) | ((TYPE) << 3)))
40-
_ASM_MACRO_CRC32(crc32b, 0, 0);
41-
_ASM_MACRO_CRC32(crc32h, 1, 0);
42-
_ASM_MACRO_CRC32(crc32w, 2, 0);
43-
_ASM_MACRO_CRC32(crc32d, 3, 0);
44-
_ASM_MACRO_CRC32(crc32cb, 0, 1);
45-
_ASM_MACRO_CRC32(crc32ch, 1, 1);
46-
_ASM_MACRO_CRC32(crc32cw, 2, 1);
47-
_ASM_MACRO_CRC32(crc32cd, 3, 1);
48-
#define _ASM_SET_CRC ""
40+
#define _ASM_UNSET_CRC(op, SZ, TYPE) ".purgem " #op "\n\t"
4941
#else /* !TOOLCHAIN_SUPPORTS_CRC */
50-
#define _ASM_SET_CRC ".set\tcrc\n\t"
42+
#define _ASM_SET_CRC(op, SZ, TYPE) ".set\tcrc\n\t"
43+
#define _ASM_UNSET_CRC(op, SZ, TYPE)
5144
#endif
5245

53-
#define _CRC32(crc, value, size, type) \
54-
do { \
55-
__asm__ __volatile__( \
56-
".set push\n\t" \
57-
_ASM_SET_CRC \
58-
#type #size " %0, %1, %0\n\t" \
59-
".set pop" \
60-
: "+r" (crc) \
61-
: "r" (value)); \
46+
#define __CRC32(crc, value, op, SZ, TYPE) \
47+
do { \
48+
__asm__ __volatile__( \
49+
".set push\n\t" \
50+
_ASM_SET_CRC(op, SZ, TYPE) \
51+
#op " %0, %1, %0\n\t" \
52+
_ASM_UNSET_CRC(op, SZ, TYPE) \
53+
".set pop" \
54+
: "+r" (crc) \
55+
: "r" (value)); \
6256
} while (0)
6357

58+
#define _CRC32_crc32b(crc, value) __CRC32(crc, value, crc32b, 0, 0)
59+
#define _CRC32_crc32h(crc, value) __CRC32(crc, value, crc32h, 1, 0)
60+
#define _CRC32_crc32w(crc, value) __CRC32(crc, value, crc32w, 2, 0)
61+
#define _CRC32_crc32d(crc, value) __CRC32(crc, value, crc32d, 3, 0)
62+
#define _CRC32_crc32cb(crc, value) __CRC32(crc, value, crc32cb, 0, 1)
63+
#define _CRC32_crc32ch(crc, value) __CRC32(crc, value, crc32ch, 1, 1)
64+
#define _CRC32_crc32cw(crc, value) __CRC32(crc, value, crc32cw, 2, 1)
65+
#define _CRC32_crc32cd(crc, value) __CRC32(crc, value, crc32cd, 3, 1)
66+
67+
#define _CRC32(crc, value, size, op) \
68+
_CRC32_##op##size(crc, value)
69+
6470
#define CRC32(crc, value, size) \
6571
_CRC32(crc, value, size, crc32)
6672

0 commit comments

Comments
 (0)