Skip to content

Commit c5cdfdf

Browse files
jbeulichH. Peter Anvin
authored andcommitted
x86, hash: Swap arguments passed to crc32_u32()
... to match the function's parameters. While reportedly commutative, using the proper order allows for leveraging the instruction permitting the source operand to be in memory. [ hpa: This code originated in the dpdk toolkit. This was a bug in dpdk which has recently been fixed in part due to an earlier version of this patch. ] Signed-off-by: Jan Beulich <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Acked-by: Daniel Borkmann <[email protected]> Cc: Francesco Fusco <[email protected]> Cc: Thomas Graf <[email protected]> Cc: David S. Miller <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
1 parent 0632519 commit c5cdfdf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/x86/lib/hash.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static u32 intel_crc4_2_hash(const void *data, u32 len, u32 seed)
5353
u32 i, tmp = 0;
5454

5555
for (i = 0; i < len / 4; i++)
56-
seed = crc32_u32(*p32++, seed);
56+
seed = crc32_u32(seed, *p32++);
5757

5858
switch (3 - (len & 0x03)) {
5959
case 0:
@@ -64,7 +64,7 @@ static u32 intel_crc4_2_hash(const void *data, u32 len, u32 seed)
6464
/* fallthrough */
6565
case 2:
6666
tmp |= *((const u8 *) p32);
67-
seed = crc32_u32(tmp, seed);
67+
seed = crc32_u32(seed, tmp);
6868
default:
6969
break;
7070
}
@@ -78,7 +78,7 @@ static u32 intel_crc4_2_hash2(const u32 *data, u32 len, u32 seed)
7878
u32 i;
7979

8080
for (i = 0; i < len; i++)
81-
seed = crc32_u32(*p32++, seed);
81+
seed = crc32_u32(seed, *p32++);
8282

8383
return seed;
8484
}

0 commit comments

Comments
 (0)