Blame kexec-tools-2.0.21-makedumpfile-make-use-of-uts_namespace.name-offset-in-VMCOR.patch

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