Skip to contentSkip to conversation

crypto: mips/crc32 - fix the CRC32C implementation

PATCH In review Eric Biggers 4 participants 4 messages Oct 20, 2024 – Oct 26, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: mips/crc32 - fix the CRC32C implementation

From: Eric Biggers <[email protected]>

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]>

---

This is a regression in 6.12, so it should be fixed in a 6.12-rc.

 arch/mips/crypto/crc32-mips.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/mips/crypto/crc32-mips.c +3 -3
index a7a1d43a1b2ca..90eacf00cfc31 100644
@@ -121,24 +121,24 @@ static u32 crc32c_mips_le_hw(u32 crc_, const u8 *p, unsigned int len)
 
 	if (IS_ENABLED(CONFIG_64BIT)) {
 		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);
 		}
 	}
 
 	if (len & sizeof(u16)) {

base-commit: 7fa4be6d6752512278c4cbf2d2745568626e7369

Signature · 1 line
2.47.0
Acked-by on v1 1/1
#2 lore raw
In reply to Eric Biggers
Quoted 54 lines · Eric Biggers

From: Eric Biggers <[email protected]>

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]>

---

This is a regression in 6.12, so it should be fixed in a 6.12-rc.

  arch/mips/crypto/crc32-mips.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
arch/mips/crypto/crc32-mips.c +3 -3
index a7a1d43a1b2ca..90eacf00cfc31 100644
@@ -121,24 +121,24 @@ static u32 crc32c_mips_le_hw(u32 crc_, const u8 *p, unsigned int len)
 
  	if (IS_ENABLED(CONFIG_64BIT)) {
  		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);
  		}
  	}
 
  	if (len & sizeof(u16)) {
Quoted 1 line

base-commit: 7fa4be6d6752512278c4cbf2d2745568626e7369

Ah...I apologize for the oversight that introduced this bug...And it's indeed a necessary fix. Thanks,

Signature · 1 line
WangYuli
maintainer
#3 lore raw
In reply to Eric Biggers
Quoted 14 lines · Eric Biggers

From: Eric Biggers <[email protected]>

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]>
Quoted 6 lines

---

This is a regression in 6.12, so it should be fixed in a 6.12-rc.

arch/mips/crypto/crc32-mips.c | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt