public inbox for kexec@lists.infradead.org
 help / color / mirror / Atom feed
From: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
To: kexec@lists.infradead.org
Subject: [PATCH v2 09/14] Estimate phys_base based on linux_banner position
Date: Fri, 28 Oct 2011 18:48:53 +0900	[thread overview]
Message-ID: <20111028094853.20940.37936.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20111028094454.20940.1209.stgit@localhost6.localdomain6>

sadump doesn't save phys_base, so we must estimate it in any way. Here
we borrow the method in crash utility that we search a certain range
of addresses for linux_banner symbol value.

Signed-off-by: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
---

 makedumpfile.c |   12 ++++++++++++
 sadump_info.c  |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 sadump_info.h  |   13 +++++++++++++
 3 files changed, 72 insertions(+), 0 deletions(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index 205d3de..6e9dd83 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -2504,6 +2504,15 @@ initial(void)
 
 		(void) sadump_set_timestamp(&info->timestamp);
 
+		/*
+		 * NOTE: phys_base is never saved by sadump and so
+		 * must be computed in some way. We here choose the
+		 * way of looking at linux_banner. See
+		 * sadump_virt_phys_base(). The processing is
+		 * postponed until debug information becomes
+		 * available.
+		 */
+
 	} else if (!get_phys_base())
 		return FALSE;
 
@@ -2579,6 +2588,9 @@ out:
 		return FALSE;
 
 	if (debug_info) {
+		if (info->flag_sadump)
+			(void) sadump_virt_phys_base();
+
 		if (!get_machdep_info())
 			return FALSE;
 
diff --git a/sadump_info.c b/sadump_info.c
index abc81d9..adca47b 100644
--- a/sadump_info.c
+++ b/sadump_info.c
@@ -22,6 +22,12 @@
 #include "print_info.h"
 #include "sadump_mod.h"
 
+#ifdef __x86_64__
+
+#define MEGABYTES(x)	((x) * (1048576))
+
+#endif
+
 struct sadump_diskset_info {
 	char *name_memory;
 	int fd_memory;
@@ -666,6 +672,47 @@ sadump_get_max_mapnr(void)
 	return si->sh_memory->max_mapnr;
 }
 
+#ifdef __x86_64__
+
+int
+sadump_virt_phys_base(void)
+{
+        char buf[BUFSIZE];
+        unsigned long phys, linux_banner_phys;
+
+	if (SYMBOL(linux_banner) == NOT_FOUND_SYMBOL) {
+		DEBUG_MSG("sadump: symbol linux_banner is not found\n");
+		goto failed;
+	}
+
+        linux_banner_phys = SYMBOL(linux_banner) - __START_KERNEL_map;
+
+        if (readmem(PADDR, linux_banner_phys + info->phys_base, buf,
+		    strlen("Linux version")) && STRNEQ(buf, "Linux version"))
+                return TRUE;
+
+        for (phys = (-MEGABYTES(16)); phys != MEGABYTES(16+1);
+             phys += MEGABYTES(1)) {
+                if (readmem(PADDR, linux_banner_phys + phys, buf,
+			    strlen("Linux version")) &&
+		    STRNEQ(buf, "Linux version")) {
+                        DEBUG_MSG("sadump: phys_base: %lx %s\n", phys,
+				  info->phys_base != phys ? "override" : "");
+                        info->phys_base = phys;
+                        return TRUE;
+                }
+        }
+
+failed:
+	info->phys_base = 0;
+
+	DEBUG_MSG("sadump: failed to calculate phys_base; default to 0\n");
+
+        return FALSE;
+}
+
+#endif /* __x86_64__ */
+
 int
 readpmem_sadump(unsigned long long paddr, void *bufptr, size_t size)
 {
diff --git a/sadump_info.h b/sadump_info.h
index b6b9cdd..401b769 100644
--- a/sadump_info.h
+++ b/sadump_info.h
@@ -22,6 +22,19 @@
 
 #include "makedumpfile.h"
 
+#ifdef __x86_64__
+
+int sadump_virt_phys_base(void);
+
+#else
+
+static inline int sadump_virt_phys_base(void)
+{
+	return TRUE;
+}
+
+#endif
+
 #if defined(__x86__) || defined(__x86_64__)
 
 int check_and_get_sadump_header_info(char *filename);


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

  parent reply	other threads:[~2011-10-28  9:48 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-28  9:48 [PATCH v2 00/14] Support Fujitsu Stand Alone Dump Format HATAYAMA Daisuke
2011-10-28  9:48 ` [PATCH v2 01/14] Add sadump module header file HATAYAMA Daisuke
2011-10-28  9:48 ` [PATCH v2 02/14] Extend DumpInfo structure HATAYAMA Daisuke
2011-10-28  9:48 ` [PATCH v2 03/14] Implement command-line processing HATAYAMA Daisuke
2011-10-28  9:48 ` [PATCH v2 04/14] Verify and read VMCORE(s) in sadump-related formats HATAYAMA Daisuke
2011-10-28  9:48 ` [PATCH v2 05/14] Export helpers for bitmap table handling HATAYAMA Daisuke
2011-10-28  9:48 ` [PATCH v2 06/14] Initialize internal data according to sadump-related formats HATAYAMA Daisuke
2011-10-28  9:48 ` [PATCH v2 07/14] Initialize debug information for ELF note extraction HATAYAMA Daisuke
2011-10-28  9:48 ` [PATCH v2 08/14] Implement readmem() interface on sadump-related formats HATAYAMA Daisuke
2011-10-28  9:48 ` HATAYAMA Daisuke [this message]
2011-10-28  9:48 ` [PATCH v2 10/14] Generate and save VMCOREINFO and ELF note information HATAYAMA Daisuke
2011-12-20  8:18   ` Atsushi Kumagai
2011-12-20  9:31     ` HATAYAMA Daisuke
2011-12-21  8:22       ` Atsushi Kumagai
2011-12-21  8:39         ` HATAYAMA Daisuke
2011-10-28  9:49 ` [PATCH v2 11/14] Procees CPUs based on online ones HATAYAMA Daisuke
2011-10-28  9:49 ` [PATCH v2 12/14] Read kexec backup region HATAYAMA Daisuke
2011-10-28  9:49 ` [PATCH v2 13/14] Add description of sadump-related formts in usage information HATAYAMA Daisuke
2011-10-28  9:49 ` [PATCH v2 14/14] Add description of sadump-related formats in manual page HATAYAMA Daisuke
2011-10-28 12:05 ` [PATCH v2 00/14] Support Fujitsu Stand Alone Dump Format tachibana
2011-12-15  6:47   ` HATAYAMA Daisuke
2011-12-15  8:55     ` tachibana
2011-12-15  9:09       ` HATAYAMA Daisuke

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=20111028094853.20940.37936.stgit@localhost6.localdomain6 \
    --to=d.hatayama@jp.fujitsu.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