From: Ard Biesheuvel <ardb@kernel.org>
To: linux-efi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org,
Ard Biesheuvel <ardb@kernel.org>,
Huacai Chen <chenhuacai@kernel.org>,
WANG Xuerui <kernel@xen0n.name>,
loongarch@lists.linux.dev
Subject: [PATCH 1/3] efi: Turn boot memmap handling into shared code
Date: Thu, 13 Aug 2026 09:45:08 +0200 [thread overview]
Message-ID: <20260813074506.643472-6-ardb@kernel.org> (raw)
In-Reply-To: <20260813074506.643472-5-ardb@kernel.org>
Move the handling of the boot memmap config table from loongarch
specific code to code that is shared between all architectures that
select EFI_GENERIC_STUB (all EFI archs except x86).
This will be used in a subsequent patch to replace the clunky FDT based
passing of the memmap parameters.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/loongarch/kernel/efi.c | 10 ++++------
drivers/firmware/efi/efi.c | 4 ++++
include/linux/efi.h | 3 +++
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/arch/loongarch/kernel/efi.c b/arch/loongarch/kernel/efi.c
index 69dd83f8082f..089378856bab 100644
--- a/arch/loongarch/kernel/efi.c
+++ b/arch/loongarch/kernel/efi.c
@@ -28,12 +28,10 @@
static unsigned long efi_nr_tables;
static unsigned long efi_config_table;
-static unsigned long __initdata boot_memmap = EFI_INVALID_TABLE_ADDR;
static unsigned long __initdata fdt_pointer = EFI_INVALID_TABLE_ADDR;
static efi_system_table_t *efi_systab;
static efi_config_table_type_t arch_tables[] __initdata = {
- {LINUX_EFI_BOOT_MEMMAP_GUID, &boot_memmap, "MEMMAP" },
{DEVICE_TREE_GUID, &fdt_pointer, "FDTPTR" },
{},
};
@@ -132,14 +130,14 @@ void __init efi_init(void)
if (IS_ENABLED(CONFIG_EFI_EARLYCON) || IS_ENABLED(CONFIG_SYSFB))
init_primary_display();
- if (boot_memmap == EFI_INVALID_TABLE_ADDR)
+ if (efi.boot_memmap == EFI_INVALID_TABLE_ADDR)
return;
- tbl = early_memremap_ro(boot_memmap, sizeof(*tbl));
+ tbl = early_memremap_ro(efi.boot_memmap, sizeof(*tbl));
if (tbl) {
struct efi_memory_map_data data;
- data.phys_map = boot_memmap + sizeof(*tbl);
+ data.phys_map = efi.boot_memmap + sizeof(*tbl);
data.size = tbl->map_size;
data.desc_size = tbl->desc_size;
data.desc_version = tbl->desc_ver;
@@ -156,7 +154,7 @@ void __init efi_init(void)
* Also, set the EFI_PRESERVE_BS_REGIONS flag to indicate that
* critical boot services code/data regions like this are preserved.
*/
- memblock_reserve((phys_addr_t)boot_memmap, sizeof(*tbl) + data.size);
+ memblock_reserve((phys_addr_t)efi.boot_memmap, sizeof(*tbl) + data.size);
set_bit(EFI_PRESERVE_BS_REGIONS, &efi.flags);
early_memunmap(tbl, sizeof(*tbl));
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 0327a39d31fa..d33760d6a527 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -55,6 +55,9 @@ struct efi __read_mostly efi = {
#ifdef CONFIG_UNACCEPTED_MEMORY
.unaccepted = EFI_INVALID_TABLE_ADDR,
#endif
+#ifdef CONFIG_EFI_GENERIC_STUB
+ .boot_memmap = EFI_INVALID_TABLE_ADDR,
+#endif
};
EXPORT_SYMBOL(efi);
@@ -647,6 +650,7 @@ static const efi_config_table_type_t common_tables[] __initconst = {
{LINUX_EFI_UNACCEPTED_MEM_TABLE_GUID, &efi.unaccepted, "Unaccepted" },
#endif
#ifdef CONFIG_EFI_GENERIC_STUB
+ {LINUX_EFI_BOOT_MEMMAP_GUID, &efi.boot_memmap, "MEMMAP" },
{LINUX_EFI_PRIMARY_DISPLAY_TABLE_GUID, &primary_display_table },
#endif
{},
diff --git a/include/linux/efi.h b/include/linux/efi.h
index aa15ff88539b..bc1cd005ca0f 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -650,6 +650,9 @@ extern struct efi {
unsigned long mokvar_table; /* MOK variable config table */
unsigned long coco_secret; /* Confidential computing secret table */
unsigned long unaccepted; /* Unaccepted memory table */
+#ifdef CONFIG_EFI_GENERIC_STUB
+ unsigned long boot_memmap; /* The EFI memory map captured by the stub */
+#endif
efi_get_time_t *get_time;
efi_set_time_t *set_time;
--
2.47.3
next prev parent reply other threads:[~2026-08-13 7:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 7:45 [PATCH 0/3] efi: Simply DT handoff from stub to kernel Ard Biesheuvel
2026-08-13 7:45 ` Ard Biesheuvel [this message]
2026-08-13 8:24 ` [PATCH 1/3] efi: Turn boot memmap handling into shared code Richard Lyu
2026-08-13 7:45 ` [PATCH 2/3] efi: Pass EFI boot memmap struct address to core kernel Ard Biesheuvel
2026-08-13 8:25 ` Richard Lyu
2026-08-13 7:45 ` [PATCH 3/3] efi: Make the 'linux,uefi-boot-memmap' DT property optional Ard Biesheuvel
2026-08-13 8:25 ` Richard Lyu
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=20260813074506.643472-6-ardb@kernel.org \
--to=ardb@kernel.org \
--cc=chenhuacai@kernel.org \
--cc=kernel@xen0n.name \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-efi@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
/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