summaryrefslogtreecommitdiffstats
path: root/arch/arm/lib
diff options
context:
space:
mode:
authorStefan Müller-Klieser <s.mueller-klieser@phytec.de>2016-07-01 16:48:39 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-07-04 11:31:05 +0200
commit6a218d456c28960c7625c50ac924f120e448a03d (patch)
tree7ee275624b5f3a612102c3cd216d218de0419fbe /arch/arm/lib
parentd7fc1c18e785277f24a69e2aaa1a2c6e80e2b0cf (diff)
downloadbarebox-6a218d456c28960c7625c50ac924f120e448a03d.tar.gz
barebox-6a218d456c28960c7625c50ac924f120e448a03d.tar.xz
ARM: bootm: recalculate decompression space
According to the kernel documentation it is recommended to place the compressed image between 32 MiB and 128 MiB. The DTB and initrd should be placed above 128 MiB. We will follow the recommendation as long as we have enough RAM. If this is not the case, we fall back to the scheme. This change is required because of the ARM default kernel config changes regarding RODATA layout, which lead to an increased compression factor of the kernel image. This should be regarded as an intermediate solution until there is a mechanism for the kernel image to report the decompressed layout requirements to the bootloader. Signed-off-by: Stefan Müller-Klieser <s.mueller-klieser@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/lib')
-rw-r--r--arch/arm/lib/bootm.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 803aa94490..be1259bbff 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -81,10 +81,15 @@ static int get_kernel_addresses(size_t image_size,
return ret;
/*
- * We don't know the exact decompressed size so just use a conservative
- * default of 4 times the size of the compressed image.
+ * The kernel documentation "Documentation/arm/Booting" advises
+ * to place the compressed image outside of the lowest 32 MiB to
+ * avoid relocation. We should do this if we have at least 64 MiB
+ * of ram. If we have less space, we assume a maximum
+ * compression factor of 5.
*/
- image_decomp_size = PAGE_ALIGN(image_size * 4);
+ image_decomp_size = PAGE_ALIGN(image_size * 5);
+ if (mem_size >= SZ_64M)
+ image_decomp_size = max(image_decomp_size, SZ_32M);
/*
* By default put oftree/initrd close behind compressed kernel image to
@@ -113,6 +118,13 @@ static int get_kernel_addresses(size_t image_size,
*mem_free = PAGE_ALIGN(*load_address + image_size + spacing);
+ /*
+ * Place oftree/initrd outside of the first 128 MiB, if we have space
+ * for it. This avoids potential conflicts with the kernel decompressor.
+ */
+ if (mem_size > SZ_256M)
+ *mem_free = max(*mem_free, mem_start + SZ_128M);
+
return 0;
}