initramfs: move the legacy keepinitrd parameter to core code
authorChristoph Hellwig <hch@lst.de>
Tue, 14 May 2019 00:18:30 +0000 (17:18 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 14 May 2019 16:47:47 +0000 (09:47 -0700)
No need to handle the freeing disable in arch code when we already have a
core hook (and a different name for the option) for it.

Link: http://lkml.kernel.org/r/20190213174621.29297-7-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Catalin Marinas <catalin.marinas@arm.com> [arm64]
Acked-by: Mike Rapoport <rppt@linux.ibm.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org> [m68k]
Cc: Steven Price <steven.price@arm.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Guan Xuetao <gxt@pku.edu.cn>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/Kconfig
arch/arm/Kconfig
arch/arm/mm/init.c
arch/arm64/Kconfig
arch/arm64/mm/init.c
arch/unicore32/Kconfig
arch/unicore32/mm/init.c
init/initramfs.c

index 5e43fcbad4ca551493345f4a052c73461a85ae78..f11f0698b148c05924c5ab7528179611861e7ea4 100644 (file)
@@ -245,6 +245,13 @@ config ARCH_HAS_FORTIFY_SOURCE
          An architecture should select this when it can successfully
          build and run with CONFIG_FORTIFY_SOURCE.
 
+#
+# Select if the arch provides a historic keepinit alias for the retain_initrd
+# command line option
+#
+config ARCH_HAS_KEEPINITRD
+       bool
+
 # Select if arch has all set_memory_ro/rw/x/nx() functions in asm/cacheflush.h
 config ARCH_HAS_SET_MEMORY
        bool
index dc9855c4a3b404cff6a4dd2ac81ba92d12bbe4fc..a11dfcc2a1309098e2bde4ef15d890ce44adb30b 100644 (file)
@@ -9,6 +9,7 @@ config ARM
        select ARCH_HAS_DEVMEM_IS_ALLOWED
        select ARCH_HAS_ELF_RANDOMIZE
        select ARCH_HAS_FORTIFY_SOURCE
+       select ARCH_HAS_KEEPINITRD
        select ARCH_HAS_KCOV
        select ARCH_HAS_MEMBARRIER_SYNC_CORE
        select ARCH_HAS_PTE_SPECIAL if ARM_LPAE
index c2daabbe0af05da23a469efe0ea2ed1a6eb2eb7b..68dcd5f8d7c63d2d1c0f7be00d07840faf45efbc 100644 (file)
@@ -695,27 +695,14 @@ void free_initmem(void)
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
-
-static int keep_initrd;
-
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
-       if (!keep_initrd) {
-               if (start == initrd_start)
-                       start = round_down(start, PAGE_SIZE);
-               if (end == initrd_end)
-                       end = round_up(end, PAGE_SIZE);
+       if (start == initrd_start)
+               start = round_down(start, PAGE_SIZE);
+       if (end == initrd_end)
+               end = round_up(end, PAGE_SIZE);
 
-               poison_init_mem((void *)start, PAGE_ALIGN(end) - start);
-               free_reserved_area((void *)start, (void *)end, -1, "initrd");
-       }
+       poison_init_mem((void *)start, PAGE_ALIGN(end) - start);
+       free_reserved_area((void *)start, (void *)end, -1, "initrd");
 }
-
-static int __init keepinitrd_setup(char *__unused)
-{
-       keep_initrd = 1;
-       return 1;
-}
-
-__setup("keepinitrd", keepinitrd_setup);
 #endif
index 3f957443f2869b3b32d803f19411be414d9a7420..e24dc16453aa49b07218f2daa151d047657da93c 100644 (file)
@@ -21,6 +21,7 @@ config ARM64
        select ARCH_HAS_GCOV_PROFILE_ALL
        select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
        select ARCH_HAS_KCOV
+       select ARCH_HAS_KEEPINITRD
        select ARCH_HAS_MEMBARRIER_SYNC_CORE
        select ARCH_HAS_PTE_SPECIAL
        select ARCH_HAS_SETUP_DMA_OPS
index 40e2d7e5efcb1e10c34b4abf83352ca4ec4c0d99..007c05a4cce0967de7830f56f2f5bc7eed7b674a 100644 (file)
@@ -578,24 +578,11 @@ void free_initmem(void)
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
-
-static int keep_initrd __initdata;
-
 void __init free_initrd_mem(unsigned long start, unsigned long end)
 {
-       if (!keep_initrd) {
-               free_reserved_area((void *)start, (void *)end, 0, "initrd");
-               memblock_free(__virt_to_phys(start), end - start);
-       }
-}
-
-static int __init keepinitrd_setup(char *__unused)
-{
-       keep_initrd = 1;
-       return 1;
+       free_reserved_area((void *)start, (void *)end, 0, "initrd");
+       memblock_free(__virt_to_phys(start), end - start);
 }
-
-__setup("keepinitrd", keepinitrd_setup);
 #endif
 
 /*
index 2445dfcf64446bd1fbcadb4fe75bab9c6ea62efd..afe4949cfc2d499d2cf9982bc4a89842ccc70edc 100644 (file)
@@ -3,6 +3,7 @@ config UNICORE32
        def_bool y
        select ARCH_32BIT_OFF_T
        select ARCH_HAS_DEVMEM_IS_ALLOWED
+       select ARCH_HAS_KEEPINITRD
        select ARCH_MIGHT_HAVE_PC_PARPORT
        select ARCH_MIGHT_HAVE_PC_SERIO
        select HAVE_KERNEL_GZIP
index 74b6a2e29809a8b0253bc5ac5561f943809f2d42..c0573feb5064b155c2c8b96ab4e17ca74874c252 100644 (file)
@@ -294,20 +294,8 @@ void free_initmem(void)
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
-
-static int keep_initrd;
-
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
-       if (!keep_initrd)
-               free_reserved_area((void *)start, (void *)end, -1, "initrd");
-}
-
-static int __init keepinitrd_setup(char *__unused)
-{
-       keep_initrd = 1;
-       return 1;
+       free_reserved_area((void *)start, (void *)end, -1, "initrd");
 }
-
-__setup("keepinitrd", keepinitrd_setup);
 #endif
index 32f940473d6768c8191df1b02e91cac33adaa3bb..cb3d17735c6627948f295dc13db440d1df5f8295 100644 (file)
@@ -513,6 +513,15 @@ static int __init retain_initrd_param(char *str)
 }
 __setup("retain_initrd", retain_initrd_param);
 
+#ifdef CONFIG_ARCH_HAS_KEEPINITRD
+static int __init keepinitrd_setup(char *__unused)
+{
+       do_retain_initrd = 1;
+       return 1;
+}
+__setup("keepinitrd", keepinitrd_setup);
+#endif
+
 extern char __initramfs_start[];
 extern unsigned long __initramfs_size;
 #include <linux/initrd.h>