x86/efi: Delete efi_late_init() and simplify EFI initialization
Now that acpi_early_init() has been moved earlier in start_kernel(), we
can significantly cleanup init/main.c by deleting efi_late_init()
altogether and freeing the reserved boot services regions inside
efi_enter_virtual_mode().
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Matthew Garrett <mjg59@srcf.ucam.org>
Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 270640c..4758421 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -458,7 +458,7 @@
}
}
-void __init efi_free_boot_services(void)
+static void __init efi_free_boot_services(void)
{
void *p;
@@ -697,11 +697,6 @@
print_efi_memmap();
}
-void __init efi_late_init(void)
-{
- efi_bgrt_init();
-}
-
void __init efi_set_executable(efi_memory_desc_t *md, bool executable)
{
u64 addr, npages;
@@ -881,6 +876,8 @@
panic("EFI call to SetVirtualAddressMap() failed!");
}
+ efi_bgrt_init();
+
/*
* Now that EFI is in virtual mode, update the function
* pointers in the runtime service table to the new virtual addresses.
@@ -905,6 +902,8 @@
if (efi_enabled(EFI_OLD_MEMMAP) && (__supported_pte_mask & _PAGE_NX))
runtime_code_page_mkexec();
+ efi_free_boot_services();
+
kfree(new_memmap);
/* clean DUMMY object */
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 2e2fbde..7ec70ab 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -152,8 +152,8 @@
/*
* We can't ioremap data in EFI boot services RAM, because we've already mapped
- * it as RAM. So, look it up in the existing EFI memory map instead. Only
- * callable after efi_enter_virtual_mode and before efi_free_boot_services.
+ * it as RAM. So, look it up in the existing EFI memory map instead. Only
+ * callable before efi_free_boot_services().
*/
void __iomem *efi_lookup_mapped_addr(u64 phys_addr)
{
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 6c0ca52..c73d563 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -592,13 +592,8 @@
extern void efi_gettimeofday (struct timespec *ts);
extern void efi_enter_virtual_mode (void); /* switch EFI to virtual mode, if possible */
#ifdef CONFIG_X86
-extern void efi_late_init(void);
-extern void efi_free_boot_services(void);
extern efi_status_t efi_query_variable_store(u32 attributes, unsigned long size);
#else
-static inline void efi_late_init(void) {}
-static inline void efi_free_boot_services(void) {}
-
static inline efi_status_t efi_query_variable_store(u32 attributes, unsigned long size)
{
return EFI_SUCCESS;
diff --git a/init/main.c b/init/main.c
index 7523dcb..9ede3e7 100644
--- a/init/main.c
+++ b/init/main.c
@@ -632,11 +632,6 @@
sfi_init_late();
- if (efi_enabled(EFI_RUNTIME_SERVICES)) {
- efi_late_init();
- efi_free_boot_services();
- }
-
ftrace_init();
/* Do the rest non-__init'ed, we're now alive */