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

HAGIO KAZUHITO(萩尾 一仁) k-hagio-ab at nec.com
Wed Oct 9 00:26:51 PDT 2024


On 2024/10/09 15:06, Ming Wang wrote:
> 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)

Thank you for the v2 patch.

I confirmed that without the patch "makedumpfile -d 0" excluded some pages wrongly:

$ makedumpfile -d 0 vmcore dump.d0
...
pfn 0000000000054000 pfn_end 0000000000054000
pfn 000000000006989f pfn_end 00000000000698a0

crash> ptob 6989f
6989f: 6989f000
crash> rd -p 6989f000
rd: page excluded: physical address: 6989f000  type: "64-bit PHYSADDR"

and it didn't with the patch:

$ makedumpfile -d 0 vmcore dump.d0.patched
...
pfn 0000000000054000 pfn_end 0000000000054000
pfn 00000000000698a0 pfn_end 00000000000698a0

crash> rd -p 6989f000
         6989f000:  cccccccc30646870                    phd0....


Tested ok and applied.
https://github.com/makedumpfile/makedumpfile/commit/f2c5f761ea99dbacaaf988caf1d51bc142b353fa

Thanks,
Kazu


More information about the kexec mailing list