Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Egorenkov <egorenar@linux.ibm.com>
To: kexec@lists.infradead.org
Cc: Alexander Egorenkov <egorenar@linux.ibm.com>
Subject: [PATCH v2 1/1] Calculate offset to field 'init_uts_ns.name'
Date: Wed, 16 Sep 2020 15:51:47 +0200	[thread overview]
Message-ID: <20200916135147.1303016-1-egorenar@linux.ibm.com> (raw)

The offset has changed in linux-next (v5.9.0) from 4 to 0 because
there is no more 'kref' member variable at the beginning of 'init_uts_ns'.
The change was introduced with commit 9a56493f6942c0e2df1579986128721da96e00d8.
To handle both cases correctly, calculate the offset at run time instead.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
---
 makedumpfile.c | 8 ++++++--
 makedumpfile.h | 4 ++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index 4c4251e..2d62db8 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -1159,7 +1159,7 @@ 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);
+		utsname = SYMBOL(init_uts_ns) + OFFSET(init_uts_ns.name);
 	} else {
 		ERRMSG("Can't get the symbol of system_utsname.\n");
 		return FALSE;
@@ -2077,7 +2077,7 @@ 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);
+		utsname = SYMBOL(init_uts_ns) + OFFSET(init_uts_ns.name);
 	} else {
 		ERRMSG("Can't get the symbol of system_utsname.\n");
 		return FALSE;
@@ -2285,6 +2285,8 @@ write_vmcoreinfo_data(void)
 	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("init_uts_ns.name", init_uts_ns.name);
+
 	if (SYMBOL(node_data) != NOT_FOUND_SYMBOL)
 		WRITE_ARRAY_LENGTH("node_data", node_data);
 	if (SYMBOL(pgdat_list) != NOT_FOUND_SYMBOL)
@@ -2697,6 +2699,8 @@ read_vmcoreinfo(void)
 		READ_MEMBER_OFFSET("log.text_len", printk_log.text_len);
 	}
 
+	READ_MEMBER_OFFSET("init_uts_ns.name", init_uts_ns.name);
+
 	READ_ARRAY_LENGTH("node_data", node_data);
 	READ_ARRAY_LENGTH("pgdat_list", pgdat_list);
 	READ_ARRAY_LENGTH("mem_section", mem_section);
diff --git a/makedumpfile.h b/makedumpfile.h
index 03fb4ce..7d8c54d 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -1880,6 +1880,10 @@ struct offset_table {
 	struct cpu_spec_s {
 		long	mmu_features;
 	} cpu_spec;
+
+	struct init_uts_ns_s {
+		long	name;
+	} init_uts_ns;
 };
 
 /*
-- 
2.26.2


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

             reply	other threads:[~2020-09-16 13:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-16 13:51 Alexander Egorenkov [this message]
2020-09-17  5:34 ` [PATCH v2 1/1] Calculate offset to field 'init_uts_ns.name' HAGIO KAZUHITO(萩尾 一仁)
2020-09-17 11:03   ` Alexander Egorenkov
2020-09-17 16:32   ` Alexander Egorenkov
2020-09-18  2:23     ` HAGIO KAZUHITO(萩尾 一仁)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200916135147.1303016-1-egorenar@linux.ibm.com \
    --to=egorenar@linux.ibm.com \
    --cc=kexec@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox