All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv4 0/3] Fix ACPI BGRT support for images located in EFI boot services memory
@ 2012-09-29  0:55 Josh Triplett
  2012-09-29  0:55 ` [PATCHv4 1/3] efi: Defer freeing boot services memory until after ACPI init Josh Triplett
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Josh Triplett @ 2012-09-29  0:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Len Brown,
	Matt Fleming, Olof Johansson, Matthew Garrett, David Howells,
	Rusty Russell, Peter Zijlstra, Pawel Moll, linux-acpi

The ACPI BGRT lets the OS access the BIOS logo image and its position on the
screen at boot time, allowing it to maintain that image on the screen until
ready to display something else, making boot more seamless.  This series fixes
support for accessing the boot logo image via the BGRT when the BIOS stores it
in EFI boot services memory, as recommended by the ACPI 5.0 spec.  Linux needs
to copy the image out of boot services memory before reclaiming boot services
memory.

The first patch refactors EFI initialization to defer freeing boot services
memory until much later in the boot process, and in particular until after we
have ACPI available.  The second patch adds a helper function to look up
existing EFI boot services mappings, to avoid re-mapping them.  The third patch
moves BGRT initialization to before the reclamation of boot services memory,
copies the logo at that point, and reworks the existing BGRT driver to use that
existing copy.

v2: Made the new internal function efi_unmap_memmap static.  Incorporated
    feedback from H. Peter Anvin and Matt Fleming: added stubs for
    x86-specific EFI functions called from init/main.c to eliminate the
    corresponding ifdefs in start_kernel; deferred
    efi_free_boot_services even later, to just before free_initmem.

v3: Moved efi_free_boot_services back to right after EFI initialization, to
    avoid a WARN from check_early_ioremap_leak about not calling
    early_iounmap soon enough.

v4: Cast the integral phys_addr through unsigned long before casting it to a
    pointer, to avoid a warning "cast to pointer from integer of
    different size" on 32-bit x86.  Don't define efi_enter_virtual_mode
    as a stub on non-x86, because a different function exists on ia64
    with that name, and ia64 calls that function in a different point in
    its initialiation; instead, go back to calling
    efi_enter_virtual_mode in init/main.c under an #ifdef CONFIG_X86.
    Define the stubs for efi_late_init and efi_free_boot_services using
    "static inline" to avoid unused function warnings.

v4 should replace the version currently in tip x86/efi.

Josh Triplett (3):
  efi: Defer freeing boot services memory until after ACPI init
  efi: Add a function to look up existing IO memory mappings
  efi: Fix the ACPI BGRT driver for images located in EFI boot services memory

 arch/x86/platform/efi/Makefile   |    1 +
 arch/x86/platform/efi/efi-bgrt.c |   76 ++++++++++++++++++++++++++++++++++++++
 arch/x86/platform/efi/efi.c      |   65 +++++++++++++++++++++++++-------
 drivers/acpi/Kconfig             |    4 +-
 drivers/acpi/bgrt.c              |   76 +++++---------------------------------
 include/linux/efi-bgrt.h         |   21 +++++++++++
 include/linux/efi.h              |    8 ++++
 init/main.c                      |    5 +++
 8 files changed, 174 insertions(+), 82 deletions(-)
 create mode 100644 arch/x86/platform/efi/efi-bgrt.c
 create mode 100644 include/linux/efi-bgrt.h

-- 
1.7.10.4


^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCHv3 2/4] efi: Defer freeing boot services memory until after ACPI init
@ 2012-09-08 22:06 Josh Triplett
  2012-09-27 21:56 ` [tip:x86/efi] " tip-bot for Josh Triplett
  0 siblings, 1 reply; 8+ messages in thread
From: Josh Triplett @ 2012-09-08 22:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Len Brown,
	Matt Fleming, Olof Johansson, Matthew Garrett, David Howells,
	Rusty Russell, Jim Cromie, Peter Zijlstra, linux-acpi

Some new ACPI 5.0 tables reference resources stored in boot services
memory, so keep that memory around until we have ACPI and can extract
data from it.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
---
 arch/x86/platform/efi/efi.c |   31 ++++++++++++++++++-------------
 include/linux/efi.h         |    2 ++
 init/main.c                 |    3 +++
 3 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 92660eda..ab2cfe8 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -419,10 +419,21 @@ void __init efi_reserve_boot_services(void)
 	}
 }
 
-static void __init efi_free_boot_services(void)
+static void __init efi_unmap_memmap(void)
+{
+	if (memmap.map) {
+		early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size);
+		memmap.map = NULL;
+	}
+}
+
+void __init efi_free_boot_services(void)
 {
 	void *p;
 
+	if (!efi_native)
+		return;
+
 	for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
 		efi_memory_desc_t *md = p;
 		unsigned long long start = md->phys_addr;
@@ -438,6 +449,8 @@ static void __init efi_free_boot_services(void)
 
 		free_bootmem_late(start, size);
 	}
+
+	efi_unmap_memmap();
 }
 
 static int __init efi_systab_init(void *phys)
@@ -787,8 +800,10 @@ void __init efi_enter_virtual_mode(void)
 	 * non-native EFI
 	 */
 
-	if (!efi_native)
-		goto out;
+	if (!efi_native) {
+		efi_unmap_memmap();
+		return;
+	}
 
 	/* Merge contiguous regions of the same type and attribute */
 	for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
@@ -878,13 +893,6 @@ void __init efi_enter_virtual_mode(void)
 	}
 
 	/*
-	 * Thankfully, it does seem that no runtime services other than
-	 * SetVirtualAddressMap() will touch boot services code, so we can
-	 * get rid of it all at this point
-	 */
-	efi_free_boot_services();
-
-	/*
 	 * Now that EFI is in virtual mode, update the function
 	 * pointers in the runtime service table to the new virtual addresses.
 	 *
@@ -906,9 +914,6 @@ void __init efi_enter_virtual_mode(void)
 	if (__supported_pte_mask & _PAGE_NX)
 		runtime_code_page_mkexec();
 
-out:
-	early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size);
-	memmap.map = NULL;
 	kfree(new_memmap);
 }
 
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 52fbedf..3c72c27 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -497,8 +497,10 @@ extern void efi_memmap_walk (efi_freemem_callback_t callback, void *arg);
 extern void efi_gettimeofday (struct timespec *ts);
 #ifdef CONFIG_X86
 extern void efi_enter_virtual_mode (void);	/* switch EFI to virtual mode, if possible */
+extern void efi_free_boot_services(void);
 #else
 static void efi_enter_virtual_mode(void) {}
+static void efi_free_boot_services(void) {}
 #endif
 extern u64 efi_get_iobase (void);
 extern u32 efi_mem_type (unsigned long phys_addr);
diff --git a/init/main.c b/init/main.c
index ebb1ba5..78e5491 100644
--- a/init/main.c
+++ b/init/main.c
@@ -629,6 +629,9 @@ asmlinkage void __init start_kernel(void)
 	acpi_early_init(); /* before LAPIC and SMP init */
 	sfi_init_late();
 
+	if (efi_enabled)
+		efi_free_boot_services();
+
 	ftrace_init();
 
 	/* Do the rest non-__init'ed, we're now alive */
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-09-29 23:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-29  0:55 [PATCHv4 0/3] Fix ACPI BGRT support for images located in EFI boot services memory Josh Triplett
2012-09-29  0:55 ` [PATCHv4 1/3] efi: Defer freeing boot services memory until after ACPI init Josh Triplett
2012-09-29 23:13   ` [tip:x86/efi] " tip-bot for Josh Triplett
2012-09-29  0:56 ` [PATCHv4 2/3] efi: Add a function to look up existing IO memory mappings Josh Triplett
2012-09-29 23:14   ` [tip:x86/efi] " tip-bot for Josh Triplett
2012-09-29  0:57 ` [PATCHv4 3/3] efi: Fix the ACPI BGRT driver for images located in EFI boot services memory Josh Triplett
2012-09-29 23:15   ` [tip:x86/efi] " tip-bot for Josh Triplett
  -- strict thread matches above, loose matches on Subject: below --
2012-09-08 22:06 [PATCHv3 2/4] efi: Defer freeing boot services memory until after ACPI init Josh Triplett
2012-09-27 21:56 ` [tip:x86/efi] " tip-bot for Josh Triplett

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.