linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <suravee.suthikulpanit@amd.com>
To: <catalin.marinas@arm.com>, <will.deacon@arm.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-apci@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <astone@redhat.com>,
	<hanjun.guo@linaro.org>, <rjw@rjwysocki.net>,
	<marc.zyngier@arm.com>, <mark.rutland@arm.com>,
	<Sudeep.Holla@arm.com>, <olof@lixom.net>,
	<grant.likely@linaro.org>, <graeme.gregory@linaro.org>,
	<arnd@arndb.de>, <jason@lakedaemon.net>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH 2/4] arm64/efi: efistub: don't abort if base of DRAM is occupied
Date: Mon, 15 Sep 2014 19:47:24 -0500	[thread overview]
Message-ID: <1410828446-28502-3-git-send-email-suravee.suthikulpanit@amd.com> (raw)
In-Reply-To: <1410828446-28502-1-git-send-email-suravee.suthikulpanit@amd.com>

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

If we cannot relocate the kernel Image to its preferred offset of base of DRAM
plus TEXT_OFFSET, instead relocate it to the lowest available 2 MB boundary plus
TEXT_OFFSET. We may lose a bit of memory at the low end, but we can still
proceed normally otherwise.

Acked-by: Mark Salter <msalter@redhat.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Leif Lindholm <leif.lindholm@linaro.org>
Tested-by: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/kernel/efi-stub.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/arch/arm64/kernel/efi-stub.c b/arch/arm64/kernel/efi-stub.c
index 1317fef..d27dd98 100644
--- a/arch/arm64/kernel/efi-stub.c
+++ b/arch/arm64/kernel/efi-stub.c
@@ -28,20 +28,16 @@ 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_LOAD_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 + TEXT_OFFSET;
 	}
 
 
-- 
1.9.3


  parent reply	other threads:[~2014-09-16  2:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-16  0:47 [RFC PATCH for AMD Seattle 0/4] Drivers for AMD-Seatlle to boot from ACPI suravee.suthikulpanit
2014-09-16  0:47 ` [PATCH 1/4] ata: ahci_platform: Add ACPI support for AMD Seattle SATA controller suravee.suthikulpanit
2014-09-17  1:26   ` Matthew Garrett
2014-10-01 21:19     ` Suravee Suthikulanit
2014-10-02  8:39       ` Arnd Bergmann
2014-10-06 16:31         ` Matthew Garrett
2014-10-06 18:19           ` Arnd Bergmann
2014-10-06 18:21             ` Matthew Garrett
2014-10-06 18:44               ` Arnd Bergmann
2014-10-06 18:47                 ` Matthew Garrett
2014-09-16  0:47 ` suravee.suthikulpanit [this message]
2014-09-16  0:47 ` [PATCH 3/4] efi/arm64: fix fdt-related memory reservation suravee.suthikulpanit
2014-09-16  0:47 ` [PATCH 4/4] [RFC PATCH for Juno 2/2] tty: SBSA compatible UART suravee.suthikulpanit
2014-09-17 10:40   ` One Thousand Gnomes
2014-09-17 17:01     ` Graeme Gregory
2014-09-16  4:28 ` [RFC PATCH for AMD Seattle 0/4] Drivers for AMD-Seatlle to boot from ACPI Suravee Suthikulpanit
2014-09-16 22:56   ` Jon Masters

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=1410828446-28502-3-git-send-email-suravee.suthikulpanit@amd.com \
    --to=suravee.suthikulpanit@amd.com \
    --cc=Sudeep.Holla@arm.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=arnd@arndb.de \
    --cc=astone@redhat.com \
    --cc=catalin.marinas@arm.com \
    --cc=graeme.gregory@linaro.org \
    --cc=grant.likely@linaro.org \
    --cc=hanjun.guo@linaro.org \
    --cc=jason@lakedaemon.net \
    --cc=linux-apci@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=mark.rutland@arm.com \
    --cc=olof@lixom.net \
    --cc=rjw@rjwysocki.net \
    --cc=will.deacon@arm.com \
    /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).