From bdd3061883174d861d85edb267b40ad2466fabb1 Mon Sep 17 00:00:00 2001 From: Kazuhito Hagio Date: Mon, 9 Sep 2019 16:55:16 -0400 Subject: [PATCH] makedumpfile: Fix exclusion range in find_vmemmap_pages() Backport from the makedumpfile devel branch in upstream. commit b461971bfac0f193a0c274c3b657d158e07d4995 Author: Kazuhito Hagio 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 Signed-off-by: Kazuhito Hagio Acked-by: Kairui Song --- ...xclusion-range-in-find_vmemmap_pages.patch | 37 +++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 39 insertions(+) create mode 100644 kexec-tools-2.0.20-makedumpfile-Fix-exclusion-range-in-find_vmemmap_pages.patch diff --git a/kexec-tools-2.0.20-makedumpfile-Fix-exclusion-range-in-find_vmemmap_pages.patch b/kexec-tools-2.0.20-makedumpfile-Fix-exclusion-range-in-find_vmemmap_pages.patch new file mode 100644 index 0000000..2c94711 --- /dev/null +++ b/kexec-tools-2.0.20-makedumpfile-Fix-exclusion-range-in-find_vmemmap_pages.patch @@ -0,0 +1,37 @@ +From b461971bfac0f193a0c274c3b657d158e07d4995 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +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 +--- + 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 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 3fd41a7..4d356ad 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -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