The only cofig option that selects this is CONFIG_KEXEC_HANDOVER. Replace CONFIG_MEMBLOCK_KHO_SCRATCH with CONFIG_KEXEC_HANDOVER to simplify code. No functional change intended. Suggested-by: Kiryl Shutsemau Signed-off-by: Usama Arif Reviewed-by: Pratyush Yadav Reviewed-by: Kiryl Shutsemau --- include/linux/memblock.h | 2 +- kernel/Kconfig.kexec | 1 - mm/Kconfig | 4 ---- mm/memblock.c | 4 ++-- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 221118b5a16e1..8bd9bcaccceb8 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -611,7 +611,7 @@ static inline void early_memtest(phys_addr_t start, phys_addr_t end) { } static inline void memtest_report_meminfo(struct seq_file *m) { } #endif -#ifdef CONFIG_MEMBLOCK_KHO_SCRATCH +#ifdef CONFIG_KEXEC_HANDOVER void memblock_set_kho_scratch_only(void); void memblock_clear_kho_scratch_only(void); void memmap_init_kho_scratch_pages(void); diff --git a/kernel/Kconfig.kexec b/kernel/Kconfig.kexec index 54e5810726176..06a7c43652cfd 100644 --- a/kernel/Kconfig.kexec +++ b/kernel/Kconfig.kexec @@ -98,7 +98,6 @@ config KEXEC_HANDOVER bool "kexec handover" depends on ARCH_SUPPORTS_KEXEC_HANDOVER && ARCH_SUPPORTS_KEXEC_FILE depends on !DEFERRED_STRUCT_PAGE_INIT - select MEMBLOCK_KHO_SCRATCH select KEXEC_FILE select DEBUG_FS select LIBFDT diff --git a/mm/Kconfig b/mm/Kconfig index bd0ea5454af82..6d6002f57c18f 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -442,10 +442,6 @@ config HAVE_GUP_FAST depends on MMU bool -# Enable memblock support for scratch memory which is needed for kexec handover -config MEMBLOCK_KHO_SCRATCH - bool - # Don't discard allocated memory used to track "memory" and "reserved" memblocks # after early boot, so it can still be used to test for validity of memory. # Also, memblocks are updated with memory hot(un)plug. diff --git a/mm/memblock.c b/mm/memblock.c index e23e16618e9b3..8b13d5c28922a 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -112,7 +112,7 @@ unsigned long min_low_pfn; unsigned long max_pfn; unsigned long long max_possible_pfn; -#ifdef CONFIG_MEMBLOCK_KHO_SCRATCH +#ifdef CONFIG_KEXEC_HANDOVER /* When set to true, only allocate from MEMBLOCK_KHO_SCRATCH ranges */ static bool kho_scratch_only; #else @@ -948,7 +948,7 @@ int __init_memblock memblock_physmem_add(phys_addr_t base, phys_addr_t size) } #endif -#ifdef CONFIG_MEMBLOCK_KHO_SCRATCH +#ifdef CONFIG_KEXEC_HANDOVER __init void memblock_set_kho_scratch_only(void) { kho_scratch_only = true; -- 2.47.3 The scratch memory for kexec handover is used to bootstrap the kexec'ed kernel. Only the 1st 1MB is used as scratch, and its a hack to get around limitations with KHO. It is only needed when CONFIG_KEXEC_HANDOVER is enabled and only if it is a KHO boot (both checked by is_kho_boot). Add check to prevent marking a KHO scratch region unless needed. Fixes: a2daf83e10378 ("x86/e820: temporarily enable KHO scratch for memory below 1M") Reported-by: Vlad Poenaru Signed-off-by: Usama Arif Reviewed-by: Pratyush Yadav --- mm/memblock.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mm/memblock.c b/mm/memblock.c index 8b13d5c28922a..913cf322eb89a 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -20,8 +20,8 @@ #ifdef CONFIG_KEXEC_HANDOVER #include -#include #endif /* CONFIG_KEXEC_HANDOVER */ +#include #include #include @@ -1126,8 +1126,10 @@ int __init_memblock memblock_reserved_mark_noinit(phys_addr_t base, phys_addr_t */ __init int memblock_mark_kho_scratch(phys_addr_t base, phys_addr_t size) { - return memblock_setclr_flag(&memblock.memory, base, size, 1, - MEMBLOCK_KHO_SCRATCH); + if (is_kho_boot()) + return memblock_setclr_flag(&memblock.memory, base, size, 1, + MEMBLOCK_KHO_SCRATCH); + return 0; } /** @@ -1140,8 +1142,10 @@ __init int memblock_mark_kho_scratch(phys_addr_t base, phys_addr_t size) */ __init int memblock_clear_kho_scratch(phys_addr_t base, phys_addr_t size) { - return memblock_setclr_flag(&memblock.memory, base, size, 0, - MEMBLOCK_KHO_SCRATCH); + if (is_kho_boot()) + return memblock_setclr_flag(&memblock.memory, base, size, 0, + MEMBLOCK_KHO_SCRATCH); + return 0; } static bool should_skip_region(struct memblock_type *type, -- 2.47.3