From: chalianis1@gmail.com
To: s.hauer@pengutronix.de, a.fatoum@barebox.org
Cc: barebox@lists.infradead.org, Chali Anis <chalianis1@gmail.com>
Subject: [PATCH v3 09/11] efi: payload: early-mem: helps to correctly boot x86 linux.
Date: Tue, 16 Sep 2025 00:01:53 -0400 [thread overview]
Message-ID: <20250916040155.814159-9-chalianis1@gmail.com> (raw)
In-Reply-To: <20250916040155.814159-1-chalianis1@gmail.com>
From: Chali Anis <chalianis1@gmail.com>
remove the allocate EFI_ALLOCATE_MAX_ADDRESSES and use a different
memsize for x86 since the initrd could be bigger that those used in
arm. it might be refactored in the future with a more generic allocation
strategy (i.e barebox malloc memory vs an allocator for the boot loader data)
something like sdram_request_region or just allocate small memory for the
barebox allocator and implement a way to allocate memory for kernel/initrd
directly from efi.
Signed-off-by: Chali Anis <chalianis1@gmail.com>
---
efi/payload/early-mem.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/efi/payload/early-mem.c b/efi/payload/early-mem.c
index 0f79a8c30694..150a2a595afc 100644
--- a/efi/payload/early-mem.c
+++ b/efi/payload/early-mem.c
@@ -9,18 +9,17 @@ void *efi_earlymem_alloc(const struct efi_system_table *sys_table,
size_t *memsize, enum efi_memory_type mem_type)
{
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;
+ size_t m_sz;
- if (IS_ENABLED(CONFIG_X86)) {
- /* Try to stay clear of memory mapped devices */
- alloc_type = EFI_ALLOCATE_MAX_ADDRESS;
- mem = SZ_1G - 1;
- }
+ if (IS_ENABLED(CONFIG_X86))
+ m_sz = SZ_512M;
+ else
+ m_sz = SZ_256M;
- for (*memsize = SZ_256M; *memsize >= SZ_8M; *memsize /= 2) {
- efiret = bs->allocate_pages(alloc_type, mem_type,
+ for (*memsize = m_sz; *memsize >= SZ_8M; *memsize /= 2) {
+ efiret = bs->allocate_pages(EFI_ALLOCATE_ANY_PAGES, mem_type,
*memsize / EFI_PAGE_SIZE, &mem);
if (!EFI_ERROR(efiret) || efiret != EFI_OUT_OF_RESOURCES)
break;
--
2.34.1
next prev parent reply other threads:[~2025-09-16 4:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-16 4:01 [PATCH v3 01/11] ARM: cpu: allow selecting CPU_V7/CPU_V8 directly chalianis1
2025-09-16 4:01 ` [PATCH v3 02/11] efi: payload: split image handling from legacy handover boot support chalianis1
2025-09-16 4:01 ` [PATCH v3 03/11] efi: payload: add support for efi stub boot chalianis1
2025-09-16 4:01 ` [PATCH v3 04/11] efi: payload: add support for fit image chalianis1
2025-09-16 4:01 ` [PATCH v3 05/11] efi: payload: make selectable without COMPILE_TEST chalianis1
2025-09-16 4:01 ` [PATCH v3 06/11] arm: efi: add a generic defconfig for v8 efi payload, chalianis1
2025-09-16 4:01 ` [PATCH v3 07/11] efi: payload: initrd: implement efi initrd media protocol chalianis1
2025-09-16 4:01 ` [PATCH v3 08/11] common: filetype: add x86 linux filetype chalianis1
2025-09-16 4:01 ` chalianis1 [this message]
2025-09-16 4:01 ` [PATCH v3 10/11] efi: payload: bootm: add x86 efi stub boot support chalianis1
2025-09-16 4:01 ` [PATCH v3 11/11] lib: fdt: remove FDT_PADDING chalianis1
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250916040155.814159-9-chalianis1@gmail.com \
--to=chalianis1@gmail.com \
--cc=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox