History

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().

Dan Williams committed 7 years ago

Commit 6950e311 parent fe3e5e67 files · +26 −13Browse files

Unified · Split

7 files
  1. arch/x86/include/asm/efi.h +8 −1
  2. arch/x86/kernel/setup.c +8 −10
  3. arch/x86/platform/efi/efi.c +3 −0
  4. arch/x86/platform/efi/quirks.c +3 −0
  5. drivers/firmware/efi/esrt.c +3 −0
  6. drivers/firmware/efi/fake_mem.c +1 −1
  7. include/linux/efi.h +0 −1
arch/x86/include/asm/efi.h+8−1
@@ -140,7 +140,6 @@ extern void efi_delete_dummy_variable(void); · 139 unmodified lines
140140 extern void efi_switch_mm(struct mm_struct *mm);
141141 extern void efi_recover_from_page_fault(unsigned long phys_addr);
142142 extern void efi_free_boot_services(void);
143−extern void efi_reserve_boot_services(void);
144143
145144 struct efi_setup_data {
146145 u64 fw_vendor;
@@ -244,6 +243,8 @@ static inline bool efi_is_64bit(void) · 97 unmodified lines
244243 extern bool efi_reboot_required(void);
245244 extern bool efi_is_table_address(unsigned long phys_addr);
246245
246+extern void efi_find_mirror(void);
247+extern void efi_reserve_boot_services(void);
247248 #else
248249 static inline void parse_efi_setup(u64 phys_addr, u32 data_len) {}
249250 static inline bool efi_reboot_required(void)
@@ -254,6 +255,12 @@ static inline bool efi_is_table_address(unsigned long phys_addr) · 4 unmodified lines
254255 {
255256 return false;
256257 }
258+static inline void efi_find_mirror(void)
259+{
260+}
261+static inline void efi_reserve_boot_services(void)
262+{
263+}
257264 #endif /* CONFIG_EFI */
258265
259266 #endif /* _ASM_X86_EFI_H */
arch/x86/kernel/setup.c+8−10
@@ -1122,17 +1122,15 @@ void __init setup_arch(char **cmdline_p) · 1121 unmodified lines
11221122
11231123 reserve_bios_regions();
11241124
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();
11291128
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();
11361134
11371135 /* preallocate 4k for mptable mpc */
11381136 e820__memblock_alloc_reserved_mpc_new();
arch/x86/platform/efi/efi.c+3−0
@@ -128,6 +128,9 @@ void __init efi_find_mirror(void) · 127 unmodified lines
128128 efi_memory_desc_t *md;
129129 u64 mirror_size = 0, total_size = 0;
130130
131+ if (!efi_enabled(EFI_MEMMAP))
132+ return;
133+
131134 for_each_efi_memory_desc(md) {
132135 unsigned long long start = md->phys_addr;
133136 unsigned long long size = md->num_pages << EFI_PAGE_SHIFT;
arch/x86/platform/efi/quirks.c+3−0
@@ -320,6 +320,9 @@ void __init efi_reserve_boot_services(void) · 319 unmodified lines
320320 {
321321 efi_memory_desc_t *md;
322322
323+ if (!efi_enabled(EFI_MEMMAP))
324+ return;
325+
323326 for_each_efi_memory_desc(md) {
324327 u64 start = md->phys_addr;
325328 u64 size = md->num_pages << EFI_PAGE_SHIFT;
drivers/firmware/efi/esrt.c+3−0
@@ -246,6 +246,9 @@ void __init efi_esrt_init(void) · 245 unmodified lines
246246 int rc;
247247 phys_addr_t end;
248248
249+ if (!efi_enabled(EFI_MEMMAP))
250+ return;
251+
249252 pr_debug("esrt-init: loading.\n");
250253 if (!esrt_table_exists())
251254 return;
drivers/firmware/efi/fake_mem.c+1−1
@@ -44,7 +44,7 @@ void __init efi_fake_memmap(void) · 43 unmodified lines
4444 void *new_memmap;
4545 int i;
4646
47− if (!nr_fake_mem)
47+ if (!efi_enabled(EFI_MEMMAP) || !nr_fake_mem)
4848 return;
4949
5050 /* count up the number of EFI memory descriptor */
include/linux/efi.h+0−1
@@ -1045,7 +1045,6 @@ extern void efi_enter_virtual_mode (void); /* switch EFI to virtual mode, if pos · 1044 unmodified lines
10451045 extern efi_status_t efi_query_variable_store(u32 attributes,
10461046 unsigned long size,
10471047 bool nonblocking);
1048−extern void efi_find_mirror(void);
10491048 #else
10501049
10511050 static inline efi_status_t efi_query_variable_store(u32 attributes,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t