Commit 7636c13 ("vmcoreinfo: read vmcoreinfo using 'vmcoreinfo_data'
when unavailable in elf note") moved the vmcoreinfo reading to always
read from memory instead of relying on diskdump/netdump's local
handlers. This was later reverted to fix regression in X86_64 kslar
images.

Reintroduce the `vmcoreinfo_read_from_memory` as fallback to
diskdump/netdump vmcores.

This reverts commit 72e2776caf1ca41dffcc8aba11c55c636565725b.

Cc: Aditya Gupta <[email protected]>
Cc: Tao Liu <[email protected]>
Signed-off-by: Shivang Upadhyay <[email protected]>
---
 defs.h     |  1 +
 diskdump.c |  3 +++
 kernel.c   | 17 ++++++++++++-----
 netdump.c  |  2 ++
 4 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/defs.h b/defs.h
index ceed3a9..e5d38c2 100644
--- a/defs.h
+++ b/defs.h
@@ -6235,6 +6235,7 @@ void dump_kernel_table(int);
 void dump_bt_info(struct bt_info *, char *where);
 void dump_log(int);
 void parse_kernel_version(char *);
+char *vmcoreinfo_read_from_memory(const char *);
 
 #define LOG_LEVEL(v) ((v) & 0x07)
 #define SHOW_LOG_LEVEL    (0x1)
diff --git a/diskdump.c b/diskdump.c
index 0ff8782..c16e7b9 100644
--- a/diskdump.c
+++ b/diskdump.c
@@ -2434,6 +2434,9 @@ err:
        if (buf)
                free(buf);
 
+       if (value_string == NULL)
+               return vmcoreinfo_read_from_memory(key);
+
        return value_string;
 }
 
diff --git a/kernel.c b/kernel.c
index bb148d0..ec287bb 100644
--- a/kernel.c
+++ b/kernel.c
@@ -100,7 +100,6 @@ static ulong dump_audit_skb_queue(ulong);
 static ulong __dump_audit(char *);
 static void dump_audit(void);
 static void dump_printk_safe_seq_buf(int);
-static char *vmcoreinfo_read_string(const char *);
 static void check_vmcoreinfo(void);
 static int is_pvops_xen(void);
 static int get_linux_banner_from_vmlinux(char *, size_t);
@@ -11960,8 +11959,8 @@ dump_printk_safe_seq_buf(int msg_flags)
  * Returns a string (that has to be freed by the caller) that contains the
  * value for key or NULL if the key has not been found.
  */
-static char *
-vmcoreinfo_read_string(const char *key)
+char *
+vmcoreinfo_read_from_memory(const char *key)
 {
        char *buf, *value_string, *p1, *p2;
        size_t value_length;
@@ -11971,6 +11970,14 @@ vmcoreinfo_read_string(const char *key)
 
        buf = value_string = NULL;
 
+       if (!(pc->flags & GDB_INIT)) {
+               /*
+                * GDB interface hasn't been initialised yet, so can't
+                * access vmcoreinfo_data
+                */
+               return NULL;
+       }
+
        switch (get_symbol_type("vmcoreinfo_data", NULL, NULL))
        {
        case TYPE_CODE_PTR:
@@ -12026,10 +12033,10 @@ check_vmcoreinfo(void)
                switch (get_symbol_type("vmcoreinfo_data", NULL, NULL))
                {
                case TYPE_CODE_PTR:
-                       pc->read_vmcoreinfo = vmcoreinfo_read_string;
+                       pc->read_vmcoreinfo = vmcoreinfo_read_from_memory;
                        break;
                case TYPE_CODE_ARRAY:
-                       pc->read_vmcoreinfo = vmcoreinfo_read_string;
+                       pc->read_vmcoreinfo = vmcoreinfo_read_from_memory;
                        break;
                }
        }
diff --git a/netdump.c b/netdump.c
index ba1c6c4..fd0d545 100644
--- a/netdump.c
+++ b/netdump.c
@@ -2020,6 +2020,8 @@ vmcoreinfo_read_string(const char *key)
                }
        }
 
+       if (value == NULL)
+               return vmcoreinfo_read_from_memory(key);
        return value;
 }
 
-- 
2.52.0
--
Crash-utility mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
Contribution Guidelines: https://github.com/crash-utility/crash/wiki

Reply via email to