]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
initramfs: provide a way to ignore image provided by bootloader
authorDaniel Thompson <daniel.thompson@linaro.org>
Mon, 8 May 2017 22:56:57 +0000 (15:56 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 9 May 2017 00:15:12 +0000 (17:15 -0700)
Many "embedded" architectures provide CMDLINE_FORCE to allow the kernel
to override the command line provided by an inflexible bootloader.
However there is currrently no way for the kernel to override the
initramfs image provided by the bootloader meaning there are still ways
for bootloaders to make things difficult for us.

Fix this by introducing INITRAMFS_FORCE which can prevent the kernel
from loading the bootloader supplied image.

We use CMDLINE_FORCE (and its friend CMDLINE_EXTEND) to imply that the
system has an inflexible bootloader.  This allow us to avoid presenting
this config option to users of systems where inflexible bootloaders
aren't usually a problem.

Link: http://lkml.kernel.org/r/20170217121940.30126-1-daniel.thompson@linaro.org
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
init/initramfs.c
usr/Kconfig

index 8daf7ac6c7e2ca77ebc9f97c6bcabc33f186cd5b..9d180273ee8c010fde086f9efc4a50730a47e824 100644 (file)
@@ -613,7 +613,7 @@ static int __init populate_rootfs(void)
        if (err)
                panic("%s", err); /* Failed to decompress INTERNAL initramfs */
        /* If available load the bootloader supplied initrd */
-       if (initrd_start) {
+       if (initrd_start && !IS_ENABLED(CONFIG_INITRAMFS_FORCE)) {
 #ifdef CONFIG_BLK_DEV_RAM
                int fd;
                printk(KERN_INFO "Trying to unpack rootfs image as initramfs...\n");
index 6278f135256d424c153d3fadc48f8636ecd24ec1..c0c48507e44e2992b3624b2374cd08769a8bb607 100644 (file)
@@ -21,6 +21,16 @@ config INITRAMFS_SOURCE
 
          If you are not sure, leave it blank.
 
+config INITRAMFS_FORCE
+       bool "Ignore the initramfs passed by the bootloader"
+       depends on CMDLINE_EXTEND || CMDLINE_FORCE
+       help
+         This option causes the kernel to ignore the initramfs image
+         (or initrd image) passed to it by the bootloader. This is
+         analogous to CMDLINE_FORCE, which is found on some architectures,
+         and is useful if you cannot or don't want to change the image
+         your bootloader passes to the kernel.
+
 config INITRAMFS_ROOT_UID
        int "User ID to map to 0 (user root)"
        depends on INITRAMFS_SOURCE!=""