linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] efi/arm64: efistub: don't abort if base of DRAM is occupied
Date: Mon, 14 Jul 2014 17:27:52 +0200	[thread overview]
Message-ID: <CAKv+Gu-NDUe77uneEmZbcWN+FcFq2qHFgaF3scyjSbQMfV2J0g@mail.gmail.com> (raw)
In-Reply-To: <1405351521-12010-1-git-send-email-ard.biesheuvel@linaro.org>

On 14 July 2014 17:25, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> If we fail to relocate the kernel Image to its preferred offset of TEXT_OFFSET
> bytes above the base of DRAM, accept the lowest alternative mapping available
> instead of aborting. We may lose a bit of memory at the low end, but we can
> still proceed normally otherwise.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> This is a proposed bug fix for arm64 platforms that fail to boot through EFI
> due to the fact that some bits of EFI itself are occupying the low end of DRAM.
>
> Note that this code now triggers an 'unused function' warning for
> efi_relocate_kernel(), as that is no longer used. This warning will disappear
> automatically once the already queued up EFISTUB refactoring patches will
> get merged for 3.17.
>
>  arch/arm64/kernel/efi-stub.c | 18 ++++++------------
>  1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/arch/arm64/kernel/efi-stub.c b/arch/arm64/kernel/efi-stub.c
> index 60e98a639ac5..5165b3accefe 100644
> --- a/arch/arm64/kernel/efi-stub.c
> +++ b/arch/arm64/kernel/efi-stub.c
> @@ -60,20 +60,16 @@ static efi_status_t handle_kernel_image(efi_system_table_t *sys_table,
>         kernel_size = _edata - _text;
>         if (*image_addr != (dram_base + TEXT_OFFSET)) {
>                 kernel_memsize = kernel_size + (_end - _edata);
> -               status = efi_relocate_kernel(sys_table, image_addr,
> -                                            kernel_size, kernel_memsize,
> -                                            dram_base + TEXT_OFFSET,
> -                                            PAGE_SIZE);
> +               status = efi_low_alloc(sys_table, kernel_memsize + TEXT_OFFSET,
> +                                      SZ_2M, reserve_addr);
>                 if (status != EFI_SUCCESS) {
>                         pr_efi_err(sys_table, "Failed to relocate kernel\n");
>                         return status;
>                 }
> -               if (*image_addr != (dram_base + TEXT_OFFSET)) {
> -                       pr_efi_err(sys_table, "Failed to alloc kernel memory\n");
> -                       efi_free(sys_table, kernel_memsize, *image_addr);
> -                       return EFI_ERROR;
> -               }
> -               *image_size = kernel_memsize;
> +               memcpy((void *)*reserve_addr + TEXT_OFFSET, (void *)*image_addr,
> +                      kernel_size);
> +               *image_addr = *reserve_addr + TEXT_OFFSET;
> +               *reserve_size = kernel_memsize;

This still needs a '+ TEXT_OFFSET' btw

  reply	other threads:[~2014-07-14 15:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-14 15:25 [PATCH] efi/arm64: efistub: don't abort if base of DRAM is occupied Ard Biesheuvel
2014-07-14 15:27 ` Ard Biesheuvel [this message]
2014-07-14 18:40 ` Mark Salter
2014-07-15 10:02   ` Leif Lindholm
2014-07-15 11:05     ` Mark Rutland
2014-07-15 13:11     ` Mark Salter
2014-07-15 13:54       ` Leif Lindholm
2014-07-15 14:23         ` Mark Salter
2014-07-15 14:31           ` Mark Rutland
2014-07-15 14:49           ` Leif Lindholm
2014-07-15 15:04             ` Mark Salter
2014-07-15 15:28               ` Leif Lindholm
2014-07-16 13:13                 ` Mark Salter
2014-07-22 17:08                   ` Leif Lindholm
2014-07-22 19:28                     ` Mark Salter
2014-07-22 21:28                       ` Leif Lindholm
2014-07-15 11:00   ` Mark Rutland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKv+Gu-NDUe77uneEmZbcWN+FcFq2qHFgaF3scyjSbQMfV2J0g@mail.gmail.com \
    --to=ard.biesheuvel@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).