Rebase makedumpfile to upstream latest(8e8b8814be1)

Resolves: bz2173815

Signed-off-by: Tao Liu <ltao@redhat.com>
This commit is contained in:
Tao Liu 2023-04-21 16:00:24 +08:00
parent a0f7f2ecdf
commit 2ba6f6fb2f
8 changed files with 369 additions and 0 deletions

View File

@ -117,6 +117,14 @@ Patch602: kexec-tools-2.0.26-0002-kexec-make-a-the-default.patch
Patch603: kexec-tools-2.0.26-0003-x86-add-devicetree-support.patch
Patch604: kexec-tools-2.0.26-0004-ppc64-Add-elf-ppc64-file-types-options-and-an-arch-s.patch
Patch620: makedumpfile-1.7.2-0001-Mark-start-of-1.7.3-development-phase-with-ver.patch
Patch621: makedumpfile-1.7.2-0002-Makefile-Remove-version-from-usr-share-makedum.patch
Patch622: makedumpfile-1.7.2-0003-IMPLEMENTAION-Add-a-description-of-the-flatten.patch
Patch623: makedumpfile-1.7.2-0004-Fix-wrong-exclusion-of-slab-pages-on-Linux-6.2.patch
Patch624: makedumpfile-1.7.2-0005-sadump-fix-failure-of-reading-memory-when-5-le.patch
Patch625: makedumpfile-1.7.2-0006-1-2-eppic-Fix-incompatible-pointer-type-warnin.patch
Patch626: makedumpfile-1.7.2-0007-2-2-eppic-Fix-a-warning-about-redefining-ERRMS.patch
%description
kexec-tools provides /sbin/kexec binary that facilitates a new
kernel to boot using the kernel's kexec feature either on a
@ -136,6 +144,14 @@ tar -z -x -v -f %{SOURCE19}
%patch603 -p1
%patch604 -p1
%patch620 -p1
%patch621 -p1
%patch622 -p1
%patch623 -p1
%patch624 -p1
%patch625 -p1
%patch626 -p1
%ifarch ppc
%define archdef ARCH=ppc
%endif

View File

@ -0,0 +1,26 @@
From 2f53c3a6006a475cca65f73538dc2c844c313940 Mon Sep 17 00:00:00 2001
From: Kazuhito Hagio <k-hagio-ab@nec.com>
Date: Thu, 27 Oct 2022 09:34:28 +0900
Subject: [PATCH 1/7] [PATCH] Mark start of 1.7.3 development phase with
version 1.7.2++
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/makedumpfile-1.7.2/Makefile b/makedumpfile-1.7.2/Makefile
index 548e5b7..f982aaf 100644
--- a/makedumpfile-1.7.2/Makefile
+++ b/makedumpfile-1.7.2/Makefile
@@ -1,6 +1,6 @@
# makedumpfile
-VERSION=1.7.2
+VERSION=1.7.2++
DATE=20 Oct 2022
# Honour the environment variable CC
--
2.33.1

View File

@ -0,0 +1,34 @@
From f1d84a5d69d81bc7a89aefae504be88df1e50693 Mon Sep 17 00:00:00 2001
From: Leonidas Spyropoulos <artafinde@archlinux.org>
Date: Fri, 21 Oct 2022 11:24:59 +0100
Subject: [PATCH 2/7] [PATCH] Makefile: Remove version from
/usr/share/makedumpfile
Version specific paths doesn't make sense at /usr/share/makedumpfile.
This assumes you will have only one version installed which on a normal
system it makes sense and devs can always specify different DESTDIR per
versions.
Fixes: https://github.com/makedumpfile/makedumpfile/issues/10
Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
---
Makefile | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/makedumpfile-1.7.2/Makefile b/makedumpfile-1.7.2/Makefile
index f982aaf..a289e41 100644
--- a/makedumpfile-1.7.2/Makefile
+++ b/makedumpfile-1.7.2/Makefile
@@ -130,6 +130,6 @@ install:
install -m 755 -t ${DESTDIR}/usr/sbin makedumpfile $(VPATH)makedumpfile-R.pl
install -m 644 -t ${DESTDIR}/usr/share/man/man8 makedumpfile.8
install -m 644 -t ${DESTDIR}/usr/share/man/man5 makedumpfile.conf.5
- mkdir -p ${DESTDIR}/usr/share/makedumpfile-${VERSION}/eppic_scripts
- install -m 644 -D $(VPATH)makedumpfile.conf ${DESTDIR}/usr/share/makedumpfile-${VERSION}/makedumpfile.conf.sample
- install -m 644 -t ${DESTDIR}/usr/share/makedumpfile-${VERSION}/eppic_scripts/ $(VPATH)eppic_scripts/*
+ mkdir -p ${DESTDIR}/usr/share/makedumpfile/eppic_scripts
+ install -m 644 -D $(VPATH)makedumpfile.conf ${DESTDIR}/usr/share/makedumpfile/makedumpfile.conf.sample
+ install -m 644 -t ${DESTDIR}/usr/share/makedumpfile/eppic_scripts/ $(VPATH)eppic_scripts/*
--
2.33.1

View File

@ -0,0 +1,67 @@
From 42955c0b4d9c0723de72a810f80e4b3543053631 Mon Sep 17 00:00:00 2001
From: Kazuhito Hagio <k-hagio-ab@nec.com>
Date: Wed, 30 Nov 2022 12:02:44 +0900
Subject: [PATCH 3/7] [PATCH] IMPLEMENTAION: Add a description of the flattened
format
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
---
IMPLEMENTATION | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/makedumpfile-1.7.2/IMPLEMENTATION b/makedumpfile-1.7.2/IMPLEMENTATION
index 589c5bf..b7a1603 100644
--- a/makedumpfile-1.7.2/IMPLEMENTATION
+++ b/makedumpfile-1.7.2/IMPLEMENTATION
@@ -280,3 +280,48 @@
If there is no segment dumped into the DUMPFILE, the DUMPFILE can't be
analysed by crash.
+
+
+* The flattened format
+
+ This format is mostly used to send dump data to a remote host via SSH.
+ The kdump-compressed format and ELF format require random access to create
+ a DUMPFILE, so it cannot be written directly to standard output.
+ The flattened format adds the original offset and size of each data block,
+ and it can be rearranged to the original format on the remote host.
+
+ - File structure
+
+ This is the case of the kdump-compressed format.
+ File offset
+ +------------------------------------------+ 0x0
+ | flat header (struct makedumpfile_header) |
+ | |
+ |------------------------------------------| 0x1000 (4096)
+ | flat data header |
+ | (struct makedumpfile_data_header) |
+ | main header (struct disk_dump_header) |
+ |------------------------------------------| (not aligned)
+ | flat data header |
+ | : |
+
+ Note: For the ELF format, ELF header is not always the first data.
+
+ - flat header
+
+ struct makedumpfile_header {
+ char signature[SIG_LEN_MDF]; /* = "makedumpfile\0\0\0\0" */
+ int64_t type; /* = TYPE_FLAT_HEADER (1) */
+ int64_t version; /* = VERSION_FLAT_HEADER (1) */
+ };
+
+ Note: the type and version are big endian.
+
+ - flat data header
+
+ struct makedumpfile_data_header {
+ int64_t offset;
+ int64_t buf_size;
+ };
+
+ Note: the offset and buf_size are big endian.
--
2.33.1

View File

@ -0,0 +1,82 @@
From 5f17bdd2128998a3eeeb4521d136a192222fadb6 Mon Sep 17 00:00:00 2001
From: Kazuhito Hagio <k-hagio-ab@nec.com>
Date: Wed, 21 Dec 2022 11:06:39 +0900
Subject: [PATCH 4/7] [PATCH] Fix wrong exclusion of slab pages on Linux
6.2-rc1
* Required for kernel 6.2
Kernel commit 130d4df57390 ("mm/sl[au]b: rearrange struct slab fields to
allow larger rcu_head"), which is contained in Linux 6.2-rc1 and later,
made the offset of slab.slabs equal to page.mapping's one. As a result,
"makedumpfile -d 8", which should exclude user data, excludes some slab
pages wrongly because isAnon() returns true when slab.slabs is an odd
number. With such dumpfiles, crash can fail to start session with an
error like this:
# crash vmlinux dumpfile
...
crash: page excluded: kernel virtual address: ffff8fa047ac2fe8 type: "xa_node shift"
Make isAnon() check that the page is not slab to fix this.
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
---
makedumpfile.c | 6 +++---
makedumpfile.h | 9 +++------
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/makedumpfile-1.7.2/makedumpfile.c b/makedumpfile-1.7.2/makedumpfile.c
index ff821eb..f403683 100644
--- a/makedumpfile-1.7.2/makedumpfile.c
+++ b/makedumpfile-1.7.2/makedumpfile.c
@@ -6502,7 +6502,7 @@ __exclude_unnecessary_pages(unsigned long mem_map,
*/
else if ((info->dump_level & DL_EXCLUDE_CACHE)
&& is_cache_page(flags)
- && !isPrivate(flags) && !isAnon(mapping)) {
+ && !isPrivate(flags) && !isAnon(mapping, flags)) {
pfn_counter = &pfn_cache;
}
/*
@@ -6510,7 +6510,7 @@ __exclude_unnecessary_pages(unsigned long mem_map,
*/
else if ((info->dump_level & DL_EXCLUDE_CACHE_PRI)
&& is_cache_page(flags)
- && !isAnon(mapping)) {
+ && !isAnon(mapping, flags)) {
if (isPrivate(flags))
pfn_counter = &pfn_cache_private;
else
@@ -6522,7 +6522,7 @@ __exclude_unnecessary_pages(unsigned long mem_map,
* - hugetlbfs pages
*/
else if ((info->dump_level & DL_EXCLUDE_USER_DATA)
- && (isAnon(mapping) || isHugetlb(compound_dtor))) {
+ && (isAnon(mapping, flags) || isHugetlb(compound_dtor))) {
pfn_counter = &pfn_user;
}
/*
diff --git a/makedumpfile-1.7.2/makedumpfile.h b/makedumpfile-1.7.2/makedumpfile.h
index 70a1a91..21dec7d 100644
--- a/makedumpfile-1.7.2/makedumpfile.h
+++ b/makedumpfile-1.7.2/makedumpfile.h
@@ -161,12 +161,9 @@ 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))
-
-static inline int
-isAnon(unsigned long mapping)
-{
- return ((unsigned long)mapping & PAGE_MAPPING_ANON) != 0;
-}
+#define isSlab(flags) test_bit(NUMBER(PG_slab), flags)
+#define isAnon(mapping, flags) (((unsigned long)mapping & PAGE_MAPPING_ANON) != 0 \
+ && !isSlab(flags))
#define PTOB(X) (((unsigned long long)(X)) << PAGESHIFT())
#define BTOP(X) (((unsigned long long)(X)) >> PAGESHIFT())
--
2.33.1

View File

@ -0,0 +1,72 @@
From 58553ad03187f0cf208d6c4a0dc026c6338e5edd Mon Sep 17 00:00:00 2001
From: "Daisuke Hatayama (Fujitsu)" <d.hatayama@fujitsu.com>
Date: Wed, 29 Mar 2023 12:44:10 +0000
Subject: [PATCH 5/7] [PATCH] sadump: fix failure of reading memory when
5-level paging is enabled
makedumpfile fails as follows for memory dumps collected by sadump
when 5-level paging is enabled on the corresponding systems:
# makedumpfile -l -d 31 -x ./vmlinux ./dump.sadump dump.sadump-ld31
__vtop4_x86_64: Can't get a valid pgd.
...snip...
__vtop4_x86_64: Can't get a valid pgd.
calc_kaslr_offset: failed to calculate kaslr_offset and phys_base; default to 0
__vtop4_x86_64: Can't get a valid pgd.
readmem: Can't convert a virtual address(ffffffff82fce960) to physical address.
readmem: type_addr: 0, addr:ffffffff82fce960, size:1024
cpu_online_mask_init: Can't read cpu_online_mask memory.
makedumpfile Failed.
This is because 5-level paging support has not been done yet for
sadump; the work of the 5-level paging support was done by the commit
30a3214a7193e94c551c0cebda5918a72a35c589 (PATCH 4/4 arch/x86_64: Add
5-level paging support) but that was focused on the core part only.
Having said that, most of things has already been finished in the
commit. What needs to be newly added for sadump is just how to check
if 5-level paging is enabled for a given memory dump.
For that purpose, let's refer to CR4.LA57, bit 12 of CR4, representing
whether 5-level paging is enabled or not. We can do this because
memory dumps collected by sadump have SMRAM as note information and
they include CR4 together with the other control registers.
Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
---
sadump_info.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/makedumpfile-1.7.2/sadump_info.c b/makedumpfile-1.7.2/sadump_info.c
index adfa8dc..2c44068 100644
--- a/makedumpfile-1.7.2/sadump_info.c
+++ b/makedumpfile-1.7.2/sadump_info.c
@@ -1362,6 +1362,7 @@ static int linux_banner_sanity_check(ulong cr3)
#define PTI_USER_PGTABLE_BIT (info->page_shift)
#define PTI_USER_PGTABLE_MASK (1 << PTI_USER_PGTABLE_BIT)
#define CR3_PCID_MASK 0xFFFull
+#define CR4_LA57 (1 << 12)
int
calc_kaslr_offset(void)
{
@@ -1397,6 +1398,8 @@ calc_kaslr_offset(void)
else
cr3 = smram.Cr3 & ~CR3_PCID_MASK;
+ NUMBER(pgtable_l5_enabled) = !!(smram.Cr4 & CR4_LA57);
+
/* Convert virtual address of IDT table to physical address */
idtr_paddr = vtop4_x86_64_pagetable(idtr, cr3);
if (idtr_paddr == NOT_PADDR) {
@@ -1417,6 +1420,7 @@ calc_kaslr_offset(void)
DEBUG_MSG("sadump: idtr=%" PRIx64 "\n", idtr);
DEBUG_MSG("sadump: cr3=%" PRIx64 "\n", cr3);
+ DEBUG_MSG("sadump: cr4=%" PRIx32 "\n", smram.Cr4);
DEBUG_MSG("sadump: idtr(phys)=%" PRIx64 "\n", idtr_paddr);
DEBUG_MSG("sadump: devide_error(vmlinux)=%lx\n",
divide_error_vmlinux);
--
2.33.1

View File

@ -0,0 +1,44 @@
From f8ac9140c2e649229880a1b08e199f8245c9cd20 Mon Sep 17 00:00:00 2001
From: Petr Tesarik <ptesarik@suse.com>
Date: Sat, 15 Apr 2023 18:02:12 +0200
Subject: [PATCH 6/7] [PATCH 1/2] eppic: Fix incompatible pointer type warnings
On Linux, eppic defines ull (a bit confusingly) as uint64_t. This
is an unsigned long on 64-bit platforms with both GCC and LLVM, and
the compiler complains about passing a pointer to an unsigned long
where a pointer to an unsigned long long is expected.
It is not a real bug, because both types are identical on 64-bit
platforms, and on 32-bit platforms, uint64_t denotes an unsigned
long long, but the warning is annoying.
Signed-off-by: Petr Tesarik <petr@tesarici.cz>
---
extension_eppic.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/makedumpfile-1.7.2/extension_eppic.c b/makedumpfile-1.7.2/extension_eppic.c
index 45bc032..8aa9ed2 100644
--- a/makedumpfile-1.7.2/extension_eppic.c
+++ b/makedumpfile-1.7.2/extension_eppic.c
@@ -122,7 +122,7 @@ drilldown(ull offset, type_t *t)
{
int type_flag, len = 0, t_len = 0, nidx = 0;
int fctflg = 0, ref = 0, *idxlst = 0;
- ull die_off = offset, t_die_off;
+ unsigned long long die_off = offset, t_die_off;
char *tstr = NULL, *tstr_dup = NULL;
while (GET_DIE_ATTR_TYPE(die_off, &type_flag, &t_die_off)) {
@@ -221,7 +221,7 @@ apimember(char *mname, ull idx, type_t *tm, member_t *m, ull *last_index)
int index, nfields = -1, size;
int nbits = 0, fbits = 0;
long offset;
- ull m_die, die_off = idx;
+ unsigned long long m_die, die_off = idx;
char *name = NULL;
nfields = GET_DIE_NFIELDS_ALL(die_off);
--
2.33.1

View File

@ -0,0 +1,28 @@
From 8e8b8814be1a9f8b5b66ca06a602041b05c923df Mon Sep 17 00:00:00 2001
From: Petr Tesarik <petr@tesarici.cz>
Date: Sat, 15 Apr 2023 18:02:13 +0200
Subject: [PATCH 7/7] [PATCH 2/2] eppic: Fix a warning about redefining ERRMSG
The macro is redefined on purpose, so let's #undef it first to
silence the warning.
Signed-off-by: Petr Tesarik <petr@tesarici.cz>
---
extension_eppic.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/makedumpfile-1.7.2/extension_eppic.h b/makedumpfile-1.7.2/extension_eppic.h
index 24189ba..08f1db0 100644
--- a/makedumpfile-1.7.2/extension_eppic.h
+++ b/makedumpfile-1.7.2/extension_eppic.h
@@ -71,6 +71,7 @@ typedef TYPE_S {
ull rtype; /* type_t a reference refers too */
} type_t;
+#undef ERRMSG
#define ERRMSG(x...) \
do { \
fprintf(stderr, __FUNCTION__); \
--
2.33.1