ia64/linux-2.6.18-xen.hg

changeset 685:b54652ee29ef

xen: fix kdump kernel crash on Xen3.2

The kernel is supposed to create some "Crash note" resources (children
of the "Hypervisor code and data" resource in /proc/iomem). However,
when running on Xen 3.2, xen_machine_kexec_setup_resources()
encounters an error and returns prior to doing this.

The error occurs when it calls the "kexec_get_range" hypercall to
determine the location of the "vmcoreinfo". This was only implemented
in Xen 3.3.

This patch makes the kernel handle this error gracefully by simply not
creating the sysfs file "hypervisor/vmcoreinfo" if the hypervisor is
unable to provide the info - rather than bailing out of
xen_machine_kexec_setup_resources() early.

Signed-off-by: Alex Zeffertt <alex.zeffertt@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Oct 02 11:29:02 2008 +0100 (2008-10-02)
parents fc1b82ca1e6a
children 96655d262fa5 39a4dda735d3
files drivers/xen/core/machine_kexec.c drivers/xen/core/xen_sysfs.c include/xen/interface/kexec.h
line diff
     1.1 --- a/drivers/xen/core/machine_kexec.c	Mon Sep 29 10:07:48 2008 +0100
     1.2 +++ b/drivers/xen/core/machine_kexec.c	Thu Oct 02 11:29:02 2008 +0100
     1.3 @@ -27,6 +27,7 @@ void __init xen_machine_kexec_setup_reso
     1.4  	xen_kexec_range_t range;
     1.5  	struct resource *res;
     1.6  	int k = 0;
     1.7 +	int rc;
     1.8  
     1.9  	if (!is_initial_xendomain())
    1.10  		return;
    1.11 @@ -103,12 +104,26 @@ void __init xen_machine_kexec_setup_reso
    1.12  	memset(&range, 0, sizeof(range));
    1.13  	range.range = KEXEC_RANGE_MA_VMCOREINFO;
    1.14  
    1.15 -	if (HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range))
    1.16 -		return;
    1.17 +	rc = HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range);
    1.18  
    1.19 -	if (range.size) {
    1.20 +	if (rc == 0) {
    1.21 +		/* Hypercall succeeded */
    1.22 +		vmcoreinfo_size_xen = range.size;
    1.23  		paddr_vmcoreinfo_xen = range.start;
    1.24 -		vmcoreinfo_size_xen = range.size;
    1.25 +
    1.26 +	} else {
    1.27 +		/* Hypercall failed.
    1.28 +		 * Indicate not to create sysfs file by resetting globals
    1.29 +		 */
    1.30 +		vmcoreinfo_size_xen = 0;
    1.31 +		paddr_vmcoreinfo_xen = 0;
    1.32 +		
    1.33 +		/* The KEXEC_CMD_kexec_get_range hypercall did not implement
    1.34 +		 * KEXEC_RANGE_MA_VMCOREINFO until Xen 3.3.
    1.35 +		 * Do not bail out if it fails for this reason.
    1.36 +		 */
    1.37 +		if (rc != -EINVAL)
    1.38 +			return;
    1.39  	}
    1.40  
    1.41  	if (machine_kexec_setup_resources(&xen_hypervisor_res, xen_phys_cpus,
     2.1 --- a/drivers/xen/core/xen_sysfs.c	Mon Sep 29 10:07:48 2008 +0100
     2.2 +++ b/drivers/xen/core/xen_sysfs.c	Thu Oct 02 11:29:02 2008 +0100
     2.3 @@ -339,9 +339,6 @@ static void xen_properties_destroy(void)
     2.4  
     2.5  static ssize_t vmcoreinfo_show(struct hyp_sysfs_attr *attr, char *page)
     2.6  {
     2.7 -	extern size_t vmcoreinfo_size_xen;
     2.8 -	extern unsigned long paddr_vmcoreinfo_xen;
     2.9 -
    2.10  	return sprintf(page, "%lx %zx\n",
    2.11  		paddr_vmcoreinfo_xen, vmcoreinfo_size_xen);
    2.12  }
    2.13 @@ -359,11 +356,6 @@ static void xen_sysfs_vmcoreinfo_destroy
    2.14  	sysfs_remove_file(&hypervisor_subsys.kset.kobj, &vmcoreinfo_attr.attr);
    2.15  }
    2.16  
    2.17 -#else
    2.18 -
    2.19 -#define xen_sysfs_vmcoreinfo_init()	0
    2.20 -#define xen_sysfs_vmcoreinfo_destroy()	((void)0)
    2.21 -
    2.22  #endif
    2.23  
    2.24  static int __init hyper_sysfs_init(void)
    2.25 @@ -388,10 +380,19 @@ static int __init hyper_sysfs_init(void)
    2.26  	ret = xen_properties_init();
    2.27  	if (ret)
    2.28  		goto prop_out;
    2.29 -	ret = xen_sysfs_vmcoreinfo_init();
    2.30 -	if (!ret)
    2.31 -		goto out;
    2.32 +#ifdef CONFIG_KEXEC
    2.33 +	if (vmcoreinfo_size_xen != 0) {
    2.34 +		ret = xen_sysfs_vmcoreinfo_init();
    2.35 +		if (ret)
    2.36 +			goto vmcoreinfo_out;
    2.37 +	}
    2.38 +#endif
    2.39  
    2.40 +	goto out;
    2.41 +
    2.42 +#ifdef CONFIG_KEXEC
    2.43 +vmcoreinfo_out:
    2.44 +#endif
    2.45  	xen_properties_destroy();
    2.46  prop_out:
    2.47  	xen_sysfs_uuid_destroy();
    2.48 @@ -407,7 +408,10 @@ out:
    2.49  
    2.50  static void __exit hyper_sysfs_exit(void)
    2.51  {
    2.52 -	xen_sysfs_vmcoreinfo_destroy();
    2.53 +#ifdef CONFIG_KEXEC
    2.54 +	if (vmcoreinfo_size_xen != 0)
    2.55 +		xen_sysfs_vmcoreinfo_destroy();
    2.56 +#endif
    2.57  	xen_properties_destroy();
    2.58  	xen_compilation_destroy();
    2.59  	xen_sysfs_uuid_destroy();
     3.1 --- a/include/xen/interface/kexec.h	Mon Sep 29 10:07:48 2008 +0100
     3.2 +++ b/include/xen/interface/kexec.h	Thu Oct 02 11:29:02 2008 +0100
     3.3 @@ -175,6 +175,8 @@ void vmcoreinfo_append_str(const char *f
     3.4  #define VMCOREINFO_OFFSET_ALIAS(name, field, alias) \
     3.5         vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #alias, \
     3.6                               (unsigned long)offsetof(struct name, field))
     3.7 +extern size_t vmcoreinfo_size_xen;
     3.8 +extern unsigned long paddr_vmcoreinfo_xen;
     3.9  
    3.10  #endif /* _XEN_PUBLIC_KEXEC_H */
    3.11