]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] powerpc: Don't overwrite flat device tree with kdump kernel
authorMichael Ellerman <michael@ellerman.id.au>
Fri, 3 Feb 2006 08:05:47 +0000 (19:05 +1100)
committerPaul Mackerras <paulus@samba.org>
Tue, 7 Feb 2006 10:32:44 +0000 (21:32 +1100)
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@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/kernel/prom.c
arch/powerpc/kernel/setup_64.c
include/asm-powerpc/prom.h

index 535a33e4aa37b9f8a9e0a4fd1b6ae72d7c99f0c3..2b062853bcc7a1715f0e026ac1e8566c1f4651dd 100644 (file)
@@ -1922,3 +1922,30 @@ int prom_update_property(struct device_node *np,
 
        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 e29b275e09e01a9400f12d99f9322b81ed845ef2..a717dff695ef28f09302c1690b13c921ac09dc02 100644 (file)
@@ -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 5b2bd4eefb01870e4a31647232331a1d10bbd962..cbd297f44cce6490ac1220898a945d58c95158aa 100644 (file)
@@ -222,5 +222,7 @@ extern int of_address_to_resource(struct device_node *dev, int index,
 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 */