
From: Simon Glass <sjg@chromium.org> The app cannot know the address to use in advance, so does not have a value for kernel_addr_r in its environment, if it even has an environment. Allocate memory for the kernel instead. Limit it to 64MB which seems like plenty for the distros out there. It is enough to load a full kernel if needed. Signed-off-by: Simon Glass <sjg@chromium.org> --- boot/bootmeth_efi.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index 78fb84334e5..6903734c546 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -281,13 +281,34 @@ static int distro_efi_read_bootflow(struct udevice *dev, struct bootflow *bflow) static int distro_efi_boot(struct udevice *dev, struct bootflow *bflow) { + int size = SZ_1G; ulong kernel, fdt; int ret; log_debug("distro EFI boot\n"); - kernel = env_get_hex("kernel_addr_r", 0); + if (IS_ENABLED(CONFIG_EFI_APP)) { + struct efi_priv *priv = efi_get_priv(); + efi_status_t eret; + void *ptr; + + /* + * we don't expect the app to be larger than 64M and in fact, + * for Linux, it is typically only a few MB + */ + size = SZ_64M; + ptr = efi_malloc(priv, size, &eret); + if (!ptr) { + log_err("Out of memory for image (%x bytes): err=%lx\n", + size, eret); + return -ENOMEM; + } + kernel = map_to_sysmem(ptr); + } else { + kernel = env_get_hex("kernel_addr_r", 0); + } + if (!bootmeth_uses_network(bflow)) { - ret = efiload_read_file(bflow, kernel, SZ_1G); + ret = efiload_read_file(bflow, kernel, size); if (ret) return log_msg_ret("read", ret); -- 2.43.0