Subject: kexec/kdump: call xen_machine_kexec_setup_resources() after init_bootmem()
Date: Thu, 27 Sep 2007 13:28:05 +0900
To: xen-ia64-devel@lists.xensource.com
From: Simon Horman <horms@verge.net.au>

Early on in find_memory(), reserve_memory() is called,
which in turn calls xen_machine_kexec_setup_resources()
and in turn alloc_bootmem_low().

However, before alloc_bootmem_low() can be called,
init_bootmem() needs to be called.

To resolve this problem, the call to xen_machine_kexec_setup_resources()
is moved to just after the call to init_bootmem() in alloc_bootmem_low().

Signed-off-by: Simon Horman <horms@verge.net.au>

---
This replaces an earlier patch that made use of a staic allocation
to avoid calling alloc_bootmem_low() in xen_machine_kexec_setup_resources().

Index: linux-2.6.18-xen.hg/arch/ia64/kernel/setup.c
===================================================================
--- linux-2.6.18-xen.hg.orig/arch/ia64/kernel/setup.c	2007-09-27 13:20:20.000000000 +0900
+++ linux-2.6.18-xen.hg/arch/ia64/kernel/setup.c	2007-09-27 13:20:29.000000000 +0900
@@ -308,12 +308,9 @@ reserve_memory (void)
 		char *from = strstr(saved_command_line, "crashkernel=");
 		unsigned long base, size;
 #ifdef CONFIG_XEN
-		if (is_initial_xendomain()) {
-			if (from)
+		if (is_initial_xendomain() && from)
 				printk("Ignoring crashkernel command line, "
 				       "parameter will be supplied by xen\n");
-			xen_machine_kexec_setup_resources();
-		}
 		else {
 #endif
 		if (from) {
Index: linux-2.6.18-xen.hg/arch/ia64/mm/contig.c
===================================================================
--- linux-2.6.18-xen.hg.orig/arch/ia64/mm/contig.c	2007-09-27 13:20:20.000000000 +0900
+++ linux-2.6.18-xen.hg/arch/ia64/mm/contig.c	2007-09-27 13:23:02.000000000 +0900
@@ -18,6 +18,9 @@
 #include <linux/efi.h>
 #include <linux/mm.h>
 #include <linux/swap.h>
+#ifdef CONFIG_XEN
+#include <linux/kexec.h>
+#endif
 
 #include <asm/meminit.h>
 #include <asm/pgalloc.h>
@@ -172,6 +175,9 @@ find_memory (void)
 	/* Free all available memory, then mark bootmem-map as being in use. */
 	efi_memmap_walk(filter_rsvd_memory, free_bootmem);
 	reserve_bootmem(bootmap_start, bootmap_size);
+#ifdef CONFIG_XEN
+	xen_machine_kexec_setup_resources();
+#endif
 
 	find_initrd();
 
