* [PATCH master 1/2] efi: loader: release bootm OS staging buffer
@ 2026-06-11 21:22 Ahmad Fatoum
2026-06-11 21:22 ` [PATCH master 2/2] efi: loader: bump memory map key on FreePages Ahmad Fatoum
2026-06-15 7:48 ` [PATCH master 1/2] efi: loader: release bootm OS staging buffer Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2026-06-11 21:22 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
The initial location of the OS image is currently kept reserved until
it's reclaimed after exiting boot services. This is unnecessary though
as the relevant parts of the PE are copied out anyway.
Therefore, free the original OS image to leave more space to the
decompresser.
Fixes: 229bc3b37e64 ("efi: loader: implement bootm handler")
Assisted-by: Codex:gpt-5.5
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
efi/loader/bootm.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/efi/loader/bootm.c b/efi/loader/bootm.c
index e1f1d508c59e..a68db742e173 100644
--- a/efi/loader/bootm.c
+++ b/efi/loader/bootm.c
@@ -267,6 +267,14 @@ static int efi_loader_bootm(struct image_data *data)
goto out;
}
+ /*
+ * efi_load_pe() copied the executable image into EFI-managed memory.
+ * The bootm staging buffer is no longer needed, and keeping it in the
+ * memory map can block payloads from using their normal load address.
+ */
+ release_sdram_region(data->os_res);
+ data->os_res = NULL;
+
efiret = efi_set_load_options(handle, load_option_size, load_option);
if (efiret)
goto out;
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH master 2/2] efi: loader: bump memory map key on FreePages
2026-06-11 21:22 [PATCH master 1/2] efi: loader: release bootm OS staging buffer Ahmad Fatoum
@ 2026-06-11 21:22 ` Ahmad Fatoum
2026-06-15 7:48 ` [PATCH master 1/2] efi: loader: release bootm OS staging buffer Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2026-06-11 21:22 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
efi_allocate_pages() increments the map key on every allocation, but
efi_free_pages() did not.
A payload that calls FreePages() before ExitBootServices() may thus
pass a stale memory map under a key that barebox still accepts.
Fix this by incrementing the key after a successful free.
Fixes: b880bfb8ed85 ("efi: loader: add memory accounting")
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
efi/loader/memory.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/efi/loader/memory.c b/efi/loader/memory.c
index e8dfd59ee8ca..8931cd1bab52 100644
--- a/efi/loader/memory.c
+++ b/efi/loader/memory.c
@@ -301,6 +301,8 @@ efi_status_t efi_free_pages(uint64_t memory, size_t pages)
if (nfreed <= 0)
return EFI_INVALID_PARAMETER;
+ ++efi_memory_map_key;
+
return EFI_SUCCESS;
}
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH master 1/2] efi: loader: release bootm OS staging buffer
2026-06-11 21:22 [PATCH master 1/2] efi: loader: release bootm OS staging buffer Ahmad Fatoum
2026-06-11 21:22 ` [PATCH master 2/2] efi: loader: bump memory map key on FreePages Ahmad Fatoum
@ 2026-06-15 7:48 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2026-06-15 7:48 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Thu, 11 Jun 2026 23:22:00 +0200, Ahmad Fatoum wrote:
> The initial location of the OS image is currently kept reserved until
> it's reclaimed after exiting boot services. This is unnecessary though
> as the relevant parts of the PE are copied out anyway.
>
> Therefore, free the original OS image to leave more space to the
> decompresser.
>
> [...]
Applied, thanks!
[1/2] efi: loader: release bootm OS staging buffer
https://git.pengutronix.de/cgit/barebox/commit/?id=a290d0f8bc7a (link may not be stable)
[2/2] efi: loader: bump memory map key on FreePages
https://git.pengutronix.de/cgit/barebox/commit/?id=cbe4bd04edec (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-15 7:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-11 21:22 [PATCH master 1/2] efi: loader: release bootm OS staging buffer Ahmad Fatoum
2026-06-11 21:22 ` [PATCH master 2/2] efi: loader: bump memory map key on FreePages Ahmad Fatoum
2026-06-15 7:48 ` [PATCH master 1/2] efi: loader: release bootm OS staging buffer Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox