From: Marko Kohtala <marko.kohtala@gmail.com>
To: Olof Johansson <olof@lixom.net>, Matthew Garrett <mjg@redhat.com>
Cc: Marko Kohtala <marko.kohtala@gmail.com>, linux-kernel@vger.kernel.org
Subject: [PATCH] efivars: prevent Oops if efi_enabled but no EFI runtime
Date: Thu, 14 Jun 2012 23:47:30 +0300 [thread overview]
Message-ID: <1339706851-10618-1-git-send-email-marko.kohtala@gmail.com> (raw)
Since v3.3-rc4-5-g1adbfa3, there has been an Oops in register_efivars
calling ops->get_next_variable and ending up at EIP 0 during module init.
I boot 32-bit x86 kernel from 64-bit EFI bootloader.
The efi_enabled is true, but runtime is not available. The functions
are NULL due to 32/64-bit mismatch between kernel and EFI.
Signed-off-by: Marko Kohtala <marko.kohtala@gmail.com>
---
I currently see this on v3.4.2.
I could not figure out how I'm supposed to detect lack of runtime, so
I ended up with this quick and overly precise check that all required
functions are available. There may be other drivers that need to take
this new condition into account, so maybe Olof wants to make a better
fix.
drivers/firmware/efivars.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 47408e8..612a097 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -1223,12 +1223,16 @@ efivars_init(void)
return -ENOMEM;
}
- ops.get_variable = efi.get_variable;
- ops.set_variable = efi.set_variable;
- ops.get_next_variable = efi.get_next_variable;
- error = register_efivars(&__efivars, &ops, efi_kobj);
- if (error)
- goto err_put;
+ /* We may have efi_enabled for systab, but no runtime for variables.
+ * Check the functions we need before proceeding. */
+ if (efi.get_variable && efi.set_variable && efi.get_next_variable) {
+ ops.get_variable = efi.get_variable;
+ ops.set_variable = efi.set_variable;
+ ops.get_next_variable = efi.get_next_variable;
+ error = register_efivars(&__efivars, &ops, efi_kobj);
+ if (error)
+ goto err_put;
+ }
/* Don't forget the systab entry */
error = sysfs_create_group(efi_kobj, &efi_subsys_attr_group);
@@ -1251,10 +1255,10 @@ err_put:
static void __exit
efivars_exit(void)
{
- if (efi_enabled) {
+ if (__efivars.kset)
unregister_efivars(&__efivars);
+ if (efi_kobj)
kobject_put(efi_kobj);
- }
}
module_init(efivars_init);
--
1.7.10.4
next reply other threads:[~2012-06-14 20:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-14 20:47 Marko Kohtala [this message]
2012-06-17 23:00 ` Olof Johansson
2012-06-18 20:06 ` Marko Kohtala
2012-06-27 21:35 ` [PATCH] efi: add efi_runtime state checking Olof Johansson
2012-06-27 21:52 ` 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=1339706851-10618-1-git-send-email-marko.kohtala@gmail.com \
--to=marko.kohtala@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mjg@redhat.com \
--cc=olof@lixom.net \
/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®