[PATCH 05/15] efi: payload: early-mem: EFI_ALLOCATE_ANY_PAGES on non-x86
Ahmad Fatoum
a.fatoum at barebox.org
Tue May 27 14:22:50 PDT 2025
From: Ahmad Fatoum <a.fatoum at pengutronix.de>
Using EFI_ALLOCATE_MAX_ADDRESS with an address of ~0 means that the EFI
implementation is free to give us any region it sees fit, so let's use
EFI_ALLOCATE_ANY_PAGES explicitly instead to make this clearer.
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
efi/payload/early-mem.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/efi/payload/early-mem.c b/efi/payload/early-mem.c
index b4e8790a39c4..52052f7ed128 100644
--- a/efi/payload/early-mem.c
+++ b/efi/payload/early-mem.c
@@ -9,13 +9,18 @@ efi_physical_addr_t efi_earlymem_alloc(const struct efi_system_table *sys_table,
size_t *memsize)
{
struct efi_boot_services *bs = sys_table->boottime;
+ enum efi_allocate_type alloc_type = EFI_ALLOCATE_ANY_PAGES;
efi_physical_addr_t mem;
efi_status_t efiret;
- mem = IS_ENABLED(CONFIG_X86) ? 0x3fffffff : ~0ULL;
+ if (IS_ENABLED(CONFIG_X86)) {
+ /* Try to stay clear of memory mapped devices */
+ alloc_type = EFI_ALLOCATE_MAX_ADDRESS;
+ mem = SZ_1G - 1;
+ }
+
for (*memsize = SZ_256M; *memsize >= SZ_8M; *memsize /= 2) {
- efiret = bs->allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
- EFI_LOADER_DATA,
+ efiret = bs->allocate_pages(alloc_type, EFI_LOADER_DATA,
*memsize / EFI_PAGE_SIZE, &mem);
if (!EFI_ERROR(efiret) || efiret != EFI_OUT_OF_RESOURCES)
break;
--
2.39.5
More information about the barebox
mailing list