From: Olof Johansson <olof@lixom.net>
To: hpa@zytor.com
Cc: Marko Kohtala <marko.kohtala@gmail.com>,
linux-kernel@vger.kernel.org, mjg@redhat.com,
Olof Johansson <olof@lixom.net>
Subject: [PATCH] efi: add efi_runtime state checking
Date: Wed, 27 Jun 2012 14:35:57 -0700 [thread overview]
Message-ID: <1340832957-7386-1-git-send-email-olof@lixom.net> (raw)
In-Reply-To: <CAJ0yFaxO-ZU7d_RNbQ3y1cfB5EJL9wgvmgZk-nmkVOLoBRH88A@mail.gmail.com>
This adds an efi_runtime variable indicating whether the
efi runtime services are available. The only time they are
expected to not be available is when a 32-bit kernel has been
booted using 64-but EFI and vice versa.
It also adds checking to the two locations where functions are
called; x86 reboot and efivars.
Signed-off-by: Olof Johansson <olof@lixom.net>
Cc: stable@kernel.org # 3.4
---
Marko,
This should solve the issue for you, I hope. I've verified that it works
here on my 64-bit EFI / 32-bit kernel systems (first-gen Chromebook).
Peter, let me know if you want this split up across several patches. I
preserved the previous probe/return behaviour for efivars, I suppose
it could be switched to -ENXIO return instead but this smaller change
seemed more suitable for -stable.
-Olof
arch/x86/kernel/reboot.c | 2 +-
arch/x86/platform/efi/efi.c | 6 ++++++
drivers/firmware/efivars.c | 2 +-
include/linux/efi.h | 3 +++
4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 52190a9..fa5bb6c 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -592,7 +592,7 @@ static void native_machine_emergency_restart(void)
break;
case BOOT_EFI:
- if (efi_enabled)
+ if (efi_runtime)
efi.reset_system(reboot_mode ?
EFI_RESET_WARM :
EFI_RESET_COLD,
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 2dc29f5..cc2bc12 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -53,6 +53,9 @@
int efi_enabled;
EXPORT_SYMBOL(efi_enabled);
+bool efi_runtime;
+EXPORT_SYMBOL(efi_runtime);
+
struct efi __read_mostly efi = {
.mps = EFI_INVALID_TABLE_ADDR,
.acpi = EFI_INVALID_TABLE_ADDR,
@@ -77,6 +80,7 @@ static efi_system_table_t efi_systab __initdata;
static int __init setup_noefi(char *arg)
{
efi_enabled = 0;
+ efi_runtime = 0;
return 0;
}
early_param("noefi", setup_noefi);
@@ -615,6 +619,8 @@ static int __init efi_runtime_init(void)
early_iounmap(runtime, sizeof(efi_runtime_services_t));
+ efi_runtime = 1;
+
return 0;
}
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 47408e8..265449a 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -1213,7 +1213,7 @@ efivars_init(void)
printk(KERN_INFO "EFI Variables Facility v%s %s\n", EFIVARS_VERSION,
EFIVARS_DATE);
- if (!efi_enabled)
+ if (!efi_runtime)
return 0;
/* For now we'll register the efi directory at /sys/firmware/efi */
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 103adc6..ac9c28d 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -539,11 +539,14 @@ extern int __init efi_setup_pcdp_console(char *);
# ifdef CONFIG_X86
extern int efi_enabled;
extern bool efi_64bit;
+ extern bool efi_runtime;
# else
# define efi_enabled 1
+# define efi_runtime 1
# endif
#else
# define efi_enabled 0
+# define efi_runtime 0
#endif
/*
--
1.7.10.1.488.g05fbf7a
next prev parent reply other threads:[~2012-06-27 21:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-14 20:47 [PATCH] efivars: prevent Oops if efi_enabled but no EFI runtime Marko Kohtala
2012-06-17 23:00 ` Olof Johansson
2012-06-18 20:06 ` Marko Kohtala
2012-06-27 21:35 ` Olof Johansson [this message]
2012-06-27 21:52 ` [PATCH] efi: add efi_runtime state checking H. Peter Anvin
2012-06-28 17:02 ` Olof Johansson
2012-08-15 0:51 ` H. Peter Anvin
2012-08-18 13:39 ` Matt Fleming
2012-06-18 20:22 ` [PATCH] efivars: prevent Oops if efi_enabled but no EFI runtime H. Peter Anvin
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=1340832957-7386-1-git-send-email-olof@lixom.net \
--to=olof@lixom.net \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=marko.kohtala@gmail.com \
--cc=mjg@redhat.com \
/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
all inboxes | Powered by JetHome®