summaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel/relocate.c
diff options
context:
space:
mode:
authorSteven J. Hill2016-12-09 09:36:22 +0100
committerRalf Baechle2017-01-03 16:34:36 +0100
commit8cc709d7d4f013f51d38ceb2e3c8c82d230cf457 (patch)
tree399021521ac8980327d6e9447a28e40b152d9ce4 /arch/mips/kernel/relocate.c
parentMIPS: Octeon: Enable KASLR (diff)
downloadkernel-qcow2-linux-8cc709d7d4f013f51d38ceb2e3c8c82d230cf457.tar.gz
kernel-qcow2-linux-8cc709d7d4f013f51d38ceb2e3c8c82d230cf457.tar.xz
kernel-qcow2-linux-8cc709d7d4f013f51d38ceb2e3c8c82d230cf457.zip
MIPS: Relocatable: Provide plat_post_relocation hook
This hook provides the platform the chance to perform any required setup before the boot processor switches to the relocated kernel. The relocated kernel has been copied and fixed up ready for execution at this point. Secondary CPUs may wish to switch to it early. There is also the opportunity for the platform to abort jumping to the relocated kernel if there is anything wrong with the chosen offset. Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com> Signed-off-by: Steven J. Hill <Steven.Hill@cavium.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/14651/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel/relocate.c')
-rw-r--r--arch/mips/kernel/relocate.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/arch/mips/kernel/relocate.c b/arch/mips/kernel/relocate.c
index 1958910b75c0..c82288569eb1 100644
--- a/arch/mips/kernel/relocate.c
+++ b/arch/mips/kernel/relocate.c
@@ -31,6 +31,17 @@ extern u32 _relocation_end[]; /* End relocation table */
extern long __start___ex_table; /* Start exception table */
extern long __stop___ex_table; /* End exception table */
+/*
+ * This function may be defined for a platform to perform any post-relocation
+ * fixup necessary.
+ * Return non-zero to abort relocation
+ */
+int __weak plat_post_relocation(long offset)
+{
+ return 0;
+}
+
+
static inline u32 __init get_synci_step(void)
{
u32 res;
@@ -338,6 +349,15 @@ void *__init relocate_kernel(void)
*/
memcpy(RELOCATED(&__bss_start), &__bss_start, bss_length);
+ /*
+ * Last chance for the platform to abort relocation.
+ * This may also be used by the platform to perform any
+ * initialisation required now that the new kernel is
+ * resident in memory and ready to be executed.
+ */
+ if (plat_post_relocation(offset))
+ goto out;
+
/* The current thread is now within the relocated image */
__current_thread_info = RELOCATED(&init_thread_union);