direct-io.hg

changeset 12804:7c3dee5ff185

[LINUX] Kexec: Do not bug if a kexec hypercall fails.

This is non fatal since we can recover and boot without kexec
functionality.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
author Ian Campbell <ian.campbell@xensource.com>
date Fri Dec 08 11:46:48 2006 +0000 (2006-12-08)
parents df5fa63490f4
children 1db125262365
files linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c	Fri Dec 08 11:30:30 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c	Fri Dec 08 11:46:48 2006 +0000
     1.3 @@ -20,7 +20,7 @@ void xen_machine_kexec_setup_resources(v
     1.4  {
     1.5  	xen_kexec_range_t range;
     1.6  	struct resource *res;
     1.7 -	int err, k = 0;
     1.8 +	int k = 0;
     1.9  
    1.10  	if (!is_initial_xendomain())
    1.11  		return;
    1.12 @@ -32,26 +32,21 @@ void xen_machine_kexec_setup_resources(v
    1.13  		range.range = KEXEC_RANGE_MA_CPU;
    1.14  		range.nr = k;
    1.15  
    1.16 -		/*
    1.17 -		 * Anything other than EINVAL or success indictates
    1.18 -		 * that we are not running on a hypervisor which
    1.19 -		 * supports kexec.
    1.20 -		 */
    1.21 -		err = HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range);
    1.22 -		if (err == -EINVAL)
    1.23 +		if(HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range))
    1.24  			break;
    1.25 -		else if (err)
    1.26 -			return;
    1.27  
    1.28  		k++;
    1.29  	}
    1.30  
    1.31 +	if (k == 0)
    1.32 +		return;
    1.33 +
    1.34  	xen_max_nr_phys_cpus = k;
    1.35  
    1.36  	/* allocate xen_phys_cpus */
    1.37  
    1.38  	xen_phys_cpus = alloc_bootmem_low(k * sizeof(struct resource));
    1.39 -	BUG_ON(!xen_phys_cpus);
    1.40 +	BUG_ON(xen_phys_cpus == NULL);
    1.41  
    1.42  	/* fill in xen_phys_cpus with per-cpu crash note information */
    1.43  
    1.44 @@ -61,7 +56,7 @@ void xen_machine_kexec_setup_resources(v
    1.45  		range.nr = k;
    1.46  
    1.47  		if (HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range))
    1.48 -			BUG();
    1.49 +			goto err;
    1.50  
    1.51  		res = xen_phys_cpus + k;
    1.52  
    1.53 @@ -78,7 +73,7 @@ void xen_machine_kexec_setup_resources(v
    1.54  	range.range = KEXEC_RANGE_MA_XEN;
    1.55  
    1.56  	if (HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range))
    1.57 -		BUG();
    1.58 +		goto err;
    1.59  
    1.60  	xen_hypervisor_res.name = "Hypervisor code and data";
    1.61  	xen_hypervisor_res.start = range.start;
    1.62 @@ -91,12 +86,23 @@ void xen_machine_kexec_setup_resources(v
    1.63  	range.range = KEXEC_RANGE_MA_CRASH;
    1.64  
    1.65  	if (HYPERVISOR_kexec_op(KEXEC_CMD_kexec_get_range, &range))
    1.66 -		BUG();
    1.67 +		return;
    1.68  
    1.69  	if (range.size) {
    1.70  		crashk_res.start = range.start;
    1.71  		crashk_res.end = range.start + range.size - 1;
    1.72  	}
    1.73 +
    1.74 +	return;
    1.75 +
    1.76 + err:
    1.77 +	/*
    1.78 +	 * It isn't possible to free xen_phys_cpus this early in the
    1.79 +	 * boot. Since failure at this stage is unexpected and the
    1.80 +	 * amount is small we leak the memory.
    1.81 +         */
    1.82 +	xen_max_nr_phys_cpus = 0;
    1.83 +	return;
    1.84  }
    1.85  
    1.86  void xen_machine_kexec_register_resources(struct resource *res)