aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/generic/init.c
diff options
context:
space:
mode:
authorMatt Redfearn <matt.redfearn@imgtec.com>2016-10-17 12:25:24 -0400
committerRalf Baechle <ralf@linux-mips.org>2016-11-03 19:32:06 -0400
commit9a59061cfd7ac00f21111d2e8aa7f4ab11d27f6c (patch)
treec74bb639bcb32b6ca2ce0661481095f9c81e4d85 /arch/mips/generic/init.c
parent4736697963385e6257ee8e260e97347e858cd962 (diff)
MIPS: generic: Fix KASLR for generic kernel.
The KASLR code requires that the plat_get_fdt() function return the address of the device tree, and it must be available early in the boot, before prom_init() is called. Move the code determining the address of the device tree into plat_get_fdt, and call that from prom_init(). The fdt pointer will be set up by plat_get_fdt() called from relocate_kernel initially and once the relocated kernel has started, prom_init() will use it again to determine the address in the relocated image. Fixes: eed0eabd12ef ("MIPS: generic: Introduce generic DT-based board support") Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com> Reviewed-by: James Hogan <james.hogan@imgtec.com> Reviewed-by: Paul Burton <paul.burton@imgtec.com> Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/14415/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/generic/init.c')
-rw-r--r--arch/mips/generic/init.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/arch/mips/generic/init.c b/arch/mips/generic/init.c
index 0ea73e845440..d493ccbf274a 100644
--- a/arch/mips/generic/init.c
+++ b/arch/mips/generic/init.c
@@ -30,9 +30,19 @@ static __initdata const void *mach_match_data;
30 30
31void __init prom_init(void) 31void __init prom_init(void)
32{ 32{
33 plat_get_fdt();
34 BUG_ON(!fdt);
35}
36
37void __init *plat_get_fdt(void)
38{
33 const struct mips_machine *check_mach; 39 const struct mips_machine *check_mach;
34 const struct of_device_id *match; 40 const struct of_device_id *match;
35 41
42 if (fdt)
43 /* Already set up */
44 return (void *)fdt;
45
36 if ((fw_arg0 == -2) && !fdt_check_header((void *)fw_arg1)) { 46 if ((fw_arg0 == -2) && !fdt_check_header((void *)fw_arg1)) {
37 /* 47 /*
38 * We booted using the UHI boot protocol, so we have been 48 * We booted using the UHI boot protocol, so we have been
@@ -75,12 +85,6 @@ void __init prom_init(void)
75 /* Retrieve the machine's FDT */ 85 /* Retrieve the machine's FDT */
76 fdt = mach->fdt; 86 fdt = mach->fdt;
77 } 87 }
78
79 BUG_ON(!fdt);
80}
81
82void __init *plat_get_fdt(void)
83{
84 return (void *)fdt; 88 return (void *)fdt;
85} 89}
86 90