From e113f1c974c820f9633dc0073eda525d7575f365 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Mon, 20 Jan 2020 10:25:24 +0800 Subject: [PATCH 3/7] [PATCH] cope with not-present mem section After kernel commit ba72b4c8cf60 ("mm/sparsemem: support sub-section hotplug"), when hot-removed, section_mem_map is still encoded with section start pfn, not NULL. This break the current makedumpfile. # makedumpfile -x vmlinux -l -d 31 vmcore vmcore.dump get_mem_section: Could not validate mem_section. get_mm_sparsemem: Can't get the address of mem_section. makedumpfile Failed. Whatever section_mem_map coding info after hot-removed, it is reliable just to work on SECTION_MARKED_PRESENT bit. Fixing makedumpfile by this way. [ This issue occurs on kernel 5.3 through 5.5, and should be fixed by commit 1f503443e7df ("mm/sparse.c: reset section's mem_map when fully deactivated") in 5.6-rc1, 5.5.3 and 5.4.19. ] Signed-off-by: Pingfan Liu To: kexec@lists.infradead.org Cc: Kazuhito Hagio Cc: Baoquan He Cc: David Hildenbrand Cc: Andrew Morton Cc: Dan Williams Cc: Oscar Salvador Cc: Michal Hocko Cc: Qian Cai --- makedumpfile.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/makedumpfile-1.6.7/makedumpfile.c b/makedumpfile-1.6.7/makedumpfile.c index ae7336a..607e07f 100644 --- a/makedumpfile-1.6.7/makedumpfile.c +++ b/makedumpfile-1.6.7/makedumpfile.c @@ -3406,8 +3406,6 @@ section_mem_map_addr(unsigned long addr, unsigned long *map_mask) map = ULONG(mem_section + OFFSET(mem_section.section_mem_map)); mask = SECTION_MAP_MASK; *map_mask = map & ~mask; - if (map == 0x0) - *map_mask |= SECTION_MARKED_PRESENT; map &= mask; free(mem_section); @@ -3453,10 +3451,8 @@ validate_mem_section(unsigned long *mem_sec, mem_map = NOT_MEMMAP_ADDR; } else { mem_map = section_mem_map_addr(section, &map_mask); + /* for either no mem_map or hot-removed */ if (!(map_mask & SECTION_MARKED_PRESENT)) { - return FALSE; - } - if (mem_map == 0) { mem_map = NOT_MEMMAP_ADDR; } else { mem_map = sparse_decode_mem_map(mem_map, -- 2.7.5