[PATCH] ppc/uImage: Find new kernel load_addr if the default addr is not available

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 7, 2012 at 7:36 AM, Suzuki K. Poulose <suzuki at in.ibm.com> wrote:
> From: Suzuki K. Poulose <suzuki at in.ibm.com>
>
> 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.

Without testing, this looks reasonable to me.

-M

>
> Signed-off-by: Suzuki K. Poulose <suzuki at in.ibm.com>
> Cc: Sebastian Andrzej Siewior <bigeasy at linutronix.de>
> Cc: Matthew McClintock <msm at freescale.com>
> ---
>  kexec/arch/ppc/kexec-uImage-ppc.c |   21 +++++++++++++++------
>  1 file 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);
>
>
> _______________________________________________
> kexec mailing list
> kexec at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux