* [PATCH v2] lib: fix bitmap_parse() on 64-bit big endian archs
@ 2020-06-08 16:41 Alexander Gordeev
2020-06-09 9:40 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Alexander Gordeev @ 2020-06-08 16:41 UTC (permalink / raw)
To: linux-kernel
Cc: linux-s390, Alexander Gordeev, stable, Andrew Morton, Yury Norov,
Andy Shevchenko, Amritha Nambiar, Arnaldo Carvalho de Melo,
Chris Wilson, Kees Cook, Matthew Wilcox, Miklos Szeredi,
Rasmus Villemoes, Steffen Klassert, Tobin C . Harding,
Vineet Gupta, Will Deacon, Willem de Bruijn
Commit 2d6261583be0 ("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.
Fixes: 2d6261583be0 ("lib: rework bitmap_parse()")
Cc: stable@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Yury Norov <yury.norov@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Amritha Nambiar <amritha.nambiar@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Kees Cook <keescook@chromium.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Miklos Szeredi <mszeredi@redhat.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Steffen Klassert <steffen.klassert@secunet.com>
Cc: "Tobin C . Harding" <tobin@kernel.org>
Cc: Vineet Gupta <vineet.gupta1@synopsys.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Willem de Bruijn <willemb@google.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
---
lib/bitmap.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 89260aa342d6..80d26b183248 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -739,6 +739,7 @@ int bitmap_parse(const char *start, unsigned int buflen,
const char *end = strnchrnul(start, buflen, '\n') - 1;
int chunks = BITS_TO_U32(nmaskbits);
u32 *bitmap = (u32 *)maskp;
+ int chunk = 0;
int unset_bit;
while (1) {
@@ -749,9 +750,14 @@ int bitmap_parse(const char *start, unsigned int buflen,
if (!chunks--)
return -EOVERFLOW;
- end = bitmap_get_x32_reverse(start, end, bitmap++);
+#if defined(CONFIG_64BIT) && defined(__BIG_ENDIAN)
+ end = bitmap_get_x32_reverse(start, end, &bitmap[chunk ^ 1]);
+#else
+ end = bitmap_get_x32_reverse(start, end, &bitmap[chunk]);
+#endif
if (IS_ERR(end))
return PTR_ERR(end);
+ chunk++;
}
unset_bit = (BITS_TO_U32(nmaskbits) - chunks) * 32;
--
2.23.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] lib: fix bitmap_parse() on 64-bit big endian archs
2020-06-08 16:41 [PATCH v2] lib: fix bitmap_parse() on 64-bit big endian archs Alexander Gordeev
@ 2020-06-09 9:40 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2020-06-09 9:40 UTC (permalink / raw)
To: Alexander Gordeev
Cc: Linux Kernel Mailing List, linux-s390, Stable, Andrew Morton,
Yury Norov, Andy Shevchenko, Amritha Nambiar,
Arnaldo Carvalho de Melo, Chris Wilson, Kees Cook,
Matthew Wilcox, Miklos Szeredi, Rasmus Villemoes,
Steffen Klassert, Tobin C . Harding, Vineet Gupta, Will Deacon,
Willem de Bruijn
On Mon, Jun 8, 2020 at 8:47 PM Alexander Gordeev <agordeev@linux.ibm.com> wrote:
>
> Commit 2d6261583be0 ("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.
LGTM (I would replace while loop, but it's style preference and one
can consider worse than infinite loop)
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>
> Fixes: 2d6261583be0 ("lib: rework bitmap_parse()")
> Cc: stable@vger.kernel.org
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Yury Norov <yury.norov@gmail.com>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Amritha Nambiar <amritha.nambiar@intel.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Matthew Wilcox <willy@infradead.org>
> Cc: Miklos Szeredi <mszeredi@redhat.com>
> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> Cc: Steffen Klassert <steffen.klassert@secunet.com>
> Cc: "Tobin C . Harding" <tobin@kernel.org>
> Cc: Vineet Gupta <vineet.gupta1@synopsys.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Willem de Bruijn <willemb@google.com>
> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
> ---
> lib/bitmap.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/lib/bitmap.c b/lib/bitmap.c
> index 89260aa342d6..80d26b183248 100644
> --- a/lib/bitmap.c
> +++ b/lib/bitmap.c
> @@ -739,6 +739,7 @@ int bitmap_parse(const char *start, unsigned int buflen,
> const char *end = strnchrnul(start, buflen, '\n') - 1;
> int chunks = BITS_TO_U32(nmaskbits);
> u32 *bitmap = (u32 *)maskp;
> + int chunk = 0;
> int unset_bit;
>
> while (1) {
> @@ -749,9 +750,14 @@ int bitmap_parse(const char *start, unsigned int buflen,
> if (!chunks--)
> return -EOVERFLOW;
>
> - end = bitmap_get_x32_reverse(start, end, bitmap++);
> +#if defined(CONFIG_64BIT) && defined(__BIG_ENDIAN)
> + end = bitmap_get_x32_reverse(start, end, &bitmap[chunk ^ 1]);
> +#else
> + end = bitmap_get_x32_reverse(start, end, &bitmap[chunk]);
> +#endif
> if (IS_ERR(end))
> return PTR_ERR(end);
> + chunk++;
> }
>
> unset_bit = (BITS_TO_U32(nmaskbits) - chunks) * 32;
> --
> 2.23.0
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-09 9:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-08 16:41 [PATCH v2] lib: fix bitmap_parse() on 64-bit big endian archs Alexander Gordeev
2020-06-09 9:40 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).