makedumpfile: Fix exclusion range in find_vmemmap_pages()

Backport from the makedumpfile devel branch in upstream.

commit b461971bfac0f193a0c274c3b657d158e07d4995
Author: Kazuhito Hagio <k-hagio@ab.jp.nec.com>
Date:   Thu Aug 29 14:51:56 2019 -0400

    [PATCH] Fix exclusion range in find_vmemmap_pages()

    In the function, since pfn ranges are literally start and end, not start
    and end+1, if the struct page of endpfn is at the last in a vmemmap page,
    the vmemmap page is dropped by the following code, and not excluded.

        npfns_offset = endpfn - vmapp->rep_pfn_start;
        vmemmap_offset = npfns_offset * size_table.page;
        // round down to page boundary
        vmemmap_offset -= (vmemmap_offset % pagesize);

    We can use (endpfn+1) here to fix.

    Signed-off-by: Kazuhito Hagio <k-hagio@ab.jp.nec.com>

Signed-off-by: Kazuhito Hagio <k-hagio@ab.jp.nec.com>
Acked-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
Kazuhito Hagio 2019-09-09 16:55:16 -04:00 committed by Kairui Song
parent 68f9e69a16
commit bdd3061883
2 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,37 @@
From b461971bfac0f193a0c274c3b657d158e07d4995 Mon Sep 17 00:00:00 2001
From: Kazuhito Hagio <k-hagio@ab.jp.nec.com>
Date: Thu, 29 Aug 2019 14:51:56 -0400
Subject: [PATCH] Fix exclusion range in find_vmemmap_pages()
In the function, since pfn ranges are literally start and end, not start
and end+1, if the struct page of endpfn is at the last in a vmemmap page,
the vmemmap page is dropped by the following code, and not excluded.
npfns_offset = endpfn - vmapp->rep_pfn_start;
vmemmap_offset = npfns_offset * size_table.page;
// round down to page boundary
vmemmap_offset -= (vmemmap_offset % pagesize);
We can use (endpfn+1) here to fix.
Signed-off-by: Kazuhito Hagio <k-hagio@ab.jp.nec.com>
---
makedumpfile.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/makedumpfile-1.6.6/makedumpfile.c b/makedumpfile-1.6.6/makedumpfile.c
index 88df788..37df77d 100644
--- a/makedumpfile-1.6.6/makedumpfile.c
+++ b/makedumpfile-1.6.6/makedumpfile.c
@@ -6315,7 +6315,7 @@ find_vmemmap_pages(unsigned long startpfn, unsigned long endpfn, unsigned long *
start_vmemmap_pfn = vmapp->vmap_pfn_start + vmemmap_pfns;
*vmappfn = start_vmemmap_pfn;
- npfns_offset = endpfn - vmapp->rep_pfn_start;
+ npfns_offset = (endpfn+1) - vmapp->rep_pfn_start;
vmemmap_offset = npfns_offset * size_table.page;
// round down to page boundary
vmemmap_offset -= (vmemmap_offset % pagesize);
--
2.20.1

View File

@ -78,6 +78,7 @@ Patch0: kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch
# Patches 101 through 200 are meant for x86_64 kexec-tools enablement
#
Patch101: kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option.patch
Patch102: kexec-tools-2.0.20-makedumpfile-Fix-exclusion-range-in-find_vmemmap_pages.patch
#
# Patches 301 through 400 are meant for ppc64 kexec-tools enablement
@ -114,6 +115,7 @@ tar -z -x -v -f %{SOURCE19}
%patch601 -p1
%patch602 -p1
%patch101 -p1
%patch102 -p1
%ifarch ppc
%define archdef ARCH=ppc