Re: [PATCH 1/3] efi: Turn boot memmap handling into shared code
Richard Lyu <[email protected]>
| Newsgroups | dev.linux.lists.loongarch,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-efi |
|---|---|
| Message-ID | <an1_K40ZWobCkCky@r1chard> |
On 2026/08/13 09:45, Ard Biesheuvel wrote: >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 <[email protected]> >--- > 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 > > Reviewed-by: Richard Lyu <[email protected]>