1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * relocate_kernel.S for kexec
8 #include <asm/asmmacro.h>
9 #include <asm/regdef.h>
10 #include <asm/mipsregs.h>
11 #include <asm/stackframe.h>
12 #include <asm/addrspace.h>
14 #include <kernel-entry-init.h>
16 LEAF(relocate_new_kernel)
22 PTR_L s0, kexec_indirection_page
23 PTR_L s1, kexec_start_address
27 PTR_ADDIU s0, s0, SZREG
30 * In case of a kdump/crash kernel, the indirection page is not
31 * populated as the kernel is directly copied to a reserved location
35 /* destination page */
38 and s4, s2, ~0x1 /* store destination addr in s4 */
42 /* indirection page, update s0 */
56 beq s3, zero, process_entry
58 li s6, (1 << _PAGE_SHIFT) / SZREG
61 /* copy page word by word */
64 PTR_ADDIU s4, s4, SZREG
65 PTR_ADDIU s2, s2, SZREG
67 beq s6, zero, process_entry
73 /* kexec_flag reset is signal to other CPUs what kernel
74 was moved to it's location. Note - we need relocated address
86 #ifdef CONFIG_CPU_CAVIUM_OCTEON
87 /* We need to flush I-cache before jumping to new kernel.
88 * Unfortunately, this code is cpu-specific.
99 /* jump to kexec_start_address */
101 END(relocate_new_kernel)
105 * Other CPUs should wait until code is relocated and
106 * then start at entry (?) point.
113 PTR_L s1, kexec_start_address
115 /* Non-relocated address works for args and kexec_start_address ( old
116 * kernel is not overwritten). But we need relocated address of
130 #ifdef USE_KEXEC_SMP_WAIT_FINAL
140 /* all PTR's must be aligned to 8 byte in 64-bit mode */
144 /* All parameters to new kernel are passed in registers a0-a3.
145 * kexec_args[0..3] are used to prepare register values.
154 .size kexec_args,PTRSIZE*4
158 * Secondary CPUs may have different kernel parameters in
159 * their registers a0-a3. secondary_kexec_args[0..3] are used
160 * to prepare register values.
162 secondary_kexec_args:
163 EXPORT(secondary_kexec_args)
168 .size secondary_kexec_args,PTRSIZE*4
175 EXPORT(kexec_start_address)
177 .size kexec_start_address, PTRSIZE
179 kexec_indirection_page:
180 EXPORT(kexec_indirection_page)
182 .size kexec_indirection_page, PTRSIZE
184 relocate_new_kernel_end:
186 relocate_new_kernel_size:
187 EXPORT(relocate_new_kernel_size)
188 PTR relocate_new_kernel_end - relocate_new_kernel
189 .size relocate_new_kernel_size, PTRSIZE