[PATCH] makedumpfile: ARM: get correct mem_map offset

Liu Hua sdu.liu at huawei.com
Tue May 6 23:15:56 PDT 2014


When converting paddr to pfn, makedumpfile firstly minuses the
offset of physical memory, and then do the right shift. But the
kernel only does the right shift.

For the cases of ARCH_PFN_OFFSET=0 or non sparse memormy model,
this introduces no problem.

But for my arma9 platform with ARCH_PFN_OFFSET=0x80000 and sparse
memory model. Makedumfile can not get the mem_map correctly. It it
due to there is still offset for mem_map array.

This patch introduces the offset of the mem_map.

But I have no environment to test this patch for other paltfrom.
So I am not sure this patch works on other platforms.

Signed-off-by: Liu Hua <sdu.liu at huawei.com>
---
 makedumpfile.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index 94515f6..6cf6e24 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -2807,6 +2807,7 @@ int
 get_mm_sparsemem(void)
 {
 	unsigned int section_nr, mem_section_size, num_section;
+	unsigned int section_start;
 	mdf_pfn_t pfn_start, pfn_end;
 	unsigned long section, mem_map;
 	unsigned long *mem_sec = NULL;
@@ -2817,6 +2818,7 @@ get_mm_sparsemem(void)
 	 * Get the address of the symbol "mem_section".
 	 */
 	num_section = divideup(info->max_mapnr, PAGES_PER_SECTION());
+	section_start = ARCH_PFN_OFFSET / PAGES_PER_SECTION();
 	if (is_sparsemem_extreme()) {
 		info->sections_per_root = _SECTIONS_PER_ROOT_EXTREME();
 		mem_section_size = sizeof(void *) * NR_SECTION_ROOTS();
@@ -2842,7 +2844,7 @@ get_mm_sparsemem(void)
 		goto out;
 	}
 	for (section_nr = 0; section_nr < num_section; section_nr++) {
-		section = nr_to_section(section_nr, mem_sec);
+		section = nr_to_section(section_nr + section_start, mem_sec);
 		if (section == NOT_KV_ADDR) {
 			mem_map = NOT_MEMMAP_ADDR;
 		} else {
@@ -2851,7 +2853,7 @@ get_mm_sparsemem(void)
 				mem_map = NOT_MEMMAP_ADDR;
 			} else {
 				mem_map = sparse_decode_mem_map(mem_map,
-								section_nr);
+								section_nr + section_start);
 				if (!is_kvaddr(mem_map))
 					mem_map = NOT_MEMMAP_ADDR;
 			}
-- 
1.9.0




More information about the kexec mailing list