summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorVineet Gupta <vgupta@synopsys.com>2013-02-21 13:07:06 +0100
committerVineet Gupta <vgupta@synopsys.com>2013-02-26 09:55:18 +0100
commiteab6a08c082b82dff884eb49a2229b0474d0b7e5 (patch)
tree4acffa75b89ecdef8d4f38558155b0afdd2fbe19 /arch
parentARC: [plat-arcfpga] DT arc-uart bindings change: "baud" => "current-speed" (diff)
downloadlinux-eab6a08c082b82dff884eb49a2229b0474d0b7e5.tar.xz
linux-eab6a08c082b82dff884eb49a2229b0474d0b7e5.zip
ARC: make a copy of flat DT
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>
Diffstat (limited to 'arch')
-rw-r--r--arch/arc/include/asm/mach_desc.h2
-rw-r--r--arch/arc/kernel/devtree.c15
-rw-r--r--arch/arc/kernel/setup.c2
3 files changed, 19 insertions, 0 deletions
diff --git a/arch/arc/include/asm/mach_desc.h b/arch/arc/include/asm/mach_desc.h
index eaebaf835f85..9998dc846ebb 100644
--- a/arch/arc/include/asm/mach_desc.h
+++ b/arch/arc/include/asm/mach_desc.h
@@ -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
diff --git a/arch/arc/kernel/devtree.c b/arch/arc/kernel/devtree.c
index a7d98b30358b..bdee3a812052 100644
--- a/arch/arc/kernel/devtree.c
+++ b/arch/arc/kernel/devtree.c
@@ -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;
+ }
+}
diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
index e591c6ae88a6..dc0f968dae0a 100644
--- a/arch/arc/kernel/setup.c
+++ b/arch/arc/kernel/setup.c
@@ -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"