aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/boot/compressed/head.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/boot/compressed/head.S')
-rw-r--r--arch/arm/boot/compressed/head.S35
1 files changed, 24 insertions, 11 deletions
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index adf583cd0c35..49f5b2eaaa87 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -179,15 +179,14 @@ not_angel:
179 bl cache_on 179 bl cache_on
180 180
181restart: adr r0, LC0 181restart: adr r0, LC0
182 ldmia r0, {r1, r2, r3, r5, r6, r9, r11, r12} 182 ldmia r0, {r1, r2, r3, r6, r9, r11, r12}
183 ldr sp, [r0, #32] 183 ldr sp, [r0, #28]
184 184
185 /* 185 /*
186 * We might be running at a different address. We need 186 * We might be running at a different address. We need
187 * to fix up various pointers. 187 * to fix up various pointers.
188 */ 188 */
189 sub r0, r0, r1 @ calculate the delta offset 189 sub r0, r0, r1 @ calculate the delta offset
190 add r5, r5, r0 @ _start
191 add r6, r6, r0 @ _edata 190 add r6, r6, r0 @ _edata
192 191
193#ifndef CONFIG_ZBOOT_ROM 192#ifndef CONFIG_ZBOOT_ROM
@@ -206,31 +205,40 @@ restart: adr r0, LC0
206/* 205/*
207 * Check to see if we will overwrite ourselves. 206 * Check to see if we will overwrite ourselves.
208 * r4 = final kernel address 207 * r4 = final kernel address
209 * r5 = start of this image
210 * r9 = size of decompressed image 208 * r9 = size of decompressed image
211 * r10 = end of this image, including bss/stack/malloc space if non XIP 209 * r10 = end of this image, including bss/stack/malloc space if non XIP
212 * We basically want: 210 * We basically want:
213 * r4 >= r10 -> OK 211 * r4 - 16k page directory >= r10 -> OK
214 * r4 + image length <= r5 -> OK 212 * r4 + image length <= current position (pc) -> OK
215 */ 213 */
214 add r10, r10, #16384
216 cmp r4, r10 215 cmp r4, r10
217 bhs wont_overwrite 216 bhs wont_overwrite
218 add r10, r4, r9 217 add r10, r4, r9
219 cmp r10, r5 218 ARM( cmp r10, pc )
219 THUMB( mov lr, pc )
220 THUMB( cmp r10, lr )
220 bls wont_overwrite 221 bls wont_overwrite
221 222
222/* 223/*
223 * Relocate ourselves past the end of the decompressed kernel. 224 * Relocate ourselves past the end of the decompressed kernel.
224 * r5 = start of this image
225 * r6 = _edata 225 * r6 = _edata
226 * r10 = end of the decompressed kernel 226 * r10 = end of the decompressed kernel
227 * Because we always copy ahead, we need to do it from the end and go 227 * Because we always copy ahead, we need to do it from the end and go
228 * backward in case the source and destination overlap. 228 * backward in case the source and destination overlap.
229 */ 229 */
230 /* Round up to next 256-byte boundary. */ 230 /*
231 add r10, r10, #256 231 * Bump to the next 256-byte boundary with the size of
232 * the relocation code added. This avoids overwriting
233 * ourself when the offset is small.
234 */
235 add r10, r10, #((reloc_code_end - restart + 256) & ~255)
232 bic r10, r10, #255 236 bic r10, r10, #255
233 237
238 /* Get start of code we want to copy and align it down. */
239 adr r5, restart
240 bic r5, r5, #31
241
234 sub r9, r6, r5 @ size to copy 242 sub r9, r6, r5 @ size to copy
235 add r9, r9, #31 @ rounded up to a multiple 243 add r9, r9, #31 @ rounded up to a multiple
236 bic r9, r9, #31 @ ... of 32 bytes 244 bic r9, r9, #31 @ ... of 32 bytes
@@ -245,6 +253,11 @@ restart: adr r0, LC0
245 /* Preserve offset to relocated code. */ 253 /* Preserve offset to relocated code. */
246 sub r6, r9, r6 254 sub r6, r9, r6
247 255
256#ifndef CONFIG_ZBOOT_ROM
257 /* cache_clean_flush may use the stack, so relocate it */
258 add sp, sp, r6
259#endif
260
248 bl cache_clean_flush 261 bl cache_clean_flush
249 262
250 adr r0, BSYM(restart) 263 adr r0, BSYM(restart)
@@ -333,7 +346,6 @@ not_relocated: mov r0, #0
333LC0: .word LC0 @ r1 346LC0: .word LC0 @ r1
334 .word __bss_start @ r2 347 .word __bss_start @ r2
335 .word _end @ r3 348 .word _end @ r3
336 .word _start @ r5
337 .word _edata @ r6 349 .word _edata @ r6
338 .word _image_size @ r9 350 .word _image_size @ r9
339 .word _got_start @ r11 351 .word _got_start @ r11
@@ -1062,6 +1074,7 @@ memdump: mov r12, r0
1062#endif 1074#endif
1063 1075
1064 .ltorg 1076 .ltorg
1077reloc_code_end:
1065 1078
1066 .align 1079 .align
1067 .section ".stack", "aw", %nobits 1080 .section ".stack", "aw", %nobits