makedumpfile: make use of 'uts_namespace.name' offset in VMCOREINFO

Backports:

commit 54aec3878b3f91341e6bc735eda158cca5c54ec9
Author: Alexander Egorenkov <egorenar@linux.ibm.com>
Date:   Fri Sep 18 13:55:56 2020 +0200

    [PATCH] make use of 'uts_namespace.name' offset in VMCOREINFO

    * Required for kernel 5.11

    The offset of the field 'init_uts_ns.name' has changed since
    kernel commit 9a56493f6942 ("uts: Use generic ns_common::count").
    Make use of the offset 'uts_namespace.name' if available in
    VMCOREINFO.

    Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>

Signed-off-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
Kairui Song 2021-01-08 11:03:43 +08:00
parent 0bd0c5b9f1
commit 0e540f7328
2 changed files with 103 additions and 0 deletions

View File

@ -0,0 +1,101 @@
From 54aec3878b3f91341e6bc735eda158cca5c54ec9 Mon Sep 17 00:00:00 2001
From: Alexander Egorenkov <egorenar@linux.ibm.com>
Date: Fri, 18 Sep 2020 13:55:56 +0200
Subject: [PATCH] [PATCH] make use of 'uts_namespace.name' offset in VMCOREINFO
* Required for kernel 5.11
The offset of the field 'init_uts_ns.name' has changed since
kernel commit 9a56493f6942 ("uts: Use generic ns_common::count").
Make use of the offset 'uts_namespace.name' if available in
VMCOREINFO.
Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
---
makedumpfile.c | 17 +++++++++++++++--
makedumpfile.h | 6 ++++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/makedumpfile.c b/makedumpfile.c
index 061741f..ecd63fa 100644
--- a/makedumpfile-1.6.8/makedumpfile.c
+++ b/makedumpfile-1.6.8/makedumpfile.c
@@ -1159,7 +1159,10 @@ check_release(void)
if (SYMBOL(system_utsname) != NOT_FOUND_SYMBOL) {
utsname = SYMBOL(system_utsname);
} else if (SYMBOL(init_uts_ns) != NOT_FOUND_SYMBOL) {
- utsname = SYMBOL(init_uts_ns) + sizeof(int);
+ if (OFFSET(uts_namespace.name) != NOT_FOUND_STRUCTURE)
+ utsname = SYMBOL(init_uts_ns) + OFFSET(uts_namespace.name);
+ else
+ utsname = SYMBOL(init_uts_ns) + sizeof(int);
} else {
ERRMSG("Can't get the symbol of system_utsname.\n");
return FALSE;
@@ -2040,6 +2043,11 @@ get_structure_info(void)
SIZE_INIT(cpu_spec, "cpu_spec");
OFFSET_INIT(cpu_spec.mmu_features, "cpu_spec", "mmu_features");
+ /*
+ * Get offsets of the uts_namespace's members.
+ */
+ OFFSET_INIT(uts_namespace.name, "uts_namespace", "name");
+
return TRUE;
}
@@ -2109,7 +2117,10 @@ get_str_osrelease_from_vmlinux(void)
if (SYMBOL(system_utsname) != NOT_FOUND_SYMBOL) {
utsname = SYMBOL(system_utsname);
} else if (SYMBOL(init_uts_ns) != NOT_FOUND_SYMBOL) {
- utsname = SYMBOL(init_uts_ns) + sizeof(int);
+ if (OFFSET(uts_namespace.name) != NOT_FOUND_STRUCTURE)
+ utsname = SYMBOL(init_uts_ns) + OFFSET(uts_namespace.name);
+ else
+ utsname = SYMBOL(init_uts_ns) + sizeof(int);
} else {
ERRMSG("Can't get the symbol of system_utsname.\n");
return FALSE;
@@ -2344,6 +2355,7 @@ write_vmcoreinfo_data(void)
WRITE_MEMBER_OFFSET("vmemmap_backing.list", vmemmap_backing.list);
WRITE_MEMBER_OFFSET("mmu_psize_def.shift", mmu_psize_def.shift);
WRITE_MEMBER_OFFSET("cpu_spec.mmu_features", cpu_spec.mmu_features);
+ WRITE_MEMBER_OFFSET("uts_namespace.name", uts_namespace.name);
if (SYMBOL(node_data) != NOT_FOUND_SYMBOL)
WRITE_ARRAY_LENGTH("node_data", node_data);
@@ -2743,6 +2755,7 @@ read_vmcoreinfo(void)
READ_MEMBER_OFFSET("vmemmap_backing.list", vmemmap_backing.list);
READ_MEMBER_OFFSET("mmu_psize_def.shift", mmu_psize_def.shift);
READ_MEMBER_OFFSET("cpu_spec.mmu_features", cpu_spec.mmu_features);
+ READ_MEMBER_OFFSET("uts_namespace.name", uts_namespace.name);
READ_STRUCTURE_SIZE("printk_log", printk_log);
READ_STRUCTURE_SIZE("printk_ringbuffer", printk_ringbuffer);
diff --git a/makedumpfile.h b/makedumpfile.h
index 47f7e79..5f50080 100644
--- a/makedumpfile-1.6.8/makedumpfile.h
+++ b/makedumpfile-1.6.8/makedumpfile.h
@@ -1728,6 +1728,8 @@ struct size_table {
long cpu_spec;
long pageflags;
+
+ long uts_namespace;
};
struct offset_table {
@@ -1935,6 +1937,10 @@ struct offset_table {
struct cpu_spec_s {
long mmu_features;
} cpu_spec;
+
+ struct uts_namespace_s {
+ long name;
+ } uts_namespace;
};
/*
--
2.29.2

View File

@ -103,6 +103,7 @@ Requires: systemd-udev%{?_isa}
Patch601: ./kexec-tools-2.0.20-eppic-Remove-duplicated-variable-declaration.patch
Patch603: ./kexec-tools-2.0.20-makedumpfile-printk-add-support-for-lockless-ringbuffer.patch
Patch604: ./kexec-tools-2.0.20-makedumpfile-printk-use-committed-finalized-state-value.patch
Patch605: ./kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch
%description
kexec-tools provides /sbin/kexec binary that facilitates a new
@ -121,6 +122,7 @@ tar -z -x -v -f %{SOURCE19}
%patch601 -p1
%patch603 -p1
%patch604 -p1
%patch605 -p1
%ifarch ppc
%define archdef ARCH=ppc