[U-Boot] [PATCH 1/1] efi_loader: fix memory allocation on sandbox
Simon Glass
sjg at chromium.org
Tue Jan 8 00:38:24 UTC 2019
On Sat, 5 Jan 2019 at 15:41, Heinrich Schuchardt <xypron.glpk at gmx.de> wrote:
>
> Commit 7b78d6438a2b ("efi_loader: Reserve unaccessible memory") introduced
> a comparison between RAM top and RAM start that was not known at the time
> when the patch of commit 49759743bf09 ("efi_loader: eliminate sandbox
> addresses") was written.
>
> The sandbox uses an address space that is only relevant in the sandbox
> context. We have to map ram_top from the sandbox address space to the
> physical address space before using it in the EFI subsystem.
>
> Fixes: 49759743bf09 ("efi_loader: eliminate sandbox addresses")
> Fixes: 7b78d6438a2b ("efi_loader: Reserve unaccessible memory")
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> ---
> Travis CI showed no error:
> https://travis-ci.org/xypron2/u-boot/builds/475766261
> ---
> lib/efi_loader/efi_memory.c | 6 ++++++
> 1 file changed, 6 insertions(+)
Reviewed-by: Simon Glass <sjg at chromium.org>
I'm not a big fan of using a u64 to store a pointer. By using ulong
for addresses and void * for pointers, we can make bugs like this
easier to spot.
>
> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
> index 4bb517473e..0ae49f5d5f 100644
> --- a/lib/efi_loader/efi_memory.c
> +++ b/lib/efi_loader/efi_memory.c
> @@ -554,6 +554,12 @@ __weak void efi_add_known_memory(void)
> u64 ram_top = board_get_usable_ram_top(0) & ~EFI_PAGE_MASK;
> int i;
>
> + /*
> + * ram_top is just outside mapped memory. So use an offset of one for
> + * mapping the sandbox address.
> + */
> + ram_top = (uintptr_t)map_sysmem(ram_top - 1, 0) + 1;
> +
> /* Fix for 32bit targets with ram_top at 4G */
> if (!ram_top)
> ram_top = 0x100000000ULL;
> --
> 2.20.1
>
More information about the U-Boot
mailing list