Skip to content

Commit

Permalink
ARC: make a copy of flat DT
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Vineet Gupta committed Feb 26, 2013
1 parent fc32781 commit eab6a08
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arch/arc/include/asm/mach_desc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 15 additions & 0 deletions arch/arc/kernel/devtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 2 additions & 0 deletions arch/arc/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit eab6a08

Please sign in to comment.