summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuzuki K. Poulose <suzuki@in.ibm.com>2012-11-07 19:06:35 +0530
committerSimon Horman <horms@verge.net.au>2012-11-08 09:52:58 +0900
commit64283a8f05a2088ea10373ef73cb9560e8b8ec40 (patch)
tree29125a7da10155da1c32582887eb67695b1eca12
parent75d1a16f0b4e5b33e91a51d93014f1fd8303f36e (diff)
ppc/uImage: Find new kernel load_addr if the default addr is not available
If the kernel cannot be loaded at the default load_addr, provided by the image, we should try finding a free area using locate_hole(). This is usually applicable for the CRASH case, where the memory should be located in the reserved region. Without this patch, sometime the kernel fails to load for uImage formatted relocatable kernel images. Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: Matthew McClintock <msm@freescale.com> Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r--kexec/arch/ppc/kexec-uImage-ppc.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/kexec/arch/ppc/kexec-uImage-ppc.c b/kexec/arch/ppc/kexec-uImage-ppc.c
index b5579f0..e55bf94 100644
--- a/kexec/arch/ppc/kexec-uImage-ppc.c
+++ b/kexec/arch/ppc/kexec-uImage-ppc.c
@@ -130,13 +130,22 @@ static int ppc_load_bare_bits(int argc, char **argv, const char *buf,
* allocated from memtop down towards zero so we should never get too
* close to the bss :)
*/
- ret = valid_memory_range(info, load_addr, load_addr + (len + (1 * 1024 * 1024)));
- if (!ret) {
- printf("Can't add kernel to addr 0x%08x len %ld\n",
- load_addr, len + (1 * 1024 * 1024));
- return -1;
+#define _1MiB (1 * 1024 * 1024)
+
+ /*
+ * If the provided load_addr cannot be allocated, find a new
+ * area.
+ */
+ if (!valid_memory_range(info, load_addr, load_addr + (len + _1MiB))) {
+ load_addr = locate_hole(info, len + _1MiB, 0, 0, max_addr, 1);
+ if (load_addr == ULONG_MAX) {
+ printf("Can't allocate memory for kernel of len %ld\n",
+ len + _1MiB);
+ return -1;
+ }
}
- add_segment(info, buf, len, load_addr, len + (1 * 1024 * 1024));
+
+ add_segment(info, buf, len, load_addr, len + _1MiB);
if (info->kexec_flags & KEXEC_ON_CRASH) {
crash_cmdline = xmalloc(COMMAND_LINE_SIZE);