[Concept,v2,13/22] efi: app: Allocate pages in any region

Message ID 20250819185900.835939-14-sjg@u-boot.org
State New
Headers
Series efi: Improvements for the EFI app on ARM |

Commit Message

Simon Glass Aug. 19, 2025, 6:58 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

Rather than immediately falling back to the pool allocator when we
cannot get enough memory below 4GB, try the page allocator first. This
provides 4K-aligned memory, which is nicer to look at when debugging.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 lib/efi_client/efi_app.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Patch

diff --git a/lib/efi_client/efi_app.c b/lib/efi_client/efi_app.c
index 764e562692e..92aee94a695 100644
--- a/lib/efi_client/efi_app.c
+++ b/lib/efi_client/efi_app.c
@@ -112,6 +112,11 @@  static efi_status_t setup_memory(struct efi_priv *priv)
 	addr = 1ULL << 32;
 	ret = boot->allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
 				   priv->image_data_type, pages, &addr);
+	if (ret) {
+		log_info("(any address) ");
+		ret = boot->allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+					   priv->image_data_type, pages, &addr);
+	}
 	if (ret) {
 		log_info("(using pool %lx) ", ret);
 		priv->ram_base = (ulong)efi_malloc(priv, CONFIG_EFI_RAM_SIZE,
@@ -123,6 +128,7 @@  static efi_status_t setup_memory(struct efi_priv *priv)
 		log_info("(using allocated RAM address %lx) ", (ulong)addr);
 		priv->ram_base = addr;
 	}
+	gd->ram_base = addr;
 	gd->ram_size = pages << 12;
 
 	return 0;