linux-parisc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] parisc: Fix unaligned-access crash in bootloader
@ 2021-09-03  8:00 Helge Deller
  2021-09-03 12:42 ` John David Anglin
  0 siblings, 1 reply; 2+ messages in thread
From: Helge Deller @ 2021-09-03  8:00 UTC (permalink / raw)
  To: linux-parisc; +Cc: James Bottomley, John David Anglin, Arnd Bergmann, stable

Kernel v5.14 has various changes to optimize unaligned memory accesses,
e.g. commit 0652035a5794 ("asm-generic: unaligned: remove byteshift helpers").

Those changes triggered an unalignment-exception and thus crashed the
bootloader on parisc because the unaligned "output_len" variable now suddenly
was read word-wise while it was read byte-wise in the past.

Fix this issue by declaring the external output_len variable as char which then
forces the compiler to generate byte-accesses.

Signed-off-by: Helge Deller <deller@gmx.de>
Cc: Arnd Bergmann <arnd@kernel.org>
Cc: John David Anglin <dave.anglin@bell.net>
Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102162
Fixes: 8c031ba63f8f ("parisc: Unbreak bootloader due to gcc-7 optimizations")
Fixes: 0652035a5794 ("asm-generic: unaligned: remove byteshift helpers")
Cc: <stable@vger.kernel.org> # v5.14+
---
 arch/parisc/boot/compressed/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/parisc/boot/compressed/misc.c b/arch/parisc/boot/compressed/misc.c
index 2d395998f524..7ee49f5881d1 100644
--- a/arch/parisc/boot/compressed/misc.c
+++ b/arch/parisc/boot/compressed/misc.c
@@ -26,7 +26,7 @@
 extern char input_data[];
 extern int input_len;
 /* output_len is inserted by the linker possibly at an unaligned address */
-extern __le32 output_len __aligned(1);
+extern char output_len;
 extern char _text, _end;
 extern char _bss, _ebss;
 extern char _startcode_end;
--
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] parisc: Fix unaligned-access crash in bootloader
  2021-09-03  8:00 [PATCH] parisc: Fix unaligned-access crash in bootloader Helge Deller
@ 2021-09-03 12:42 ` John David Anglin
  0 siblings, 0 replies; 2+ messages in thread
From: John David Anglin @ 2021-09-03 12:42 UTC (permalink / raw)
  To: Helge Deller, linux-parisc; +Cc: James Bottomley, Arnd Bergmann, stable

This worked for me on c8000.

Regards,
Dave

On 2021-09-03 4:00 a.m., Helge Deller wrote:
> Kernel v5.14 has various changes to optimize unaligned memory accesses,
> e.g. commit 0652035a5794 ("asm-generic: unaligned: remove byteshift helpers").
>
> Those changes triggered an unalignment-exception and thus crashed the
> bootloader on parisc because the unaligned "output_len" variable now suddenly
> was read word-wise while it was read byte-wise in the past.
>
> Fix this issue by declaring the external output_len variable as char which then
> forces the compiler to generate byte-accesses.
>
> Signed-off-by: Helge Deller <deller@gmx.de>
> Cc: Arnd Bergmann <arnd@kernel.org>
> Cc: John David Anglin <dave.anglin@bell.net>
> Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102162
> Fixes: 8c031ba63f8f ("parisc: Unbreak bootloader due to gcc-7 optimizations")
> Fixes: 0652035a5794 ("asm-generic: unaligned: remove byteshift helpers")
> Cc: <stable@vger.kernel.org> # v5.14+
> ---
>  arch/parisc/boot/compressed/misc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/parisc/boot/compressed/misc.c b/arch/parisc/boot/compressed/misc.c
> index 2d395998f524..7ee49f5881d1 100644
> --- a/arch/parisc/boot/compressed/misc.c
> +++ b/arch/parisc/boot/compressed/misc.c
> @@ -26,7 +26,7 @@
>  extern char input_data[];
>  extern int input_len;
>  /* output_len is inserted by the linker possibly at an unaligned address */
> -extern __le32 output_len __aligned(1);
> +extern char output_len;
>  extern char _text, _end;
>  extern char _bss, _ebss;
>  extern char _startcode_end;
> --
> 2.31.1
>


-- 
John David Anglin  dave.anglin@bell.net


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-03 12:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03  8:00 [PATCH] parisc: Fix unaligned-access crash in bootloader Helge Deller
2021-09-03 12:42 ` John David Anglin

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).