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

R Sharada sharada at in.ibm.com
Fri Sep 2 10:28:47 EST 2005


Hello Paulus/All,
	While working on the kexec-tools for ppc64, we came across this 
requirement - kexec-tools needs to be able to discover a set of memory ranges 
in userspace, such that we can allocate a hole from that memory to load the
various kernel segments.
	In kexec on ppc64 it means the following:
	- in non-lpar machines, the memory ranges obtained should exclude
tce_tables and htab_tables
	- in all machines, the memory ranges obtained should exclude
the kernel resident memory (from _start to _end), rtas region, as we use RTAS
in kexec-ed kernel

	While rtas, and tce details are available in userspace via
/proc/device-tree, end of kernel and htab values are currently not available.
Hence the need for a patch to export the htab and kernel end values into 
/proc/device-tree.

	The other alternative, as it has been discussed before, is to be able 
to export a complete set of memory_ranges from kernel into /proc/device-tree, 
that displays only valid mempory ranges, excluding all the above regions,
something similar to /proc/iomem of x86.

	This current patch export htab and kernel end values, and does the 
exclusion logic from within kexec-tools.

	I would like to request feedback on
	- this patch and consider for temporary inclusion (while a cleaner or
more acceptable approach is put down)
	- on this approach vs exporting the complete set of ranges from
kernel in a lightweight manner

Thanks and Regards,
Sharada

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


diff -puN include/asm-ppc64/mmu.h~kexec-export-htab-value include/asm-ppc64/mmu.h
--- linux-2.6.13-rc6-org/include/asm-ppc64/mmu.h~kexec-export-htab-value	2005-08-25 05:27:35.000000000 +0530
+++ linux-2.6.13-rc6-org-sharada/include/asm-ppc64/mmu.h	2005-08-29 22:09:04.000000000 +0530
@@ -58,6 +58,7 @@
  * Hash table
  */
 
+#define HASH_GROUP_SIZE 0x80    /* size of each hash group */
 #define HPTES_PER_GROUP 8
 
 #define HPTE_V_AVPN_SHIFT	7
diff -puN ./arch/ppc64/kernel/setup.c~kexec-export-htab-value ./arch/ppc64/kernel/setup.c
--- linux-2.6.13-rc6-org/./arch/ppc64/kernel/setup.c~kexec-export-htab-value	2005-08-25 05:27:35.000000000 +0530
+++ linux-2.6.13-rc6-org-sharada/./arch/ppc64/kernel/setup.c	2005-09-02 11:31:33.000000000 +0530
@@ -1033,6 +1033,59 @@ void __init setup_syscall_map(void)
 	       count32, count64);
 }
 
+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);
+}
+
 /*
  * Called into from start_kernel, after lock_kernel has been called.
  * Initializes bootmem, which is unsed to manage page allocation until
@@ -1086,6 +1139,12 @@ void __init setup_arch(char **cmdline_p)
 	}
 
 	paging_init();
+
+	/* export htab and kernel end values into /proc/device-tree/chosen
+	 * for kexec
+	 */
+	export_htab_value();
+	export_kernel_end();
 	ppc64_boot_msg(0x15, "Setup Done");
 }
 
_



More information about the Linuxppc64-dev mailing list