Commit e26eee76 authored by Zhen Lei's avatar Zhen Lei Committed by Zheng Zengkai
Browse files

arm64: kdump: Don't force page-level mappings for memory above 4G

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I545H8


CVE: NA

-------------------------------------------------------------------------

If the crashkernel reservation is deferred, such boundaries are not known
when the linear mapping is created. But its upper limit is fixed, cannot
above 4G. Therefore, unless otherwise required, block mapping should be
used for memory above 4G to improve performance.

Signed-off-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent b712bd16
Loading
Loading
Loading
Loading
+26 −3
Original line number Diff line number Diff line
@@ -490,10 +490,10 @@ static void __init map_mem(pgd_t *pgdp)
	phys_addr_t kernel_start = __pa_symbol(_text);
	phys_addr_t kernel_end = __pa_symbol(__init_begin);
	phys_addr_t start, end;
	int flags = 0;
	int flags = 0, eflags = 0;
	u64 i;

	if (rodata_full || crash_mem_map || debug_pagealloc_enabled())
	if (rodata_full || debug_pagealloc_enabled())
		flags = NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS;

#ifdef CONFIG_KFENCE
@@ -514,17 +514,40 @@ static void __init map_mem(pgd_t *pgdp)
	 */
	memblock_mark_nomap(kernel_start, kernel_end - kernel_start);

#ifdef CONFIG_KEXEC_CORE
	if (crash_mem_map)
		eflags = NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS;
#endif

	/* map all the memory banks */
	for_each_mem_range(i, &start, &end) {
		if (start >= end)
			break;

#ifdef CONFIG_KEXEC_CORE
		if (eflags && (end >= SZ_4G)) {
			/*
			 * The memory block cross the 4G boundary.
			 * Forcibly use page-level mappings for memory under 4G.
			 */
			if (start < SZ_4G) {
				__map_memblock(pgdp, start, SZ_4G - 1,
					       pgprot_tagged(PAGE_KERNEL), flags | eflags);
				start  = SZ_4G;
			}

			/* Page-level mappings is not mandatory for memory above 4G */
			eflags = 0;
		}
#endif

		/*
		 * The linear map must allow allocation tags reading/writing
		 * if MTE is present. Otherwise, it has the same attributes as
		 * PAGE_KERNEL.
		 */
		__map_memblock(pgdp, start, end, pgprot_tagged(PAGE_KERNEL),
			       flags);
			       flags | eflags);
	}

	/*