Skip to content

Commit 81c4f4d

Browse files
Alexander Gordeevtorvalds
authored andcommitted
lib: fix bitmap_parse() on 64-bit big endian archs
Commit 2d62615 ("lib: rework bitmap_parse()") does not take into account order of halfwords on 64-bit big endian architectures. As result (at least) Receive Packet Steering, IRQ affinity masks and runtime kernel test "test_bitmap" get broken on s390. [[email protected]: convert infinite while loop to a for loop] Link: http://lkml.kernel.org/r/[email protected] Fixes: 2d62615 ("lib: rework bitmap_parse()") Signed-off-by: Alexander Gordeev <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Cc: Yury Norov <[email protected]> Cc: Amritha Nambiar <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Chris Wilson <[email protected]> Cc: Kees Cook <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Miklos Szeredi <[email protected]> Cc: Rasmus Villemoes <[email protected]> Cc: Steffen Klassert <[email protected]> Cc: "Tobin C . Harding" <[email protected]> Cc: Vineet Gupta <[email protected]> Cc: Will Deacon <[email protected]> Cc: Willem de Bruijn <[email protected]> Cc: <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 2581ac7 commit 81c4f4d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/bitmap.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,16 +741,21 @@ int bitmap_parse(const char *start, unsigned int buflen,
741741
int chunks = BITS_TO_U32(nmaskbits);
742742
u32 *bitmap = (u32 *)maskp;
743743
int unset_bit;
744+
int chunk;
744745

745-
while (1) {
746+
for (chunk = 0; ; chunk++) {
746747
end = bitmap_find_region_reverse(start, end);
747748
if (start > end)
748749
break;
749750

750751
if (!chunks--)
751752
return -EOVERFLOW;
752753

753-
end = bitmap_get_x32_reverse(start, end, bitmap++);
754+
#if defined(CONFIG_64BIT) && defined(__BIG_ENDIAN)
755+
end = bitmap_get_x32_reverse(start, end, &bitmap[chunk ^ 1]);
756+
#else
757+
end = bitmap_get_x32_reverse(start, end, &bitmap[chunk]);
758+
#endif
754759
if (IS_ERR(end))
755760
return PTR_ERR(end);
756761
}

0 commit comments

Comments
 (0)