summaryrefslogtreecommitdiffstats
path: root/arch/metag/kernel/devtree.c
diff options
context:
space:
mode:
authorJames Hogan <james.hogan@imgtec.com>2013-02-20 13:59:13 +0000
committerJames Hogan <james.hogan@imgtec.com>2013-03-02 20:11:17 +0000
commit2270e6d30bb6601ffd42e9d972442df0499ad547 (patch)
treec72e32a15d041cfe38560dca277f335da3f6e7cf /arch/metag/kernel/devtree.c
parentd7900504480ea9d49a6b5f8811f2678ad08d3255 (diff)
downloadlinux-stable-2270e6d30bb6601ffd42e9d972442df0499ad547.tar.gz
linux-stable-2270e6d30bb6601ffd42e9d972442df0499ad547.tar.bz2
linux-stable-2270e6d30bb6601ffd42e9d972442df0499ad547.zip
metag: copy devicetree to non-init memory
Make a copy of the device tree blob in non-init memory. It is required when using built-in device tree files that the platform code copies the blob to non-init memory prior to calling unflatten_device_tree(), otherwise the strings that the device tree refer to will get poisoned and potentially reused, breaking later reading of the device tree post-init (such as compatible matching in modules, debugfs, and the procfs interface). Signed-off-by: James Hogan <james.hogan@imgtec.com> Reviewed-by: Vineet Gupta <vgupta@synopsys.com>
Diffstat (limited to 'arch/metag/kernel/devtree.c')
-rw-r--r--arch/metag/kernel/devtree.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/arch/metag/kernel/devtree.c b/arch/metag/kernel/devtree.c
index 5b6b1d855492..7cd02529636e 100644
--- a/arch/metag/kernel/devtree.c
+++ b/arch/metag/kernel/devtree.c
@@ -95,3 +95,20 @@ struct machine_desc * __init setup_machine_fdt(void *dt)
return mdesc_best;
}
+
+/**
+ * copy_fdt - Copy device tree into non-init memory.
+ *
+ * We must copy the flattened device tree blob into non-init memory because the
+ * unflattened device tree will reference the strings in it directly.
+ */
+void __init copy_fdt(void)
+{
+ void *alloc = early_init_dt_alloc_memory_arch(
+ be32_to_cpu(initial_boot_params->totalsize), 0x40);
+ if (alloc) {
+ memcpy(alloc, initial_boot_params,
+ be32_to_cpu(initial_boot_params->totalsize));
+ initial_boot_params = alloc;
+ }
+}