Hongchen Zhang (4): Revert "LoongArch: kdump: Add high memory reservation" Revert "LoongArch: Fix kdump failure on v40 interface specification" Revert "LoongArch: kdump: Add memory reservation for old kernel" LoongArch: fix efi map page table error
arch/loongarch/kernel/efi.c | 39 ++++++++++++--- arch/loongarch/kernel/setup.c | 94 +++++------------------------------ 2 files changed, 44 insertions(+), 89 deletions(-)
LoongArch inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I9QMTK
------------------------------------------
This reverts commit d379ed4dbc906cdbb6fce39ff0dc7b9c72854f18.
There is no need to reserve extra memory to the crash kernel, as if the kdump test failed, we should increase the size of the crash kernel instead of reserve high memory for user.
Signed-off-by: Hongchen Zhang zhanghongchen@loongson.cn --- arch/loongarch/kernel/setup.c | 49 +++-------------------------------- 1 file changed, 3 insertions(+), 46 deletions(-)
diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c index bfe1f05b279d..9197f974edfe 100644 --- a/arch/loongarch/kernel/setup.c +++ b/arch/loongarch/kernel/setup.c @@ -383,49 +383,13 @@ static void __init bootcmdline_init(char **cmdline_p) * memory area used by the previous production kernel should be reserved to * avoid destroy to the captured data. */ -static void reserve_oldmem_region(int node, unsigned long s0, unsigned long e0) +static void reserve_oldmem_region(void) { #ifdef CONFIG_CRASH_DUMP - unsigned long s1, e1; - if (!is_kdump_kernel()) return;
- if ((e0 - s0) > (SZ_1G >> PAGE_SHIFT)) - e0 = e0 - (SZ_512M >> PAGE_SHIFT); - - /* crashmem_start is crashk_res reserved by primary production kernel */ - s1 = PFN_UP(crashmem_start); - e1 = PFN_DOWN(crashmem_start + crashmem_size); - - if (s1 == 0) - return; - - if (node == 0) { - memblock_reserve(PFN_PHYS(s0), (s1 - s0) << PAGE_SHIFT); - memblock_reserve(PFN_PHYS(e1), (e0 - e1) << PAGE_SHIFT); - } else { - memblock_reserve(PFN_PHYS(s0), (e0 - s0) << PAGE_SHIFT); - } -#endif -} - -/* Traditionally, LoongArch's contiguous low memory is 256M, so crashkernel=X@Y is - * unable to be large enough in some cases. Thus, if the total memory of a node - * is more than 1GB, we reserve the top 512MB for the capture kernel - */ -static void reserve_crashm_region(int node, unsigned long s0, unsigned long e0) -{ -#ifdef CONFIG_KEXEC - if (crashk_res.start == crashk_res.end) - return; - - if ((e0 - s0) <= (SZ_1G >> PAGE_SHIFT)) - return; - - s0 = e0 - (SZ_512M >> PAGE_SHIFT); - - memblock_reserve(PFN_PHYS(s0), (e0 - s0) << PAGE_SHIFT); + memblock_cap_memory_range(crashmem_start, crashmem_size); #endif }
@@ -468,16 +432,9 @@ static void __init check_kernel_sections_mem(void) */ static void __init arch_mem_init(char **cmdline_p) { - unsigned int node; - unsigned long start_pfn, end_pfn; - arch_reserve_vmcore(); arch_parse_crashkernel(); - for_each_online_node(node) { - get_pfn_range_for_nid(node, &start_pfn, &end_pfn); - reserve_crashm_region(node, start_pfn, end_pfn); - reserve_oldmem_region(node, start_pfn, end_pfn); - } + reserve_oldmem_region();
if (usermem) pr_info("User-defined physical RAM map overwrite\n");
LoongArch inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I9QMTK
------------------------------------------
This reverts commit b859d4add1bd255823ace0b18d77e2fe714327a0.
This patch is only a work around, and the root cause is efi map table error. Therefore, we fix the problem of efi map table error at the following patch instead of adding this work around.
Signed-off-by: Hongchen Zhang zhanghongchen@loongson.cn --- arch/loongarch/kernel/setup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c index 9197f974edfe..1581a8700124 100644 --- a/arch/loongarch/kernel/setup.c +++ b/arch/loongarch/kernel/setup.c @@ -395,6 +395,10 @@ static void reserve_oldmem_region(void)
void __init platform_init(void) { + arch_reserve_vmcore(); + arch_parse_crashkernel(); + reserve_oldmem_region(); + #ifdef CONFIG_ACPI_TABLE_UPGRADE acpi_table_upgrade(); #endif @@ -432,10 +436,6 @@ static void __init check_kernel_sections_mem(void) */ static void __init arch_mem_init(char **cmdline_p) { - arch_reserve_vmcore(); - arch_parse_crashkernel(); - reserve_oldmem_region(); - if (usermem) pr_info("User-defined physical RAM map overwrite\n");
LoongArch inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I9QMTK
------------------------------------------
This reverts commit 2dc80ab461df0f00168cb685f494f4ea83d1ce43.
In the current state, elfcorehdr will not be destroyed, because it is allocated at the memory reserved for crash kernel, so this patch is not required.
Signed-off-by: Hongchen Zhang zhanghongchen@loongson.cn --- arch/loongarch/kernel/setup.c | 45 ++++++++--------------------------- 1 file changed, 10 insertions(+), 35 deletions(-)
diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c index 1581a8700124..80874fa75337 100644 --- a/arch/loongarch/kernel/setup.c +++ b/arch/loongarch/kernel/setup.c @@ -69,8 +69,6 @@ EXPORT_SYMBOL(cpu_data); struct loongson_board_info b_info; static const char dmi_empty_string[] = " ";
-static phys_addr_t crashmem_start, crashmem_size; - /* * Setup information * @@ -208,15 +206,6 @@ static int __init early_parse_mem(char *p) return -EINVAL; }
- start = 0; - size = memparse(p, &p); - if (*p == '@') - start = memparse(p + 1, &p); - else { - pr_err("Invalid format!\n"); - return -EINVAL; - } - /* * If a user specifies memory size, we * blow away any automatically generated @@ -224,14 +213,16 @@ static int __init early_parse_mem(char *p) */ if (usermem == 0) { usermem = 1; - if (!strstr(boot_command_line, "elfcorehdr")) { - memblock_remove(memblock_start_of_DRAM(), - memblock_end_of_DRAM() - memblock_start_of_DRAM()); - } else { - crashmem_start = start; - crashmem_size = size; - return 0; - } + memblock_remove(memblock_start_of_DRAM(), + memblock_end_of_DRAM() - memblock_start_of_DRAM()); + } + start = 0; + size = memparse(p, &p); + if (*p == '@') + start = memparse(p + 1, &p); + else { + pr_err("Invalid format!\n"); + return -EINVAL; }
if (!IS_ENABLED(CONFIG_NUMA)) @@ -378,26 +369,10 @@ static void __init bootcmdline_init(char **cmdline_p) *cmdline_p = boot_command_line; }
-/* - * After the kdump operation is performed to enter the capture kernel, the - * memory area used by the previous production kernel should be reserved to - * avoid destroy to the captured data. - */ -static void reserve_oldmem_region(void) -{ -#ifdef CONFIG_CRASH_DUMP - if (!is_kdump_kernel()) - return; - - memblock_cap_memory_range(crashmem_start, crashmem_size); -#endif -} - void __init platform_init(void) { arch_reserve_vmcore(); arch_parse_crashkernel(); - reserve_oldmem_region();
#ifdef CONFIG_ACPI_TABLE_UPGRADE acpi_table_upgrade();
LoongArch inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9QMTK
------------------------------------------
we should map all efi used memory, not the kernel usable memory.
Fixes: 221e2e8bdbb8 ("LoongArch: add kernel setvirtmap for runtime") Signed-off-by: Yun Liu liuyun@loongson.cn Signed-off-by: Hongchen Zhang zhanghongchen@loongson.cn --- arch/loongarch/kernel/efi.c | 39 +++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-)
diff --git a/arch/loongarch/kernel/efi.c b/arch/loongarch/kernel/efi.c index b132af112664..140b43d3f182 100644 --- a/arch/loongarch/kernel/efi.c +++ b/arch/loongarch/kernel/efi.c @@ -69,8 +69,10 @@ static int __init efimap_populate_hugepages( if (pud_none(*pud)) { void *p = memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
- if (!p) + if (!p) { + pr_err("can not alloc efimap huge pages!\n"); return -1; + } pmd_init(p); pud_populate(&init_mm, pud, p); } @@ -88,7 +90,8 @@ static void __init efi_map_pgt(void) { unsigned long node; unsigned long start, end; - unsigned long start_pfn, end_pfn; + efi_memory_desc_t *md; + u32 mem_type;
pgd_efi = memblock_alloc_low(PAGE_SIZE, PAGE_SIZE); if (!pgd_efi) { @@ -105,13 +108,33 @@ static void __init efi_map_pgt(void) /* MMIO Registers, Uncached */ efimap_populate_hugepages(SZ_256M | (node << 44), SZ_512M | (node << 44), PAGE_KERNEL_SUC); + }
- get_pfn_range_for_nid(node, &start_pfn, &end_pfn); - start = ALIGN_DOWN(start_pfn << PAGE_SHIFT, PMD_SIZE); - end = ALIGN(end_pfn << PAGE_SHIFT, PMD_SIZE); - - /* System memory, Cached */ - efimap_populate_hugepages(node ? start : SZ_512M, end, PAGE_KERNEL); + /* Parse memory information */ + for_each_efi_memory_desc(md) { + mem_type = md->type; + start = ALIGN_DOWN(md->phys_addr, PMD_SIZE); + end = ALIGN(start + (md->num_pages << EFI_PAGE_SHIFT), PMD_SIZE); + node = start >> 44; + + switch (mem_type) { + case EFI_LOADER_CODE: + case EFI_LOADER_DATA: + case EFI_BOOT_SERVICES_CODE: + case EFI_BOOT_SERVICES_DATA: + case EFI_PAL_CODE: + case EFI_UNUSABLE_MEMORY: + case EFI_ACPI_RECLAIM_MEMORY: + case EFI_RESERVED_TYPE: + case EFI_RUNTIME_SERVICES_CODE: + case EFI_RUNTIME_SERVICES_DATA: + efimap_populate_hugepages(node ? start : SZ_512M, end, PAGE_KERNEL); + break; + case EFI_MEMORY_MAPPED_IO: + case EFI_MEMORY_MAPPED_IO_PORT_SPACE: + efimap_populate_hugepages(node ? start : SZ_512M, end, PAGE_KERNEL_SUC); + break; + } } }
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/7823 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/J...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/7823 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/J...