[PATCH] powerpc: Don't overwrite flat device tree with kdump kernel

Haren Myneni haren at us.ibm.com
Sun Feb 5 13:25:14 EST 2006


Kumar Gala wrote:

>On Feb 3, 2006, at 2:05 AM, Michael Ellerman wrote:
>
>  
>
>>It's possible for prom_init to allocate the flat device tree inside  
>>the
>>kdump crash kernel region. If this happens, when we load the kdump  
>>kernel we
>>overwrite the flattened device tree, which is bad.
>>
>>We could make prom_init try and avoid allocating inside the crash  
>>kernel
>>region, but then we run into issues if the crash kernel region uses  
>>all the
>>space inside the RMO. The easiest solution is to move the flat  
>>device tree
>>once we're running in the kernel.
>>
>>Signed-off-by: Michael Ellerman <michael at ellerman.id.au>
>>    
>>
>
>Doesn't setup_32.c need a similar change?
>  
>
At present kdump will not be supported on ppc32.
In case, kdump_move_device_tree() can be called at the beginning of 
unflatten_device_tree() to support both ppc32 and 64 instead of making 
changes in setup_64.c and setup_32.c.  The extern definition can be 
removed from asm-powerpc/prom.h and this function can be static.

Michael, what do you think if we have some printk to tell the user that 
device_tree is moved to new location. Because, the console messages from 
prom_init are saying about old addresses.

Thanks
Haren

>- k
>
>  
>
>>---
>>
>> arch/powerpc/kernel/prom.c     |   27 +++++++++++++++++++++++++++
>> arch/powerpc/kernel/setup_64.c |    3 +++
>> include/asm-powerpc/prom.h     |    2 ++
>> 3 files changed, 32 insertions(+)
>>
>>Index: kdump/arch/powerpc/kernel/prom.c
>>===================================================================
>>--- kdump.orig/arch/powerpc/kernel/prom.c
>>+++ kdump/arch/powerpc/kernel/prom.c
>>@@ -1913,3 +1913,30 @@ int prom_update_property(struct device_n
>>
>> 	return 0;
>> }
>>+
>>+#ifdef CONFIG_KEXEC
>>+/* We may have allocated the flat device tree inside the crash  
>>kernel region
>>+ * in prom_init. If so we need to move it out into regular memory. */
>>+void kdump_move_device_tree(void)
>>+{
>>+	unsigned long start, end;
>>+	struct boot_param_header *new;
>>+
>>+	start = __pa((unsigned long)initial_boot_params);
>>+	end = start + initial_boot_params->totalsize;
>>+
>>+	if (end < crashk_res.start || start > crashk_res.end)
>>+		return;
>>+
>>+	new = (struct boot_param_header*)
>>+		__va(lmb_alloc(initial_boot_params->totalsize, PAGE_SIZE));
>>+
>>+	memcpy(new, initial_boot_params, initial_boot_params->totalsize);
>>+
>>+	initial_boot_params = new;
>>+
>>+	DBG("Flat device tree blob moved to %p\n", initial_boot_params);
>>+
>>+	/* XXX should we unreserve the old DT? */
>>+}
>>+#endif /* CONFIG_KEXEC */
>>Index: kdump/arch/powerpc/kernel/setup_64.c
>>===================================================================
>>--- kdump.orig/arch/powerpc/kernel/setup_64.c
>>+++ kdump/arch/powerpc/kernel/setup_64.c
>>@@ -398,6 +398,9 @@ void __init setup_system(void)
>> {
>> 	DBG(" -> setup_system()\n");
>>
>>+#ifdef CONFIG_KEXEC
>>+	kdump_move_device_tree();
>>+#endif
>> 	/*
>> 	 * Unflatten the device-tree passed by prom_init or kexec
>> 	 */
>>Index: kdump/include/asm-powerpc/prom.h
>>===================================================================
>>--- kdump.orig/include/asm-powerpc/prom.h
>>+++ kdump/include/asm-powerpc/prom.h
>>@@ -222,5 +222,7 @@ extern int of_address_to_resource(struct
>> extern int of_pci_address_to_resource(struct device_node *dev, int  
>>bar,
>> 				      struct resource *r);
>>
>>+extern void kdump_move_device_tree(void);
>>+
>> #endif /* __KERNEL__ */
>> #endif /* _POWERPC_PROM_H */
>>_______________________________________________
>>Linuxppc64-dev mailing list
>>Linuxppc64-dev at ozlabs.org
>>https://ozlabs.org/mailman/listinfo/linuxppc64-dev
>>    
>>
>
>_______________________________________________
>Linuxppc64-dev mailing list
>Linuxppc64-dev at ozlabs.org
>https://ozlabs.org/mailman/listinfo/linuxppc64-dev
>
>  
>




More information about the Linuxppc64-dev mailing list