Skip to content

Commit

Permalink
initramfs: move the legacy keepinitrd parameter to core code
Browse files Browse the repository at this point in the history
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/[email protected]
Signed-off-by: Christoph Hellwig <[email protected]>
Acked-by: Catalin Marinas <[email protected]>	[arm64]
Acked-by: Mike Rapoport <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>	[m68k]
Cc: Steven Price <[email protected]>
Cc: Alexander Viro <[email protected]>
Cc: Guan Xuetao <[email protected]>
Cc: Russell King <[email protected]>
Cc: Will Deacon <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Christoph Hellwig authored and torvalds committed May 14, 2019
1 parent afef788 commit d8ae8a3
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 47 deletions.
7 changes: 7 additions & 0 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 6 additions & 19 deletions arch/arm/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions arch/arm64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 2 additions & 15 deletions arch/arm64/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

/*
Expand Down
1 change: 1 addition & 0 deletions arch/unicore32/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 1 addition & 13 deletions arch/unicore32/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions init/initramfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit d8ae8a3

Please sign in to comment.