diff mbox

[U-Boot] efi_loader: Reserve 2 additional pages for fdt

Message ID 1457083150-160370-1-git-send-email-agraf@suse.de
State Superseded
Delegated to: Tom Rini
Headers show

Commit Message

Alexander Graf March 4, 2016, 9:19 a.m. UTC
We mark the device tree as reserved today, spanning exactly the amount
of space it needs. If some other piece of code (like grub2) comes in and
wants to modify the device tree to for example add a kernel command line
though, it might assume that it has some space to do so.

So let's just reserve 2 additional pages for the device tree to play nicely.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 cmd/bootefi.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Leif Lindholm March 4, 2016, 9:41 a.m. UTC | #1
On Fri, Mar 04, 2016 at 10:19:10AM +0100, Alexander Graf wrote:
> We mark the device tree as reserved today, spanning exactly the amount
> of space it needs. If some other piece of code (like grub2) comes in and
> wants to modify the device tree to for example add a kernel command line
> though, it might assume that it has some space to do so.
> 
> So let's just reserve 2 additional pages for the device tree to play nicely.

I presume this was triggered by something you found on AArch32 grub,
booting a kernel without EFI stub?
If so, the issue will go away once I fix the AArch32 grub to use the
AArch64 loader for kernel images with the EFI stub. Could you possibly
send an email to grub-devel, or raise a ticket directly on the
savannah bugtracker if you have an account?
This fix really should go into 2.02 release.

Regardless, this seems like it provides a potential optimisation
opportunity for such agents, to use the tree in place instead of
always allocating more memory.

> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  cmd/bootefi.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> index de17e49..faa6978 100644
> --- a/cmd/bootefi.c
> +++ b/cmd/bootefi.c
> @@ -119,6 +119,8 @@ static unsigned long do_bootefi_exec(void *efi)
>  		fdt_end = ((ulong)working_fdt) + fdt_totalsize(working_fdt);
>  		fdt_size = (fdt_end - fdt_start) + EFI_PAGE_MASK;
>  		fdt_pages = fdt_size >> EFI_PAGE_SHIFT;
> +		/* Give a bootloader the chance to modify the device tree */
> +		fdt_pages += 2;
>  		efi_add_memory_map(fdt_start, fdt_pages,
>  				   EFI_BOOT_SERVICES_DATA, true);
>  
> -- 
> 1.8.5.6
>
diff mbox

Patch

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index de17e49..faa6978 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -119,6 +119,8 @@  static unsigned long do_bootefi_exec(void *efi)
 		fdt_end = ((ulong)working_fdt) + fdt_totalsize(working_fdt);
 		fdt_size = (fdt_end - fdt_start) + EFI_PAGE_MASK;
 		fdt_pages = fdt_size >> EFI_PAGE_SHIFT;
+		/* Give a bootloader the chance to modify the device tree */
+		fdt_pages += 2;
 		efi_add_memory_map(fdt_start, fdt_pages,
 				   EFI_BOOT_SERVICES_DATA, true);