commit 29b1ba17f5158a32985f581d56e6161675902879 Author: MSVSphere Packaging Team Date: Tue Nov 26 17:26:51 2024 +0300 import makedumpfile-1.7.5-12.el10 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..89eb1ef --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +SOURCES/eppic-e8844d3.tar.gz +SOURCES/makedumpfile-1.7.5.tar.gz diff --git a/.makedumpfile.metadata b/.makedumpfile.metadata new file mode 100644 index 0000000..72b38c8 --- /dev/null +++ b/.makedumpfile.metadata @@ -0,0 +1,2 @@ +80ac3f5e77d3c79883edadf14428734db4720009 SOURCES/eppic-e8844d3.tar.gz +f2af3dcdac5f006078880f600380a490c75da8e4 SOURCES/makedumpfile-1.7.5.tar.gz diff --git a/SOURCES/0001-PATCH-Fix-failure-of-hugetlb-pages-exclusion-on-Linu.patch b/SOURCES/0001-PATCH-Fix-failure-of-hugetlb-pages-exclusion-on-Linu.patch new file mode 100644 index 0000000..a18c0c3 --- /dev/null +++ b/SOURCES/0001-PATCH-Fix-failure-of-hugetlb-pages-exclusion-on-Linu.patch @@ -0,0 +1,100 @@ +From 985e575253f1c2de8d6876cfe685c68a24ee06e1 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Thu, 30 May 2024 16:59:02 +0900 +Subject: [PATCH 1/2] [PATCH] Fix failure of hugetlb pages exclusion on Linux + 6.9 and later + +* Required for kernel 6.9 + +Kernel commit d99e3140a4d3 ("mm: turn folio_test_hugetlb into a +PageType") moved the PG_hugetlb flag from folio._flags_1 into +page._mapcount and introduced NUMBER(PAGE_HUGETLB_MAPCOUNT_VALUE) entry +into vmcoreinfo. + +Without the patch, "makedumpfile -d 8" cannot exclude hugetlb pages. + +Signed-off-by: Kazuhito Hagio +Signed-off-by: Lianbo Jiang +--- + makedumpfile.c | 22 ++++++++++++++++++++-- + makedumpfile.h | 3 +++ + 2 files changed, 23 insertions(+), 2 deletions(-) + +diff --git a/makedumpfile.c b/makedumpfile.c +index d7f1dd41d2ca..437ad916f816 100644 +--- a/makedumpfile.c ++++ b/makedumpfile.c +@@ -2975,6 +2975,7 @@ read_vmcoreinfo(void) + READ_SRCFILE("pud_t", pud_t); + + READ_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE); ++ READ_NUMBER("PAGE_HUGETLB_MAPCOUNT_VALUE", PAGE_HUGETLB_MAPCOUNT_VALUE); + READ_NUMBER("PAGE_OFFLINE_MAPCOUNT_VALUE", PAGE_OFFLINE_MAPCOUNT_VALUE); + READ_NUMBER("phys_base", phys_base); + READ_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE); +@@ -6510,6 +6511,9 @@ __exclude_unnecessary_pages(unsigned long mem_map, + _count = UINT(pcache + OFFSET(page._refcount)); + mapping = ULONG(pcache + OFFSET(page.mapping)); + ++ if (OFFSET(page._mapcount) != NOT_FOUND_STRUCTURE) ++ _mapcount = UINT(pcache + OFFSET(page._mapcount)); ++ + compound_order = 0; + compound_dtor = 0; + /* +@@ -6520,6 +6524,22 @@ __exclude_unnecessary_pages(unsigned long mem_map, + if ((index_pg < PGMM_CACHED - 1) && isCompoundHead(flags)) { + unsigned char *addr = pcache + SIZE(page); + ++ /* ++ * Linux 6.9 and later kernels use _mapcount value for hugetlb pages. ++ * See kernel commit d99e3140a4d3. ++ */ ++ if (NUMBER(PAGE_HUGETLB_MAPCOUNT_VALUE) != NOT_FOUND_NUMBER) { ++ unsigned long _flags_1 = ULONG(addr + OFFSET(page.flags)); ++ unsigned int PG_hugetlb = ~NUMBER(PAGE_HUGETLB_MAPCOUNT_VALUE); ++ ++ compound_order = _flags_1 & 0xff; ++ ++ if ((_mapcount & (PAGE_TYPE_BASE | PG_hugetlb)) == PAGE_TYPE_BASE) ++ compound_dtor = IS_HUGETLB; ++ ++ goto check_order; ++ } ++ + /* + * Linux 6.6 and later. Kernels that have PG_hugetlb should also + * have the compound order in the low byte of folio._flags_1. +@@ -6564,8 +6584,6 @@ check_order: + if (OFFSET(page.compound_head) != NOT_FOUND_STRUCTURE) + compound_head = ULONG(pcache + OFFSET(page.compound_head)); + +- if (OFFSET(page._mapcount) != NOT_FOUND_STRUCTURE) +- _mapcount = UINT(pcache + OFFSET(page._mapcount)); + if (OFFSET(page.private) != NOT_FOUND_STRUCTURE) + private = ULONG(pcache + OFFSET(page.private)); + +diff --git a/makedumpfile.h b/makedumpfile.h +index 75b66ceaba21..f08c49fc73be 100644 +--- a/makedumpfile.h ++++ b/makedumpfile.h +@@ -165,6 +165,8 @@ test_bit(int nr, unsigned long addr) + #define isAnon(mapping, flags) (((unsigned long)mapping & PAGE_MAPPING_ANON) != 0 \ + && !isSlab(flags)) + ++#define PAGE_TYPE_BASE (0xf0000000) ++ + #define PTOB(X) (((unsigned long long)(X)) << PAGESHIFT()) + #define BTOP(X) (((unsigned long long)(X)) >> PAGESHIFT()) + +@@ -2255,6 +2257,7 @@ struct number_table { + long PG_hugetlb; + + long PAGE_BUDDY_MAPCOUNT_VALUE; ++ long PAGE_HUGETLB_MAPCOUNT_VALUE; + long PAGE_OFFLINE_MAPCOUNT_VALUE; + long SECTION_SIZE_BITS; + long MAX_PHYSMEM_BITS; +-- +2.45.1 + diff --git a/SOURCES/0001-PATCH-Workaround-for-segfault-by-makedumpfile-mem-us.patch b/SOURCES/0001-PATCH-Workaround-for-segfault-by-makedumpfile-mem-us.patch new file mode 100644 index 0000000..e98c7d2 --- /dev/null +++ b/SOURCES/0001-PATCH-Workaround-for-segfault-by-makedumpfile-mem-us.patch @@ -0,0 +1,58 @@ +From 900190de6b67b2de410cfc8023c1b198a416ceb3 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Mon, 22 Jul 2024 14:31:43 +0900 +Subject: [PATCH] [PATCH] Workaround for segfault by "makedumpfile --mem-usage" + on PPC64 + +"makedumpfile --mem-usage /proc/kcore" can cause a segmentation fault on +PPC64, because the readmem() of the following code path uses cache +before it's initialized in initial(). + + show_mem_usage + get_page_offset + get_versiondep_info_ppc64 + readmem + ... + initial + cache_init + +The get_page_offset() is needed to get vmcoreinfo from /proc/kcore data, +so we can avoid calling it when a vmcoreinfo exists in the ELF NOTE +segment of /proc/kcore, i.e. on Linux 4.19 and later. + +(Note: for older kernels, we will need another way to fix it.) + +Reported-by: Lichen Liu +Signed-off-by: Kazuhito Hagio +--- + makedumpfile.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/makedumpfile.c b/makedumpfile.c +index 5b34712..7d1dfcc 100644 +--- a/makedumpfile.c ++++ b/makedumpfile.c +@@ -12019,14 +12019,14 @@ int show_mem_usage(void) + DEBUG_MSG("Read vmcoreinfo from NOTE segment: %d\n", vmcoreinfo); + } + +- if (!get_page_offset()) +- return FALSE; ++ if (!vmcoreinfo) { ++ if (!get_page_offset()) ++ return FALSE; + +- /* paddr_to_vaddr() on arm64 needs phys_base. */ +- if (!get_phys_base()) +- return FALSE; ++ /* paddr_to_vaddr() on arm64 needs phys_base. */ ++ if (!get_phys_base()) ++ return FALSE; + +- if (!vmcoreinfo) { + if (!get_sys_kernel_vmcoreinfo(&vmcoreinfo_addr, &vmcoreinfo_len)) + return FALSE; + +-- +2.45.2 + diff --git a/SOURCES/0002-PATCH-Fix-wrong-exclusion-of-Slab-pages-on-Linux-6.1.patch b/SOURCES/0002-PATCH-Fix-wrong-exclusion-of-Slab-pages-on-Linux-6.1.patch new file mode 100644 index 0000000..06a02e3 --- /dev/null +++ b/SOURCES/0002-PATCH-Fix-wrong-exclusion-of-Slab-pages-on-Linux-6.1.patch @@ -0,0 +1,130 @@ +From bad2a7c4fa75d37a41578441468584963028bdda Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Fri, 7 Jun 2024 15:34:05 +0900 +Subject: [PATCH 2/2] [PATCH] Fix wrong exclusion of Slab pages on Linux + 6.10-rc1 and later + +* Required for kernel 6.10 + +Kernel commit 46df8e73a4a3 ("mm: free up PG_slab") moved the PG_slab +flag from page.flags into page._mapcount (slab.__page_type), and +introduced NUMBER(PAGE_SLAB_MAPCOUNT_VALUE) entry into vmcoreinfo. + +Without the patch, "makedumpfile -d 8" option wrongly excludes Slab +pages and crash cannot open the dumpfile with an error like this: + + $ crash --kaslr auto vmlinux dumpfile + ... + please wait... (gathering task table data) + crash: page excluded: kernel virtual address: ffff909980440270 type: "xa_node.slots[off]" + +Signed-off-by: Kazuhito Hagio +Signed-off-by: Lianbo Jiang +--- + makedumpfile.c | 24 +++++++++++++++++++----- + makedumpfile.h | 6 +++--- + 2 files changed, 22 insertions(+), 8 deletions(-) + +diff --git a/makedumpfile.c b/makedumpfile.c +index 437ad916f816..5b347126db76 100644 +--- a/makedumpfile.c ++++ b/makedumpfile.c +@@ -275,13 +275,26 @@ isHugetlb(unsigned long dtor) + && (SYMBOL(free_huge_page) == dtor)); + } + ++static inline int ++isSlab(unsigned long flags, unsigned int _mapcount) ++{ ++ /* Linux 6.10 and later */ ++ if (NUMBER(PAGE_SLAB_MAPCOUNT_VALUE) != NOT_FOUND_NUMBER) { ++ unsigned int PG_slab = ~NUMBER(PAGE_SLAB_MAPCOUNT_VALUE); ++ if ((_mapcount & (PAGE_TYPE_BASE | PG_slab)) == PAGE_TYPE_BASE) ++ return TRUE; ++ } ++ ++ return flags & (1UL << NUMBER(PG_slab)); ++} ++ + static int + isOffline(unsigned long flags, unsigned int _mapcount) + { + if (NUMBER(PAGE_OFFLINE_MAPCOUNT_VALUE) == NOT_FOUND_NUMBER) + return FALSE; + +- if (flags & (1UL << NUMBER(PG_slab))) ++ if (isSlab(flags, _mapcount)) + return FALSE; + + if (_mapcount == (int)NUMBER(PAGE_OFFLINE_MAPCOUNT_VALUE)) +@@ -2977,6 +2990,7 @@ read_vmcoreinfo(void) + READ_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE); + READ_NUMBER("PAGE_HUGETLB_MAPCOUNT_VALUE", PAGE_HUGETLB_MAPCOUNT_VALUE); + READ_NUMBER("PAGE_OFFLINE_MAPCOUNT_VALUE", PAGE_OFFLINE_MAPCOUNT_VALUE); ++ READ_NUMBER("PAGE_SLAB_MAPCOUNT_VALUE", PAGE_SLAB_MAPCOUNT_VALUE); + READ_NUMBER("phys_base", phys_base); + READ_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE); + +@@ -6043,7 +6057,7 @@ static int + page_is_buddy_v3(unsigned long flags, unsigned int _mapcount, + unsigned long private, unsigned int _count) + { +- if (flags & (1UL << NUMBER(PG_slab))) ++ if (isSlab(flags, _mapcount)) + return FALSE; + + if (_mapcount == (int)NUMBER(PAGE_BUDDY_MAPCOUNT_VALUE)) +@@ -6618,7 +6632,7 @@ check_order: + */ + else if ((info->dump_level & DL_EXCLUDE_CACHE) + && is_cache_page(flags) +- && !isPrivate(flags) && !isAnon(mapping, flags)) { ++ && !isPrivate(flags) && !isAnon(mapping, flags, _mapcount)) { + pfn_counter = &pfn_cache; + } + /* +@@ -6626,7 +6640,7 @@ check_order: + */ + else if ((info->dump_level & DL_EXCLUDE_CACHE_PRI) + && is_cache_page(flags) +- && !isAnon(mapping, flags)) { ++ && !isAnon(mapping, flags, _mapcount)) { + if (isPrivate(flags)) + pfn_counter = &pfn_cache_private; + else +@@ -6638,7 +6652,7 @@ check_order: + * - hugetlbfs pages + */ + else if ((info->dump_level & DL_EXCLUDE_USER_DATA) +- && (isAnon(mapping, flags) || isHugetlb(compound_dtor))) { ++ && (isAnon(mapping, flags, _mapcount) || isHugetlb(compound_dtor))) { + pfn_counter = &pfn_user; + } + /* +diff --git a/makedumpfile.h b/makedumpfile.h +index f08c49fc73be..6b43a8b44f93 100644 +--- a/makedumpfile.h ++++ b/makedumpfile.h +@@ -161,9 +161,8 @@ test_bit(int nr, unsigned long addr) + #define isSwapBacked(flags) test_bit(NUMBER(PG_swapbacked), flags) + #define isHWPOISON(flags) (test_bit(NUMBER(PG_hwpoison), flags) \ + && (NUMBER(PG_hwpoison) != NOT_FOUND_NUMBER)) +-#define isSlab(flags) test_bit(NUMBER(PG_slab), flags) +-#define isAnon(mapping, flags) (((unsigned long)mapping & PAGE_MAPPING_ANON) != 0 \ +- && !isSlab(flags)) ++#define isAnon(mapping, flags, _mapcount) \ ++ (((unsigned long)mapping & PAGE_MAPPING_ANON) != 0 && !isSlab(flags, _mapcount)) + + #define PAGE_TYPE_BASE (0xf0000000) + +@@ -2259,6 +2258,7 @@ struct number_table { + long PAGE_BUDDY_MAPCOUNT_VALUE; + long PAGE_HUGETLB_MAPCOUNT_VALUE; + long PAGE_OFFLINE_MAPCOUNT_VALUE; ++ long PAGE_SLAB_MAPCOUNT_VALUE; + long SECTION_SIZE_BITS; + long MAX_PHYSMEM_BITS; + long HUGETLB_PAGE_DTOR; +-- +2.45.1 + diff --git a/SPECS/makedumpfile.spec b/SPECS/makedumpfile.spec new file mode 100644 index 0000000..a5e11af --- /dev/null +++ b/SPECS/makedumpfile.spec @@ -0,0 +1,73 @@ +%global eppic_ver e8844d3793471163ae4a56d8f95897be9e5bd554 +%global eppic_shortver %(c=%{eppic_ver}; echo ${c:0:7}) +Name: makedumpfile +Version: 1.7.5 +Summary: make a small dumpfile of kdump +Release: 12%{?dist} + +License: GPL-2.0-only +URL: https://github.com/makedumpfile/makedumpfile +Source0: https://github.com/makedumpfile/makedumpfile/archive/%{version}/%{name}-%{version}.tar.gz +Source1: https://github.com/lucchouina/eppic/archive/%{eppic_ver}/eppic-%{eppic_shortver}.tar.gz + +Conflicts: kexec-tools < 2.0.28-5 +BuildRequires: make +BuildRequires: gcc +BuildRequires: zlib-devel +BuildRequires: elfutils-devel +BuildRequires: glib2-devel +BuildRequires: bzip2-devel +BuildRequires: ncurses-devel +BuildRequires: bison +BuildRequires: flex +BuildRequires: lzo-devel +BuildRequires: snappy-devel +BuildRequires: libzstd-devel +BuildRequires: pkgconfig +BuildRequires: intltool +BuildRequires: gettext + +Patch0: 0001-PATCH-Fix-failure-of-hugetlb-pages-exclusion-on-Linu.patch +Patch1: 0002-PATCH-Fix-wrong-exclusion-of-Slab-pages-on-Linux-6.1.patch +Patch2: 0001-PATCH-Workaround-for-segfault-by-makedumpfile-mem-us.patch + +%description +makedumpfile is a tool to compress and filter out unneeded data from kernel +dumps to reduce its file size. It is typically used with the kdump mechanism. + +%prep +%autosetup -p1 +tar -z -x -v -f %{SOURCE1} +sed -r -i 's|/usr/sbin|%_sbindir|g' Makefile + +%build +%make_build LINKTYPE=dynamic USELZO=on USESNAPPY=on USEZSTD=on +%make_build -C eppic-%{eppic_ver}/libeppic +%make_build LDFLAGS="$LDFLAGS -Ieppic-%{eppic_ver}/libeppic -Leppic-%{eppic_ver}/libeppic" eppic_makedumpfile.so + +%install +%make_install +install -m 644 -D makedumpfile.conf %{buildroot}/%{_sysconfdir}/makedumpfile.conf.sample +rm %{buildroot}/%{_sbindir}/makedumpfile-R.pl + +install -m 755 -D eppic_makedumpfile.so %{buildroot}/%{_libdir}/eppic_makedumpfile.so + +%files +%{_sbindir}/makedumpfile +%{_mandir}/man5/makedumpfile.conf.5* +%{_mandir}/man8/makedumpfile.8* +%{_sysconfdir}/makedumpfile.conf.sample +%{_libdir}/eppic_makedumpfile.so +%{_datadir}/makedumpfile/ +%license COPYING + +%changelog +* Fri Jul 26 2024 Lichen Liu - 1.7.5-12 +- Resolves: RHEL-41117 + +* Fri Jun 21 2024 Lianbo Jiang - 1.7.5-11 +- Fix failure of hugetlb pages exclusion on Linux 6.9 and later +- Fix wrong exclusion of Slab pages on Linux 6.10-rc1 and later + +* Thu Nov 23 2023 Coiby Xu - 1.7.5-1 +- split from kexec-tools