1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <linux/linkage.h>
3 #include <linux/kexec.h>
5 #include <asm/assembly.h>
6 #include <asm/asm-offsets.h>
13 .macro kexec_param name
22 ENTRY(kexec\()_\name\()_offset)
23 .word kexec\()_\name - relocate_new_kernel
30 * r25 - start address of kernel
31 * r24 - physical address of relocate code
34 ENTRY_CFI(relocate_new_kernel)
36 /* disable I and Q bit, so we are allowed to execute RFI */
56 * After return-from-interrupt, we want to run without Code/Data
57 * translation enabled just like on a normal boot.
60 /* calculate new physical execution address */
62 mtctl %r0, %cr17 /* IIASQ */
63 mtctl %r0, %cr17 /* IIASQ */
64 mtctl %r1, %cr18 /* IIAOQ */
66 mtctl %r1, %cr18 /* IIAOQ */
68 depdi,z 1, PSW_W_BIT, 1, %r1
69 mtctl %r1, %cr22 /* IPSW */
71 mtctl %r0, %cr22 /* IPSW */
79 LDREG,ma REG_SZ(%arg0), %r3
80 /* If crash kernel, no copy needed */
81 cmpib,COND(=),n 0,%r3,boot
83 bb,<,n %r3, 31 - IND_DONE_BIT, boot
84 bb,>=,n %r3, 31 - IND_INDIRECTION_BIT, .Lnotind
85 /* indirection, load and restart */
86 movb %r3, %arg0, .Lloop
87 depi 0, 31, PAGE_SHIFT, %arg0
90 bb,>=,n %r3, 31 - IND_DESTINATION_BIT, .Lnotdest
95 bb,>= %r3, 31 - IND_SOURCE_BIT, .Lloop
96 depi 0, 31, PAGE_SHIFT, %r3
101 zdepi 1, 31 - PAGE_SHIFT, 1, %r18
104 depi 0, 31, PAGE_SHIFT, %r20
107 LDREG,ma REG_SZ(%r21), %r8
108 LDREG,ma REG_SZ(%r21), %r9
109 LDREG,ma REG_SZ(%r21), %r10
110 LDREG,ma REG_SZ(%r21), %r11
111 STREG,ma %r8, REG_SZ(%r20)
112 STREG,ma %r9, REG_SZ(%r20)
113 STREG,ma %r10, REG_SZ(%r20)
114 STREG,ma %r11, REG_SZ(%r20)
117 LDREG,ma REG_SZ(%r21), %r8
118 LDREG,ma REG_SZ(%r21), %r9
119 LDREG,ma REG_SZ(%r21), %r10
120 LDREG,ma REG_SZ(%r21), %r11
121 STREG,ma %r8, REG_SZ(%r20)
122 STREG,ma %r9, REG_SZ(%r20)
123 STREG,ma %r10, REG_SZ(%r20)
124 STREG,ma %r11, REG_SZ(%r20)
128 cmpb,COND(<<) %r20,%r17,.Lcopy
135 LDREG kexec_free_mem-0b(%arg2), %arg0
136 LDREG kexec_cmdline-0b(%arg2), %arg1
137 LDREG kexec_initrd_end-0b(%arg2), %arg3
138 LDREG kexec_initrd_start-0b(%arg2), %arg2
141 ENDPROC_CFI(relocate_new_kernel);
143 ENTRY(relocate_new_kernel_size)
144 .word relocate_new_kernel_size - relocate_new_kernel
147 kexec_param initrd_start
148 kexec_param initrd_end