All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb@kernel.org>
To: linux-efi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org,
	Ard Biesheuvel <ardb@kernel.org>,
	Maxim Uvarov <maxim.uvarov@linaro.org>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Atish Patra <atish.patra@wdc.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Jens Wiklander <jens.wiklander@linaro.org>,
	Francois Ozog <francois.ozog@linaro.org>,
	Etienne CARRIERE <etienne.carriere@st.com>,
	Takahiro Akashi <takahiro.akashi@linaro.org>,
	Patrice CHOTARD <patrice.chotard@st.com>,
	Sumit Garg <sumit.garg@linaro.org>,
	Grant Likely <Grant.Likely@arm.com>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Christophe Priouzeau <christophe.priouzeau@linaro.org>,
	Rouven Czerwinski <r.czerwinski@pengutronix.de>,
	Patrick DELAUNAY <patrick.delaunay@st.com>
Subject: [PATCH RFC/RFT 3/3] efi/libstub: base FDT and initrd placement on image address not DRAM base
Date: Wed,  9 Sep 2020 18:16:23 +0300	[thread overview]
Message-ID: <20200909151623.16153-4-ardb@kernel.org> (raw)
In-Reply-To: <20200909151623.16153-1-ardb@kernel.org>

The way we use the base of DRAM in the EFI stub is problematic as it
is ill defined what the base of DRAM actually means. There are some
restrictions on the placement of FDT and initrd which are defined in
terms of dram_base, but given that the placement of the kernel in
memory is what defines these boundaries, it is better to use the image
address in these cases, and disregard dram_base altogether.

In a future patch, we should be able to get rid of dram_base entirely,
but at the moment, RISC-V support is in flight in another tree, so we
keep it around for now.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 arch/arm/include/asm/efi.h              | 6 +++---
 arch/arm64/include/asm/efi.h            | 2 +-
 drivers/firmware/efi/libstub/efi-stub.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/include/asm/efi.h b/arch/arm/include/asm/efi.h
index 5dcf3c6011b7..9e481b362227 100644
--- a/arch/arm/include/asm/efi.h
+++ b/arch/arm/include/asm/efi.h
@@ -75,16 +75,16 @@ static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt)
 #define MIN_ZIMAGE_OFFSET	MAX_UNCOMP_KERNEL_SIZE
 
 /* on ARM, the FDT should be located in the first 128 MB of RAM */
-static inline unsigned long efi_get_max_fdt_addr(unsigned long dram_base)
+static inline unsigned long efi_get_max_fdt_addr(unsigned long image_addr)
 {
-	return dram_base + ZIMAGE_OFFSET_LIMIT;
+	return image_addr + ZIMAGE_OFFSET_LIMIT;
 }
 
 /* on ARM, the initrd should be loaded in a lowmem region */
 static inline unsigned long efi_get_max_initrd_addr(unsigned long dram_base,
 						    unsigned long image_addr)
 {
-	return dram_base + SZ_512M;
+	return image_addr + SZ_512M;
 }
 
 struct efi_arm_entry_state {
diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h
index d4ab3f73e7a3..27c2e8959ab6 100644
--- a/arch/arm64/include/asm/efi.h
+++ b/arch/arm64/include/asm/efi.h
@@ -65,7 +65,7 @@ efi_status_t __efi_rt_asm_wrapper(void *, const char *, ...);
 	(SEGMENT_ALIGN > THREAD_ALIGN ? SEGMENT_ALIGN : THREAD_ALIGN)
 
 /* on arm64, the FDT may be located anywhere in system RAM */
-static inline unsigned long efi_get_max_fdt_addr(unsigned long dram_base)
+static inline unsigned long efi_get_max_fdt_addr(unsigned long image_addr)
 {
 	return ULONG_MAX;
 }
diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
index a5a405d8ab44..76ce60065f10 100644
--- a/drivers/firmware/efi/libstub/efi-stub.c
+++ b/drivers/firmware/efi/libstub/efi-stub.c
@@ -306,7 +306,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
 	install_memreserve_table();
 
 	status = allocate_new_fdt_and_exit_boot(handle, &fdt_addr,
-						efi_get_max_fdt_addr(dram_base),
+						efi_get_max_fdt_addr(image_addr),
 						initrd_addr, initrd_size,
 						cmdline_ptr, fdt_addr, fdt_size);
 	if (status != EFI_SUCCESS)
-- 
2.17.1


WARNING: multiple messages have this Message-ID (diff)
From: Ard Biesheuvel <ardb@kernel.org>
To: linux-efi@vger.kernel.org
Cc: Etienne CARRIERE <etienne.carriere@st.com>,
	Francois Ozog <francois.ozog@linaro.org>,
	Maxim Uvarov <maxim.uvarov@linaro.org>,
	Rouven Czerwinski <r.czerwinski@pengutronix.de>,
	Takahiro Akashi <takahiro.akashi@linaro.org>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Patrice CHOTARD <patrice.chotard@st.com>,
	Patrick DELAUNAY <patrick.delaunay@st.com>,
	Jens Wiklander <jens.wiklander@linaro.org>,
	Atish Patra <atish.patra@wdc.com>,
	Grant Likely <Grant.Likely@arm.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Christophe Priouzeau <christophe.priouzeau@linaro.org>,
	Ard Biesheuvel <ardb@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	Sumit Garg <sumit.garg@linaro.org>
Subject: [PATCH RFC/RFT 3/3] efi/libstub: base FDT and initrd placement on image address not DRAM base
Date: Wed,  9 Sep 2020 18:16:23 +0300	[thread overview]
Message-ID: <20200909151623.16153-4-ardb@kernel.org> (raw)
In-Reply-To: <20200909151623.16153-1-ardb@kernel.org>

The way we use the base of DRAM in the EFI stub is problematic as it
is ill defined what the base of DRAM actually means. There are some
restrictions on the placement of FDT and initrd which are defined in
terms of dram_base, but given that the placement of the kernel in
memory is what defines these boundaries, it is better to use the image
address in these cases, and disregard dram_base altogether.

In a future patch, we should be able to get rid of dram_base entirely,
but at the moment, RISC-V support is in flight in another tree, so we
keep it around for now.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 arch/arm/include/asm/efi.h              | 6 +++---
 arch/arm64/include/asm/efi.h            | 2 +-
 drivers/firmware/efi/libstub/efi-stub.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/include/asm/efi.h b/arch/arm/include/asm/efi.h
index 5dcf3c6011b7..9e481b362227 100644
--- a/arch/arm/include/asm/efi.h
+++ b/arch/arm/include/asm/efi.h
@@ -75,16 +75,16 @@ static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt)
 #define MIN_ZIMAGE_OFFSET	MAX_UNCOMP_KERNEL_SIZE
 
 /* on ARM, the FDT should be located in the first 128 MB of RAM */
-static inline unsigned long efi_get_max_fdt_addr(unsigned long dram_base)
+static inline unsigned long efi_get_max_fdt_addr(unsigned long image_addr)
 {
-	return dram_base + ZIMAGE_OFFSET_LIMIT;
+	return image_addr + ZIMAGE_OFFSET_LIMIT;
 }
 
 /* on ARM, the initrd should be loaded in a lowmem region */
 static inline unsigned long efi_get_max_initrd_addr(unsigned long dram_base,
 						    unsigned long image_addr)
 {
-	return dram_base + SZ_512M;
+	return image_addr + SZ_512M;
 }
 
 struct efi_arm_entry_state {
diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h
index d4ab3f73e7a3..27c2e8959ab6 100644
--- a/arch/arm64/include/asm/efi.h
+++ b/arch/arm64/include/asm/efi.h
@@ -65,7 +65,7 @@ efi_status_t __efi_rt_asm_wrapper(void *, const char *, ...);
 	(SEGMENT_ALIGN > THREAD_ALIGN ? SEGMENT_ALIGN : THREAD_ALIGN)
 
 /* on arm64, the FDT may be located anywhere in system RAM */
-static inline unsigned long efi_get_max_fdt_addr(unsigned long dram_base)
+static inline unsigned long efi_get_max_fdt_addr(unsigned long image_addr)
 {
 	return ULONG_MAX;
 }
diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
index a5a405d8ab44..76ce60065f10 100644
--- a/drivers/firmware/efi/libstub/efi-stub.c
+++ b/drivers/firmware/efi/libstub/efi-stub.c
@@ -306,7 +306,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
 	install_memreserve_table();
 
 	status = allocate_new_fdt_and_exit_boot(handle, &fdt_addr,
-						efi_get_max_fdt_addr(dram_base),
+						efi_get_max_fdt_addr(image_addr),
 						initrd_addr, initrd_size,
 						cmdline_ptr, fdt_addr, fdt_size);
 	if (status != EFI_SUCCESS)
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-09-09 17:19 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-09 15:16 [PATCH RFC/RFT 0/3] efi/libstub: arm32: Remove dependency on dram_base Ard Biesheuvel
2020-09-09 15:16 ` Ard Biesheuvel
2020-09-09 15:16 ` [PATCH RFC/RFT 1/3] efi/libstub: Export efi_low_alloc_above() to other units Ard Biesheuvel
2020-09-09 15:16   ` Ard Biesheuvel
2020-09-09 15:16 ` [PATCH RFC/RFT 2/3] efi/libstub: Use low allocation for the uncompressed kernel Ard Biesheuvel
2020-09-09 15:16   ` Ard Biesheuvel
2020-09-09 15:16 ` Ard Biesheuvel [this message]
2020-09-09 15:16   ` [PATCH RFC/RFT 3/3] efi/libstub: base FDT and initrd placement on image address not DRAM base Ard Biesheuvel
2020-09-09 15:25 ` [PATCH RFC/RFT 0/3] efi/libstub: arm32: Remove dependency on dram_base Grant Likely
2020-09-09 15:25   ` Grant Likely
2020-09-09 15:30   ` Ard Biesheuvel
2020-09-09 15:30     ` Ard Biesheuvel
2020-09-09 20:52 ` Palmer Dabbelt
2020-09-09 20:52   ` Palmer Dabbelt
2020-09-09 21:44   ` Atish Patra
2020-09-09 21:44     ` Atish Patra
2020-09-10  1:34     ` Atish Patra
2020-09-10  1:34       ` Atish Patra
2020-09-10 10:04       ` Ard Biesheuvel
2020-09-10 10:04         ` Ard Biesheuvel
2020-09-10 14:08         ` Ard Biesheuvel
2020-09-10 14:08           ` Ard Biesheuvel
2020-09-10 23:32           ` Atish Patra
2020-09-10 23:32             ` Atish Patra
2020-09-11  2:16           ` Palmer Dabbelt
2020-09-11  2:16             ` Palmer Dabbelt
2020-09-11  7:56             ` Ard Biesheuvel
2020-09-11  7:56               ` Ard Biesheuvel
2020-09-11 10:27               ` Maxim Uvarov
2020-09-11 10:27                 ` Maxim Uvarov
2020-09-11 18:45                 ` Ard Biesheuvel
2020-09-11 18:45                   ` Ard Biesheuvel
2020-09-16 15:43                   ` Maxim Uvarov
2020-09-16 15:43                     ` Maxim Uvarov
2020-09-16 15:58                     ` Ard Biesheuvel
2020-09-16 15:58                       ` Ard Biesheuvel
2020-09-16 16:02               ` Ard Biesheuvel
2020-09-16 16:02                 ` Ard Biesheuvel
2020-09-16 22:01                 ` Atish Patra
2020-09-16 22:01                   ` Atish Patra

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=20200909151623.16153-4-ardb@kernel.org \
    --to=ardb@kernel.org \
    --cc=Grant.Likely@arm.com \
    --cc=atish.patra@wdc.com \
    --cc=christophe.priouzeau@linaro.org \
    --cc=etienne.carriere@st.com \
    --cc=francois.ozog@linaro.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jens.wiklander@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=maxim.uvarov@linaro.org \
    --cc=palmer@dabbelt.com \
    --cc=patrice.chotard@st.com \
    --cc=patrick.delaunay@st.com \
    --cc=r.czerwinski@pengutronix.de \
    --cc=sumit.garg@linaro.org \
    --cc=takahiro.akashi@linaro.org \
    --cc=xypron.glpk@gmx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.