提交 0011036b 编写于 作者: A Atsushi Nemoto 提交者: Ralf Baechle

[MIPS] Probe initrd header only if explicitly specified

Currently init_initrd() probes initrd header at the last page of kernel
image, but it is valid only if addinitrd was used.  If addinitrd was not
used, the area contains garbage so probing there might misdetect initrd
header (magic number is not strictly robust).

This patch introduces CONFIG_PROBE_INITRD_HEADER to explicitly enable this
probing.
Signed-off-by: NAtsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
上级 3885ec8c
...@@ -1886,6 +1886,15 @@ config STACKTRACE_SUPPORT ...@@ -1886,6 +1886,15 @@ config STACKTRACE_SUPPORT
source "init/Kconfig" source "init/Kconfig"
config PROBE_INITRD_HEADER
bool "Probe initrd header created by addinitrd"
depends on BLK_DEV_INITRD
help
Probe initrd header at the last page of kernel image.
Say Y here if you are using arch/mips/boot/addinitrd.c to
add initrd or initramfs image to the kernel image.
Otherwise, say N.
menu "Bus options (PCI, PCMCIA, EISA, ISA, TC)" menu "Bus options (PCI, PCMCIA, EISA, ISA, TC)"
config HW_HAS_EISA config HW_HAS_EISA
......
...@@ -160,20 +160,20 @@ early_param("rd_size", rd_size_early); ...@@ -160,20 +160,20 @@ early_param("rd_size", rd_size_early);
static unsigned long __init init_initrd(void) static unsigned long __init init_initrd(void)
{ {
unsigned long end; unsigned long end;
u32 *initrd_header;
/* /*
* Board specific code or command line parser should have * Board specific code or command line parser should have
* already set up initrd_start and initrd_end. In these cases * already set up initrd_start and initrd_end. In these cases
* perfom sanity checks and use them if all looks good. * perfom sanity checks and use them if all looks good.
*/ */
if (initrd_start && initrd_end > initrd_start) if (!initrd_start || initrd_end <= initrd_start) {
goto sanitize; #ifdef CONFIG_PROBE_INITRD_HEADER
u32 *initrd_header;
/* /*
* See if initrd has been added to the kernel image by * See if initrd has been added to the kernel image by
* arch/mips/boot/addinitrd.c. In that case a header is * arch/mips/boot/addinitrd.c. In that case a header is
* prepended to initrd and is made up by 8 bytes. The fisrt * prepended to initrd and is made up by 8 bytes. The first
* word is a magic number and the second one is the size of * word is a magic number and the second one is the size of
* initrd. Initrd start must be page aligned in any cases. * initrd. Initrd start must be page aligned in any cases.
*/ */
...@@ -182,8 +182,11 @@ static unsigned long __init init_initrd(void) ...@@ -182,8 +182,11 @@ static unsigned long __init init_initrd(void)
goto disable; goto disable;
initrd_start = (unsigned long)(initrd_header + 2); initrd_start = (unsigned long)(initrd_header + 2);
initrd_end = initrd_start + initrd_header[1]; initrd_end = initrd_start + initrd_header[1];
#else
goto disable;
#endif
}
sanitize:
if (initrd_start & ~PAGE_MASK) { if (initrd_start & ~PAGE_MASK) {
pr_err("initrd start must be page aligned\n"); pr_err("initrd start must be page aligned\n");
goto disable; goto disable;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册