[PATCH v2] Fix: Exclude pages correctly in exclude_nodata_pages()

Ming Wang wangming01 at loongson.cn
Tue Oct 8 23:06:35 PDT 2024


The calculation of the starting PFN for exclusion in
exclude_nodata_pages() was rounding down, potentially excluding
the last valid page of a LOAD segment.

This commit fixes the issue by rounding up the calculated PFN to the
nearest page boundary, ensuring that the last valid page is included and
not erroneously excluded.

Signed-off-by: Ming Wang <wangming01 at loongson.cn>
---
 makedumpfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index 2fa67e7..b356eb3 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -5215,7 +5215,7 @@ exclude_nodata_pages(struct cycle *cycle)
 				   NULL, &file_size)) {
 		unsigned long long pfn, pfn_end;
 
-		pfn = paddr_to_pfn(phys_start + file_size);
+		pfn = paddr_to_pfn(roundup(phys_start + file_size, PAGESIZE()));
 		pfn_end = paddr_to_pfn(roundup(phys_end, PAGESIZE()));
 
 		if (pfn < cycle->start_pfn)
-- 
2.39.2




More information about the kexec mailing list