Commit 0f5b2c69 authored by Ard Biesheuvel's avatar Ard Biesheuvel

efi: vars: Remove deprecated 'efivars' sysfs interface

Commit 5d9db883 ("efi: Add support for a UEFI variable filesystem")
dated Oct 5, 2012, introduced a new efivarfs pseudo-filesystem to
replace the efivars sysfs interface that was used up to that point to
expose EFI variables to user space.

The main problem with the sysfs interface was that it only supported up
to 1024 bytes of payload per file, whereas the underlying variables
themselves are only bounded by a platform specific per-variable and
global limit that is typically much higher than 1024 bytes.

The deprecated sysfs interface is only enabled on x86 and Itanium, other
EFI enabled architectures only support the efivarfs pseudo-filesystem.

So let's finally rip off the band aid, and drop the old interface
entirely. This will make it easier to refactor and clean up the
underlying infrastructure that is shared between efivars, efivarfs and
efi-pstore, and is long overdue for a makeover.
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
parent 5ac94136
......@@ -29,7 +29,7 @@ Mechanics
be selected::
CONFIG_EFI=y
CONFIG_EFI_VARS=y or m # optional
CONFIG_EFIVAR_FS=y or m # optional
- Create a VFAT partition on the disk
- Copy the following to the VFAT partition:
......
......@@ -44,7 +44,6 @@ CONFIG_ARM_CPUIDLE=y
CONFIG_VFP=y
CONFIG_NEON=y
CONFIG_KERNEL_MODE_NEON=y
CONFIG_EFI_VARS=m
CONFIG_EFI_CAPSULE_LOADER=m
CONFIG_ARM_CRYPTO=y
CONFIG_CRYPTO_SHA1_ARM_NEON=m
......
......@@ -10,7 +10,6 @@ CONFIG_SMP=y
CONFIG_NR_CPUS=2
CONFIG_PREEMPT=y
CONFIG_IA64_PALINFO=y
CONFIG_EFI_VARS=y
CONFIG_BINFMT_MISC=m
CONFIG_ACPI_BUTTON=m
CONFIG_ACPI_FAN=m
......
......@@ -21,7 +21,6 @@ CONFIG_IA64_MCA_RECOVERY=y
CONFIG_IA64_PALINFO=y
CONFIG_KEXEC=y
CONFIG_CRASH_DUMP=y
CONFIG_EFI_VARS=y
CONFIG_BINFMT_MISC=m
CONFIG_ACPI_BUTTON=m
CONFIG_ACPI_FAN=m
......
......@@ -18,7 +18,6 @@ CONFIG_HOTPLUG_CPU=y
CONFIG_SPARSEMEM_MANUAL=y
CONFIG_IA64_MCA_RECOVERY=y
CONFIG_IA64_PALINFO=y
CONFIG_EFI_VARS=y
CONFIG_BINFMT_MISC=m
CONFIG_ACPI_BUTTON=m
CONFIG_ACPI_FAN=m
......
......@@ -23,7 +23,6 @@ CONFIG_FORCE_CPEI_RETARGET=y
CONFIG_IA64_MCA_RECOVERY=y
CONFIG_IA64_PALINFO=y
CONFIG_KEXEC=y
CONFIG_EFI_VARS=y
CONFIG_BINFMT_MISC=m
CONFIG_ACPI_BUTTON=m
CONFIG_ACPI_FAN=m
......
......@@ -12,7 +12,6 @@ CONFIG_FLATMEM_MANUAL=y
CONFIG_IA64_MCA_RECOVERY=y
CONFIG_IA64_PALINFO=y
CONFIG_CRASH_DUMP=y
CONFIG_EFI_VARS=y
CONFIG_BINFMT_MISC=y
CONFIG_HOTPLUG_PCI=y
CONFIG_HOTPLUG_PCI_ACPI=y
......
......@@ -135,7 +135,6 @@ CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
CONFIG_DEBUG_DEVRES=y
CONFIG_CONNECTOR=y
CONFIG_EFI_VARS=y
CONFIG_EFI_CAPSULE_LOADER=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_VIRTIO_BLK=y
......
......@@ -134,7 +134,6 @@ CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
CONFIG_DEBUG_DEVRES=y
CONFIG_CONNECTOR=y
CONFIG_EFI_VARS=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_VIRTIO_BLK=y
CONFIG_BLK_DEV_SD=y
......
......@@ -2,18 +2,6 @@
menu "EFI (Extensible Firmware Interface) Support"
depends on EFI
config EFI_VARS
tristate "EFI Variable Support via sysfs"
depends on EFI && (X86 || IA64)
default n
help
If you say Y here, you are able to get EFI (Extensible Firmware
Interface) variable information via sysfs. You may read,
write, create, and destroy EFI variables through this interface.
Note that this driver is only retained for compatibility with
legacy users: new users should use the efivarfs filesystem
instead.
config EFI_ESRT
bool
depends on EFI && !IA64
......
......@@ -17,7 +17,6 @@ ifneq ($(CONFIG_EFI_CAPSULE_LOADER),)
obj-$(CONFIG_EFI) += capsule.o
endif
obj-$(CONFIG_EFI_PARAMS_FROM_FDT) += fdtparams.o
obj-$(CONFIG_EFI_VARS) += efivars.o
obj-$(CONFIG_EFI_ESRT) += esrt.o
obj-$(CONFIG_EFI_VARS_PSTORE) += efi-pstore.o
obj-$(CONFIG_UEFI_CPER) += cper.o
......
This diff is collapsed.
......@@ -547,36 +547,6 @@ static void efivar_entry_list_del_unlock(struct efivar_entry *entry)
up(&efivars_lock);
}
/**
* __efivar_entry_delete - delete an EFI variable
* @entry: entry containing EFI variable to delete
*
* Delete the variable from the firmware but leave @entry on the
* variable list.
*
* This function differs from efivar_entry_delete() because it does
* not remove @entry from the variable list. Also, it is safe to be
* called from within a efivar_entry_iter_begin() and
* efivar_entry_iter_end() region, unlike efivar_entry_delete().
*
* Returns 0 on success, or a converted EFI status code if
* set_variable() fails.
*/
int __efivar_entry_delete(struct efivar_entry *entry)
{
efi_status_t status;
if (!__efivars)
return -EINVAL;
status = __efivars->ops->set_variable(entry->var.VariableName,
&entry->var.VendorGuid,
0, 0, NULL);
return efi_status_to_err(status);
}
EXPORT_SYMBOL_GPL(__efivar_entry_delete);
/**
* efivar_entry_delete - delete variable and remove entry from list
* @entry: entry containing variable to delete
......@@ -614,213 +584,6 @@ int efivar_entry_delete(struct efivar_entry *entry)
}
EXPORT_SYMBOL_GPL(efivar_entry_delete);
/**
* efivar_entry_set - call set_variable()
* @entry: entry containing the EFI variable to write
* @attributes: variable attributes
* @size: size of @data buffer
* @data: buffer containing variable data
* @head: head of variable list
*
* Calls set_variable() for an EFI variable. If creating a new EFI
* variable, this function is usually followed by efivar_entry_add().
*
* Before writing the variable, the remaining EFI variable storage
* space is checked to ensure there is enough room available.
*
* If @head is not NULL a lookup is performed to determine whether
* the entry is already on the list.
*
* Returns 0 on success, -EINTR if we can't grab the semaphore,
* -EEXIST if a lookup is performed and the entry already exists on
* the list, or a converted EFI status code if set_variable() fails.
*/
int efivar_entry_set(struct efivar_entry *entry, u32 attributes,
unsigned long size, void *data, struct list_head *head)
{
const struct efivar_operations *ops;
efi_status_t status;
efi_char16_t *name = entry->var.VariableName;
efi_guid_t vendor = entry->var.VendorGuid;
if (down_interruptible(&efivars_lock))
return -EINTR;
if (!__efivars) {
up(&efivars_lock);
return -EINVAL;
}
ops = __efivars->ops;
if (head && efivar_entry_find(name, vendor, head, false)) {
up(&efivars_lock);
return -EEXIST;
}
status = check_var_size(attributes, size + ucs2_strsize(name, 1024));
if (status == EFI_SUCCESS || status == EFI_UNSUPPORTED)
status = ops->set_variable(name, &vendor,
attributes, size, data);
up(&efivars_lock);
return efi_status_to_err(status);
}
EXPORT_SYMBOL_GPL(efivar_entry_set);
/*
* efivar_entry_set_nonblocking - call set_variable_nonblocking()
*
* This function is guaranteed to not block and is suitable for calling
* from crash/panic handlers.
*
* Crucially, this function will not block if it cannot acquire
* efivars_lock. Instead, it returns -EBUSY.
*/
static int
efivar_entry_set_nonblocking(efi_char16_t *name, efi_guid_t vendor,
u32 attributes, unsigned long size, void *data)
{
const struct efivar_operations *ops;
efi_status_t status;
if (down_trylock(&efivars_lock))
return -EBUSY;
if (!__efivars) {
up(&efivars_lock);
return -EINVAL;
}
status = check_var_size_nonblocking(attributes,
size + ucs2_strsize(name, 1024));
if (status != EFI_SUCCESS) {
up(&efivars_lock);
return -ENOSPC;
}
ops = __efivars->ops;
status = ops->set_variable_nonblocking(name, &vendor, attributes,
size, data);
up(&efivars_lock);
return efi_status_to_err(status);
}
/**
* efivar_entry_set_safe - call set_variable() if enough space in firmware
* @name: buffer containing the variable name
* @vendor: variable vendor guid
* @attributes: variable attributes
* @block: can we block in this context?
* @size: size of @data buffer
* @data: buffer containing variable data
*
* Ensures there is enough free storage in the firmware for this variable, and
* if so, calls set_variable(). If creating a new EFI variable, this function
* is usually followed by efivar_entry_add().
*
* Returns 0 on success, -ENOSPC if the firmware does not have enough
* space for set_variable() to succeed, or a converted EFI status code
* if set_variable() fails.
*/
int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes,
bool block, unsigned long size, void *data)
{
const struct efivar_operations *ops;
efi_status_t status;
unsigned long varsize;
if (!__efivars)
return -EINVAL;
ops = __efivars->ops;
if (!ops->query_variable_store)
return -ENOSYS;
/*
* If the EFI variable backend provides a non-blocking
* ->set_variable() operation and we're in a context where we
* cannot block, then we need to use it to avoid live-locks,
* since the implication is that the regular ->set_variable()
* will block.
*
* If no ->set_variable_nonblocking() is provided then
* ->set_variable() is assumed to be non-blocking.
*/
if (!block && ops->set_variable_nonblocking)
return efivar_entry_set_nonblocking(name, vendor, attributes,
size, data);
varsize = size + ucs2_strsize(name, 1024);
if (!block) {
if (down_trylock(&efivars_lock))
return -EBUSY;
status = check_var_size_nonblocking(attributes, varsize);
} else {
if (down_interruptible(&efivars_lock))
return -EINTR;
status = check_var_size(attributes, varsize);
}
if (status != EFI_SUCCESS) {
up(&efivars_lock);
return -ENOSPC;
}
status = ops->set_variable(name, &vendor, attributes, size, data);
up(&efivars_lock);
return efi_status_to_err(status);
}
EXPORT_SYMBOL_GPL(efivar_entry_set_safe);
/**
* efivar_entry_find - search for an entry
* @name: the EFI variable name
* @guid: the EFI variable vendor's guid
* @head: head of the variable list
* @remove: should we remove the entry from the list?
*
* Search for an entry on the variable list that has the EFI variable
* name @name and vendor guid @guid. If an entry is found on the list
* and @remove is true, the entry is removed from the list.
*
* The caller MUST call efivar_entry_iter_begin() and
* efivar_entry_iter_end() before and after the invocation of this
* function, respectively.
*
* Returns the entry if found on the list, %NULL otherwise.
*/
struct efivar_entry *efivar_entry_find(efi_char16_t *name, efi_guid_t guid,
struct list_head *head, bool remove)
{
struct efivar_entry *entry, *n;
int strsize1, strsize2;
bool found = false;
list_for_each_entry_safe(entry, n, head, list) {
strsize1 = ucs2_strsize(name, 1024);
strsize2 = ucs2_strsize(entry->var.VariableName, 1024);
if (strsize1 == strsize2 &&
!memcmp(name, &(entry->var.VariableName), strsize1) &&
!efi_guidcmp(guid, entry->var.VendorGuid)) {
found = true;
break;
}
}
if (!found)
return NULL;
if (remove)
list_del(&entry->list);
return entry;
}
EXPORT_SYMBOL_GPL(efivar_entry_find);
/**
* efivar_entry_size - obtain the size of a variable
* @entry: entry for this variable
......@@ -1010,30 +773,6 @@ int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes,
}
EXPORT_SYMBOL_GPL(efivar_entry_set_get_size);
/**
* efivar_entry_iter_begin - begin iterating the variable list
*
* Lock the variable list to prevent entry insertion and removal until
* efivar_entry_iter_end() is called. This function is usually used in
* conjunction with __efivar_entry_iter() or efivar_entry_iter().
*/
int efivar_entry_iter_begin(void)
{
return down_interruptible(&efivars_lock);
}
EXPORT_SYMBOL_GPL(efivar_entry_iter_begin);
/**
* efivar_entry_iter_end - finish iterating the variable list
*
* Unlock the variable list and allow modifications to the list again.
*/
void efivar_entry_iter_end(void)
{
up(&efivars_lock);
}
EXPORT_SYMBOL_GPL(efivar_entry_iter_end);
/**
* efivar_entry_iter - iterate over variable list
* @func: callback function
......@@ -1054,7 +793,7 @@ int efivar_entry_iter(int (*func)(struct efivar_entry *, void *),
struct efivar_entry *entry, *n;
int err = 0;
err = efivar_entry_iter_begin();
err = down_interruptible(&efivars_lock);
if (err)
return err;
......@@ -1063,7 +802,7 @@ int efivar_entry_iter(int (*func)(struct efivar_entry *, void *),
if (err)
break;
}
efivar_entry_iter_end();
up(&efivars_lock);
return err;
}
......
......@@ -1045,12 +1045,6 @@ struct efivar_entry {
struct kobject kobj;
};
static inline void
efivar_unregister(struct efivar_entry *var)
{
kobject_put(&var->kobj);
}
int efivars_register(struct efivars *efivars,
const struct efivar_operations *ops,
struct kobject *kobject);
......@@ -1064,8 +1058,6 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *),
int efivar_entry_add(struct efivar_entry *entry, struct list_head *head);
void __efivar_entry_add(struct efivar_entry *entry, struct list_head *head);
void efivar_entry_remove(struct efivar_entry *entry);
int __efivar_entry_delete(struct efivar_entry *entry);
int efivar_entry_delete(struct efivar_entry *entry);
int efivar_entry_size(struct efivar_entry *entry, unsigned long *size);
......@@ -1073,22 +1065,12 @@ int __efivar_entry_get(struct efivar_entry *entry, u32 *attributes,
unsigned long *size, void *data);
int efivar_entry_get(struct efivar_entry *entry, u32 *attributes,
unsigned long *size, void *data);
int efivar_entry_set(struct efivar_entry *entry, u32 attributes,
unsigned long size, void *data, struct list_head *head);
int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes,
unsigned long *size, void *data, bool *set);
int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes,
bool block, unsigned long size, void *data);
int efivar_entry_iter_begin(void);
void efivar_entry_iter_end(void);
int efivar_entry_iter(int (*func)(struct efivar_entry *, void *),
struct list_head *head, void *data);
struct efivar_entry *efivar_entry_find(efi_char16_t *name, efi_guid_t guid,
struct list_head *head, bool remove);
bool efivar_validate(efi_guid_t vendor, efi_char16_t *var_name, u8 *data,
unsigned long data_size);
bool efivar_variable_is_removable(efi_guid_t vendor, const char *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