Skip to content

Commit 6950e31

Browse files
djbwrafaeljw
authored andcommitted
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 <[email protected]> Reviewed-by: Ard Biesheuvel <[email protected]> Signed-off-by: Dan Williams <[email protected]> Acked-by: Thomas Gleixner <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent fe3e5e6 commit 6950e31

File tree

7 files changed

+26
-13
lines changed

7 files changed

+26
-13
lines changed

arch/x86/include/asm/efi.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ extern void efi_delete_dummy_variable(void);
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)
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)
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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,17 +1122,15 @@ void __init setup_arch(char **cmdline_p)
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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ void __init efi_find_mirror(void)
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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@ void __init efi_reserve_boot_services(void)
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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ void __init efi_esrt_init(void)
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void __init efi_fake_memmap(void)
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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,6 @@ extern void efi_enter_virtual_mode (void); /* switch EFI to virtual mode, if pos
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,

0 commit comments

Comments
 (0)