summaryrefslogtreecommitdiff
path: root/arch/loongarch/kernel/head.S
diff options
context:
space:
mode:
authorQing Zhang <zhangqing@loongson.cn>2023-09-06 17:54:16 +0300
committerHuacai Chen <chenhuacai@loongson.cn>2023-09-06 17:54:16 +0300
commit9fbcc076798ead2af28c854a265d9da83bec8429 (patch)
treee6a28a961e50a2a2219f101b1c9cf62310cdcbe1 /arch/loongarch/kernel/head.S
parentfb6d5c1d99ab6958c5e284f7aa5f0cc553f0268c (diff)
downloadlinux-9fbcc076798ead2af28c854a265d9da83bec8429.tar.xz
LoongArch: Simplify the processing of jumping new kernel for KASLR
Modified relocate_kernel() doesn't return new kernel's entry point but the random_offset. In this way we share the start_kernel() processing with the normal kernel, which avoids calling 'jr a0' directly and allows some other operations (e.g, kasan_early_init) before start_kernel() when KASLR (CONFIG_RANDOMIZE_BASE) is turned on. Signed-off-by: Qing Zhang <zhangqing@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Diffstat (limited to 'arch/loongarch/kernel/head.S')
-rw-r--r--arch/loongarch/kernel/head.S11
1 files changed, 6 insertions, 5 deletions
diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S
index 5e828a8bc0a0..5743fef70dfe 100644
--- a/arch/loongarch/kernel/head.S
+++ b/arch/loongarch/kernel/head.S
@@ -95,13 +95,14 @@ SYM_CODE_START(kernel_entry) # kernel entry point
PTR_LI sp, (_THREAD_SIZE - PT_SIZE)
PTR_ADD sp, sp, tp
set_saved_sp sp, t0, t1
-#endif
- /* relocate_kernel() returns the new kernel entry point */
- jr a0
- ASM_BUG()
+ /* Jump to the new kernel: new_pc = current_pc + random_offset */
+ pcaddi t0, 0
+ add.d t0, t0, a0
+ jirl zero, t0, 0xc
+#endif /* CONFIG_RANDOMIZE_BASE */
-#endif
+#endif /* CONFIG_RELOCATABLE */
bl start_kernel
ASM_BUG()