Skip to contentSkip to conversation

extract vmcoreinfo from /proc/vmcore for Xen

PATCH In review Itsuro ODA 1 participant 1 message Jun 12, 2008

Subsystems (2)
lore
Share & tools
lore

Itsuro ODA

author
#0 lore raw

PATCH 1/2 extract vmcoreinfo from /proc/vmcore for Xen

This patch is for xen-unstable.

- the machine address and the size of the vmcoreinfo area is returned via the kexec_op(get_range) hypercall
- fill the vmcoreinfo data when the kexec_op(crash load) hypercall is called

xen/arch/ia64/xen/machine_kexec.c +9 -0
diff -r a0561bcf9333 xen/arch/ia64/xen/machine_kexec.c
@@ -193,6 +193,15 @@ int machine_kexec_get(xen_kexec_range_t 
 	return -EINVAL;
 }
 
+void arch_crash_save_vmcoreinfo(void)
+{
+	VMCOREINFO_SYMBOL(dom_xen);
+	VMCOREINFO_SYMBOL(dom_io);
+	VMCOREINFO_SYMBOL(xen_pstart);
+	VMCOREINFO_SYMBOL(frametable_pg_dir);
+	VMCOREINFO_SYMBOL_ALIAS(xen_heap_start, xen_pickle_offset);
+}
+
 /*
  * Local variables:
  * mode: C
xen/arch/ia64/xen/mm.c +1 -1
diff -r a0561bcf9333 xen/arch/ia64/xen/mm.c
@@ -189,7 +189,7 @@ static void domain_page_flush_and_put(st
 
 extern unsigned long ia64_iobase;
 
-static struct domain *dom_xen, *dom_io;
+struct domain *dom_xen, *dom_io;
 
 /*
  * This number is bigger than DOMID_SELF, DOMID_XEN and DOMID_IO.
xen/arch/x86/machine_kexec.c +13 -0
diff -r a0561bcf9333 xen/arch/x86/machine_kexec.c
@@ -145,6 +145,19 @@ int machine_kexec_get(xen_kexec_range_t 
 	return machine_kexec_get_xen(range);
 }
 
+void arch_crash_save_vmcoreinfo(void)
+{
+	VMCOREINFO_SYMBOL(dom_xen);
+	VMCOREINFO_SYMBOL(dom_io);
+
+#ifdef CONFIG_X86_PAE
+	VMCOREINFO_SYMBOL_ALIAS(pgd_l3, idle_pg_table);
+#endif
+#ifdef CONFIG_X86_64
+	VMCOREINFO_SYMBOL_ALIAS(pgd_l4, idle_pg_table);
+#endif
+}
+
 /*
  * Local variables:
  * mode: C
xen/arch/x86/mm.c +1 -1
diff -r a0561bcf9333 xen/arch/x86/mm.c
@@ -151,7 +151,7 @@ static DEFINE_PER_CPU(struct percpu_mm_i
 #define FOREIGNDOM (this_cpu(percpu_mm_info).foreign ?: current->domain)
 
 /* Private domain structs for DOMID_XEN and DOMID_IO. */
-static struct domain *dom_xen, *dom_io;
+struct domain *dom_xen, *dom_io;
 
 /* Frame table and its size in pages. */
 struct page_info *frame_table;
xen/common/kexec.c +65 -0

95 lines not on this page · raw message

xen/common/page_alloc.c +1 -1
diff -r a0561bcf9333 xen/common/page_alloc.c
@@ -102,7 +102,7 @@ static unsigned long scrub_pages;
  *  One bit per page of memory. Bit set => page is allocated.
  */
 
-static unsigned long *alloc_bitmap;
+unsigned long *alloc_bitmap;
 #define PAGES_PER_MAPWORD (sizeof(unsigned long) * 8)
 
 #define allocated_in_map(_pn)                       \
xen/include/asm-ia64/config.h +2 -0
diff -r a0561bcf9333 xen/include/asm-ia64/config.h
@@ -294,4 +294,6 @@ struct screen_info { };
 
 #define CONFIG_XENCOMM_MARK_DIRTY 1
 
+#define ARCH_CRASH_SAVE_VMCOREINFO
+
 #endif	/* _IA64_CONFIG_H_ */
xen/include/asm-ia64/mm.h +2 -0
diff -r a0561bcf9333 xen/include/asm-ia64/mm.h
@@ -503,4 +503,6 @@ int steal_page(
 
 unsigned long domain_get_maximum_gpfn(struct domain *d);
 
+extern struct domain *dom_xen, *dom_io;	/* for vmcoreinfo */
+
 #endif /* __ASM_IA64_MM_H__ */
xen/include/asm-x86/config.h +2 -0
diff -r a0561bcf9333 xen/include/asm-x86/config.h
@@ -379,4 +379,6 @@ extern unsigned long xen_phys_start, xen
 #define ELFSIZE 32
 #endif
 
+#define ARCH_CRASH_SAVE_VMCOREINFO
+
 #endif /* __X86_CONFIG_H__ */
xen/include/asm-x86/mm.h +2 -0
diff -r a0561bcf9333 xen/include/asm-x86/mm.h
@@ -351,4 +351,6 @@ unsigned int domain_clamp_alloc_bitsize(
 
 unsigned long domain_get_maximum_gpfn(struct domain *d);
 
+extern struct domain *dom_xen, *dom_io;	/* for vmcoreinfo */
+
 #endif /* __ASM_X86_MM_H__ */
xen/include/public/kexec.h +22 -0
diff -r a0561bcf9333 xen/include/public/kexec.h
@@ -138,6 +138,7 @@ typedef struct xen_kexec_load {
                                      * the ia64_boot_param */
 #define KEXEC_RANGE_MA_EFI_MEMMAP 5 /* machine address and size of
                                      * of the EFI Memory Map */
+#define KEXEC_RANGE_MA_VMCOREINFO 6 /* machine address and size of vmcoreinfo */
 
 /*
  * Find the address and size of certain memory areas
@@ -154,6 +155,27 @@ typedef struct xen_kexec_range {
     unsigned long start;
 } xen_kexec_range_t;
 
+/* vmcoreinfo stuff */
+#define VMCOREINFO_BYTES           (4096)
+#define VMCOREINFO_NOTE_NAME       "VMCOREINFO_XEN"
+void arch_crash_save_vmcoreinfo(void);
+void vmcoreinfo_append_str(const char *fmt, ...)
+       __attribute__ ((format (printf, 1, 2)));
+#define VMCOREINFO_PAGESIZE(value) \
+       vmcoreinfo_append_str("PAGESIZE=%ld\n", value)
+#define VMCOREINFO_SYMBOL(name) \
+       vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)&name)
+#define VMCOREINFO_SYMBOL_ALIAS(alias, name) \
+       vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #alias, (unsigned long)&name)
+#define VMCOREINFO_STRUCT_SIZE(name) \
+       vmcoreinfo_append_str("SIZE(%s)=%zu\n", #name, sizeof(struct name))
+#define VMCOREINFO_OFFSET(name, field) \
+       vmcoreinfo_append_str("OFFSET(%s.%s)=%zu\n", #name, #field, \
+                             offsetof(struct name, field))
+#define VMCOREINFO_OFFSET_ALIAS(name, field, alias) \
+       vmcoreinfo_append_str("OFFSET(%s.%s)=%zu\n", #name, #alias, \
+                             offsetof(struct name, field))
+
 #endif /* _XEN_PUBLIC_KEXEC_H */
 
 /*
xen/include/xen/mm.h +2 -0
diff -r a0561bcf9333 xen/include/xen/mm.h
@@ -104,4 +104,6 @@ int guest_remove_page(struct domain *d, 
 /* Returns TRUE if the memory at address @p is ordinary RAM. */
 int memory_is_conventional_ram(paddr_t p);
 
+extern unsigned long *alloc_bitmap;	/* for vmcoreinfo */
+
 #endif /* __XEN_MM_H__ */
Signature · 1 line
Itsuro ODA <[email protected]>