From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] arm64/efi: use efi_low_alloc() with offset to allocate kernel
Date: Wed, 29 Jul 2015 12:04:19 +0200 [thread overview]
Message-ID: <1438164259-14470-3-git-send-email-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <1438164259-14470-1-git-send-email-ard.biesheuvel@linaro.org>
Now that efi_low_alloc() supports an offset parameter, we can use it
to allocate memory for the kernel at TEXT_OFFSET bytes above a 2 MB
aligned boundary directly. This prevents issues when the base of
DRAM is at 0x0, which efi_low_alloc() refuses to use as the address
of an allocation. It also helps when fewer than TEXT_OFFSET bytes are
occupied by the firmware at the base of DRAM, since efi_low_alloc()
will now do the rounding for us, and return 'base of DRAM + TEXT_OFFSET'
directly, regardless of whether any regions below it are in use.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
arch/arm64/kernel/efi-stub.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/arch/arm64/kernel/efi-stub.c b/arch/arm64/kernel/efi-stub.c
index d85a0b2098b3..e3085b391570 100644
--- a/arch/arm64/kernel/efi-stub.c
+++ b/arch/arm64/kernel/efi-stub.c
@@ -23,21 +23,22 @@ efi_status_t __init handle_kernel_image(efi_system_table_t *sys_table,
{
efi_status_t status;
unsigned long kernel_size, kernel_memsize = 0;
+ unsigned long new_image_addr;
/* Relocate the image, if required. */
kernel_size = _edata - _text;
if (*image_addr != (dram_base + TEXT_OFFSET)) {
kernel_memsize = kernel_size + (_end - _edata);
- status = efi_low_alloc(sys_table, kernel_memsize + TEXT_OFFSET,
- SZ_2M, 0, reserve_addr);
+ status = efi_low_alloc(sys_table, kernel_memsize, SZ_2M,
+ TEXT_OFFSET, &new_image_addr);
if (status != EFI_SUCCESS) {
pr_efi_err(sys_table, "Failed to relocate kernel\n");
return status;
}
- memcpy((void *)*reserve_addr + TEXT_OFFSET, (void *)*image_addr,
+ memcpy((void *)new_image_addr, (void *)*image_addr,
kernel_size);
- *image_addr = *reserve_addr + TEXT_OFFSET;
- *reserve_size = kernel_memsize + TEXT_OFFSET;
+ *image_addr = new_image_addr;
+ *image_size = kernel_memsize;
}
--
1.9.1
prev parent reply other threads:[~2015-07-29 10:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-29 10:04 [PATCH 0/2] arm64/efi: fix kernel allocation at base of DRAM Ard Biesheuvel
2015-07-29 10:04 ` [PATCH 1/2] efi: add 'offset' param to efi_low_alloc() Ard Biesheuvel
2015-07-30 14:01 ` Matt Fleming
2015-07-30 14:06 ` Ard Biesheuvel
2015-07-29 10:04 ` Ard Biesheuvel [this message]
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=1438164259-14470-3-git-send-email-ard.biesheuvel@linaro.org \
--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).