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