diff options
author | Nicolas Pitre <nicolas.pitre@linaro.org> | 2015-01-27 10:10:42 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2015-01-29 10:23:01 -0500 |
commit | c2607f74aad96d18316a6e709b40e0ffe9def148 (patch) | |
tree | 7ca8b21b5631d9fe31faa075544cfe1c26db5f3f /arch/arm/boot/compressed | |
parent | c2273a185354fe9420fb342b1ca09a6fed857fb3 (diff) |
ARM: 8294/1: ATAG_DTB_COMPAT: remove the DT workspace's hardcoded 64KB size
There is currently a hardcoded limit of 64KB for the DTB to live in and
be extended with ATAG info. Some DTBs have outgrown that limit:
$ du -b arch/arm/boot/dts/omap3-n900.dtb
70212 arch/arm/boot/dts/omap3-n900.dtb
Furthermore, the actual size passed to atags_to_fdt() included the stack
size which is obviously wrong.
The initial DTB size is known, so use it to size the allocated workspace
with a 50% growth assumption and relocate the temporary stack above that.
This is also clamped to 32KB min / 1MB max for robustness against bad
DTB data.
Reported-by: Pali Rohár <pali.rohar@gmail.com>
Tested-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/boot/compressed')
-rw-r--r-- | arch/arm/boot/compressed/head.S | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index 68be9017593d..132c70e2d2f1 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S | |||
@@ -263,16 +263,37 @@ restart: adr r0, LC0 | |||
263 | * OK... Let's do some funky business here. | 263 | * OK... Let's do some funky business here. |
264 | * If we do have a DTB appended to zImage, and we do have | 264 | * If we do have a DTB appended to zImage, and we do have |
265 | * an ATAG list around, we want the later to be translated | 265 | * an ATAG list around, we want the later to be translated |
266 | * and folded into the former here. To be on the safe side, | 266 | * and folded into the former here. No GOT fixup has occurred |
267 | * let's temporarily move the stack away into the malloc | 267 | * yet, but none of the code we're about to call uses any |
268 | * area. No GOT fixup has occurred yet, but none of the | 268 | * global variable. |
269 | * code we're about to call uses any global variable. | ||
270 | */ | 269 | */ |
271 | add sp, sp, #0x10000 | 270 | |
271 | /* Get the initial DTB size */ | ||
272 | ldr r5, [r6, #4] | ||
273 | #ifndef __ARMEB__ | ||
274 | /* convert to little endian */ | ||
275 | eor r1, r5, r5, ror #16 | ||
276 | bic r1, r1, #0x00ff0000 | ||
277 | mov r5, r5, ror #8 | ||
278 | eor r5, r5, r1, lsr #8 | ||
279 | #endif | ||
280 | /* 50% DTB growth should be good enough */ | ||
281 | add r5, r5, r5, lsr #1 | ||
282 | /* preserve 64-bit alignment */ | ||
283 | add r5, r5, #7 | ||
284 | bic r5, r5, #7 | ||
285 | /* clamp to 32KB min and 1MB max */ | ||
286 | cmp r5, #(1 << 15) | ||
287 | movlo r5, #(1 << 15) | ||
288 | cmp r5, #(1 << 20) | ||
289 | movhi r5, #(1 << 20) | ||
290 | /* temporarily relocate the stack past the DTB work space */ | ||
291 | add sp, sp, r5 | ||
292 | |||
272 | stmfd sp!, {r0-r3, ip, lr} | 293 | stmfd sp!, {r0-r3, ip, lr} |
273 | mov r0, r8 | 294 | mov r0, r8 |
274 | mov r1, r6 | 295 | mov r1, r6 |
275 | sub r2, sp, r6 | 296 | mov r2, r5 |
276 | bl atags_to_fdt | 297 | bl atags_to_fdt |
277 | 298 | ||
278 | /* | 299 | /* |
@@ -285,11 +306,11 @@ restart: adr r0, LC0 | |||
285 | bic r0, r0, #1 | 306 | bic r0, r0, #1 |
286 | add r0, r0, #0x100 | 307 | add r0, r0, #0x100 |
287 | mov r1, r6 | 308 | mov r1, r6 |
288 | sub r2, sp, r6 | 309 | mov r2, r5 |
289 | bleq atags_to_fdt | 310 | bleq atags_to_fdt |
290 | 311 | ||
291 | ldmfd sp!, {r0-r3, ip, lr} | 312 | ldmfd sp!, {r0-r3, ip, lr} |
292 | sub sp, sp, #0x10000 | 313 | sub sp, sp, r5 |
293 | #endif | 314 | #endif |
294 | 315 | ||
295 | mov r8, r6 @ use the appended device tree | 316 | mov r8, r6 @ use the appended device tree |
@@ -306,7 +327,7 @@ restart: adr r0, LC0 | |||
306 | subs r1, r5, r1 | 327 | subs r1, r5, r1 |
307 | addhi r9, r9, r1 | 328 | addhi r9, r9, r1 |
308 | 329 | ||
309 | /* Get the dtb's size */ | 330 | /* Get the current DTB size */ |
310 | ldr r5, [r6, #4] | 331 | ldr r5, [r6, #4] |
311 | #ifndef __ARMEB__ | 332 | #ifndef __ARMEB__ |
312 | /* convert r5 (dtb size) to little endian */ | 333 | /* convert r5 (dtb size) to little endian */ |