From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Mike Rapoport <rppt@kernel.org>
Cc: linux-mm@kvack.org
Subject: Re: [PATCH v2] mm: Fix memblock_free_late() when using deferred struct page
Date: Tue, 24 Feb 2026 16:56:11 +1100 [thread overview]
Message-ID: <4093878f7fc5ad08a91aef981165860276dc92fa.camel@kernel.crashing.org> (raw)
In-Reply-To: <aZgkrVWmcz_mcn6b@kernel.org>
On Fri, 2026-02-20 at 11:09 +0200, Mike Rapoport wrote:
>
>
> Subject: [PATCH] x86/efi: defer freeing of boot services memory
>
> ...
>
> Make efi_free_boot_services() collect ranges that should be freed into
^^^^^^^^^^^^^^^^^^^^^^^
Reword "split efi_free_boot_services() in two. First
efi_unmap_boot_services() collects ..... then efi_free_boot_services()
later frees them after deferred init is complete."
IE. Your commit message still has the old names :)
That's my only comment.
Reviewed-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Link: https://lore.kernel.org/all/ec2aaef14783869b3be6e3c253b2dcbf67dbc12a.camel@kernel.crashing.org
> Fixes: 916f676f8dc0 ("x86, efi: Retain boot service code until after switching to virtual mode")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> ---
> arch/x86/include/asm/efi.h | 2 +-
> arch/x86/platform/efi/efi.c | 2 +-
> arch/x86/platform/efi/quirks.c | 55 +++++++++++++++++++++++++++--
> drivers/firmware/efi/mokvar-table.c | 2 +-
> 4 files changed, 55 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
> index f227a70ac91f..51b4cdbea061 100644
> --- a/arch/x86/include/asm/efi.h
> +++ b/arch/x86/include/asm/efi.h
> @@ -138,7 +138,7 @@ extern void __init efi_apply_memmap_quirks(void);
> extern int __init efi_reuse_config(u64 tables, int nr_tables);
> extern void efi_delete_dummy_variable(void);
> extern void efi_crash_gracefully_on_page_fault(unsigned long phys_addr);
> -extern void efi_free_boot_services(void);
> +extern void efi_unmap_boot_services(void);
>
> void arch_efi_call_virt_setup(void);
> void arch_efi_call_virt_teardown(void);
> diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
> index 463b784499a8..791c52c8393f 100644
> --- a/arch/x86/platform/efi/efi.c
> +++ b/arch/x86/platform/efi/efi.c
> @@ -837,7 +837,7 @@ static void __init __efi_enter_virtual_mode(void)
> }
>
> efi_check_for_embedded_firmwares();
> - efi_free_boot_services();
> + efi_unmap_boot_services();
>
> if (!efi_is_mixed())
> efi_native_runtime_setup();
> diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
> index 553f330198f2..35caa5746115 100644
> --- a/arch/x86/platform/efi/quirks.c
> +++ b/arch/x86/platform/efi/quirks.c
> @@ -341,7 +341,7 @@ void __init efi_reserve_boot_services(void)
>
> /*
> * Because the following memblock_reserve() is paired
> - * with memblock_free_late() for this region in
> + * with free_reserved_area() for this region in
> * efi_free_boot_services(), we must be extremely
> * careful not to reserve, and subsequently free,
> * critical regions of memory (like the kernel image) or
> @@ -404,17 +404,33 @@ static void __init efi_unmap_pages(efi_memory_desc_t *md)
> pr_err("Failed to unmap VA mapping for 0x%llx\n", va);
> }
>
> -void __init efi_free_boot_services(void)
> +struct efi_freeable_range {
> + u64 start;
> + u64 end;
> +};
> +
> +static struct efi_freeable_range *ranges_to_free;
> +
> +void __init efi_unmap_boot_services(void)
> {
> struct efi_memory_map_data data = { 0 };
> efi_memory_desc_t *md;
> int num_entries = 0;
> + int idx = 0;
> + size_t sz;
> void *new, *new_md;
>
> /* Keep all regions for /sys/kernel/debug/efi */
> if (efi_enabled(EFI_DBG))
> return;
>
> + sz = sizeof(*ranges_to_free) * efi.memmap.nr_map + 1;
> + ranges_to_free = kzalloc(sz, GFP_KERNEL);
> + if (!ranges_to_free) {
> + pr_err("Failed to allocate storage for freeable EFI regions\n");
> + return;
> + }
> +
> for_each_efi_memory_desc(md) {
> unsigned long long start = md->phys_addr;
> unsigned long long size = md->num_pages << EFI_PAGE_SHIFT;
> @@ -471,7 +487,15 @@ void __init efi_free_boot_services(void)
next prev parent reply other threads:[~2026-02-24 5:56 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-03 8:02 [PATCH] " Benjamin Herrenschmidt
2026-02-03 18:40 ` Mike Rapoport
2026-02-03 19:53 ` Benjamin Herrenschmidt
2026-02-04 7:39 ` Mike Rapoport
2026-02-04 9:02 ` Benjamin Herrenschmidt
2026-02-06 10:33 ` Mike Rapoport
2026-02-10 1:04 ` Benjamin Herrenschmidt
2026-02-10 2:10 ` Benjamin Herrenschmidt
2026-02-10 6:17 ` Benjamin Herrenschmidt
2026-02-10 8:34 ` Benjamin Herrenschmidt
2026-02-10 14:32 ` Mike Rapoport
2026-02-10 23:23 ` Benjamin Herrenschmidt
2026-02-11 5:20 ` Mike Rapoport
2026-02-16 5:34 ` Benjamin Herrenschmidt
2026-02-16 6:51 ` Benjamin Herrenschmidt
2026-02-16 4:53 ` Benjamin Herrenschmidt
2026-02-16 15:28 ` Mike Rapoport
2026-02-16 10:36 ` Alexander Potapenko
2026-02-17 8:28 ` [PATCH v2] " Benjamin Herrenschmidt
2026-02-17 12:32 ` Mike Rapoport
2026-02-17 22:00 ` Benjamin Herrenschmidt
2026-02-17 21:47 ` Benjamin Herrenschmidt
2026-02-18 0:15 ` Benjamin Herrenschmidt
2026-02-18 8:05 ` Mike Rapoport
2026-02-19 2:48 ` Benjamin Herrenschmidt
2026-02-19 10:16 ` Mike Rapoport
2026-02-19 22:46 ` Benjamin Herrenschmidt
2026-02-20 4:57 ` Benjamin Herrenschmidt
2026-02-20 9:09 ` Mike Rapoport
2026-02-23 2:54 ` Benjamin Herrenschmidt
2026-02-24 5:56 ` Benjamin Herrenschmidt [this message]
2026-02-20 9:00 ` Mike Rapoport
2026-02-20 5:12 ` Benjamin Herrenschmidt
2026-02-20 5:15 ` Benjamin Herrenschmidt
2026-02-20 5:47 ` Benjamin Herrenschmidt
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=4093878f7fc5ad08a91aef981165860276dc92fa.camel@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--cc=linux-mm@kvack.org \
--cc=rppt@kernel.org \
/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