Skip to content

Commit

Permalink
crypto: mips/crc32 - fix the CRC32C implementation
Browse files Browse the repository at this point in the history
Commit ca459e5f826f ("crypto: mips/crc32 - Clean up useless assignment
operations") changed crc32c_mips_le_hw() to use the instructions that
use the "regular" CRC32 polynomial instead of the Castagnoli polynomial.
Therefore it can't be computing CRC32C values correctly anymore.

I haven't been successful in running a MIPS kernel in QEMU, but based on
code review this is the fix that is needed.

Fixes: ca459e5f826f ("crypto: mips/crc32 - Clean up useless assignment operations")
Cc: Guan Wentao <[email protected]>
Cc: WangYuli <[email protected]>
Signed-off-by: Eric Biggers <[email protected]>
Acked-by: Wentao Guan <[email protected]>
Acked-by: WangYuli <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
ebiggers authored and Avenger-285714 committed Nov 2, 2024
1 parent 0dba3bf commit dc8f26e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions arch/mips/crypto/crc32-mips.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,20 @@ static u32 crc32c_mips_le_hw(u32 crc_, const u8 *p, unsigned int len)
for (; len >= sizeof(u64); p += sizeof(u64), len -= sizeof(u64)) {
u64 value = get_unaligned_le64(p);

CRC32(crc, value, d);
CRC32C(crc, value, d);
}

if (len & sizeof(u32)) {
u32 value = get_unaligned_le32(p);

CRC32(crc, value, w);
CRC32C(crc, value, w);
p += sizeof(u32);
}
} else {
for (; len >= sizeof(u32); len -= sizeof(u32)) {
u32 value = get_unaligned_le32(p);

CRC32(crc, value, w);
CRC32C(crc, value, w);
p += sizeof(u32);
}
}
Expand Down

0 comments on commit dc8f26e

Please sign in to comment.