[PATCH] - Revised patch to export kernel end, htab values

R Sharada sharada at in.ibm.com
Wed Sep 14 21:46:30 EST 2005


Hello Paulus/Michael,
	I got caught up with kexec-tools work and could not come back to this
earlier.
	The code started off, initially, under CONFIG_KEXEC, but later I
removed it thinking it might not be necessary. Putting it back under 
CONFIG_KEXEC is perhaps the best way to ensure we are not breaking any other
configurations. Here's the same patch, under ifdef CONFIG_KEXEC.

Kindly consider for inclusion, if there are no objections to this.

Thanks and Regards,
Sharada

-----------------------------------------------------------------------------

This patch exports the htab_base, htab_size, and kernel_end values into
/proc/device-tree/chosen. This is required by kexec, to be able to exclude
htab and kernel ranges, from the list of valid memory ranges that kexec uses
for loading the kexec segments

Signed-off-by: R Sharada <sharada at in.ibm.com>
---

 2614rc1-sharada/linux-2.6.14-rc1/arch/ppc64/kernel/setup.c |   63 +++++++++++++
 2614rc1-sharada/linux-2.6.14-rc1/include/asm-ppc64/mmu.h   |    1 
 2 files changed, 64 insertions(+)

diff -puN linux-2.6.14-rc1/arch/ppc64/kernel/setup.c~kexec-export-htab-value linux-2.6.14-rc1/arch/ppc64/kernel/setup.c
--- 2614rc1/linux-2.6.14-rc1/arch/ppc64/kernel/setup.c~kexec-export-htab-value	2005-09-14 17:04:37.000000000 +0530
+++ 2614rc1-sharada/linux-2.6.14-rc1/arch/ppc64/kernel/setup.c	2005-09-14 17:05:16.000000000 +0530
@@ -1003,6 +1003,61 @@ void __init setup_syscall_map(void)
 	       count32, count64);
 }
 
+#ifdef CONFIG_KEXEC
+static void __init export_kernel_end(void)
+{
+	static unsigned long kernel_end;
+	static struct property kernel_end_prop = {
+		.name = "kernel_end",
+		.length = sizeof(unsigned long),
+		.value = (unsigned char *)&kernel_end,
+	};
+
+	struct device_node *node;
+	node = of_find_node_by_path("/chosen");
+	if (!node)
+		return;
+
+	kernel_end = __pa(_end);
+	prom_add_property(node, &kernel_end_prop);
+
+	of_node_put(node);
+}
+
+static void __init export_htab_value(void)
+{
+	static unsigned long htab_base;
+	static struct property htab_base_prop = {
+		.name = "htab_base",
+		.length = sizeof(unsigned long),
+		.value = (unsigned char *)&htab_base,
+	};
+
+	static unsigned long htab_size;
+	static struct property htab_size_prop = {
+		.name = "htab_size",
+		.length = sizeof(unsigned long),
+		.value = (unsigned char *)&htab_size,
+	};
+
+	struct device_node *node;
+
+	if (systemcfg->platform == PLATFORM_PSERIES_LPAR)
+		return;
+
+	node = of_find_node_by_path("/chosen");
+	if (!node)
+		return;
+
+	htab_base = __pa(htab_address);
+	prom_add_property(node, &htab_base_prop);
+	htab_size = (htab_hash_mask + 1) * HASH_GROUP_SIZE;
+	prom_add_property(node, &htab_size_prop);
+
+	of_node_put(node);
+}
+#endif /* CONFIG_KEXEC */
+
 /*
  * Called into from start_kernel, after lock_kernel has been called.
  * Initializes bootmem, which is unsed to manage page allocation until
@@ -1056,6 +1111,14 @@ void __init setup_arch(char **cmdline_p)
 	}
 
 	paging_init();
+
+	/* export htab and kernel end values into /proc/device-tree/chosen
+	 * for kexec
+	 */
+#ifdef CONFIG_KEXEC
+	export_htab_value();
+	export_kernel_end();
+#endif /* CONFIG_KEXEC */
 	ppc64_boot_msg(0x15, "Setup Done");
 }
 
diff -puN linux-2.6.14-rc1/include/asm-ppc64/mmu.h~kexec-export-htab-value linux-2.6.14-rc1/include/asm-ppc64/mmu.h
--- 2614rc1/linux-2.6.14-rc1/include/asm-ppc64/mmu.h~kexec-export-htab-value	2005-09-14 17:04:37.000000000 +0530
+++ 2614rc1-sharada/linux-2.6.14-rc1/include/asm-ppc64/mmu.h	2005-09-14 17:05:16.000000000 +0530
@@ -63,6 +63,7 @@ extern char initial_stab[];
  * Hash table
  */
 
+#define HASH_GROUP_SIZE 0x80    /* size of each hash group */
 #define HPTES_PER_GROUP 8
 
 #define HPTE_V_AVPN_SHIFT	7
_



More information about the Linuxppc64-dev mailing list