Skip to contentSkip to conversation

parisc: Fix unaligned-access crash in bootloader

PATCH In review Helge Deller 2 participants 2 messages Sep 3, 2021

Subsystems (2)
lore
Share & tools
lore

Helge Deller

author maintainer
#0 lore raw

PATCH 1/1 parisc: Fix unaligned-access crash in bootloader

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.

Cc Arnd Bergmann <[email protected]>
Cc John David Anglin <[email protected]>
Fixes 8c031ba63f8f ("parisc: Unbreak bootloader due to gcc-7 optimizations")
Fixes 0652035a5794 ("asm-generic: unaligned: remove byteshift helpers")
Cc <[email protected]> # v5.14+
---
 arch/parisc/boot/compressed/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/boot/compressed/misc.c +1 -1
index 2d395998f524..7ee49f5881d1 100644
@@ -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

#1 lore raw

This worked for me on c8000.

Regards,
Dave

Quoted 37 lines · Helge Deller

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.

Cc Arnd Bergmann <[email protected]>
Cc John David Anglin <[email protected]>
Fixes 8c031ba63f8f ("parisc: Unbreak bootloader due to gcc-7 optimizations")
Fixes 0652035a5794 ("asm-generic: unaligned: remove byteshift helpers")
Cc <[email protected]> # v5.14+
---
 arch/parisc/boot/compressed/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/boot/compressed/misc.c +1 -2
index 2d395998f524..7ee49f5881d1 100644
@@ -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

Signature · 1 line
John David Anglin  [email protected]