stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	alan@lxorguk.ukuu.org.uk, Marko Kohtala <marko.kohtala@gmail.com>,
	Maxim Kammerer <mk@dee.su>, Olof Johansson <olof@lixom.net>,
	Maarten Lankhorst <maarten.lankhorst@canonical.com>,
	Matthew Garrett <mjg@redhat.com>,
	Matt Fleming <matt.fleming@intel.com>
Subject: [ 51/54] x86: efi: Turn off efi_enabled after setup on mixed fw/kernel
Date: Mon, 29 Oct 2012 14:40:52 -0700	[thread overview]
Message-ID: <20121029213808.456967567@linuxfoundation.org> (raw)
In-Reply-To: <20121029213802.697479610@linuxfoundation.org>

3.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Olof Johansson <olof@lixom.net>

commit 5189c2a7c7769ee9d037d76c1a7b8550ccf3481c upstream.

When 32-bit EFI is used with 64-bit kernel (or vice versa), turn off
efi_enabled once setup is done. Beyond setup, it is normally used to
determine if runtime services are available and we will have none.

This will resolve issues stemming from efivars modprobe panicking on a
32/64-bit setup, as well as some reboot issues on similar setups.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=45991

Reported-by: Marko Kohtala <marko.kohtala@gmail.com>
Reported-by: Maxim Kammerer <mk@dee.su>
Signed-off-by: Olof Johansson <olof@lixom.net>
Acked-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Cc: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/include/asm/efi.h  |    1 +
 arch/x86/kernel/setup.c     |   12 ++++++++++++
 arch/x86/platform/efi/efi.c |   18 ++++++++++--------
 3 files changed, 23 insertions(+), 8 deletions(-)

--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -98,6 +98,7 @@ extern void efi_set_executable(efi_memor
 extern int efi_memblock_x86_reserve_range(void);
 extern void efi_call_phys_prelog(void);
 extern void efi_call_phys_epilog(void);
+extern void efi_unmap_memmap(void);
 
 #ifndef CONFIG_EFI
 /*
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1053,6 +1053,18 @@ void __init setup_arch(char **cmdline_p)
 	mcheck_init();
 
 	arch_init_ideal_nops();
+
+#ifdef CONFIG_EFI
+	/* Once setup is done above, disable efi_enabled on mismatched
+	 * firmware/kernel archtectures since there is no support for
+	 * runtime services.
+	 */
+	if (efi_enabled && IS_ENABLED(CONFIG_X86_64) != efi_64bit) {
+		pr_info("efi: Setup done, disabling due to 32/64-bit mismatch\n");
+		efi_unmap_memmap();
+		efi_enabled = 0;
+	}
+#endif
 }
 
 #ifdef CONFIG_X86_32
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -69,11 +69,15 @@ EXPORT_SYMBOL(efi);
 struct efi_memory_map memmap;
 
 bool efi_64bit;
-static bool efi_native;
 
 static struct efi efi_phys __initdata;
 static efi_system_table_t efi_systab __initdata;
 
+static inline bool efi_is_native(void)
+{
+	return IS_ENABLED(CONFIG_X86_64) == efi_64bit;
+}
+
 static int __init setup_noefi(char *arg)
 {
 	efi_enabled = 0;
@@ -419,7 +423,7 @@ void __init efi_reserve_boot_services(vo
 	}
 }
 
-static void __init efi_unmap_memmap(void)
+void __init efi_unmap_memmap(void)
 {
 	if (memmap.map) {
 		early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size);
@@ -431,7 +435,7 @@ void __init efi_free_boot_services(void)
 {
 	void *p;
 
-	if (!efi_native)
+	if (!efi_is_native())
 		return;
 
 	for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
@@ -683,12 +687,10 @@ void __init efi_init(void)
 		return;
 	}
 	efi_phys.systab = (efi_system_table_t *)boot_params.efi_info.efi_systab;
-	efi_native = !efi_64bit;
 #else
 	efi_phys.systab = (efi_system_table_t *)
 			  (boot_params.efi_info.efi_systab |
 			  ((__u64)boot_params.efi_info.efi_systab_hi<<32));
-	efi_native = efi_64bit;
 #endif
 
 	if (efi_systab_init(efi_phys.systab)) {
@@ -722,7 +724,7 @@ void __init efi_init(void)
 	 * that doesn't match the kernel 32/64-bit mode.
 	 */
 
-	if (!efi_native)
+	if (!efi_is_native())
 		pr_info("No EFI runtime due to 32/64-bit mismatch with kernel\n");
 	else if (efi_runtime_init()) {
 		efi_enabled = 0;
@@ -734,7 +736,7 @@ void __init efi_init(void)
 		return;
 	}
 #ifdef CONFIG_X86_32
-	if (efi_native) {
+	if (efi_is_native()) {
 		x86_platform.get_wallclock = efi_get_time;
 		x86_platform.set_wallclock = efi_set_rtc_mmss;
 	}
@@ -800,7 +802,7 @@ void __init efi_enter_virtual_mode(void)
 	 * non-native EFI
 	 */
 
-	if (!efi_native) {
+	if (!efi_is_native()) {
 		efi_unmap_memmap();
 		return;
 	}



  parent reply	other threads:[~2012-10-29 21:40 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-29 21:40 [ 00/54] 3.4.17-stable review Greg Kroah-Hartman
2012-10-29 21:40 ` [ 01/54] drm/radeon: add some new SI PCI ids Greg Kroah-Hartman
2012-10-29 21:40 ` [ 02/54] drm/radeon: add error output if VM CS fails on cayman Greg Kroah-Hartman
2012-10-29 21:40 ` [ 03/54] ALSA: hda - add dock support for Thinkpad T430 Greg Kroah-Hartman
2012-10-29 21:40 ` [ 04/54] gen_init_cpio: avoid stack overflow when expanding Greg Kroah-Hartman
2012-10-29 21:40 ` [ 05/54] fs/compat_ioctl.c: VIDEO_SET_SPU_PALETTE missing error check Greg Kroah-Hartman
2012-10-29 21:40 ` [ 06/54] drivers/rtc/rtc-imxdi.c: add missing spin lock initialization Greg Kroah-Hartman
2012-10-29 21:40 ` [ 07/54] genalloc: stop crashing the system when destroying a pool Greg Kroah-Hartman
2012-10-29 21:40 ` [ 08/54] ARM: 7559/1: smp: switch away from the idmap before updating init_mm.mm_count Greg Kroah-Hartman
2012-10-29 21:40 ` [ 09/54] x86, mm: Trim memory in memblock to be page aligned Greg Kroah-Hartman
2012-10-29 21:40 ` [ 10/54] mm: fix XFS oops due to dirty pages without buffers on s390 Greg Kroah-Hartman
2012-10-29 21:40 ` [ 11/54] SUNRPC: Get rid of the xs_error_report socket callback Greg Kroah-Hartman
2012-10-29 21:40 ` [ 12/54] SUNRPC: Clear the connect flag when socket state is TCP_CLOSE_WAIT Greg Kroah-Hartman
2012-10-29 21:40 ` [ 13/54] Revert "SUNRPC: Ensure we close the socket on EPIPE errors too..." Greg Kroah-Hartman
2012-10-29 21:40 ` [ 14/54] SUNRPC: Prevent races in xs_abort_connection() Greg Kroah-Hartman
2012-10-29 21:40 ` [ 15/54] xhci: Fix potential NULL ptr deref in command cancellation Greg Kroah-Hartman
2012-10-29 21:40 ` [ 16/54] sysfs: sysfs_pathname/sysfs_add_one: Use strlcat() instead of strcat() Greg Kroah-Hartman
2012-10-29 21:40 ` [ 17/54] Staging: android: binder: Fix memory leak on thread/process exit Greg Kroah-Hartman
2012-10-29 21:40 ` [ 18/54] Staging: android: binder: Allow using highmem for binder buffers Greg Kroah-Hartman
2012-10-29 21:40 ` [ 19/54] Drivers: hv: Cleanup error handling in vmbus_open() Greg Kroah-Hartman
2012-10-29 21:40 ` [ 20/54] ehci: fix Lucid nohandoff pci quirk to be more generic with BIOS versions Greg Kroah-Hartman
2012-10-29 21:40 ` [ 21/54] ehci: Add yet-another Lucid nohandoff pci quirk Greg Kroah-Hartman
2012-10-29 21:40 ` [ 22/54] usb-storage: add unusual_devs entry for Casio EX-N1 digital camera Greg Kroah-Hartman
2012-10-29 21:40 ` [ 23/54] usb hub: send clear_tt_buffer_complete events when canceling TT clear work Greg Kroah-Hartman
2012-10-29 21:40 ` [ 24/54] USB: whiteheat: fix memory leak in error path Greg Kroah-Hartman
2012-10-29 21:40 ` [ 25/54] USB: opticon: fix DMA from stack Greg Kroah-Hartman
2012-10-29 21:40 ` [ 26/54] USB: opticon: fix memory leak in error path Greg Kroah-Hartman
2012-10-29 21:40 ` [ 27/54] USB: serial: Fix memory leak in sierra_release() Greg Kroah-Hartman
2012-10-29 21:40 ` [ 28/54] USB: sierra: fix memory leak in attach error path Greg Kroah-Hartman
2012-10-29 21:40 ` [ 29/54] USB: sierra: fix memory leak in probe " Greg Kroah-Hartman
2012-10-29 21:40 ` [ 30/54] USB: mos7840: fix urb leak at release Greg Kroah-Hartman
2012-10-29 21:40 ` [ 31/54] USB: mos7840: fix port-device leak in error path Greg Kroah-Hartman
2012-10-29 21:40 ` [ 32/54] USB: mos7840: remove NULL-urb submission Greg Kroah-Hartman
2012-10-29 21:40 ` [ 33/54] USB: mos7840: remove invalid disconnect handling Greg Kroah-Hartman
2012-10-29 21:40 ` [ 34/54] vhost: fix mergeable bufs on BE hosts Greg Kroah-Hartman
2012-10-29 21:40 ` [ 35/54] ARM: SAMSUNG: Add naming of s3c64xx-spi devices Greg Kroah-Hartman
2012-11-04  6:17   ` Colin Cross
2012-11-05  7:51     ` Greg Kroah-Hartman
2012-11-05  7:55       ` Colin Cross
2012-10-29 21:40 ` [ 36/54] ARM: at91/tc: fix typo in the DT document Greg Kroah-Hartman
2012-10-29 21:40 ` [ 37/54] ARM: at91/i2c: change id to let i2c-gpio work Greg Kroah-Hartman
2012-10-29 21:40 ` [ 38/54] ARM: at91: at91sam9g10: fix SOC type detection Greg Kroah-Hartman
2012-10-29 21:40 ` [ 39/54] mac80211: check if key has TKIP type before updating IV Greg Kroah-Hartman
2012-10-29 21:40 ` [ 40/54] Bluetooth: SMP: Fix setting unknown auth_req bits Greg Kroah-Hartman
2012-10-29 21:40 ` [ 41/54] freezer: exec should clear PF_NOFREEZE along with PF_KTHREAD Greg Kroah-Hartman
2012-10-29 21:40 ` [ 42/54] dmaengine: sirf: fix a typo in dma_prep_interleaved Greg Kroah-Hartman
2012-10-29 21:40 ` [ 43/54] dmaengine: sirf: fix a typo in moving running dma_desc to active queue Greg Kroah-Hartman
2012-10-29 21:40 ` [ 44/54] dmaengine: imx-dma: fix missing unlock on error in imxdma_xfer_desc() Greg Kroah-Hartman
2012-10-29 21:40 ` [ 45/54] bcma: fix unregistration of cores Greg Kroah-Hartman
2012-10-29 21:40 ` [ 46/54] cpufreq / powernow-k8: Remove usage of smp_processor_id() in preemptible code Greg Kroah-Hartman
2012-10-29 21:40 ` [ 47/54] Revert "ath9k_hw: Updated AR9003 tx gain table for 5GHz" Greg Kroah-Hartman
2012-10-29 21:40 ` [ 48/54] x86, mm: Find_early_table_space based on ranges that are actually being mapped Greg Kroah-Hartman
2012-10-29 21:40 ` [ 49/54] x86, mm: Undo incorrect revert in arch/x86/mm/init.c Greg Kroah-Hartman
2012-10-29 21:40 ` [ 50/54] efi: Defer freeing boot services memory until after ACPI init Greg Kroah-Hartman
2012-10-29 21:40 ` Greg Kroah-Hartman [this message]
2012-10-29 21:40 ` [ 52/54] staging: comedi: amplc_pc236: fix invalid register access during detach Greg Kroah-Hartman
2012-10-29 21:40 ` [ 53/54] x86, mm: Use memblock memory loop instead of e820_RAM Greg Kroah-Hartman
2012-10-29 21:40 ` [ 54/54] drm/i915: no lvds quirk for Zotac ZDBOX SD ID12/ID13 Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121029213808.456967567@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@canonical.com \
    --cc=marko.kohtala@gmail.com \
    --cc=matt.fleming@intel.com \
    --cc=mjg@redhat.com \
    --cc=mk@dee.su \
    --cc=olof@lixom.net \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).