Skip to contentSkip to conversation

efi/x86: Ensure that EFI_RUNTIME_MAP is enabled for kexec

PATCH Superseded Ard Biesheuvel 2 participants 3 messages Aug 2, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ard Biesheuvel

author maintainer
#0 lore raw

PATCH 1/1 efi/x86: Ensure that EFI_RUNTIME_MAP is enabled for kexec

CONFIG_EFI_RUNTIME_MAP needs to be enabled in order for kexec to be able to provide the required information about the EFI runtime mappings to the incoming kernel, regardless of whether kexec_load() or kexec_file_load() is being used. Without this information, kexec boot in EFI mode is not possible.

The CONFIG_EFI_RUNTIME_MAP option is currently directly configurable if CONFIG_EXPERT is enabled, so that it can be turned on for debugging purposes even if KEXEC is. However, the upshot of this is that it can also be disabled even when it shouldn't.

So tweak the Kconfig declarations to avoid this situation.

---
 arch/x86/Kconfig | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/x86/Kconfig +5 -1
index 7422db4097701c96..616498cdc91e8f01 100644
@@ -2027,10 +2027,14 @@ config EFI_MAX_FAKE_MEM
 	  Ranges can be set up to this value using comma-separated list.
 	  The default value is 8.
 
+config EFI_NEED_RUNTIME_MAP
+	def_bool y
+	depends on EFI && KEXEC_CORE
+	select EFI_RUNTIME_MAP
+
 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
Signature · 1 line
2.39.2
Tested-by on v1 1/1
#1 lore raw
Quoted 11 lines · Ard Biesheuvel

CONFIG_EFI_RUNTIME_MAP needs to be enabled in order for kexec to be able to provide the required information about the EFI runtime mappings to the incoming kernel, regardless of whether kexec_load() or kexec_file_load() is being used. Without this information, kexec boot in EFI mode is not possible.

The CONFIG_EFI_RUNTIME_MAP option is currently directly configurable if CONFIG_EXPERT is enabled, so that it can be turned on for debugging purposes even if KEXEC is. However, the upshot of this is that it can also be disabled even when it shouldn't.

Quoted 4 lines

So tweak the Kconfig declarations to avoid this situation.

With the patch 'make oldconfig' updates config to enable EFI_NEED_RUNTIME_MAP.

Thanks.

Quoted 9 lines
---
 arch/x86/Kconfig | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/x86/Kconfig +0 -0
index 7422db4097701c96..616498cdc91e8f01 100644

arch/x86/Kconfig config EFI_MAX_FAKE_MEM · line 2034

Quoted 8 lines
arch/x86/Kconfig +5 -0
@@ -2027,10 +2027,14 @@ config EFI_MAX_FAKE_MEM
 	  Ranges can be set up to this value using comma-separated list.
 	  The default value is 8.
 
+config EFI_NEED_RUNTIME_MAP
+	def_bool y
+	depends on EFI && KEXEC_CORE
+	select EFI_RUNTIME_MAP
+

Just curious, why not extend 'config EFI' with 'select EFI_RUNTIME_MAP if KEXEC_CORE'? It seems functionally equivalent, but more concise.

Quoted 10 lines
arch/x86/Kconfig +0 -1
 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
Signature · 1 line
2.39.2
Signature · 1 line
  Kiryl Shutsemau / Kirill A. Shutemov
author maintainer
#2 lore raw
Quoted 36 lines · Kirill A . Shutemov
Quoted 11 lines · Ard Biesheuvel

CONFIG_EFI_RUNTIME_MAP needs to be enabled in order for kexec to be able to provide the required information about the EFI runtime mappings to the incoming kernel, regardless of whether kexec_load() or kexec_file_load() is being used. Without this information, kexec boot in EFI mode is not possible.

The CONFIG_EFI_RUNTIME_MAP option is currently directly configurable if CONFIG_EXPERT is enabled, so that it can be turned on for debugging purposes even if KEXEC is. However, the upshot of this is that it can also be disabled even when it shouldn't.

Quoted 4 lines

So tweak the Kconfig declarations to avoid this situation.

With the patch 'make oldconfig' updates config to enable EFI_NEED_RUNTIME_MAP.

Thanks.

Quoted 12 lines
---
 arch/x86/Kconfig | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/x86/Kconfig +0 -0
index 7422db4097701c96..616498cdc91e8f01 100644
@@ -2027,10 +2027,14 @@ config EFI_MAX_FAKE_MEM
        Ranges can be set up to this value using comma-separated list.
        The default value is 8.
 
Quoted 9 lines

arch/x86/Kconfig config EFI_MAX_FAKE_MEM · line 2034

Quoted 5 lines
arch/x86/Kconfig +5 -0
+config EFI_NEED_RUNTIME_MAP
+     def_bool y
+     depends on EFI && KEXEC_CORE
+     select EFI_RUNTIME_MAP
+

Just curious, why not extend 'config EFI' with 'select EFI_RUNTIME_MAP if KEXEC_CORE'? It seems functionally equivalent, but more concise.

Yeah, agreed - I didn't realize every arch has its own 'config EFI' definition.

Quoted 13 lines
Quoted 10 lines
arch/x86/Kconfig +0 -2
 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
--

2.39.2

--
Kiryl Shutsemau / Kirill A. Shutemov