Accepting request 1126689 from Kernel:kdump

- Enable build for riscv64.
- Reduce compatibility cruft.
- Update to 1.7.4:
  * Add riscv64 support
  * Support kernels up to v6.6 (x86_64)
- Drop upstreamed patches:
  * ppc64-do-page-traversal-if-vmemmap_list-not-po.patch
  * Support-struct-module_memory-on-Linux-6.4-and-.patch
- Build with a bundled eppic git snapshot.

OBS-URL: https://build.opensuse.org/request/show/1126689
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/makedumpfile?expand=0&rev=91
This commit is contained in:
Ana Guerrero 2023-11-16 19:27:19 +00:00 committed by Git OBS Bridge
commit 91e85c8779
8 changed files with 49 additions and 389 deletions

View File

@ -1,109 +0,0 @@
From f23bb943568188a2746dbf9b6692668f5a2ac3b6 Mon Sep 17 00:00:00 2001
From: Kazuhito Hagio <k-hagio-ab@nec.com>
Date: Wed, 17 May 2023 16:42:46 +0900
Subject: [PATCH] [PATCH] Support struct module_memory on Linux 6.4 and later
* Required for kernel 6.4
Kernel commit [1] replaced module_layout with module_memory on Linux
6.4. As a result, makedumpfile with --config option cannot load module
symbols correctly and fails with an error like this:
$ makedumpfile -d 31 --config mkdf.conf -x vmlinux vmcore dumpfile
...
__vtop4_x86_64: Can't get a valid pgd.
readmem: Can't convert a virtual address(0) to physical address.
readmem: type_addr: 0, addr:0, size:0
__load_module_symbol: Can't access module in memory.
makedumpfile Failed.
To fix this, adopt module offsets to module_memory ones.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ac3b43283923
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
---
makedumpfile.c | 24 ++++++++++++++++++++++++
makedumpfile.h | 7 +++++++
2 files changed, 31 insertions(+)
diff --git a/makedumpfile.c b/makedumpfile.c
index ba2bb46fe54e..cadc59662bef 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -1710,6 +1710,9 @@ get_symbol_info(void)
return TRUE;
}
+#define MOD_DATA 1
+#define MOD_INIT_DATA 5
+
int
get_structure_info(void)
{
@@ -1817,6 +1820,26 @@ get_structure_info(void)
OFFSET_INIT(module.num_symtab, "module", "num_symtab");
OFFSET_INIT(module.list, "module", "list");
OFFSET_INIT(module.name, "module", "name");
+
+ /* kernel >= 6.4 */
+ SIZE_INIT(module_memory, "module_memory");
+ if (SIZE(module_memory) != NOT_FOUND_STRUCTURE) {
+ OFFSET_INIT(module.mem, "module", "mem");
+ OFFSET_INIT(module_memory.base, "module_memory", "base");
+ OFFSET_INIT(module_memory.size, "module_memory", "size");
+
+ OFFSET(module.module_core) = OFFSET(module.mem) +
+ SIZE(module_memory) * MOD_DATA + OFFSET(module_memory.base);
+ OFFSET(module.core_size) = OFFSET(module.mem) +
+ SIZE(module_memory) * MOD_DATA + OFFSET(module_memory.size);
+ OFFSET(module.module_init) = OFFSET(module.mem) +
+ SIZE(module_memory) * MOD_INIT_DATA + OFFSET(module_memory.base);
+ OFFSET(module.init_size) = OFFSET(module.mem) +
+ SIZE(module_memory) * MOD_INIT_DATA + OFFSET(module_memory.size);
+
+ goto module_end;
+ }
+
OFFSET_INIT(module.module_core, "module", "module_core");
if (OFFSET(module.module_core) == NOT_FOUND_STRUCTURE) {
/* for kernel version 4.5 and above */
@@ -1858,6 +1881,7 @@ get_structure_info(void)
OFFSET(module.init_size) += init_layout;
}
+module_end:
ENUM_NUMBER_INIT(NR_FREE_PAGES, "NR_FREE_PAGES");
ENUM_NUMBER_INIT(N_ONLINE, "N_ONLINE");
ENUM_NUMBER_INIT(pgtable_l5_enabled, "pgtable_l5_enabled");
diff --git a/makedumpfile.h b/makedumpfile.h
index 99ccf0a3bd6c..85e5a4932983 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -1842,6 +1842,7 @@ struct size_table {
* for loading module symbol data
*/
long module;
+ long module_memory;
/*
* for sadump
@@ -1944,8 +1945,14 @@ struct offset_table {
long num_symtab;
long symtab;
long strtab;
+ long mem;
} module;
+ struct module_memory {
+ long base;
+ long size;
+ } module_memory;
+
/*
* for loading elf_prstaus symbol data
*/
--
2.42.0

BIN
eppic-21808c78596d6d80c67eeaa08a618570ae0d886d.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f059dbebf5156a9ab97cd3c1f41ad5df3436c7ab4dd6dbffa234fc4e93cfa2ce
size 206343

BIN
makedumpfile-1.7.4.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -54,8 +54,8 @@ Index: makedumpfile-1.7.1/makedumpfile.h
--- makedumpfile-1.7.1.orig/makedumpfile.h
+++ makedumpfile-1.7.1/makedumpfile.h
@@ -2069,6 +2069,9 @@ struct number_table {
unsigned long PHYS_OFFSET;
unsigned long kimage_voffset;
unsigned long kernel_link_addr;
unsigned long va_kernel_pa_offset;
#endif
+
+ /* Distro-specific */

View File

@ -1,3 +1,24 @@
-------------------------------------------------------------------
Wed Nov 15 14:00:28 UTC 2023 - Petr Tesařík <petr@tesarici.cz>
- Enable build for riscv64.
-------------------------------------------------------------------
Wed Nov 15 12:29:49 UTC 2023 - Petr Tesařík <petr@tesarici.cz>
- Reduce compatibility cruft.
-------------------------------------------------------------------
Wed Nov 15 12:05:18 UTC 2023 - Petr Tesařík <petr@tesarici.cz>
- Update to 1.7.4:
* Add riscv64 support
* Support kernels up to v6.6 (x86_64)
- Drop upstreamed patches:
* ppc64-do-page-traversal-if-vmemmap_list-not-po.patch
* Support-struct-module_memory-on-Linux-6.4-and-.patch
- Build with a bundled eppic git snapshot.
-------------------------------------------------------------------
Fri Oct 6 08:29:14 UTC 2023 - Michal Suchanek <msuchanek@suse.de>

View File

@ -16,19 +16,8 @@
#
%if 0%{?suse_version} && 0%{?suse_version} <= 1500
%define build_eppic 1
%else
%define build_eppic 0
%endif
%if 0%{!?have_snappy:1}
%if 0%{?suse_version} >= 1310
%define have_snappy 1
%else
%define have_snappy 0
%endif
%endif
%define eppic_commit 21808c78596d6d80c67eeaa08a618570ae0d886d
%if 0%{!?have_zstd:1}
%if 0%{?sle_version} >= 150200 || 0%{?suse_version} > 1500
@ -38,45 +27,36 @@
%endif
%endif
# Compatibility cruft
# there is no separate -ltinfo until openSUSE 13.1 / SLE 12
%if 0%{?suse_version} < 1310 && 0%{?sles_version} < 12
%define ncurses_make_opts TINFOLIB=-lncurses
%endif
# End of compatibility cruft
Name: makedumpfile
Version: 1.7.3
Version: 1.7.4
Release: 0
Summary: Partial kernel dump
License: GPL-2.0-only
Group: System/Kernel
URL: https://github.com/makedumpfile/makedumpfile
Source: https://github.com/makedumpfile/makedumpfile/releases/download/%{version}/%{name}-%{version}.tar.gz
Source1: https://github.com/lucchouina/eppic/archive/%{eppic_commit}.tar.gz#/eppic-%{eppic_commit}.tar.gz
Source99: %{name}-rpmlintrc
Patch0: %{name}-override-libtinfo.patch
Patch1: %{name}-ppc64-VA-range-SUSE.patch
Patch2: %{name}-PN_XNUM.patch
Patch3: Support-struct-module_memory-on-Linux-6.4-and-.patch
Patch4: ppc64-do-page-traversal-if-vmemmap_list-not-po.patch
BuildRequires: libbz2-devel
BuildRequires: libdw-devel
BuildRequires: libelf-devel
%if %{build_eppic}
BuildRequires: libeppic-devel
%endif
BuildRequires: lzo-devel
BuildRequires: ncurses-devel
BuildRequires: snappy-devel
BuildRequires: xz-devel
BuildRequires: zlib-devel
BuildRoot: %{_tmppath}/%{name}-%{version}-build
ExclusiveArch: %{ix86} x86_64 ia64 ppc ppc64 ppc64le s390x %{arm} aarch64
%if %{have_snappy}
BuildRequires: snappy-devel
%endif
ExclusiveArch: %{ix86} x86_64 ia64 ppc ppc64 ppc64le riscv64 s390x %{arm} aarch64
%if %{have_zstd}
BuildRequires: libzstd-devel
%endif
%if %{build_eppic}
BuildRequires: bison
BuildRequires: flex
%endif
%description
makedumpfile is a dump program to shorten the size of dump file. It
@ -85,20 +65,28 @@ and can compress the page data. The obtained dump file can by analyzed
via gdb or crash utility.
%prep
%if %{build_eppic}
%autosetup -p1 -b1
%else
%autosetup -p1
%endif
%build
export CFLAGS="%{optflags} -fcommon"
%if %{have_snappy}
export USESNAPPY=on
%endif
%if %{have_zstd}
export USEZSTD=on
%endif
export USELZO=on
export LINKTYPE=dynamic
make %{?_smp_mflags} LDFLAGS="-Wl,-rpath,%{_libdir}/%{name}-%{version}"
%if %{build_eppic}
pushd ../eppic-%{eppic_commit}/libeppic
make
popd
export CFLAGS="-I../eppic-%{eppic_commit}/libeppic $CFLAGS"
export LDFLAGS="-L../eppic-%{eppic_commit}/libeppic $LDFLAGS"
make %{?_smp_mflags} eppic_makedumpfile.so %{?ncurses_make_opts}
%endif
@ -122,8 +110,7 @@ install -m 0644 -t %{buildroot}%{_datadir}/%{name}-%{version}/eppic_scripts/ epp
%if 0%(test ! -d %{_defaultlicensedir} && echo 1)
%define _defaultlicensedir %{_defaultdocdir}
%endif
%endif
# End of compatibility cruft
%endif # End of compatibility cruft
%files
%defattr(-,root,root)

View File

@ -1,242 +0,0 @@
From a34f017965583e89c4cb0b00117c200a6c191e54 Mon Sep 17 00:00:00 2001
From: Aditya Gupta <adityag@linux.ibm.com>
Date: Thu, 14 Sep 2023 14:52:23 +0530
Subject: [PATCH] [PATCH] ppc64: do page traversal if vmemmap_list not
populated
Currently 'makedumpfile' fails to collect vmcore on upstream kernel,
with the errors:
readpage_elf: Attempt to read non-existent page at 0x4000000000000000.
readmem: type_addr: 0, addr:0, size:8
get_vmemmap_list_info: Can't get vmemmap region addresses
get_machdep_info_ppc64: Can't get vmemmap list info.
This occurs since makedumpfile depends on 'vmemmap_list' for translating
vmemmap addresses. But with below commit in Linux 6.6-rc1, vmemmap_list
can be empty, in case of Radix MMU on PowerPC64.
368a0590d954: (powerpc/book3s64/vmemmap: switch radix to use a
different vmemmap handling function)
In case vmemmap_list is empty, then it's head is NULL, which causes
makedumpfile to fail with above error.
Since with above commit, 'vmemmap_list' is not populated (when MMU is
Radix MMU), kernel populates corresponding page table entries in kernel
page table. Hence, instead of depending on 'vmemmap_list' for address
translation for vmemmap addresses, do a kernel pagetable walk.
And since the pte can also be introduced at higher levels in the page
table, such as at PMD level, add hugepage support, by checking for
PAGE_PTE flag.
Reported-by: Sachin Sant <sachinp@linux.ibm.com>
Tested-by: Sachin Sant <sachinp@linux.ibm.com>
Signed-off-by: Aditya Gupta <adityag@linux.ibm.com>
---
arch/ppc64.c | 111 ++++++++++++++++++++++++++++++++++---------------
makedumpfile.h | 6 +++
2 files changed, 84 insertions(+), 33 deletions(-)
diff --git a/arch/ppc64.c b/arch/ppc64.c
index 5e70acb51aba..96c357cb0335 100644
--- a/arch/ppc64.c
+++ b/arch/ppc64.c
@@ -196,6 +196,10 @@ ppc64_vmemmap_init(void)
int psize, shift;
ulong head;
+ /* initialise vmemmap_list in case SYMBOL(vmemmap_list) is not found */
+ info->vmemmap_list = NULL;
+ info->vmemmap_cnt = 0;
+
if ((SYMBOL(vmemmap_list) == NOT_FOUND_SYMBOL)
|| (SYMBOL(mmu_psize_defs) == NOT_FOUND_SYMBOL)
|| (SYMBOL(mmu_vmemmap_psize) == NOT_FOUND_SYMBOL)
@@ -216,15 +220,24 @@ ppc64_vmemmap_init(void)
return FALSE;
info->vmemmap_psize = 1 << shift;
- if (!readmem(VADDR, SYMBOL(vmemmap_list), &head, sizeof(unsigned long)))
- return FALSE;
-
/*
- * Get vmemmap list count and populate vmemmap regions info
- */
- info->vmemmap_cnt = get_vmemmap_list_info(head);
- if (info->vmemmap_cnt == 0)
- return FALSE;
+ * vmemmap_list symbol can be missing or set to 0 in the kernel.
+ * This would imply vmemmap region is mapped in the kernel pagetable.
+ *
+ * So, read vmemmap_list anyway, and use 'vmemmap_list' if it's not empty
+ * (head != NULL), or we will do a kernel pagetable walk for vmemmap address
+ * translation later
+ **/
+ readmem(VADDR, SYMBOL(vmemmap_list), &head, sizeof(unsigned long));
+
+ if (head) {
+ /*
+ * Get vmemmap list count and populate vmemmap regions info
+ */
+ info->vmemmap_cnt = get_vmemmap_list_info(head);
+ if (info->vmemmap_cnt == 0)
+ return FALSE;
+ }
info->flag_vmemmap = TRUE;
return TRUE;
@@ -347,29 +360,6 @@ ppc64_vmalloc_init(void)
return TRUE;
}
-/*
- * If the vmemmap address translation information is stored in the kernel,
- * make the translation.
- */
-static unsigned long long
-ppc64_vmemmap_to_phys(unsigned long vaddr)
-{
- int i;
- ulong offset;
- unsigned long long paddr = NOT_PADDR;
-
- for (i = 0; i < info->vmemmap_cnt; i++) {
- if ((vaddr >= info->vmemmap_list[i].virt) && (vaddr <
- (info->vmemmap_list[i].virt + info->vmemmap_psize))) {
- offset = vaddr - info->vmemmap_list[i].virt;
- paddr = info->vmemmap_list[i].phys + offset;
- break;
- }
- }
-
- return paddr;
-}
-
static unsigned long long
ppc64_vtop_level4(unsigned long vaddr)
{
@@ -379,6 +369,8 @@ ppc64_vtop_level4(unsigned long vaddr)
unsigned long long pgd_pte, pud_pte;
unsigned long long pmd_pte, pte;
unsigned long long paddr = NOT_PADDR;
+ uint is_hugepage = 0;
+ uint pdshift;
uint swap = 0;
if (info->page_buf == NULL) {
@@ -413,6 +405,13 @@ ppc64_vtop_level4(unsigned long vaddr)
if (!pgd_pte)
return NOT_PADDR;
+ if (IS_HUGEPAGE(pgd_pte)) {
+ is_hugepage = 1;
+ pte = pgd_pte;
+ pdshift = info->l4_shift;
+ goto out;
+ }
+
/*
* Sometimes we don't have level3 pagetable entries
*/
@@ -426,6 +425,13 @@ ppc64_vtop_level4(unsigned long vaddr)
pud_pte = swap64(ULONG((info->page_buf + PAGEOFFSET(page_upper))), swap);
if (!pud_pte)
return NOT_PADDR;
+
+ if (IS_HUGEPAGE(pud_pte)) {
+ is_hugepage = 1;
+ pte = pud_pte;
+ pdshift = info->l3_shift;
+ goto out;
+ }
} else {
pud_pte = pgd_pte;
}
@@ -440,6 +446,13 @@ ppc64_vtop_level4(unsigned long vaddr)
if (!(pmd_pte))
return NOT_PADDR;
+ if (IS_HUGEPAGE(pmd_pte)) {
+ is_hugepage = 1;
+ pte = pmd_pte;
+ pdshift = info->l2_shift;
+ goto out;
+ }
+
pmd_pte = pmd_page_vaddr_l4(pmd_pte);
page_table = (ulong *)(pmd_pte)
+ (BTOP(vaddr) & (info->ptrs_per_l1 - 1));
@@ -456,8 +469,40 @@ ppc64_vtop_level4(unsigned long vaddr)
if (!pte)
return NOT_PADDR;
- paddr = PAGEBASE(PTOB((pte & info->pte_rpn_mask) >> info->pte_rpn_shift))
+out:
+ if (is_hugepage) {
+ paddr = PAGEBASE(PTOB((pte & info->pte_rpn_mask) >> info->pte_rpn_shift))
+ + (vaddr & ((1UL << pdshift) - 1));
+ } else {
+ paddr = PAGEBASE(PTOB((pte & info->pte_rpn_mask) >> info->pte_rpn_shift))
+ PAGEOFFSET(vaddr);
+ }
+
+ return paddr;
+}
+
+/*
+ * If the vmemmap address translation information is stored in the kernel,
+ * make the translation.
+ */
+static unsigned long long
+ppc64_vmemmap_to_phys(unsigned long vaddr)
+{
+ int i;
+ ulong offset;
+ unsigned long long paddr = NOT_PADDR;
+
+ if (!info->vmemmap_list)
+ return ppc64_vtop_level4(vaddr);
+
+ for (i = 0; i < info->vmemmap_cnt; i++) {
+ if ((vaddr >= info->vmemmap_list[i].virt) && (vaddr <
+ (info->vmemmap_list[i].virt + info->vmemmap_psize))) {
+ offset = vaddr - info->vmemmap_list[i].virt;
+ paddr = info->vmemmap_list[i].phys + offset;
+ break;
+ }
+ }
return paddr;
}
@@ -567,8 +612,8 @@ get_machdep_info_ppc64(void)
return FALSE;
}
+ info->vmemmap_start = VMEMMAP_REGION_ID << REGION_SHIFT;
if (SYMBOL(vmemmap_list) != NOT_FOUND_SYMBOL) {
- info->vmemmap_start = VMEMMAP_REGION_ID << REGION_SHIFT;
info->vmemmap_end = info->vmemmap_start;
if (ppc64_vmemmap_init() == FALSE) {
ERRMSG("Can't get vmemmap list info.\n");
diff --git a/makedumpfile.h b/makedumpfile.h
index 85e5a4932983..056aee191519 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -678,6 +678,12 @@ unsigned long get_kvbase_arm64(void);
#define REGION_SHIFT (60UL)
#define VMEMMAP_REGION_ID (0xfUL)
+/*
+ * If PAGE_PTE is set, then it's a leaf PTE for hugepage
+ */
+#define PAGE_PTE (1UL << 62)
+#define IS_HUGEPAGE(pte) (!!((pte) & PAGE_PTE))
+
/* 4-level page table support */
/* 4K pagesize */
--
2.42.0