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 (3)
lore
Share & tools
lore

Itsuro ODA

author
#0 lore raw

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

This patch is for linux-2.6.18-xen.

- get the machine address of the vmcoreinfo area of xen
- expose the machine address and the size of the vmcoreinfo area via /sys/hypervisor/vmcoreinfo so that the kexec-tools looks them.

drivers/xen/core/machine_kexec.c +15 -0
diff -r e01b3a133ddc drivers/xen/core/machine_kexec.c
@@ -19,6 +19,9 @@ static struct resource xen_hypervisor_re
 static struct resource xen_hypervisor_res;
 static struct resource *xen_phys_cpus;
 
+size_t vmcoreinfo_size_xen;
+unsigned long paddr_vmcoreinfo_xen;
+
 void __init xen_machine_kexec_setup_resources(void)
 {
 	xen_kexec_range_t range;
@@ -94,6 +97,18 @@ void __init xen_machine_kexec_setup_reso
 	if (range.size) {
 		crashk_res.start = range.start;
 		crashk_res.end = range.start + range.size - 1;
+	}
+
+	/* get physical address of vmcoreinfo */
+	memset(&range, 0, sizeof(range));
+	range.range = KEXEC_RANGE_MA_VMCOREINFO;
+
+	if (HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range))
+		return;
+
+	if (range.size) {
+		paddr_vmcoreinfo_xen = range.start;
+		vmcoreinfo_size_xen = range.size;
 	}
 
 	if (machine_kexec_setup_resources(&xen_hypervisor_res, xen_phys_cpus,
drivers/xen/core/xen_sysfs.c +25 -0
diff -r e01b3a133ddc drivers/xen/core/xen_sysfs.c
@@ -15,6 +15,7 @@
 #include <xen/features.h>
 #include <xen/hypervisor_sysfs.h>
 #include <xen/xenbus.h>
+#include <xen/interface/kexec.h>
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Mike D. Day <[email protected]>");
@@ -334,6 +335,24 @@ static void xen_properties_destroy(void)
 			   &xen_properties_group);
 }
 
+static ssize_t vmcoreinfo_show(struct hyp_sysfs_attr *attr, char *page)
+{
+	return sprintf(page, "%lx %zx\n",
+		paddr_vmcoreinfo_xen, vmcoreinfo_size_xen);
+}
+
+HYPERVISOR_ATTR_RO(vmcoreinfo);
+
+static int __init xen_sysfs_vmcoreinfo_init(void)
+{
+	return sysfs_create_file(&hypervisor_subsys.kset.kobj, &vmcoreinfo_attr.attr);
+}
+
+static void xen_sysfs_vmcoreinfo_destroy(void)
+{
+	sysfs_remove_file(&hypervisor_subsys.kset.kobj, &vmcoreinfo_attr.attr);
+}
+
 static int __init hyper_sysfs_init(void)
 {
 	int ret;
@@ -354,9 +373,14 @@ static int __init hyper_sysfs_init(void)
 	if (ret)
 		goto uuid_out;
 	ret = xen_properties_init();
+	if (ret)
+		goto prop_out;
+	ret = xen_sysfs_vmcoreinfo_init();
 	if (!ret)
 		goto out;
 
+	xen_properties_destroy();
+prop_out:
 	xen_sysfs_uuid_destroy();
 uuid_out:
 	xen_compilation_destroy();
@@ -370,6 +394,7 @@ out:
 
 static void __exit hyper_sysfs_exit(void)
 {
+	xen_sysfs_vmcoreinfo_destroy();
 	xen_properties_destroy();
 	xen_compilation_destroy();
 	xen_sysfs_uuid_destroy();
include/xen/interface/kexec.h +4 -0
diff -r e01b3a133ddc include/xen/interface/kexec.h
@@ -138,6 +138,10 @@ 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 */
+
+extern size_t vmcoreinfo_size_xen;
+extern unsigned long paddr_vmcoreinfo_xen;
 
 /*
  * Find the address and size of certain memory areas
Signature · 1 line
Itsuro ODA <[email protected]>