[U-Boot] [PATCH] efi_loader: don't allocate unusable RAM

Heinrich Schuchardt xypron.glpk at gmx.de
Wed Aug 1 06:07:07 UTC 2018


On 07/31/2018 09:44 PM, Stephen Warren wrote:
> From: Stephen Warren <swarren at nvidia.com>
> 
> Some boards define a maximum usable RAM top that's more restrictive than
> the ranges defined by U-Boot's memory bank definitions[1]. In this case,
> the unusable RAM isn't mapped in the page tables, and so the EFI code must
> not attempt to allocate RAM from outside the usable regions. Fix
> efi_find_free_memory() to detect when max_addr is unconstrained or out of
> range, and substitue a valid value.
> 

In this case the board has to call efi_add_memory_map() to mark the
reserved region (cf. board/raspberrypi/rpi/rpi.c) or have to mark the
memory region as reserved in the device tree (see efi_carve_out_dt_rsv()).

Please, check if the tegra boards with which you had problems do so.

Best regards

Heinrich

> [1] For example, when some peripherals can't access RAM above 4GiB, it's
> simplest to force U-Boot's ram_top to a smaller value to avoid dealing
> with this issue more explicitly. However, the RAM bank definitions still
> describe the unusable RAM so that the booted OS has access to it, since
> the OS can typically deal with such restrictions in a more complex
> manner.
> 
> Fixes: aa909462d018 "efi_loader: efi_allocate_pages is too restrictive"
> Cc: Heinrich Schuchardt <xypron.glpk at gmx.de>
> Cc: Alexander Graf <agraf at suse.de>
> Signed-off-by: Stephen Warren <swarren at nvidia.com>
> ---
>  lib/efi_loader/efi_memory.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
> index 967c3f733e4c..5064ff2ccbe8 100644
> --- a/lib/efi_loader/efi_memory.c
> +++ b/lib/efi_loader/efi_memory.c
> @@ -251,6 +251,9 @@ static uint64_t efi_find_free_memory(uint64_t len, uint64_t max_addr)
>  {
>  	struct list_head *lhandle;
>  
> +	if ((max_addr == -1ULL) || (max_addr > gd->ram_top))
> +		max_addr = gd->ram_top;
> +
>  	list_for_each(lhandle, &efi_mem) {
>  		struct efi_mem_list *lmem = list_entry(lhandle,
>  			struct efi_mem_list, link);
> 



More information about the U-Boot mailing list