efi/x86: Move runtime map sysfs code into arch/x86
Ard Biesheuvel
maintainercover efi/x86: Move runtime map sysfs code into arch/x86
The EFI runtime map code is only used on x86, so let's move it out of the generic code and into arch/x86. While at it, clarify the Kconfig description so that it gets enabled automatically when required (i.e., when kexec is enabled), and can only be disabled when CONFIG_EXPERT=y
Ard Biesheuvel (2):
efi: runtime-maps: Clarify purpose and enable by default for kexec
efi: x86: Move EFI runtime map sysfs code to arch/x86
arch/x86/Kconfig | 11 ++++++++
arch/x86/include/asm/efi.h | 22 +++++++++++++++
arch/x86/platform/efi/Makefile | 1 +
{drivers/firmware => arch/x86/platform}/efi/runtime-map.c | 6 ++---
drivers/firmware/efi/Kconfig | 11 --------
drivers/firmware/efi/Makefile | 1 -
drivers/firmware/efi/efi.c | 5 +---
include/linux/efi.h | 28 --------------------
8 files changed, 38 insertions(+), 47 deletions(-)
rename {drivers/firmware => arch/x86/platform}/efi/runtime-map.c (97%)Signature · 1 line
2.35.1
Ard Biesheuvel
maintainerPATCH 1/2 efi: runtime-maps: Clarify purpose and enable by default for kexec
The current Kconfig logic for CONFIG_EFI_RUNTIME_MAPS does not convey that without it, a kexec kernel is not able to boot in EFI mode at all. So clarify this, and make the option only configurable via the menu system if CONFIG_EXPERT is set.
--- drivers/firmware/efi/Kconfig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/firmware/efi/Kconfig +6 -6
@@ -27,13 +27,13 @@ config EFI_VARS_PSTORE_DEFAULT_DISABLE using the efivars module's pstore_disable parameter. config EFI_RUNTIME_MAP - bool "Export efi runtime maps to sysfs" - depends on X86 && EFI && KEXEC_CORE - default y + bool "Export EFI runtime maps to sysfs" if EXPERT + depends on X86 && EFI + default KEXEC_CORE help - Export efi runtime memory maps to /sys/firmware/efi/runtime-map. - That memory map is used for example by kexec to set up efi virtual - mapping the 2nd kernel, but can also be used for debugging purposes. + Export EFI runtime memory regions to /sys/firmware/efi/runtime-map. + That memory map is required by the 2nd kernel to set up EFI virtual + mappings after kexec, but can also be used for debugging purposes. See also Documentation/ABI/testing/sysfs-firmware-efi-runtime-map.
Signature · 1 line
2.35.1
Ard Biesheuvel
maintainerPATCH 2/2 efi: x86: Move EFI runtime map sysfs code to arch/x86
In reply to Ard BiesheuvelThe EFI runtime map code is only wired up on x86, which is the only architecture that has a need for it in its implementation of kexec.
So let's move this code under arch/x86 and drop all references to it from generic code. To ensure that the efi_runtime_map_init() is invoked at the appropriate time use a 'sync' subsys_initcall() that will be called right after the EFI initcall made from generic code where the original invocation of efi_runtime_map_init() resided.
---
arch/x86/Kconfig | 11 ++++++++
arch/x86/include/asm/efi.h | 22 +++++++++++++++
arch/x86/platform/efi/Makefile | 1 +
{drivers/firmware => arch/x86/platform}/efi/runtime-map.c | 6 ++---
drivers/firmware/efi/Kconfig | 11 --------
drivers/firmware/efi/Makefile | 1 -
drivers/firmware/efi/efi.c | 5 +---
include/linux/efi.h | 28 --------------------
8 files changed, 38 insertions(+), 47 deletions(-)arch/x86/Kconfig +11 -0
@@ -2015,6 +2015,17 @@ config EFI_MAX_FAKE_MEM Ranges can be set up to this value using comma-separated list. The default value is 8. +config EFI_RUNTIME_MAP + bool "Export EFI runtime maps to sysfs" if EXPERT + depends on EFI + default KEXEC_CORE + help + Export EFI runtime memory regions to /sys/firmware/efi/runtime-map. + That memory map is required by the 2nd kernel to set up EFI virtual + mappings after kexec, but can also be used for debugging purposes. + + See also Documentation/ABI/testing/sysfs-firmware-efi-runtime-map. + source "kernel/Kconfig.hz" config KEXEC
arch/x86/include/asm/efi.h +22 -0
@@ -431,4 +431,26 @@ extern void __init efi_memmap_insert(struct efi_memory_map *old_memmap,#define arch_ima_efi_boot_mode \ ({ extern struct boot_params boot_params; boot_params.secure_boot; }) +#ifdef CONFIG_EFI_RUNTIME_MAP +int efi_get_runtime_map_size (void ); +int efi_get_runtime_map_desc_size (void ); +int efi_runtime_map_copy (void *buf,size_t bufsz); +#else +static inline int efi_get_runtime_map_size (void ) +{ +return 0 ; +} + +static inline int efi_get_runtime_map_desc_size (void ) +{ +return 0 ; +} + +static inline int efi_runtime_map_copy (void *buf,size_t bufsz) +{ +return 0 ; +} + +#endif +#endif /* _ASM_X86_EFI_H */
arch/x86/platform/efi/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-$(CONFIG_EFI) += memmap.o quirks.o efi.o efi_$(BITS).o \ efi_stub_$(BITS).o obj-$(CONFIG_EFI_MIXED) += efi_thunk_$(BITS).o obj-$(CONFIG_EFI_FAKE_MEMMAP) += fake_mem.o +obj-$(CONFIG_EFI_RUNTIME_MAP) += runtime-map.o
arch/x86/platform/efi/runtime-map.c renamed from drivers/firmware/efi/runtime-map.c +3 -3
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 /* -* linux/drivers/efi/runtime-map.c * Copyright (C) 2013 Red Hat, Inc., Dave Young <[email protected]> */
@@ -157,13 +156,13 @@ int efi_runtime_map_copy(void *buf, size_t bufsz)return 0 ; } -int __init efi_runtime_map_init (struct kobject *efi_kobj) +static int __init efi_runtime_map_init (void ) {int i, j, ret =0 ;struct efi_runtime_map_entry *entry;efi_memory_desc_t *md; -if (!efi_enabled (EFI_MEMMAP )) +if (!efi_enabled (EFI_MEMMAP ) || !efi_kobj)return 0 ; map_entries =kcalloc (efi.memmap.nr_map,sizeof (entry),GFP_KERNEL );
@@ -191,3 +190,4 @@ int __init efi_runtime_map_init(struct kobject *efi_kobj) out:return ret; } +subsys_initcall_sync (efi_runtime_map_init);
drivers/firmware/efi/Kconfig +0 -11
@@ -26,17 +26,6 @@ config EFI_VARS_PSTORE_DEFAULT_DISABLE backend for pstore by default. This setting can be overridden using the efivars module's pstore_disable parameter. -config EFI_RUNTIME_MAP - bool "Export EFI runtime maps to sysfs" if EXPERT - depends on X86 && EFI - default KEXEC_CORE - help - Export EFI runtime memory regions to /sys/firmware/efi/runtime-map. - That memory map is required by the 2nd kernel to set up EFI virtual - mappings after kexec, but can also be used for debugging purposes. - - See also Documentation/ABI/testing/sysfs-firmware-efi-runtime-map. - config EFI_SOFT_RESERVE bool "Reserve EFI Specific Purpose Memory" depends on EFI && EFI_STUB && ACPI_HMAT
drivers/firmware/efi/Makefile +0 -1
@@ -20,7 +20,6 @@ obj-$(CONFIG_EFI_PARAMS_FROM_FDT) += fdtparams.o obj-$(CONFIG_EFI_ESRT) += esrt.o obj-$(CONFIG_EFI_VARS_PSTORE) += efi-pstore.o obj-$(CONFIG_UEFI_CPER) += cper.o -obj-$(CONFIG_EFI_RUNTIME_MAP) += runtime-map.o obj-$(CONFIG_EFI_RUNTIME_WRAPPERS) += runtime-wrappers.o subdir-$(CONFIG_EFI_STUB) += libstub obj-$(CONFIG_EFI_BOOTLOADER_CONTROL) += efibc.o
drivers/firmware/efi/efi.c +1 -4
@@ -394,10 +394,6 @@ static int __init efisubsys_init(void) goto err_unregister; } - error =efi_runtime_map_init (efi_kobj); -if (error) - goto err_remove_group; -/* and the standard mountpoint for efivarfs */ error =sysfs_create_mount_point (efi_kobj,"efivars" );if (error) {
@@ -423,6 +419,7 @@ static int __init efisubsys_init(void)generic_ops_unregister (); err_put:kobject_put (efi_kobj); + efi_kobj =NULL ;destroy_workqueue (efi_rts_wq);return error; }
include/linux/efi.h +0 -28
@@ -1091,34 +1091,6 @@ extern int efi_capsule_update(efi_capsule_header_t *capsule,static inline bool efi_capsule_pending (int *reset_type) {return false; }#endif -#ifdef CONFIG_EFI_RUNTIME_MAP -int efi_runtime_map_init (struct kobject *); -int efi_get_runtime_map_size (void ); -int efi_get_runtime_map_desc_size (void ); -int efi_runtime_map_copy (void *buf,size_t bufsz); -#else -static inline int efi_runtime_map_init (struct kobject *kobj) -{ -return 0 ; -} - -static inline int efi_get_runtime_map_size (void ) -{ -return 0 ; -} - -static inline int efi_get_runtime_map_desc_size (void ) -{ -return 0 ; -} - -static inline int efi_runtime_map_copy (void *buf,size_t bufsz) -{ -return 0 ; -} - -#endif -#ifdef CONFIG_EFI extern bool efi_runtime_disabled (void );#else
Signature · 1 line
2.35.1
Hi Ard,
Quoted 9 lines · Ard Biesheuvel
The EFI runtime map code is only used on x86, so let's move it out of the generic code and into
arch/x86. While at it, clarify theKconfigdescription so that it gets enabled automatically when required (i.e., when kexec is enabled), and can only be disabled whenCONFIG_EXPERT=yArd Biesheuvel (2):
efi: runtime-maps: Clarify purpose and enable by default for kexec
efi: x86: Move EFI runtime map sysfs code toarch/x86
For the series:
Quoted 15 lines
arch/x86/Kconfig | 11 ++++++++ arch/x86/include/asm/efi.h | 22 +++++++++++++++ arch/x86/platform/efi/Makefile | 1 + {drivers/firmware => arch/x86/platform}/efi/runtime-map.c | 6 ++--- drivers/firmware/efi/Kconfig | 11 -------- drivers/firmware/efi/Makefile | 1 - drivers/firmware/efi/efi.c | 5 +--- include/linux/efi.h | 28 -------------------- 8 files changed, 38 insertions(+), 47 deletions(-) rename {drivers/firmware => arch/x86/platform}/efi/runtime-map.c (97%)--
2.35.1
Ard Biesheuvel
maintainerQuoted 10 lines · Dave Young
Hi Ard,
Quoted 6 lines · Ard Biesheuvel
The EFI runtime map code is only used on x86, so let's move it out of the generic code and into
arch/x86. While at it, clarify theKconfigdescription so that it gets enabled automatically when required (i.e., when kexec is enabled), and can only be disabled whenCONFIG_EXPERT=y
Quoted 8 lines
Quoted 3 lines
Ard Biesheuvel (2):
efi: runtime-maps: Clarify purpose and enable by default for kexec
efi: x86: Move EFI runtime map sysfs code toarch/x86For the series:
Reviewed-by Dave Young <[email protected]>
Thanks Dave, I've queued these up now.
Quoted 16 lines
Quoted 15 lines
arch/x86/Kconfig | 11 ++++++++ arch/x86/include/asm/efi.h | 22 +++++++++++++++ arch/x86/platform/efi/Makefile | 1 + {drivers/firmware => arch/x86/platform}/efi/runtime-map.c | 6 ++--- drivers/firmware/efi/Kconfig | 11 -------- drivers/firmware/efi/Makefile | 1 - drivers/firmware/efi/efi.c | 5 +--- include/linux/efi.h | 28 -------------------- 8 files changed, 38 insertions(+), 47 deletions(-) rename {drivers/firmware => arch/x86/platform}/efi/runtime-map.c (97%)--
2.35.1