ARC: make a copy of flat DT
authorVineet Gupta <vgupta@synopsys.com>
Thu, 21 Feb 2013 12:07:06 +0000 (17:37 +0530)
committerVineet Gupta <vgupta@synopsys.com>
Tue, 26 Feb 2013 08:55:18 +0000 (14:25 +0530)
The flat DT (currently embedded in vmlinux) is in .init section.
The unflattened/binary tree doesn't copy strings through and references
them from orig flat DT - which could cause catestrohpy if of_* APIs are
called post init, say from a driver which is a loadable module.

Reported-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
arch/arc/include/asm/mach_desc.h
arch/arc/kernel/devtree.c
arch/arc/kernel/setup.c

index eaebaf835f8541e8476e411fa6a21ad58e9795e3..9998dc846ebb1b59944d32153e89e54e486c6423 100644 (file)
@@ -82,4 +82,6 @@ __attribute__((__section__(".arch.info.init"))) = {   \
 };
 
 extern struct machine_desc *setup_machine_fdt(void *dt);
+extern void __init copy_devtree(void);
+
 #endif
index a7d98b30358b25a6b3dbe611802ec422f07ef820..bdee3a8120521044fab496782b612157753abb83 100644 (file)
@@ -106,3 +106,18 @@ struct machine_desc * __init setup_machine_fdt(void *dt)
 
        return mdesc_best;
 }
+
+/*
+ * Copy the flattened DT out of .init since unflattening doesn't copy strings
+ * and the normal DT APIs refs them from orig flat DT
+ */
+void __init copy_devtree(void)
+{
+       void *alloc = early_init_dt_alloc_memory_arch(
+                       be32_to_cpu(initial_boot_params->totalsize), 64);
+       if (alloc) {
+               memcpy(alloc, initial_boot_params,
+                               be32_to_cpu(initial_boot_params->totalsize));
+               initial_boot_params = alloc;
+       }
+}
index e591c6ae88a61763c44ff6dea0e693841e15023b..dc0f968dae0aecfa96db2bc005a99c74bdabb71a 100644 (file)
@@ -354,6 +354,8 @@ void __init setup_arch(char **cmdline_p)
 
        setup_arch_memory();
 
+       /* copy flat DT out of .init and then unflatten it */
+       copy_devtree();
        unflatten_device_tree();
 
        /* Can be issue if someone passes cmd line arg "ro"
This page took 0.028461 seconds and 5 git commands to generate.