diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 4a8200f29b35..aa1fbea47c46 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -84,11 +84,7 @@ EXPORT_SYMBOL(memstart_addr); * Note: Page-granularity mappings are necessary for crash kernel memory * range for shrinking its size via /sys/kernel/kexec_crash_size interface. */ -#if IS_ENABLED(CONFIG_ZONE_DMA) || IS_ENABLED(CONFIG_ZONE_DMA32) phys_addr_t __ro_after_init arm64_dma_phys_limit; -#else -phys_addr_t __ro_after_init arm64_dma_phys_limit = PHYS_MASK + 1; -#endif bool crash_low_mem_page_map __initdata; static bool crash_high_mem_reserved __initdata; @@ -132,63 +128,6 @@ static int __init reserve_crashkernel_low(unsigned long long low_size) return 0; } -static void __init reserve_crashkernel_high(void) -{ - unsigned long long crash_base, crash_size; - char *cmdline = boot_command_line; - int ret; - - if (!IS_ENABLED(CONFIG_KEXEC_CORE)) - return; - - /* crashkernel=X[@offset] */ - ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), - &crash_size, &crash_base); - if (ret || !crash_size) { - ret = parse_crashkernel_high(cmdline, 0, &crash_size, &crash_base); - if (ret || !crash_size) - return; - } else if (!crash_base) { - crash_low_mem_page_map = true; - } - - crash_size = PAGE_ALIGN(crash_size); - - /* - * For the case crashkernel=X, may fall back to reserve memory above - * 4G, make reservations here in advance. It will be released later if - * the region is successfully reserved under 4G. - */ - if (!crash_base) { - crash_base = memblock_phys_alloc_range(crash_size, CRASH_ALIGN, - crash_base, CRASH_ADDR_HIGH_MAX); - if (!crash_base) - return; - - crash_high_mem_reserved = true; - } - - /* Mark the memory range that requires page-level mappings */ - crashk_res.start = crash_base; - crashk_res.end = crash_base + crash_size - 1; -} - -static void __init hand_over_reserved_high_mem(void) -{ - crashk_res_high.start = crashk_res.start; - crashk_res_high.end = crashk_res.end; - - crashk_res.start = 0; - crashk_res.end = 0; -} - -static void __init take_reserved_high_mem(unsigned long long *crash_base, - unsigned long long *crash_size) -{ - *crash_base = crashk_res_high.start; - *crash_size = resource_size(&crashk_res_high); -} - static void __init free_reserved_high_mem(void) { memblock_phys_free(crashk_res_high.start, resource_size(&crashk_res_high)); @@ -225,7 +164,8 @@ static void __init reserve_crashkernel(void) if (!IS_ENABLED(CONFIG_KEXEC_CORE)) return; - hand_over_reserved_high_mem(); + if (crashk_res.end) + return; /* crashkernel=X[@offset] */ ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), @@ -245,11 +185,6 @@ static void __init reserve_crashkernel(void) high = true; crash_max = CRASH_ADDR_HIGH_MAX; - - if (crash_high_mem_reserved) { - take_reserved_high_mem(&crash_base, &crash_size); - goto reserve_low; - } } fixed_base = !!crash_base; @@ -267,12 +202,8 @@ static void __init reserve_crashkernel(void) * to high memory, the minimum required low memory will be * reserved later. */ - if (!fixed_base && (crash_max == CRASH_ADDR_LOW_MAX)) { - if (crash_high_mem_reserved) { - take_reserved_high_mem(&crash_base, &crash_size); - goto reserve_low; - } - + if (!fixed_base && (crash_max == CRASH_ADDR_LOW_MAX + && crash_max = CRASH_ADDR_LOW_MAX) || high) { + if (crash_base >= CRASH_ADDR_LOW_MAX ) { reserve_low: /* case #3 of crashkernel,low reservation */ if (!high) @@ -299,14 +230,7 @@ static void __init reserve_crashkernel(void) memblock_phys_free(crash_base, crash_size); return; } - } else if (crash_high_mem_reserved) { - /* - * The crash memory is successfully allocated under 4G, and the - * previously reserved high memory is no longer required. - */ - free_reserved_high_mem(); } - pr_info("crashkernel reserved: 0x%016llx - 0x%016llx (%lld MB)\n", crash_base, crash_base + crash_size, crash_size >> 20); @@ -520,10 +444,10 @@ void __init arm64_memblock_init(void) early_init_fdt_scan_reserved_mem(); + arm64_dma_phys_limit = memblock_end_of_DRAM(); + if (!IS_ENABLED(CONFIG_ZONE_DMA) && !IS_ENABLED(CONFIG_ZONE_DMA32)) reserve_crashkernel(); - else - reserve_crashkernel_high(); high_memory = __va(memblock_end_of_DRAM() - 1) + 1; }