From 46d7633df37cabef0dc94740b125444220626bb8 Mon Sep 17 00:00:00 2001 From: Pratyush Anand Date: Tue, 14 Mar 2017 20:58:30 +0530 Subject: [PATCH 01/15] Fix `makedumpfile --mem-usage /proc/kcore` Patches have been taken from kexec-tools and makedumpfile to fix issue with `makedumpfile --mem-usage /proc/kcore`. Two of the patches is from kexec-tools and rest are from makedumpfile. All the patches have been acked upstream and applies without conflict. Kexec-tools patches: (kexec-tools-2.0.14-x86-x86_64-Fix-format-warning-with-die.patch), which fixes koji build issue. kexec-tools-2.0.14-build_mem_phdrs-check-if-p_paddr-is-invalid.patch fixes the regresssion caused by kernel /proc/kcore fix to use -1 as default value of p_paddr for pt_loads. Without his patch kexec -p will fail with latest kernel. Other makedumpfile patches are backported to support --mem-usage while kernel kaslr being enabled. Details please see the patch log of the individual patches. All the patches are backport of upstream commits. Patches has been tested with kernel 4.11.0-0.rc1.git0.1.fc26.x86_64. # makedumpfile --mem-usage /proc/kcore -f The kernel version is not supported. The makedumpfile operation may be incomplete. TYPE PAGES EXCLUDABLE DESCRIPTION ---------------------------------------------------------------------- ZERO 1960 yes Pages filled with zero NON_PRI_CACHE 22850 yes Cache pages without private flag PRI_CACHE 1517 yes Cache pages with private flag USER 32522 yes User process pages FREE 1898981 yes Free pages KERN_DATA 78721 no Dumpable kernel data page size: 4096 Total pages on system: 2036551 Total size on system: 8341712896 Byte We won't need to pass -f once fedora kernel is rebased with v4.12. Signed-off-by: Pratyush Anand Acked-by: Dave Young --- ...em_phdrs-check-if-p_paddr-is-invalid.patch | 43 ++++++++++ ..._info-kcore-check-for-invalid-physic.patch | 47 +++++++++++ ...-initial-call-cache_init-a-bit-early.patch | 47 +++++++++++ ...edumpfile-Correct-the-calculation-of.patch | 45 ++++++++++ ...kedumpfile-Discard-process_dump_load.patch | 57 +++++++++++++ ...-usage-allow-to-work-only-with-f-for.patch | 84 +++++++++++++++++++ ...w_mem_usage-calculate-page-offset-af.patch | 41 +++++++++ ..._64-check-physical-address-in-PT_LOA.patch | 47 +++++++++++ ...6-x86_64-Fix-format-warning-with-die.patch | 75 +++++++++++++++++ kexec-tools.spec | 19 +++++ 10 files changed, 505 insertions(+) create mode 100644 kexec-tools-2.0.14-build_mem_phdrs-check-if-p_paddr-is-invalid.patch create mode 100644 kexec-tools-2.0.14-makedumpfile-elf_info-kcore-check-for-invalid-physic.patch create mode 100644 kexec-tools-2.0.14-makedumpfile-initial-call-cache_init-a-bit-early.patch create mode 100644 kexec-tools-2.0.14-makedumpfile-makedumpfile-Correct-the-calculation-of.patch create mode 100644 kexec-tools-2.0.14-makedumpfile-makedumpfile-Discard-process_dump_load.patch create mode 100644 kexec-tools-2.0.14-makedumpfile-mem-usage-allow-to-work-only-with-f-for.patch create mode 100644 kexec-tools-2.0.14-makedumpfile-show_mem_usage-calculate-page-offset-af.patch create mode 100644 kexec-tools-2.0.14-makedumpfile-x86_64-check-physical-address-in-PT_LOA.patch create mode 100644 kexec-tools-2.0.14-x86-x86_64-Fix-format-warning-with-die.patch diff --git a/kexec-tools-2.0.14-build_mem_phdrs-check-if-p_paddr-is-invalid.patch b/kexec-tools-2.0.14-build_mem_phdrs-check-if-p_paddr-is-invalid.patch new file mode 100644 index 0000000..f479086 --- /dev/null +++ b/kexec-tools-2.0.14-build_mem_phdrs-check-if-p_paddr-is-invalid.patch @@ -0,0 +1,43 @@ +From 5520739f1e6e31c7731d34d384bbaf4904282931 Mon Sep 17 00:00:00 2001 +Message-Id: <5520739f1e6e31c7731d34d384bbaf4904282931.1489470510.git.panand@redhat.com> +From: Pratyush Anand +Date: Wed, 1 Mar 2017 11:19:42 +0530 +Subject: [PATCH] build_mem_phdrs(): check if p_paddr is invalid + +Currently, all the p_paddr of PT_LOAD headers are assigned to 0, which +is not correct and could be misleading, since 0 is a valid physical +address. + +Upstream kernel commit "464920104bf7 /proc/kcore: update physical +address for kcore ram and text" fixed it and now invalid PT_LOAD is +assigned as -1. + +kexec/arch/i386/crashdump-x86.c:get_kernel_vaddr_and_size() uses kcore +interface and so calls build_mem_phdrs() for kcore PT_LOAD headers. + +This patch fixes build_mem_phdrs() to check if p_paddr is invalid. + +Signed-off-by: Pratyush Anand +Acked-by: Dave Young +Signed-off-by: Simon Horman +--- + kexec/kexec-elf.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/kexec/kexec-elf.c b/kexec/kexec-elf.c +index 1d6320a2f0e6..be60bbd48486 100644 +--- a/kexec/kexec-elf.c ++++ b/kexec/kexec-elf.c +@@ -432,7 +432,8 @@ static int build_mem_phdrs(const char *buf, off_t len, struct mem_ehdr *ehdr, + } + return -1; + } +- if ((phdr->p_paddr + phdr->p_memsz) < phdr->p_paddr) { ++ if (phdr->p_paddr != (unsigned long long)-1 && ++ (phdr->p_paddr + phdr->p_memsz) < phdr->p_paddr) { + /* The memory address wraps */ + if (probe_debug) { + fprintf(stderr, "ELF address wrap around\n"); +-- +2.9.3 + diff --git a/kexec-tools-2.0.14-makedumpfile-elf_info-kcore-check-for-invalid-physic.patch b/kexec-tools-2.0.14-makedumpfile-elf_info-kcore-check-for-invalid-physic.patch new file mode 100644 index 0000000..1edff59 --- /dev/null +++ b/kexec-tools-2.0.14-makedumpfile-elf_info-kcore-check-for-invalid-physic.patch @@ -0,0 +1,47 @@ +From f4ab6897a716d3f3959f6cb8cab27744eaecb5a6 Mon Sep 17 00:00:00 2001 +Message-Id: +In-Reply-To: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com> +References: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com> +From: Pratyush Anand +Date: Thu, 2 Mar 2017 17:37:16 +0900 +Subject: [PATCH 4/7] [PATCH v3 4/7] elf_info: kcore: check for invalid + physical address + +kcore passes correct phys_start for direct mapped region and an invalid +value (-1) for all other regions after the kernel commit +464920104bf7(/proc/kcore: update physical address for kcore ram and +text). arch specific function is_phys_addr() accepts only virt_start. +Therefore, check for valid phys_start in get_kcore_dump_loads(). + +Signed-off-by: Pratyush Anand +--- + elf_info.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/makedumpfile-1.6.1/elf_info.c b/makedumpfile-1.6.1/elf_info.c +index 65ff333cf33a..c5743b3cab28 100644 +--- a/makedumpfile-1.6.1/elf_info.c ++++ b/makedumpfile-1.6.1/elf_info.c +@@ -881,7 +881,8 @@ int get_kcore_dump_loads(void) + + for (i = 0; i < num_pt_loads; ++i) { + struct pt_load_segment *p = &pt_loads[i]; +- if (!is_phys_addr(p->virt_start)) ++ if (p->phys_start == NOT_PADDR ++ || !is_phys_addr(p->virt_start)) + continue; + loads++; + } +@@ -901,7 +902,8 @@ int get_kcore_dump_loads(void) + + for (i = 0, j = 0; i < num_pt_loads; ++i) { + struct pt_load_segment *p = &pt_loads[i]; +- if (!is_phys_addr(p->virt_start)) ++ if (p->phys_start == NOT_PADDR ++ || !is_phys_addr(p->virt_start)) + continue; + if (j >= loads) + return FALSE; +-- +2.9.3 + diff --git a/kexec-tools-2.0.14-makedumpfile-initial-call-cache_init-a-bit-early.patch b/kexec-tools-2.0.14-makedumpfile-initial-call-cache_init-a-bit-early.patch new file mode 100644 index 0000000..8523767 --- /dev/null +++ b/kexec-tools-2.0.14-makedumpfile-initial-call-cache_init-a-bit-early.patch @@ -0,0 +1,47 @@ +From 8e2834bac4f62da3894da297f083068431be6d80 Mon Sep 17 00:00:00 2001 +Message-Id: <8e2834bac4f62da3894da297f083068431be6d80.1489471500.git.panand@redhat.com> +In-Reply-To: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com> +References: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com> +From: Pratyush Anand +Date: Thu, 2 Mar 2017 17:37:11 +0900 +Subject: [PATCH 2/7] [PATCH v3 2/7] initial(): call cache_init() a bit early + +Call cache_init() before get_kcore_dump_loads(), because latter uses +cache_search(). + +Call path is like this : +get_kcore_dump_loads() -> process_dump_load() -> vaddr_to_paddr() -> +vtop4_x86_64() -> readmem() -> cache_search() + +Signed-off-by: Pratyush Anand +--- + makedumpfile.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/makedumpfile-1.6.1/makedumpfile.c b/makedumpfile-1.6.1/makedumpfile.c +index 6942047199de..3b8e9810468d 100644 +--- a/makedumpfile-1.6.1/makedumpfile.c ++++ b/makedumpfile-1.6.1/makedumpfile.c +@@ -3878,6 +3878,9 @@ initial(void) + if (!get_value_for_old_linux()) + return FALSE; + ++ if (!is_xen_memory() && !cache_init()) ++ return FALSE; ++ + if (info->flag_mem_usage && !get_kcore_dump_loads()) + return FALSE; + +@@ -4000,9 +4003,6 @@ out: + } + } + +- if (!is_xen_memory() && !cache_init()) +- return FALSE; +- + if (debug_info && !get_machdep_info()) + return FALSE; + +-- +2.9.3 + diff --git a/kexec-tools-2.0.14-makedumpfile-makedumpfile-Correct-the-calculation-of.patch b/kexec-tools-2.0.14-makedumpfile-makedumpfile-Correct-the-calculation-of.patch new file mode 100644 index 0000000..16388c8 --- /dev/null +++ b/kexec-tools-2.0.14-makedumpfile-makedumpfile-Correct-the-calculation-of.patch @@ -0,0 +1,45 @@ +From 4c53423b995463067fbbd394e724b4d1d6ea3d62 Mon Sep 17 00:00:00 2001 +Message-Id: <4c53423b995463067fbbd394e724b4d1d6ea3d62.1489471500.git.panand@redhat.com> +In-Reply-To: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com> +References: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com> +From: Baoquan He +Date: Thu, 2 Mar 2017 17:37:19 +0900 +Subject: [PATCH 5/7] [PATCH v3 5/7] makedumpfile: Correct the calculation of + kvaddr in set_kcore_vmcoreinfo + +In set_kcore_vmcoreinfo, we calculate the virtual address of vmcoreinfo +by OR operation as below: + + kvaddr = (ulong)vmcoreinfo_addr | PAGE_OFFSET; + +When mm sections kaslr is not enabled, this is correct since the +starting address of direct mapping section is 0xffff880000000000 which +is 1T aligned. Usually system with memory below 1T won't cause problem. + +However with mm section kaslr enabled, the starting address of direct +mapping is 1G aligned. The above code makes kvaddr unsure. + +So change it to adding operation: + kvaddr = (ulong)vmcoreinfo_addr + PAGE_OFFSET; + +Signed-off-by: Baoquan He +--- + elf_info.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/makedumpfile-1.6.1/elf_info.c b/makedumpfile-1.6.1/elf_info.c +index c5743b3cab28..100272f83c48 100644 +--- a/makedumpfile-1.6.1/elf_info.c ++++ b/makedumpfile-1.6.1/elf_info.c +@@ -372,7 +372,7 @@ int set_kcore_vmcoreinfo(uint64_t vmcoreinfo_addr, uint64_t vmcoreinfo_len) + off_t offset_desc; + + offset = UNINITIALIZED; +- kvaddr = (ulong)vmcoreinfo_addr | PAGE_OFFSET; ++ kvaddr = (ulong)vmcoreinfo_addr + PAGE_OFFSET; + + for (i = 0; i < num_pt_loads; ++i) { + struct pt_load_segment *p = &pt_loads[i]; +-- +2.9.3 + diff --git a/kexec-tools-2.0.14-makedumpfile-makedumpfile-Discard-process_dump_load.patch b/kexec-tools-2.0.14-makedumpfile-makedumpfile-Discard-process_dump_load.patch new file mode 100644 index 0000000..30b0e0e --- /dev/null +++ b/kexec-tools-2.0.14-makedumpfile-makedumpfile-Discard-process_dump_load.patch @@ -0,0 +1,57 @@ +From f3ff8c6232de43fa2cc60f5ca0f233cf8eb8d2ad Mon Sep 17 00:00:00 2001 +Message-Id: +In-Reply-To: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com> +References: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com> +From: Baoquan He +Date: Thu, 2 Mar 2017 17:37:23 +0900 +Subject: [PATCH 6/7] [PATCH v3 6/7] makedumpfile: Discard process_dump_load + +Kernel commit 464920104bf7 (/proc/kcore: update physical address for +kcore ram and text) provides physical address of direct mapping kcore +program segments. So no need to calculate it specifically now. And the +old code is not correct since it calls vaddr_to_paddr() which has not +been ready at that time. + +Signed-off-by: Baoquan He +--- + elf_info.c | 17 ----------------- + 1 file changed, 17 deletions(-) + +diff --git a/makedumpfile-1.6.1/elf_info.c b/makedumpfile-1.6.1/elf_info.c +index 100272f83c48..8e2437622141 100644 +--- a/makedumpfile-1.6.1/elf_info.c ++++ b/makedumpfile-1.6.1/elf_info.c +@@ -857,22 +857,6 @@ static int exclude_segment(struct pt_load_segment **pt_loads, + return 0; + } + +-static int +-process_dump_load(struct pt_load_segment *pls) +-{ +- unsigned long long paddr; +- +- paddr = vaddr_to_paddr(pls->virt_start); +- pls->phys_start = paddr; +- pls->phys_end = paddr + (pls->virt_end - pls->virt_start); +- DEBUG_MSG("process_dump_load\n"); +- DEBUG_MSG(" phys_start : %llx\n", pls->phys_start); +- DEBUG_MSG(" phys_end : %llx\n", pls->phys_end); +- DEBUG_MSG(" virt_start : %llx\n", pls->virt_start); +- DEBUG_MSG(" virt_end : %llx\n", pls->virt_end); +- +- return TRUE; +-} + + int get_kcore_dump_loads(void) + { +@@ -917,7 +901,6 @@ int get_kcore_dump_loads(void) + } + + pls[j] = *p; +- process_dump_load(&pls[j]); + j++; + } + +-- +2.9.3 + diff --git a/kexec-tools-2.0.14-makedumpfile-mem-usage-allow-to-work-only-with-f-for.patch b/kexec-tools-2.0.14-makedumpfile-mem-usage-allow-to-work-only-with-f-for.patch new file mode 100644 index 0000000..9282a37 --- /dev/null +++ b/kexec-tools-2.0.14-makedumpfile-mem-usage-allow-to-work-only-with-f-for.patch @@ -0,0 +1,84 @@ +From 78cbb4035209add81563c00ba46d237f86b8c427 Mon Sep 17 00:00:00 2001 +Message-Id: <78cbb4035209add81563c00ba46d237f86b8c427.1489471500.git.panand@redhat.com> +In-Reply-To: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com> +References: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com> +From: Pratyush Anand +Date: Thu, 2 Mar 2017 17:37:25 +0900 +Subject: [PATCH 7/7] [PATCH v3 7/7] mem-usage: allow to work only with -f for + kernel version < 4.11 + +PT_LOAD of kcore does not have valid p_paddr values for kernel version +less that v4.11. Therefore, older kernel will no long work for mem-usage +with current makedumpfile code. They can only work when they are patched +with fix to "update physical address for kcore ram and text". + +This patch fixes the makedumpfile so that it does not allow to work +older kernel for --mem-usage until someone is sure that kernel is +rightly patched and so uses -f in command line. It also updates man page +and usage info accordingly. + +Signed-off-by: Pratyush Anand +--- + makedumpfile.8 | 9 ++++++++- + makedumpfile.c | 6 ++++++ + print_info.c | 1 + + 3 files changed, 15 insertions(+), 1 deletion(-) + +diff --git a/makedumpfile-1.6.1/makedumpfile.8 b/makedumpfile-1.6.1/makedumpfile.8 +index 9069fb18cdb6..993236486e77 100644 +--- a/makedumpfile-1.6.1/makedumpfile.8 ++++ b/makedumpfile-1.6.1/makedumpfile.8 +@@ -235,13 +235,20 @@ the ELF format does not support compressed data. + + .TP + \fB\-f\fR +-Force existing DUMPFILE to be overwritten. ++Force existing DUMPFILE to be overwritten and mem-usage to work with older ++kernel as well. + .br + .B Example: + .br + # makedumpfile \-f \-d 31 \-x vmlinux /proc/vmcore dumpfile + .br + This command overwrites \fIDUMPFILE\fR even if it already exists. ++.br ++# makedumpfile \-f \-\-mem\-usage /proc/kcore ++.br ++Kernel version lesser than v4.11 will not work with \-\-mem\-usage ++functionality until it has been patched with upstream commit 464920104bf7. ++Therefore if you have patched your older kernel then use \-f. + + .TP + \fB\-x\fR \fIVMLINUX\fR +diff --git a/makedumpfile-1.6.1/makedumpfile.c b/makedumpfile-1.6.1/makedumpfile.c +index 3b8e9810468d..e3be1ab0a9ec 100644 +--- a/makedumpfile-1.6.1/makedumpfile.c ++++ b/makedumpfile-1.6.1/makedumpfile.c +@@ -11269,6 +11269,12 @@ main(int argc, char *argv[]) + MSG("Try `makedumpfile --help' for more information.\n"); + goto out; + } ++ if (info->kernel_version < KERNEL_VERSION(4, 11, 0) && ++ !info->flag_force) { ++ MSG("mem-usage not supported for this kernel.\n"); ++ MSG("You can try with -f if your kernel's kcore has valid p_paddr\n"); ++ goto out; ++ } + + if (!show_mem_usage()) + goto out; +diff --git a/makedumpfile-1.6.1/print_info.c b/makedumpfile-1.6.1/print_info.c +index 392d863a4227..3c577d83cebb 100644 +--- a/makedumpfile-1.6.1/print_info.c ++++ b/makedumpfile-1.6.1/print_info.c +@@ -310,6 +310,7 @@ print_usage(void) + MSG("\n"); + MSG(" [-f]:\n"); + MSG(" Overwrite DUMPFILE even if it already exists.\n"); ++ MSG(" Force mem-usage to work with older kernel as well.\n"); + MSG("\n"); + MSG(" [-h, --help]:\n"); + MSG(" Show help message and LZO/snappy support status (enabled/disabled).\n"); +-- +2.9.3 + diff --git a/kexec-tools-2.0.14-makedumpfile-show_mem_usage-calculate-page-offset-af.patch b/kexec-tools-2.0.14-makedumpfile-show_mem_usage-calculate-page-offset-af.patch new file mode 100644 index 0000000..5f30a2a --- /dev/null +++ b/kexec-tools-2.0.14-makedumpfile-show_mem_usage-calculate-page-offset-af.patch @@ -0,0 +1,41 @@ +From 4b0bed3523a5f6c2c428d9dab3d27d4572207d52 Mon Sep 17 00:00:00 2001 +Message-Id: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com> +From: Pratyush Anand +Date: Thu, 2 Mar 2017 17:37:08 +0900 +Subject: [PATCH 1/7] [PATCH v3 1/7] show_mem_usage(): calculate page offset + after elf load + +x86_64 calculated page offset from PT_LOAD headers. Therefore call +get_page_offset() after get_elf_loads() + +Signed-off-by: Pratyush Anand +--- + makedumpfile.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/makedumpfile-1.6.1/makedumpfile.c b/makedumpfile-1.6.1/makedumpfile.c +index e69b6df9a9ee..6942047199de 100644 +--- a/makedumpfile-1.6.1/makedumpfile.c ++++ b/makedumpfile-1.6.1/makedumpfile.c +@@ -10944,15 +10944,15 @@ int show_mem_usage(void) + + info->dump_level = MAX_DUMP_LEVEL; + +- if (!get_page_offset()) +- return FALSE; +- + if (!open_files_for_creating_dumpfile()) + return FALSE; + + if (!get_elf_loads(info->fd_memory, info->name_memory)) + return FALSE; + ++ if (!get_page_offset()) ++ return FALSE; ++ + if (!get_sys_kernel_vmcoreinfo(&vmcoreinfo_addr, &vmcoreinfo_len)) + return FALSE; + +-- +2.9.3 + diff --git a/kexec-tools-2.0.14-makedumpfile-x86_64-check-physical-address-in-PT_LOA.patch b/kexec-tools-2.0.14-makedumpfile-x86_64-check-physical-address-in-PT_LOA.patch new file mode 100644 index 0000000..02deed8 --- /dev/null +++ b/kexec-tools-2.0.14-makedumpfile-x86_64-check-physical-address-in-PT_LOA.patch @@ -0,0 +1,47 @@ +From f1363023b909df886eca5efcb64b78be9b8e6086 Mon Sep 17 00:00:00 2001 +Message-Id: +In-Reply-To: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com> +References: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com> +From: Pratyush Anand +Date: Thu, 2 Mar 2017 17:37:13 +0900 +Subject: [PATCH 3/7] [PATCH v3 3/7] x86_64: check physical address in PT_LOAD + for none direct mapped regions + +A kcore PT_LOAD can have a section from vmalloc region. However, +physical address in that header would be invalid (-1) after kernel +commit 464920104bf7 (/proc/kcore: update physical address for kcore ram +and text). Therefore, check for valid physical address while calculating +page_offset or phys_offset. + +Signed-off-by: Pratyush Anand +--- + arch/x86_64.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/makedumpfile-1.6.1/arch/x86_64.c b/makedumpfile-1.6.1/arch/x86_64.c +index 893cd516fc8b..e978a36f8878 100644 +--- a/makedumpfile-1.6.1/arch/x86_64.c ++++ b/makedumpfile-1.6.1/arch/x86_64.c +@@ -41,7 +41,8 @@ get_page_offset_x86_64(void) + unsigned long long virt_start; + + for (i = 0; get_pt_load(i, &phys_start, NULL, &virt_start, NULL); i++) { +- if (virt_start < __START_KERNEL_map) { ++ if (virt_start < __START_KERNEL_map ++ && phys_start != NOT_PADDR) { + info->page_offset = virt_start - phys_start; + return TRUE; + } +@@ -76,7 +77,8 @@ get_phys_base_x86_64(void) + } + + for (i = 0; get_pt_load(i, &phys_start, NULL, &virt_start, NULL); i++) { +- if (virt_start >= __START_KERNEL_map) { ++ if (virt_start >= __START_KERNEL_map ++ && phys_start != NOT_PADDR) { + + info->phys_base = phys_start - + (virt_start & ~(__START_KERNEL_map)); +-- +2.9.3 + diff --git a/kexec-tools-2.0.14-x86-x86_64-Fix-format-warning-with-die.patch b/kexec-tools-2.0.14-x86-x86_64-Fix-format-warning-with-die.patch new file mode 100644 index 0000000..537a234 --- /dev/null +++ b/kexec-tools-2.0.14-x86-x86_64-Fix-format-warning-with-die.patch @@ -0,0 +1,75 @@ +From fe667ab0567d5a5631809db2ce3476c83d312d21 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Pratyush Anand +Date: Tue, 14 Mar 2017 17:59:22 +0530 +Subject: [PATCH] x86/x86_64: Fix format warning with die() + +Fedora koji uses gcc version 7.0.1-0.12.fc27, and it generates a build +warning + + kexec/arch/i386/kexec-elf-x86.c:299:3: error: format not a string + literal and no format arguments [-Werror=format-security] + die(error_msg); + ^~~ + cc1: some warnings being treated as errors + +error_msg can have a format specifier as well in string. In such cases, +if there is no other arguments for the format variable then code will +try to access a non existing argument. Therefore, use 1st argument as +format specifier for string print and pass error_msg as the string to be +printed. + +While doing that,also use const qualifier before "char *error_msg". + +Signed-off-by: Pratyush Anand +Signed-off-by: Simon Horman +--- + kexec/arch/i386/kexec-elf-x86.c | 4 ++-- + kexec/arch/x86_64/kexec-elf-x86_64.c | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/kexec/arch/i386/kexec-elf-x86.c b/kexec/arch/i386/kexec-elf-x86.c +index de00dcb869d7..fedf031cdf4a 100644 +--- a/kexec/arch/i386/kexec-elf-x86.c ++++ b/kexec/arch/i386/kexec-elf-x86.c +@@ -91,7 +91,7 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len, + char *command_line = NULL, *modified_cmdline = NULL; + const char *append = NULL; + char *tmp_cmdline = NULL; +- char *error_msg = NULL; ++ const char *error_msg = NULL; + int result; + int command_line_len; + const char *ramdisk; +@@ -296,6 +296,6 @@ out: + free(command_line); + free(modified_cmdline); + if (error_msg) +- die(error_msg); ++ die("%s", error_msg); + return result; + } +diff --git a/kexec/arch/x86_64/kexec-elf-x86_64.c b/kexec/arch/x86_64/kexec-elf-x86_64.c +index ae6569220bc8..ad2231193eb1 100644 +--- a/kexec/arch/x86_64/kexec-elf-x86_64.c ++++ b/kexec/arch/x86_64/kexec-elf-x86_64.c +@@ -99,7 +99,7 @@ int elf_x86_64_load(int argc, char **argv, const char *buf, off_t len, + #define ARG_STYLE_NONE 2 + int opt; + int result = 0; +- char *error_msg = NULL; ++ const char *error_msg = NULL; + + /* See options.h and add any new options there too! */ + static const struct option options[] = { +@@ -276,6 +276,6 @@ out: + free(command_line); + free(modified_cmdline); + if (error_msg) +- die(error_msg); ++ die("%s", error_msg); + return result; + } +-- +2.9.3 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 2a176f3..9e5a61f 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -84,6 +84,16 @@ Obsoletes: diskdumputils netdump kexec-tools-eppic # Patches 601 onward are generic patches # Patch601: kexec-tools-2.0.3-disable-kexec-test.patch +Patch602: kexec-tools-2.0.14-build_mem_phdrs-check-if-p_paddr-is-invalid.patch +Patch603: kexec-tools-2.0.14-makedumpfile-show_mem_usage-calculate-page-offset-af.patch +Patch604: kexec-tools-2.0.14-makedumpfile-initial-call-cache_init-a-bit-early.patch +Patch605: kexec-tools-2.0.14-makedumpfile-x86_64-check-physical-address-in-PT_LOA.patch +Patch606: kexec-tools-2.0.14-makedumpfile-elf_info-kcore-check-for-invalid-physic.patch +Patch607: kexec-tools-2.0.14-makedumpfile-makedumpfile-Correct-the-calculation-of.patch +Patch608: kexec-tools-2.0.14-makedumpfile-makedumpfile-Discard-process_dump_load.patch +Patch609: kexec-tools-2.0.14-makedumpfile-mem-usage-allow-to-work-only-with-f-for.patch +Patch610: kexec-tools-2.0.14-x86-x86_64-Fix-format-warning-with-die.patch + %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -107,6 +117,15 @@ tar -z -x -v -f %{SOURCE19} tar -z -x -v -f %{SOURCE23} %patch601 -p1 +%patch602 -p1 +%patch603 -p1 +%patch604 -p1 +%patch605 -p1 +%patch606 -p1 +%patch607 -p1 +%patch608 -p1 +%patch609 -p1 +%patch610 -p1 %ifarch ppc %define archdef ARCH=ppc From 0c192c9ca9c0c101db6246be4e959cdab29075b9 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Fri, 17 Mar 2017 10:33:38 +0800 Subject: [PATCH 02/15] Release 2.0.14-4.1 --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 9e5a61f..a2204fd 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.14 -Release: 4%{?dist} +Release: 4%{?dist}.1 License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -329,6 +329,9 @@ done %doc %changelog +* Fri Mar 17 2017 Dave Young - 2.0.14-4.1 +- Fix kernel kaslr caused regressions (kexec -p and makedumpfile --mem-usage) + * Mon Jan 23 2017 Dave Young - 2.0.14-4 - drop kdump script rhcrashkernel-param in kexec-tools repo - kdumpctl: sanity check of nr_cpus for x86_64 in case running out of vectors From 0a6cb9cb240e9ad9b7161b5b73b1756488671a4e Mon Sep 17 00:00:00 2001 From: Baoquan He Date: Mon, 17 Apr 2017 21:56:05 +0800 Subject: [PATCH 03/15] kdump.sysconfig/x86_64: Add nokaslr to kdump kernel cmdline KASLR is to enhance security on OS kernel. While kdump kernel is working after normal kernel corrupted. There's no need to do kaslr in kdump kernel, so add 'nokaslr' to disable kaslr. Signed-off-by: Baoquan He Acked-by: Dave Young --- kdump.sysconfig.x86_64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64 index d4e26f5..f269d02 100644 --- a/kdump.sysconfig.x86_64 +++ b/kdump.sysconfig.x86_64 @@ -21,7 +21,7 @@ KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet" # This variable lets us append arguments to the current kdump commandline # after processed by KDUMP_COMMANDLINE_REMOVE -KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 rootflags=nofail acpi_no_memhotplug transparent_hugepage=never" +KDUMP_COMMANDLINE_APPEND="irqpoll nr_cpus=1 reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 rootflags=nofail acpi_no_memhotplug transparent_hugepage=never nokaslr" # Any additional kexec arguments required. In most situations, this should # be left empty From cc3fd6fa9b1c268259bc2f6d03a111ebc1363910 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 27 Apr 2017 14:04:48 +0800 Subject: [PATCH 04/15] Release 2.0.14-4.2 --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index a2204fd..daeb4dd 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.14 -Release: 4%{?dist}.1 +Release: 4%{?dist}.2 License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -329,6 +329,9 @@ done %doc %changelog +* Thu Apr 27 2017 Dave Young - 2.0.14-4.2 +- kdump.sysconfig/x86_64: Add nokaslr to kdump kernel cmdline + * Fri Mar 17 2017 Dave Young - 2.0.14-4.1 - Fix kernel kaslr caused regressions (kexec -p and makedumpfile --mem-usage) From 17d4dcdd8eef6210863032961ac55276af6822db Mon Sep 17 00:00:00 2001 From: Dave Young Date: Fri, 23 Jun 2017 11:36:37 +0800 Subject: [PATCH 05/15] Release 2.0.15-1 --- kexec-tools.spec | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index daeb4dd..cf7170a 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools -Version: 2.0.14 -Release: 4%{?dist}.2 +Version: 2.0.15 +Release: 1%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -84,7 +84,6 @@ Obsoletes: diskdumputils netdump kexec-tools-eppic # Patches 601 onward are generic patches # Patch601: kexec-tools-2.0.3-disable-kexec-test.patch -Patch602: kexec-tools-2.0.14-build_mem_phdrs-check-if-p_paddr-is-invalid.patch Patch603: kexec-tools-2.0.14-makedumpfile-show_mem_usage-calculate-page-offset-af.patch Patch604: kexec-tools-2.0.14-makedumpfile-initial-call-cache_init-a-bit-early.patch Patch605: kexec-tools-2.0.14-makedumpfile-x86_64-check-physical-address-in-PT_LOA.patch @@ -92,7 +91,6 @@ Patch606: kexec-tools-2.0.14-makedumpfile-elf_info-kcore-check-for-invalid-physi Patch607: kexec-tools-2.0.14-makedumpfile-makedumpfile-Correct-the-calculation-of.patch Patch608: kexec-tools-2.0.14-makedumpfile-makedumpfile-Discard-process_dump_load.patch Patch609: kexec-tools-2.0.14-makedumpfile-mem-usage-allow-to-work-only-with-f-for.patch -Patch610: kexec-tools-2.0.14-x86-x86_64-Fix-format-warning-with-die.patch %description @@ -117,7 +115,6 @@ tar -z -x -v -f %{SOURCE19} tar -z -x -v -f %{SOURCE23} %patch601 -p1 -%patch602 -p1 %patch603 -p1 %patch604 -p1 %patch605 -p1 @@ -125,7 +122,6 @@ tar -z -x -v -f %{SOURCE23} %patch607 -p1 %patch608 -p1 %patch609 -p1 -%patch610 -p1 %ifarch ppc %define archdef ARCH=ppc @@ -329,6 +325,9 @@ done %doc %changelog +* Thu Jun 23 2017 Dave Young - 2.0.15-1 +- rebase upstream kexec-tools 2.0.15 + * Thu Apr 27 2017 Dave Young - 2.0.14-4.2 - kdump.sysconfig/x86_64: Add nokaslr to kdump kernel cmdline From 1015342a9a7a70d0c849eb2104d90d79abe2a230 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Fri, 23 Jun 2017 11:49:40 +0800 Subject: [PATCH 06/15] Release 2.0.15-1.1 build failure fix: update sources file --- kexec-tools.spec | 5 ++++- sources | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index cf7170a..4505509 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.15 -Release: 1%{?dist} +Release: 1%{?dist}.1 License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -325,6 +325,9 @@ done %doc %changelog +* Thu Jun 23 2017 Dave Young - 2.0.15-1.1 +- update sources file + * Thu Jun 23 2017 Dave Young - 2.0.15-1 - rebase upstream kexec-tools 2.0.15 diff --git a/sources b/sources index a3f4f60..c0a4290 100644 --- a/sources +++ b/sources @@ -2,3 +2,4 @@ SHA512 (eppic_050615.tar.gz) = de23c3cd59ded23f2f0092c194b2169e78fcd385a8df7daf3 SHA512 (kexec-tools-2.0.14.tar.xz) = 8c1f9d1f4bb69a621961d45091f9c8349535ae69b80168423663685b44d89e1b9324d5cd11c83e86d805a3371f4f1600b0def551c52efb3c6cf020e9c11c273f SHA512 (kdump-anaconda-addon-005-25-g2a4398f.tar.gz) = 0ce8602607a8d781e1804973e6affef1ed3dce729bb1a5525b2a8129f28bcb88713f6e8be5e3f41151223518096f7eed33dd3ea0e63ac7dc338b21fb78664e7e SHA512 (makedumpfile-1.6.1.tar.gz) = fd343e8117e38f9fd608f914297dfe54e0b677733db1871db5824d8ca549e6b8709ae5df6ec82362c100c6d8f35815c39c48e0c87395a30e6305aba7d11c8708 +SHA512 (kexec-tools-2.0.15.tar.xz) = 0bddf31b9bb0e203b813d820e1e248974c2d62cb388dfaf4f2f4971f764cc71e54edbaeaeb663c15d6fa06574beceb87d9ffd7d822ac6699d86c54645096e7e9 From 85309b932e2a4bf1f253e92af9185ffb50979ae3 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Fri, 23 Jun 2017 11:52:40 +0800 Subject: [PATCH 07/15] Release 2.0.15-1.2 --- kexec-tools.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 4505509..9b8f0a3 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.15 -Release: 1%{?dist}.1 +Release: 1%{?dist}.2 License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -325,7 +325,7 @@ done %doc %changelog -* Thu Jun 23 2017 Dave Young - 2.0.15-1.1 +* Fri Jun 23 2017 Dave Young - 2.0.15-1.2 - update sources file * Thu Jun 23 2017 Dave Young - 2.0.15-1 From b698bf5f7a86667dfcf6b57a5de542301a1165aa Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Mon, 15 May 2017 15:00:51 +0200 Subject: [PATCH 08/15] dracut-module-setup: Fix test for inclusion of DRM modules The /sys/modules/*/drivers sysfs entries do not exist anymore on newer kernels which means that the DRM moduels would never be included. Instead check if there is any device with a "drm" sysfs directory to decide on whether DRM modules need to be included. Acked-by: Dave Young --- dracut-module-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 1f96bb8..46e6d1e 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -20,7 +20,7 @@ check() { depends() { local _dep="base shutdown" - if [ -d /sys/module/drm/drivers ]; then + if [ -n "$( find /sys/devices -name drm )" ]; then _dep="$_dep drm" fi From 43350e9a7d093d3cdcd2b6953571cea655471ffe Mon Sep 17 00:00:00 2001 From: Pratyush Anand Date: Tue, 27 Jun 2017 15:38:46 +0530 Subject: [PATCH 09/15] aarch64: Add makedumpfile executable Add makedumpfile executable for aarch64 as well. Signed-off-by: Pratyush Anand Acked-by: Dave Young --- kexec-tools.spec | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 9b8f0a3..8d55952 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -146,7 +146,7 @@ cp %{SOURCE21} . cp %{SOURCE27} . make -%ifarch %{ix86} x86_64 ppc64 s390x ppc64le +%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 make -C eppic/libeppic make -C makedumpfile-1.6.1 LINKTYPE=dynamic USELZO=on USESNAPPY=on make -C makedumpfile-1.6.1 LDFLAGS="-I../eppic/libeppic -L../eppic/libeppic" eppic_makedumpfile.so @@ -189,7 +189,7 @@ install -m 644 %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5 install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service install -m 755 -D %{SOURCE22} $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh -%ifarch %{ix86} x86_64 ppc64 s390x ppc64le +%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 install -m 755 makedumpfile-1.6.1/makedumpfile $RPM_BUILD_ROOT/sbin/makedumpfile install -m 644 makedumpfile-1.6.1/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz install -m 644 makedumpfile-1.6.1/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz @@ -294,7 +294,7 @@ done %{_bindir}/* %{_datadir}/kdump %{_prefix}/lib/kdump -%ifarch %{ix86} x86_64 ppc64 s390x ppc64le +%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 %{_sysconfdir}/makedumpfile.conf.sample %endif %config(noreplace,missingok) %{_sysconfdir}/sysconfig/kdump @@ -314,7 +314,7 @@ done %doc kexec-kdump-howto.txt %doc kdump-in-cluster-environment.txt %doc live-image-kdump-howto.txt -%ifarch %{ix86} x86_64 ppc64 s390x ppc64le +%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 %{_libdir}/eppic_makedumpfile.so /usr/share/makedumpfile/eppic_scripts/ %endif From 6c79c1c41686cd38eea4823e67dc115129470d91 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Wed, 28 Jun 2017 14:37:50 +0800 Subject: [PATCH 10/15] Release 2.0.15-1.3 --- kexec-tools.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 8d55952..b235e65 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.15 -Release: 1%{?dist}.2 +Release: 1%{?dist}.3 License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -325,6 +325,10 @@ done %doc %changelog +* Wed Jun 28 2017 Dave Young - 2.0.15-1.3 +- aarch64: Add makedumpfile executable +- dracut-module-setup: Fix test for inclusion of DRM modules + * Fri Jun 23 2017 Dave Young - 2.0.15-1.2 - update sources file From ef5f1a7b8d867aad206ac253aad0558108db589b Mon Sep 17 00:00:00 2001 From: Dave Young Date: Wed, 20 Sep 2017 16:55:28 +0800 Subject: [PATCH 11/15] Release 2.0.15-1.4 Pull in two makedumpfile fixes which is needed by 4.13+ kernel --- ...MAP_MASK-for-kernel-bigger-than-4.13.patch | 66 +++++++++++++++++++ ...-of-init-level4-pgt-rename-in-kernel.patch | 43 ++++++++++++ kexec-tools.spec | 9 ++- 3 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 kexec-tools-2.0.15-makedumpfile-fix-SECTION_MAP_MASK-for-kernel-bigger-than-4.13.patch create mode 100644 kexec-tools-2.0.15-makedumpfile-take-care-of-init-level4-pgt-rename-in-kernel.patch diff --git a/kexec-tools-2.0.15-makedumpfile-fix-SECTION_MAP_MASK-for-kernel-bigger-than-4.13.patch b/kexec-tools-2.0.15-makedumpfile-fix-SECTION_MAP_MASK-for-kernel-bigger-than-4.13.patch new file mode 100644 index 0000000..7209d50 --- /dev/null +++ b/kexec-tools-2.0.15-makedumpfile-fix-SECTION_MAP_MASK-for-kernel-bigger-than-4.13.patch @@ -0,0 +1,66 @@ +From: Pratyush Anand +To: ats-kumagai@wm.jp.nec.com +Subject: [Makedumpfile PATCH v2] Fix SECTION_MAP_MASK for kernel >= v.13 +Date: Thu, 17 Aug 2017 09:16:59 +0530 +Cc: Pratyush Anand , dyoung@redhat.com, + kexec@lists.infradead.org, bhe@redhat.com +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Content-Type: text/plain; charset=utf-8 + +commit 2d070eab2e82 "mm: consider zone which is not fully populated to +have holes" added a new flag SECTION_IS_ONLINE and therefore +SECTION_MAP_MASK has been changed. We are not able to find correct +mem_map in makedumpfile for kernel version v4.13-rc1 and onward because +of the above kernel change. + +This patch fixes the MASK value keeping the code backward compatible + +Signed-off-by: Pratyush Anand +--- +v1->v2: Improved kernel_version comparison to take care of stable kernel +versions as well. + + makedumpfile.c | 5 ++++- + makedumpfile.h | 4 +++- + 2 files changed, 7 insertions(+), 2 deletions(-) + +diff --git kexec-tools-2.0.15/makedumpfile-1.6.1/makedumpfile.c kexec-tools-2.0.15.new/makedumpfile-1.6.1/makedumpfile.c +index 30230a15a2e7..c975651ca357 100644 +--- kexec-tools-2.0.15/makedumpfile-1.6.1/makedumpfile.c ++++ kexec-tools-2.0.15.new/makedumpfile-1.6.1/makedumpfile.c +@@ -3304,7 +3304,10 @@ section_mem_map_addr(unsigned long addr) + return NOT_KV_ADDR; + } + map = ULONG(mem_section + OFFSET(mem_section.section_mem_map)); +- map &= SECTION_MAP_MASK; ++ if (info->kernel_version < KERNEL_VERSION(4, 13, 0)) ++ map &= SECTION_MAP_MASK_4_12; ++ else ++ map &= SECTION_MAP_MASK; + free(mem_section); + + return map; +diff --git kexec-tools-2.0.15/makedumpfile-1.6.1/makedumpfile.h kexec-tools-2.0.15.new/makedumpfile-1.6.1/makedumpfile.h +index 8a05794843fb..322f28c632b0 100644 +--- kexec-tools-2.0.15/makedumpfile-1.6.1/makedumpfile.h ++++ kexec-tools-2.0.15.new/makedumpfile-1.6.1/makedumpfile.h +@@ -183,7 +183,9 @@ isAnon(unsigned long mapping) + #define SECTIONS_PER_ROOT() (info->sections_per_root) + #define SECTION_ROOT_MASK() (SECTIONS_PER_ROOT() - 1) + #define SECTION_NR_TO_ROOT(sec) ((sec) / SECTIONS_PER_ROOT()) +-#define SECTION_MAP_LAST_BIT (1UL<<2) ++#define SECTION_IS_ONLINE (1UL<<2) ++#define SECTION_MAP_LAST_BIT (1UL<<3) ++#define SECTION_MAP_MASK_4_12 (~(SECTION_IS_ONLINE-1)) + #define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1)) + #define NR_SECTION_ROOTS() divideup(num_section, SECTIONS_PER_ROOT()) + #define SECTION_NR_TO_PFN(sec) ((sec) << PFN_SECTION_SHIFT()) +-- +2.9.4 + + +_______________________________________________ +kexec mailing list +kexec@lists.infradead.org +http://lists.infradead.org/mailman/listinfo/kexec diff --git a/kexec-tools-2.0.15-makedumpfile-take-care-of-init-level4-pgt-rename-in-kernel.patch b/kexec-tools-2.0.15-makedumpfile-take-care-of-init-level4-pgt-rename-in-kernel.patch new file mode 100644 index 0000000..56c9a50 --- /dev/null +++ b/kexec-tools-2.0.15-makedumpfile-take-care-of-init-level4-pgt-rename-in-kernel.patch @@ -0,0 +1,43 @@ +Following commit renamed init_level4_pgt to init_top_pgt in kernel. + +commit 65ade2f872b474fa8a04c2d397783350326634e6 +Author: Kirill A. Shutemov +Date: Tue Jun 6 14:31:27 2017 +0300 + + x86/boot/64: Rename init_level4_pgt and early_level4_pgt + +This patch takes care of above kernel modification in makedumpfile. + +Signed-off-by: Pratyush Anand +--- +v2 -> v1 +Removed redundant 'if condition' for WRITE_SYMBOL(). + + makedumpfile.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git kexec-tools-2.0.15/makedumpfile-1.6.1/makedumpfile.c kexec-tools-2.0.15.new/makedumpfile-1.6.1/makedumpfile.c +index f85003a33551..30230a15a2e7 100644 +--- kexec-tools-2.0.15/makedumpfile-1.6.1/makedumpfile.c ++++ kexec-tools-2.0.15.new/makedumpfile-1.6.1/makedumpfile.c +@@ -1486,6 +1486,8 @@ get_symbol_info(void) + SYMBOL_INIT(_stext, "_stext"); + SYMBOL_INIT(swapper_pg_dir, "swapper_pg_dir"); + SYMBOL_INIT(init_level4_pgt, "init_level4_pgt"); ++ if (SYMBOL(init_level4_pgt) == NOT_FOUND_SYMBOL) ++ SYMBOL_INIT(init_level4_pgt, "init_top_pgt"); + SYMBOL_INIT(vmlist, "vmlist"); + SYMBOL_INIT(vmap_area_list, "vmap_area_list"); + SYMBOL_INIT(node_online_map, "node_online_map"); +@@ -2500,6 +2502,8 @@ read_vmcoreinfo(void) + READ_SYMBOL("_stext", _stext); + READ_SYMBOL("swapper_pg_dir", swapper_pg_dir); + READ_SYMBOL("init_level4_pgt", init_level4_pgt); ++ if (SYMBOL(init_level4_pgt) == NOT_FOUND_SYMBOL) ++ READ_SYMBOL("init_top_pgt", init_level4_pgt); + READ_SYMBOL("vmlist", vmlist); + READ_SYMBOL("vmap_area_list", vmap_area_list); + READ_SYMBOL("node_online_map", node_online_map); +-- +2.9.4 + diff --git a/kexec-tools.spec b/kexec-tools.spec index b235e65..13f6399 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.15 -Release: 1%{?dist}.3 +Release: 1%{?dist}.4 License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -91,6 +91,8 @@ Patch606: kexec-tools-2.0.14-makedumpfile-elf_info-kcore-check-for-invalid-physi Patch607: kexec-tools-2.0.14-makedumpfile-makedumpfile-Correct-the-calculation-of.patch Patch608: kexec-tools-2.0.14-makedumpfile-makedumpfile-Discard-process_dump_load.patch Patch609: kexec-tools-2.0.14-makedumpfile-mem-usage-allow-to-work-only-with-f-for.patch +Patch610: kexec-tools-2.0.15-makedumpfile-take-care-of-init-level4-pgt-rename-in-kernel.patch +Patch611: kexec-tools-2.0.15-makedumpfile-fix-SECTION_MAP_MASK-for-kernel-bigger-than-4.13.patch %description @@ -122,6 +124,8 @@ tar -z -x -v -f %{SOURCE23} %patch607 -p1 %patch608 -p1 %patch609 -p1 +%patch610 -p1 +%patch611 -p1 %ifarch ppc %define archdef ARCH=ppc @@ -325,6 +329,9 @@ done %doc %changelog +* Wed Sep 20 2017 Dave Young - 2.0.15-1.4 +- Pull in two makedumpfile patches for 4.13.0+ kernel + * Wed Jun 28 2017 Dave Young - 2.0.15-1.3 - aarch64: Add makedumpfile executable - dracut-module-setup: Fix test for inclusion of DRM modules From d2a1aee1bb3f3a84fd8c4a0e645b16d2d9aee4c2 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 9 Nov 2017 13:40:03 +0800 Subject: [PATCH 12/15] Use absolute path /usr/bin/dracut in mkdumprd Since we call dracut directly on current working directory "." so it is possible to trick root to call fake code. Thus move to use absolute path instead. Signed-off-by: Dave Young Acked-by: Bhupesh Sharma --- mkdumprd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkdumprd b/mkdumprd index f30d9c2..8ddabb4 100644 --- a/mkdumprd +++ b/mkdumprd @@ -17,6 +17,7 @@ SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2) [ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH # strip the duplicated "/" SAVE_PATH=$(echo $SAVE_PATH | tr -s /) +DRACUT_PATH=/usr/bin is_wdt_addition_needed() { local active @@ -514,7 +515,7 @@ then add_dracut_arg "--add-drivers" "$extra_modules" fi -dracut "${dracut_args[@]}" "$@" +${DRACUT_PATH}/dracut "${dracut_args[@]}" "$@" _rc=$? sync exit $_rc From e0bcb94c5a2b4a97600c641fea2ae777fd650dcb Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 9 Nov 2017 13:41:24 +0800 Subject: [PATCH 13/15] Release 2.0.15-1.5 --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 13f6399..926a30e 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.15 -Release: 1%{?dist}.4 +Release: 1%{?dist}.5 License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -329,6 +329,9 @@ done %doc %changelog +* Thu Nov 9 2017 Dave Young - 2.0.15-1.5 +- Use absolute path /usr/bin/dracut in mkdumprd + * Wed Sep 20 2017 Dave Young - 2.0.15-1.4 - Pull in two makedumpfile patches for 4.13.0+ kernel From c73c95b4e0b7e943e2a9719ea5a918995722db79 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 9 Nov 2017 15:33:21 +0800 Subject: [PATCH 14/15] Revert "Use absolute path /usr/bin/dracut in mkdumprd" This reverts commit d2a1aee1bb3f3a84fd8c4a0e645b16d2d9aee4c2. --- mkdumprd | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mkdumprd b/mkdumprd index 8ddabb4..f30d9c2 100644 --- a/mkdumprd +++ b/mkdumprd @@ -17,7 +17,6 @@ SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2) [ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH # strip the duplicated "/" SAVE_PATH=$(echo $SAVE_PATH | tr -s /) -DRACUT_PATH=/usr/bin is_wdt_addition_needed() { local active @@ -515,7 +514,7 @@ then add_dracut_arg "--add-drivers" "$extra_modules" fi -${DRACUT_PATH}/dracut "${dracut_args[@]}" "$@" +dracut "${dracut_args[@]}" "$@" _rc=$? sync exit $_rc From 48a9ed3b34e67a2f091bde128d51a68eb177c294 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 9 Nov 2017 15:34:45 +0800 Subject: [PATCH 15/15] Release 2.0.15-1.6 --- kexec-tools.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index 926a30e..b340b12 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.15 -Release: 1%{?dist}.5 +Release: 1%{?dist}.6 License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -329,6 +329,9 @@ done %doc %changelog +* Thu Nov 9 2017 Dave Young - 2.0.15-1.6 +- Revert "Use absolute path /usr/bin/dracut in mkdumprd" + * Thu Nov 9 2017 Dave Young - 2.0.15-1.5 - Use absolute path /usr/bin/dracut in mkdumprd