From f18c391b650ace3cea6e48278b969425a328e4cf Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Mon, 19 Sep 2022 17:49:22 +0800 Subject: [PATCH 40/89] Fix page offset issue when converting physical to virtual address When trying to convert a physical address to its virtual address in dump_vmap_area() and dump_vmlist(), the vi->retval is added by 2 values: the page aligned address "pcheck" and page offset address "PAGEOFFSET(paddr)". However "paddr" is given by "pcheck", is also page aligned, so "PAGEOFFSET(paddr)" is always 0. In this patch, we will use PAGEOFFSET(vi->spec_addr) to give the page offset, vi->spec_addr is the physical address we'd like to convert, which contains the correct page offset. Signed-off-by: Tao Liu Signed-off-by: Lianbo Jiang --- memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/memory.c b/memory.c index 9ab578134fa1..1b6f9ba17e57 100644 --- a/memory.c +++ b/memory.c @@ -8861,7 +8861,7 @@ dump_vmlist(struct meminfo *vi) (vi->spec_addr < (paddr+PAGESIZE()))) { if (vi->flags & GET_PHYS_TO_VMALLOC) { vi->retval = pcheck + - PAGEOFFSET(paddr); + PAGEOFFSET(vi->spec_addr); return; } else fprintf(fp, @@ -9010,7 +9010,7 @@ dump_vmap_area(struct meminfo *vi) (vi->spec_addr < (paddr+PAGESIZE()))) { if (vi->flags & GET_PHYS_TO_VMALLOC) { vi->retval = pcheck + - PAGEOFFSET(paddr); + PAGEOFFSET(vi->spec_addr); FREEBUF(ld->list_ptr); return; } else -- 2.37.1