mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] init: Introduce 'noinitramfs' kernel parameter
@ 2014-06-22  5:41 Ezequiel Garcia
  2014-06-22 14:53 ` Henrique de Moraes Holschuh
  0 siblings, 1 reply; 4+ messages in thread
From: Ezequiel Garcia @ 2014-06-22  5:41 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Andrew Morton, Guido Martínez, Ezequiel Garcia

Currently, we have no kernel paramater to avoid loading a configured initial
RAM filesystem. Therefore, if a kernel is built with an appended initramfs,
there's no way to avoid unpacking and mounting it as the rootfs.

This commit adds a new kernel parameter to provide such option, following the
naming of the current 'initrd' which serves a similar purpose, for an initial
RAM disk.

This commit changes the build so noinitramfs.c is unconditionally included.
If the new 'noinitramfs' option is passed in the command line, the kernel
avoids unpacking an initramfs and calls default_rootfs().

Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
---
 Documentation/kernel-parameters.txt |  4 ++++
 include/linux/initrd.h              |  2 ++
 init/Makefile                       |  3 ---
 init/initramfs.c                    | 14 +++++++++++++-
 init/noinitramfs.c                  |  4 +++-
 5 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 8849049..a8cb75e 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -102,6 +102,7 @@ parameter is applicable:
 	PPT	Parallel port support is enabled.
 	PS2	Appropriate PS/2 support is enabled.
 	RAM	RAM disk support is enabled.
+	RAMFS	Initial RAM filesystem support is enabled.
 	S390	S390 architecture is enabled.
 	SCSI	Appropriate SCSI support is enabled.
 			A lot of drivers have their options described inside
@@ -2211,6 +2212,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 
 	noisapnp	[ISAPNP] Disables ISA PnP code.
 
+	noinitramfs	[RAMFS] Tells the kernel not to load any configured
+			initial RAM filesystem.
+
 	noinitrd	[RAM] Tells the kernel not to load any configured
 			initial RAM disk.
 
diff --git a/include/linux/initrd.h b/include/linux/initrd.h
index 55289d2..f627ce6 100644
--- a/include/linux/initrd.h
+++ b/include/linux/initrd.h
@@ -17,4 +17,6 @@ extern int initrd_below_start_ok;
 extern unsigned long initrd_start, initrd_end;
 extern void free_initrd_mem(unsigned long, unsigned long);
 
+extern int default_rootfs(void);
+
 extern unsigned int real_root_dev;
diff --git a/init/Makefile b/init/Makefile
index 7bc47ee..692b91f 100644
--- a/init/Makefile
+++ b/init/Makefile
@@ -3,11 +3,8 @@
 #
 
 obj-y                          := main.o version.o mounts.o
-ifneq ($(CONFIG_BLK_DEV_INITRD),y)
 obj-y                          += noinitramfs.o
-else
 obj-$(CONFIG_BLK_DEV_INITRD)   += initramfs.o
-endif
 obj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o
 
 ifneq ($(CONFIG_ARCH_INIT_TASK),y)
diff --git a/init/initramfs.c b/init/initramfs.c
index a8497fa..cae8cee 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -580,9 +580,21 @@ static void __init clean_rootfs(void)
 }
 #endif
 
+static int __initdata skip_initramfs;
+static int __init noinitramfs_param(char *str)
+{
+	skip_initramfs = 1;
+	return 1;
+}
+__setup("noinitramfs", noinitramfs_param);
+
 static int __init populate_rootfs(void)
 {
-	char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
+	char *err;
+
+	if (skip_initramfs)
+		return default_rootfs();
+	err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
 	if (err)
 		panic("%s", err); /* Failed to decompress INTERNAL initramfs */
 	if (initrd_start) {
diff --git a/init/noinitramfs.c b/init/noinitramfs.c
index 267739d..e7e828a 100644
--- a/init/noinitramfs.c
+++ b/init/noinitramfs.c
@@ -25,7 +25,7 @@
 /*
  * Create a simple rootfs that is similar to the default initramfs
  */
-static int __init default_rootfs(void)
+int __init default_rootfs(void)
 {
 	int err;
 
@@ -49,4 +49,6 @@ out:
 	printk(KERN_WARNING "Failed to create a rootfs\n");
 	return err;
 }
+#ifndef CONFIG_BLK_DEV_INITRD
 rootfs_initcall(default_rootfs);
+#endif
-- 
1.9.1


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

* Re: [PATCH] init: Introduce 'noinitramfs' kernel parameter
  2014-06-22  5:41 [PATCH] init: Introduce 'noinitramfs' kernel parameter Ezequiel Garcia
@ 2014-06-22 14:53 ` Henrique de Moraes Holschuh
  2014-06-22 21:30   ` Ezequiel Garcia
  0 siblings, 1 reply; 4+ messages in thread
From: Henrique de Moraes Holschuh @ 2014-06-22 14:53 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: linux-kernel, Linus Torvalds, Andrew Morton, Guido Martínez

On Sun, 22 Jun 2014, Ezequiel Garcia wrote:
> This commit adds a new kernel parameter to provide such option, following the
> naming of the current 'initrd' which serves a similar purpose, for an initial
> RAM disk.

How does it interact with the early initramfs?

Maybe we should have the options to ignore both, ignore just the early
initramfs (to skip microcode updates and ACPI table updates), and ignore
just the main initramfs?

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

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

* Re: [PATCH] init: Introduce 'noinitramfs' kernel parameter
  2014-06-22 14:53 ` Henrique de Moraes Holschuh
@ 2014-06-22 21:30   ` Ezequiel Garcia
  2014-06-23  0:08     ` Henrique de Moraes Holschuh
  0 siblings, 1 reply; 4+ messages in thread
From: Ezequiel Garcia @ 2014-06-22 21:30 UTC (permalink / raw)
  To: Henrique de Moraes Holschuh
  Cc: Ezequiel Garcia, linux-kernel, Linus Torvalds, Andrew Morton,
	Guido Martínez

Hi Henrique,

On 22 Jun 11:53 AM, Henrique de Moraes Holschuh wrote:
> On Sun, 22 Jun 2014, Ezequiel Garcia wrote:
> > This commit adds a new kernel parameter to provide such option, following the
> > naming of the current 'initrd' which serves a similar purpose, for an initial
> > RAM disk.
> 
> How does it interact with the early initramfs?
> 
> Maybe we should have the options to ignore both, ignore just the early
> initramfs (to skip microcode updates and ACPI table updates), and ignore
> just the main initramfs?
> 

I must admit I don't have much experience with any "earlier" initramfs.
Maybe you can point me at some links about this?

Unless I'm missing something, this "early" initramfs is an userspace artifact
in the construction of the initramfs, so the kernel has no way to distinguish
one from the other. Thus, we cannot mount one and not the other.
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

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

* Re: [PATCH] init: Introduce 'noinitramfs' kernel parameter
  2014-06-22 21:30   ` Ezequiel Garcia
@ 2014-06-23  0:08     ` Henrique de Moraes Holschuh
  0 siblings, 0 replies; 4+ messages in thread
From: Henrique de Moraes Holschuh @ 2014-06-23  0:08 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: Ezequiel Garcia, linux-kernel, Linus Torvalds, Andrew Morton,
	Guido Martínez

On Sun, 22 Jun 2014, Ezequiel Garcia wrote:
> On 22 Jun 11:53 AM, Henrique de Moraes Holschuh wrote:
> > On Sun, 22 Jun 2014, Ezequiel Garcia wrote:
> > > This commit adds a new kernel parameter to provide such option, following the
> > > naming of the current 'initrd' which serves a similar purpose, for an initial
> > > RAM disk.
> > 
> > How does it interact with the early initramfs?
> > 
> > Maybe we should have the options to ignore both, ignore just the early
> > initramfs (to skip microcode updates and ACPI table updates), and ignore
> > just the main initramfs?
> > 
> 
> I must admit I don't have much experience with any "earlier" initramfs.
> Maybe you can point me at some links about this?

Search for kernel code that includes the linux/earlycpio.h header file.  The
implementation is at lib/earlycpio.c.

I am sorry I don't have a better reference to point you to.

> Unless I'm missing something, this "early" initramfs is an userspace artifact
> in the construction of the initramfs, so the kernel has no way to distinguish

No, it is an uncompressed cpio archive which is parsed extremely early, for
critical system firmware (currently: processor microcode updates and ACPI
table overrides).

Documentation of its two current users is at:

Documentation/x86/early-microcode.txt
Documentation/acpi/initrd_table_override.txt

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

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

end of thread, other threads:[~2014-06-23  0:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-22  5:41 [PATCH] init: Introduce 'noinitramfs' kernel parameter Ezequiel Garcia
2014-06-22 14:53 ` Henrique de Moraes Holschuh
2014-06-22 21:30   ` Ezequiel Garcia
2014-06-23  0:08     ` Henrique de Moraes Holschuh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®