Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/efi: Push EFI_MEMMAP check into leaf routines

In preparation for adding another EFI_MEMMAP dependent call that needs
to occur before e820__memblock_setup() fixup the existing efi calls to
check for EFI_MEMMAP internally. This ends up being cleaner than the
alternative of checking EFI_MEMMAP multiple times in setup_arch().

Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Dan Williams and committed by
Rafael J. Wysocki
6950e31b fe3e5e65

+26 -13
+8 -1
arch/x86/include/asm/efi.h
··· 140 140 extern void efi_switch_mm(struct mm_struct *mm); 141 141 extern void efi_recover_from_page_fault(unsigned long phys_addr); 142 142 extern void efi_free_boot_services(void); 143 - extern void efi_reserve_boot_services(void); 144 143 145 144 struct efi_setup_data { 146 145 u64 fw_vendor; ··· 243 244 extern bool efi_reboot_required(void); 244 245 extern bool efi_is_table_address(unsigned long phys_addr); 245 246 247 + extern void efi_find_mirror(void); 248 + extern void efi_reserve_boot_services(void); 246 249 #else 247 250 static inline void parse_efi_setup(u64 phys_addr, u32 data_len) {} 248 251 static inline bool efi_reboot_required(void) ··· 254 253 static inline bool efi_is_table_address(unsigned long phys_addr) 255 254 { 256 255 return false; 256 + } 257 + static inline void efi_find_mirror(void) 258 + { 259 + } 260 + static inline void efi_reserve_boot_services(void) 261 + { 257 262 } 258 263 #endif /* CONFIG_EFI */ 259 264
+8 -10
arch/x86/kernel/setup.c
··· 1122 1122 1123 1123 reserve_bios_regions(); 1124 1124 1125 - if (efi_enabled(EFI_MEMMAP)) { 1126 - efi_fake_memmap(); 1127 - efi_find_mirror(); 1128 - efi_esrt_init(); 1125 + efi_fake_memmap(); 1126 + efi_find_mirror(); 1127 + efi_esrt_init(); 1129 1128 1130 - /* 1131 - * The EFI specification says that boot service code won't be 1132 - * called after ExitBootServices(). This is, in fact, a lie. 1133 - */ 1134 - efi_reserve_boot_services(); 1135 - } 1129 + /* 1130 + * The EFI specification says that boot service code won't be 1131 + * called after ExitBootServices(). This is, in fact, a lie. 1132 + */ 1133 + efi_reserve_boot_services(); 1136 1134 1137 1135 /* preallocate 4k for mptable mpc */ 1138 1136 e820__memblock_alloc_reserved_mpc_new();
+3
arch/x86/platform/efi/efi.c
··· 128 128 efi_memory_desc_t *md; 129 129 u64 mirror_size = 0, total_size = 0; 130 130 131 + if (!efi_enabled(EFI_MEMMAP)) 132 + return; 133 + 131 134 for_each_efi_memory_desc(md) { 132 135 unsigned long long start = md->phys_addr; 133 136 unsigned long long size = md->num_pages << EFI_PAGE_SHIFT;
+3
arch/x86/platform/efi/quirks.c
··· 320 320 { 321 321 efi_memory_desc_t *md; 322 322 323 + if (!efi_enabled(EFI_MEMMAP)) 324 + return; 325 + 323 326 for_each_efi_memory_desc(md) { 324 327 u64 start = md->phys_addr; 325 328 u64 size = md->num_pages << EFI_PAGE_SHIFT;
+3
drivers/firmware/efi/esrt.c
··· 246 246 int rc; 247 247 phys_addr_t end; 248 248 249 + if (!efi_enabled(EFI_MEMMAP)) 250 + return; 251 + 249 252 pr_debug("esrt-init: loading.\n"); 250 253 if (!esrt_table_exists()) 251 254 return;
+1 -1
drivers/firmware/efi/fake_mem.c
··· 44 44 void *new_memmap; 45 45 int i; 46 46 47 - if (!nr_fake_mem) 47 + if (!efi_enabled(EFI_MEMMAP) || !nr_fake_mem) 48 48 return; 49 49 50 50 /* count up the number of EFI memory descriptor */
-1
include/linux/efi.h
··· 1045 1045 extern efi_status_t efi_query_variable_store(u32 attributes, 1046 1046 unsigned long size, 1047 1047 bool nonblocking); 1048 - extern void efi_find_mirror(void); 1049 1048 #else 1050 1049 1051 1050 static inline efi_status_t efi_query_variable_store(u32 attributes,