|
@@ -21,16 +21,26 @@
|
|
#include <linux/hardirq.h>
|
|
#include <linux/hardirq.h>
|
|
#include <linux/elf.h>
|
|
#include <linux/elf.h>
|
|
#include <linux/elfcore.h>
|
|
#include <linux/elfcore.h>
|
|
|
|
+#include <linux/utsrelease.h>
|
|
|
|
+#include <linux/utsname.h>
|
|
|
|
+#include <linux/numa.h>
|
|
|
|
|
|
#include <asm/page.h>
|
|
#include <asm/page.h>
|
|
#include <asm/uaccess.h>
|
|
#include <asm/uaccess.h>
|
|
#include <asm/io.h>
|
|
#include <asm/io.h>
|
|
#include <asm/system.h>
|
|
#include <asm/system.h>
|
|
#include <asm/semaphore.h>
|
|
#include <asm/semaphore.h>
|
|
|
|
+#include <asm/sections.h>
|
|
|
|
|
|
/* Per cpu memory for storing cpu states in case of system crash. */
|
|
/* Per cpu memory for storing cpu states in case of system crash. */
|
|
note_buf_t* crash_notes;
|
|
note_buf_t* crash_notes;
|
|
|
|
|
|
|
|
+/* vmcoreinfo stuff */
|
|
|
|
+unsigned char vmcoreinfo_data[VMCOREINFO_BYTES];
|
|
|
|
+u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4];
|
|
|
|
+unsigned int vmcoreinfo_size = 0;
|
|
|
|
+unsigned int vmcoreinfo_max_size = sizeof(vmcoreinfo_data);
|
|
|
|
+
|
|
/* Location of the reserved area for the crash kernel */
|
|
/* Location of the reserved area for the crash kernel */
|
|
struct resource crashk_res = {
|
|
struct resource crashk_res = {
|
|
.name = "Crash kernel",
|
|
.name = "Crash kernel",
|
|
@@ -1060,6 +1070,7 @@ void crash_kexec(struct pt_regs *regs)
|
|
if (kexec_crash_image) {
|
|
if (kexec_crash_image) {
|
|
struct pt_regs fixed_regs;
|
|
struct pt_regs fixed_regs;
|
|
crash_setup_regs(&fixed_regs, regs);
|
|
crash_setup_regs(&fixed_regs, regs);
|
|
|
|
+ crash_save_vmcoreinfo();
|
|
machine_crash_shutdown(&fixed_regs);
|
|
machine_crash_shutdown(&fixed_regs);
|
|
machine_kexec(kexec_crash_image);
|
|
machine_kexec(kexec_crash_image);
|
|
}
|
|
}
|
|
@@ -1134,3 +1145,102 @@ static int __init crash_notes_memory_init(void)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
module_init(crash_notes_memory_init)
|
|
module_init(crash_notes_memory_init)
|
|
|
|
+
|
|
|
|
+void crash_save_vmcoreinfo(void)
|
|
|
|
+{
|
|
|
|
+ u32 *buf;
|
|
|
|
+
|
|
|
|
+ if (!vmcoreinfo_size)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ vmcoreinfo_append_str("CRASHTIME=%d", xtime.tv_sec);
|
|
|
|
+
|
|
|
|
+ buf = (u32 *)vmcoreinfo_note;
|
|
|
|
+
|
|
|
|
+ buf = append_elf_note(buf, VMCOREINFO_NOTE_NAME, 0, vmcoreinfo_data,
|
|
|
|
+ vmcoreinfo_size);
|
|
|
|
+
|
|
|
|
+ final_note(buf);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void vmcoreinfo_append_str(const char *fmt, ...)
|
|
|
|
+{
|
|
|
|
+ va_list args;
|
|
|
|
+ char buf[0x50];
|
|
|
|
+ int r;
|
|
|
|
+
|
|
|
|
+ va_start(args, fmt);
|
|
|
|
+ r = vsnprintf(buf, sizeof(buf), fmt, args);
|
|
|
|
+ va_end(args);
|
|
|
|
+
|
|
|
|
+ if (r + vmcoreinfo_size > vmcoreinfo_max_size)
|
|
|
|
+ r = vmcoreinfo_max_size - vmcoreinfo_size;
|
|
|
|
+
|
|
|
|
+ memcpy(&vmcoreinfo_data[vmcoreinfo_size], buf, r);
|
|
|
|
+
|
|
|
|
+ vmcoreinfo_size += r;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * provide an empty default implementation here -- architecture
|
|
|
|
+ * code may override this
|
|
|
|
+ */
|
|
|
|
+void __attribute__ ((weak)) arch_crash_save_vmcoreinfo(void)
|
|
|
|
+{}
|
|
|
|
+
|
|
|
|
+unsigned long __attribute__ ((weak)) paddr_vmcoreinfo_note(void)
|
|
|
|
+{
|
|
|
|
+ return __pa((unsigned long)(char *)&vmcoreinfo_note);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int __init crash_save_vmcoreinfo_init(void)
|
|
|
|
+{
|
|
|
|
+ vmcoreinfo_append_str("OSRELEASE=%s\n", UTS_RELEASE);
|
|
|
|
+ vmcoreinfo_append_str("PAGESIZE=%d\n", PAGE_SIZE);
|
|
|
|
+
|
|
|
|
+ SYMBOL(init_uts_ns);
|
|
|
|
+ SYMBOL(node_online_map);
|
|
|
|
+ SYMBOL(swapper_pg_dir);
|
|
|
|
+ SYMBOL(_stext);
|
|
|
|
+
|
|
|
|
+#ifndef CONFIG_NEED_MULTIPLE_NODES
|
|
|
|
+ SYMBOL(mem_map);
|
|
|
|
+ SYMBOL(contig_page_data);
|
|
|
|
+#endif
|
|
|
|
+#ifdef CONFIG_SPARSEMEM
|
|
|
|
+ SYMBOL(mem_section);
|
|
|
|
+ LENGTH(mem_section, NR_SECTION_ROOTS);
|
|
|
|
+ SIZE(mem_section);
|
|
|
|
+ OFFSET(mem_section, section_mem_map);
|
|
|
|
+#endif
|
|
|
|
+ SIZE(page);
|
|
|
|
+ SIZE(pglist_data);
|
|
|
|
+ SIZE(zone);
|
|
|
|
+ SIZE(free_area);
|
|
|
|
+ SIZE(list_head);
|
|
|
|
+ OFFSET(page, flags);
|
|
|
|
+ OFFSET(page, _count);
|
|
|
|
+ OFFSET(page, mapping);
|
|
|
|
+ OFFSET(page, lru);
|
|
|
|
+ OFFSET(pglist_data, node_zones);
|
|
|
|
+ OFFSET(pglist_data, nr_zones);
|
|
|
|
+#ifdef CONFIG_FLAT_NODE_MEM_MAP
|
|
|
|
+ OFFSET(pglist_data, node_mem_map);
|
|
|
|
+#endif
|
|
|
|
+ OFFSET(pglist_data, node_start_pfn);
|
|
|
|
+ OFFSET(pglist_data, node_spanned_pages);
|
|
|
|
+ OFFSET(pglist_data, node_id);
|
|
|
|
+ OFFSET(zone, free_area);
|
|
|
|
+ OFFSET(zone, vm_stat);
|
|
|
|
+ OFFSET(zone, spanned_pages);
|
|
|
|
+ OFFSET(free_area, free_list);
|
|
|
|
+ OFFSET(list_head, next);
|
|
|
|
+ OFFSET(list_head, prev);
|
|
|
|
+ LENGTH(zone.free_area, MAX_ORDER);
|
|
|
|
+
|
|
|
|
+ arch_crash_save_vmcoreinfo();
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+module_init(crash_save_vmcoreinfo_init)
|