提交 74dbabcd 编写于 作者: P Paul Cercueil 提交者: Yang Yingliang

MIPS: boot: Fix unaligned access with CONFIG_MIPS_RAW_APPENDED_DTB

commit 4d4f9c1a upstream.

The compressed payload is not necesarily 4-byte aligned, at least when
compiling with Clang. In that case, the 4-byte value appended to the
compressed payload that corresponds to the uncompressed kernel image
size must be read using get_unaligned_le32().

This fixes Clang-built kernels not booting on MIPS (tested on a Ingenic
JZ4770 board).

Fixes: b8f54f2c ("MIPS: ZBOOT: copy appended dtb to the end of the kernel")
Cc: <stable@vger.kernel.org> # v4.7
Signed-off-by: NPaul Cercueil <paul@crapouillou.net>
Reviewed-by: NNick Desaulniers <ndesaulniers@google.com>
Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: NThomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 5d2b10c1
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/libfdt.h> #include <linux/libfdt.h>
#include <asm/addrspace.h> #include <asm/addrspace.h>
#include <asm/unaligned.h>
/* /*
* These two variables specify the free mem region * These two variables specify the free mem region
...@@ -117,7 +118,7 @@ void decompress_kernel(unsigned long boot_heap_start) ...@@ -117,7 +118,7 @@ void decompress_kernel(unsigned long boot_heap_start)
dtb_size = fdt_totalsize((void *)&__appended_dtb); dtb_size = fdt_totalsize((void *)&__appended_dtb);
/* last four bytes is always image size in little endian */ /* last four bytes is always image size in little endian */
image_size = le32_to_cpup((void *)&__image_end - 4); image_size = get_unaligned_le32((void *)&__image_end - 4);
/* copy dtb to where the booted kernel will expect it */ /* copy dtb to where the booted kernel will expect it */
memcpy((void *)VMLINUX_LOAD_ADDRESS_ULL + image_size, memcpy((void *)VMLINUX_LOAD_ADDRESS_ULL + image_size,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册