Commit f6a087af authored by Seth Forshee's avatar Seth Forshee Committed by Greg Kroah-Hartman

efivars: Allow disabling use as a pstore backend

commit ed9dc8ce upstream.

Add a new option, CONFIG_EFI_VARS_PSTORE, which can be set to N to
avoid using efivars as a backend to pstore, as some users may want to
compile out the code completely.

Set the default to Y to maintain backwards compatability, since this
feature has always been enabled until now.
Signed-off-by: default avatarSeth Forshee <seth.forshee@canonical.com>
Cc: Josh Boyer <jwboyer@redhat.com>
Cc: Matthew Garrett <mjg59@srcf.ucam.org>
Cc: Seiji Aguchi <seiji.aguchi@hds.com>
Cc: Tony Luck <tony.luck@intel.com>
Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
[xr: Backported to 3.4: adjust context]
Signed-off-by: default avatarRui Xiang <rui.xiang@huawei.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1c4e6e91
...@@ -53,6 +53,15 @@ config EFI_VARS ...@@ -53,6 +53,15 @@ config EFI_VARS
Subsequent efibootmgr releases may be found at: Subsequent efibootmgr releases may be found at:
<http://linux.dell.com/efibootmgr> <http://linux.dell.com/efibootmgr>
config EFI_VARS_PSTORE
bool "Register efivars backend for pstore"
depends on EFI_VARS && PSTORE
default y
help
Say Y here to enable use efivars as a backend to pstore. This
will allow writing console messages, crash dumps, or anything
else supported by pstore to EFI variables.
config EFI_PCDP config EFI_PCDP
bool "Console device selection via EFI PCDP or HCDP table" bool "Console device selection via EFI PCDP or HCDP table"
depends on ACPI && EFI && IA64 depends on ACPI && EFI && IA64
......
...@@ -662,8 +662,6 @@ static struct kobj_type efivar_ktype = { ...@@ -662,8 +662,6 @@ static struct kobj_type efivar_ktype = {
.default_attrs = def_attrs, .default_attrs = def_attrs,
}; };
static struct pstore_info efi_pstore_info;
static inline void static inline void
efivar_unregister(struct efivar_entry *var) efivar_unregister(struct efivar_entry *var)
{ {
...@@ -700,7 +698,7 @@ static int efi_status_to_err(efi_status_t status) ...@@ -700,7 +698,7 @@ static int efi_status_to_err(efi_status_t status)
return err; return err;
} }
#ifdef CONFIG_PSTORE #ifdef CONFIG_EFI_VARS_PSTORE
static int efi_pstore_open(struct pstore_info *psi) static int efi_pstore_open(struct pstore_info *psi)
{ {
...@@ -853,37 +851,6 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, ...@@ -853,37 +851,6 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id,
return 0; return 0;
} }
#else
static int efi_pstore_open(struct pstore_info *psi)
{
return 0;
}
static int efi_pstore_close(struct pstore_info *psi)
{
return 0;
}
static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type,
struct timespec *timespec,
char **buf, struct pstore_info *psi)
{
return -1;
}
static int efi_pstore_write(enum pstore_type_id type,
enum kmsg_dump_reason reason, u64 *id,
unsigned int part, size_t size, struct pstore_info *psi)
{
return 0;
}
static int efi_pstore_erase(enum pstore_type_id type, u64 id,
struct pstore_info *psi)
{
return 0;
}
#endif
static struct pstore_info efi_pstore_info = { static struct pstore_info efi_pstore_info = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
...@@ -895,6 +862,24 @@ static struct pstore_info efi_pstore_info = { ...@@ -895,6 +862,24 @@ static struct pstore_info efi_pstore_info = {
.erase = efi_pstore_erase, .erase = efi_pstore_erase,
}; };
static void efivar_pstore_register(struct efivars *efivars)
{
efivars->efi_pstore_info = efi_pstore_info;
efivars->efi_pstore_info.buf = kmalloc(4096, GFP_KERNEL);
if (efivars->efi_pstore_info.buf) {
efivars->efi_pstore_info.bufsize = 1024;
efivars->efi_pstore_info.data = efivars;
spin_lock_init(&efivars->efi_pstore_info.buf_lock);
pstore_register(&efivars->efi_pstore_info);
}
}
#else
static void efivar_pstore_register(struct efivars *efivars)
{
return;
}
#endif
static ssize_t efivar_create(struct file *filp, struct kobject *kobj, static ssize_t efivar_create(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr, struct bin_attribute *bin_attr,
char *buf, loff_t pos, size_t count) char *buf, loff_t pos, size_t count)
...@@ -1365,15 +1350,7 @@ int register_efivars(struct efivars *efivars, ...@@ -1365,15 +1350,7 @@ int register_efivars(struct efivars *efivars,
if (error) if (error)
unregister_efivars(efivars); unregister_efivars(efivars);
efivars->efi_pstore_info = efi_pstore_info; efivar_pstore_register(efivars);
efivars->efi_pstore_info.buf = kmalloc(4096, GFP_KERNEL);
if (efivars->efi_pstore_info.buf) {
efivars->efi_pstore_info.bufsize = 1024;
efivars->efi_pstore_info.data = efivars;
spin_lock_init(&efivars->efi_pstore_info.buf_lock);
pstore_register(&efivars->efi_pstore_info);
}
out: out:
kfree(variable_name); kfree(variable_name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment