From eab6a08c082b82dff884eb49a2229b0474d0b7e5 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Thu, 21 Feb 2013 17:37:06 +0530 Subject: 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 Signed-off-by: Vineet Gupta --- arch/arc/kernel/devtree.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'arch/arc/kernel/devtree.c') 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; + } +} -- cgit