Skip to content

Commit d8ae8a3

Browse files
Christoph Hellwigtorvalds
authored andcommitted
initramfs: move the legacy keepinitrd parameter to core code
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>
1 parent afef788 commit d8ae8a3

8 files changed

Lines changed: 28 additions & 47 deletions

File tree

‎arch/Kconfig‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,13 @@ config ARCH_HAS_FORTIFY_SOURCE
245245
An architecture should select this when it can successfully
246246
build and run with CONFIG_FORTIFY_SOURCE.
247247

248+
#
249+
# Select if the arch provides a historic keepinit alias for the retain_initrd
250+
# command line option
251+
#
252+
config ARCH_HAS_KEEPINITRD
253+
bool
254+
248255
# Select if arch has all set_memory_ro/rw/x/nx() functions in asm/cacheflush.h
249256
config ARCH_HAS_SET_MEMORY
250257
bool

‎arch/arm/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ config ARM
99
select ARCH_HAS_DEVMEM_IS_ALLOWED
1010
select ARCH_HAS_ELF_RANDOMIZE
1111
select ARCH_HAS_FORTIFY_SOURCE
12+
select ARCH_HAS_KEEPINITRD
1213
select ARCH_HAS_KCOV
1314
select ARCH_HAS_MEMBARRIER_SYNC_CORE
1415
select ARCH_HAS_PTE_SPECIAL if ARM_LPAE

‎arch/arm/mm/init.c‎

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -695,27 +695,14 @@ void free_initmem(void)
695695
}
696696

697697
#ifdef CONFIG_BLK_DEV_INITRD
698-
699-
static int keep_initrd;
700-
701698
void free_initrd_mem(unsigned long start, unsigned long end)
702699
{
703-
if (!keep_initrd) {
704-
if (start == initrd_start)
705-
start = round_down(start, PAGE_SIZE);
706-
if (end == initrd_end)
707-
end = round_up(end, PAGE_SIZE);
700+
if (start == initrd_start)
701+
start = round_down(start, PAGE_SIZE);
702+
if (end == initrd_end)
703+
end = round_up(end, PAGE_SIZE);
708704

709-
poison_init_mem((void *)start, PAGE_ALIGN(end) - start);
710-
free_reserved_area((void *)start, (void *)end, -1, "initrd");
711-
}
705+
poison_init_mem((void *)start, PAGE_ALIGN(end) - start);
706+
free_reserved_area((void *)start, (void *)end, -1, "initrd");
712707
}
713-
714-
static int __init keepinitrd_setup(char *__unused)
715-
{
716-
keep_initrd = 1;
717-
return 1;
718-
}
719-
720-
__setup("keepinitrd", keepinitrd_setup);
721708
#endif

‎arch/arm64/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ config ARM64
2121
select ARCH_HAS_GCOV_PROFILE_ALL
2222
select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
2323
select ARCH_HAS_KCOV
24+
select ARCH_HAS_KEEPINITRD
2425
select ARCH_HAS_MEMBARRIER_SYNC_CORE
2526
select ARCH_HAS_PTE_SPECIAL
2627
select ARCH_HAS_SETUP_DMA_OPS

‎arch/arm64/mm/init.c‎

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -578,24 +578,11 @@ void free_initmem(void)
578578
}
579579

580580
#ifdef CONFIG_BLK_DEV_INITRD
581-
582-
static int keep_initrd __initdata;
583-
584581
void __init free_initrd_mem(unsigned long start, unsigned long end)
585582
{
586-
if (!keep_initrd) {
587-
free_reserved_area((void *)start, (void *)end, 0, "initrd");
588-
memblock_free(__virt_to_phys(start), end - start);
589-
}
590-
}
591-
592-
static int __init keepinitrd_setup(char *__unused)
593-
{
594-
keep_initrd = 1;
595-
return 1;
583+
free_reserved_area((void *)start, (void *)end, 0, "initrd");
584+
memblock_free(__virt_to_phys(start), end - start);
596585
}
597-
598-
__setup("keepinitrd", keepinitrd_setup);
599586
#endif
600587

601588
/*

‎arch/unicore32/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ config UNICORE32
33
def_bool y
44
select ARCH_32BIT_OFF_T
55
select ARCH_HAS_DEVMEM_IS_ALLOWED
6+
select ARCH_HAS_KEEPINITRD
67
select ARCH_MIGHT_HAVE_PC_PARPORT
78
select ARCH_MIGHT_HAVE_PC_SERIO
89
select HAVE_KERNEL_GZIP

‎arch/unicore32/mm/init.c‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -294,20 +294,8 @@ void free_initmem(void)
294294
}
295295

296296
#ifdef CONFIG_BLK_DEV_INITRD
297-
298-
static int keep_initrd;
299-
300297
void free_initrd_mem(unsigned long start, unsigned long end)
301298
{
302-
if (!keep_initrd)
303-
free_reserved_area((void *)start, (void *)end, -1, "initrd");
304-
}
305-
306-
static int __init keepinitrd_setup(char *__unused)
307-
{
308-
keep_initrd = 1;
309-
return 1;
299+
free_reserved_area((void *)start, (void *)end, -1, "initrd");
310300
}
311-
312-
__setup("keepinitrd", keepinitrd_setup);
313301
#endif

‎init/initramfs.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,15 @@ static int __init retain_initrd_param(char *str)
513513
}
514514
__setup("retain_initrd", retain_initrd_param);
515515

516+
#ifdef CONFIG_ARCH_HAS_KEEPINITRD
517+
static int __init keepinitrd_setup(char *__unused)
518+
{
519+
do_retain_initrd = 1;
520+
return 1;
521+
}
522+
__setup("keepinitrd", keepinitrd_setup);
523+
#endif
524+
516525
extern char __initramfs_start[];
517526
extern unsigned long __initramfs_size;
518527
#include <linux/initrd.h>

0 commit comments

Comments
 (0)