Commit 3c01b74e authored by Ingo Molnar's avatar Ingo Molnar

Merge tag 'efi-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi into x86/efi

Pull EFI updates from Matt Fleming:

" - Move efivarfs from the misc filesystem section to pseudo filesystem,
    since that's a more logical and accurate place - Leif Lindholm

  - Update efibootmgr URL in Kconfig help - Peter Jones

  - Improve accuracy of EFI guid function names - Borislav Petkov

  - Expose firmware platform size in sysfs for the benefit of EFI boot
    loader installers and other utilities - Steve McIntyre

  - Cleanup __init annotations for arm64/efi code - Ard Biesheuvel

  - Mark the UIE as unsupported for rtc-efi - Ard Biesheuvel

  - Fix memory leak in error code path of runtime map code - Dan Carpenter

  - Improve robustness of get_memory_map() by removing assumptions on the
    size of efi_memory_desc_t (which could change in future spec
    versions) and querying the firmware instead of guessing about the
    memmap size - Ard Biesheuvel

  - Remove superfluous guid unparse calls - Ivan Khoronzhuk

  - Delete unnecessary chosen@0 DT node FDT code since was duplicated
    from code in drivers/of and is entirely unnecessary - Leif Lindholm

   There's nothing super scary, mainly cleanups, and a merge from Ricardo who
   kindly picked up some patches from the linux-efi mailing list while I
   was out on annual leave in December.

   Perhaps the biggest risk is the get_memory_map() change from Ard, which
   changes the way that both the arm64 and x86 EFI boot stub build the
   early memory map. It would be good to have it bake in linux-next for a
   while.
"
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents c59c961c 11629305
...@@ -13,13 +13,13 @@ ...@@ -13,13 +13,13 @@
#include <asm/efi.h> #include <asm/efi.h>
#include <asm/sections.h> #include <asm/sections.h>
efi_status_t handle_kernel_image(efi_system_table_t *sys_table, efi_status_t __init handle_kernel_image(efi_system_table_t *sys_table,
unsigned long *image_addr, unsigned long *image_addr,
unsigned long *image_size, unsigned long *image_size,
unsigned long *reserve_addr, unsigned long *reserve_addr,
unsigned long *reserve_size, unsigned long *reserve_size,
unsigned long dram_base, unsigned long dram_base,
efi_loaded_image_t *image) efi_loaded_image_t *image)
{ {
efi_status_t status; efi_status_t status;
unsigned long kernel_size, kernel_memsize = 0; unsigned long kernel_size, kernel_memsize = 0;
......
...@@ -715,7 +715,7 @@ int efi_partition(struct parsed_partitions *state) ...@@ -715,7 +715,7 @@ int efi_partition(struct parsed_partitions *state)
state->parts[i + 1].flags = ADDPART_FLAG_RAID; state->parts[i + 1].flags = ADDPART_FLAG_RAID;
info = &state->parts[i + 1].info; info = &state->parts[i + 1].info;
efi_guid_unparse(&ptes[i].unique_partition_guid, info->uuid); efi_guid_to_str(&ptes[i].unique_partition_guid, info->uuid);
/* Naively convert UTF16-LE to 7 bits. */ /* Naively convert UTF16-LE to 7 bits. */
label_max = min(ARRAY_SIZE(info->volname) - 1, label_max = min(ARRAY_SIZE(info->volname) - 1,
......
...@@ -12,11 +12,11 @@ config EFI_VARS ...@@ -12,11 +12,11 @@ config EFI_VARS
Note that using this driver in concert with efibootmgr requires Note that using this driver in concert with efibootmgr requires
at least test release version 0.5.0-test3 or later, which is at least test release version 0.5.0-test3 or later, which is
available from Matt Domsch's website located at: available from:
<http://linux.dell.com/efibootmgr/testing/efibootmgr-0.5.0-test3.tar.gz> <http://linux.dell.com/efibootmgr/testing/efibootmgr-0.5.0-test3.tar.gz>
Subsequent efibootmgr releases may be found at: Subsequent efibootmgr releases may be found at:
<http://linux.dell.com/efibootmgr> <http://github.com/vathpela/efibootmgr>
config EFI_VARS_PSTORE config EFI_VARS_PSTORE
tristate "Register efivars backend for pstore" tristate "Register efivars backend for pstore"
......
...@@ -115,15 +115,24 @@ EFI_ATTR_SHOW(fw_vendor); ...@@ -115,15 +115,24 @@ EFI_ATTR_SHOW(fw_vendor);
EFI_ATTR_SHOW(runtime); EFI_ATTR_SHOW(runtime);
EFI_ATTR_SHOW(config_table); EFI_ATTR_SHOW(config_table);
static ssize_t fw_platform_size_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", efi_enabled(EFI_64BIT) ? 64 : 32);
}
static struct kobj_attribute efi_attr_fw_vendor = __ATTR_RO(fw_vendor); static struct kobj_attribute efi_attr_fw_vendor = __ATTR_RO(fw_vendor);
static struct kobj_attribute efi_attr_runtime = __ATTR_RO(runtime); static struct kobj_attribute efi_attr_runtime = __ATTR_RO(runtime);
static struct kobj_attribute efi_attr_config_table = __ATTR_RO(config_table); static struct kobj_attribute efi_attr_config_table = __ATTR_RO(config_table);
static struct kobj_attribute efi_attr_fw_platform_size =
__ATTR_RO(fw_platform_size);
static struct attribute *efi_subsys_attrs[] = { static struct attribute *efi_subsys_attrs[] = {
&efi_attr_systab.attr, &efi_attr_systab.attr,
&efi_attr_fw_vendor.attr, &efi_attr_fw_vendor.attr,
&efi_attr_runtime.attr, &efi_attr_runtime.attr,
&efi_attr_config_table.attr, &efi_attr_config_table.attr,
&efi_attr_fw_platform_size.attr,
NULL, NULL,
}; };
...@@ -272,15 +281,10 @@ static __init int match_config_table(efi_guid_t *guid, ...@@ -272,15 +281,10 @@ static __init int match_config_table(efi_guid_t *guid,
unsigned long table, unsigned long table,
efi_config_table_type_t *table_types) efi_config_table_type_t *table_types)
{ {
u8 str[EFI_VARIABLE_GUID_LEN + 1];
int i; int i;
if (table_types) { if (table_types) {
efi_guid_unparse(guid, str);
for (i = 0; efi_guidcmp(table_types[i].guid, NULL_GUID); i++) { for (i = 0; efi_guidcmp(table_types[i].guid, NULL_GUID); i++) {
efi_guid_unparse(&table_types[i].guid, str);
if (!efi_guidcmp(*guid, table_types[i].guid)) { if (!efi_guidcmp(*guid, table_types[i].guid)) {
*(table_types[i].ptr) = table; *(table_types[i].ptr) = table;
pr_cont(" %s=0x%lx ", pr_cont(" %s=0x%lx ",
...@@ -403,8 +407,7 @@ static int __init fdt_find_uefi_params(unsigned long node, const char *uname, ...@@ -403,8 +407,7 @@ static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
u64 val; u64 val;
int i, len; int i, len;
if (depth != 1 || if (depth != 1 || strcmp(uname, "chosen") != 0)
(strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0))
return 0; return 0;
for (i = 0; i < ARRAY_SIZE(dt_params); i++) { for (i = 0; i < ARRAY_SIZE(dt_params); i++) {
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
* fix locking per Peter Chubb's findings * fix locking per Peter Chubb's findings
* *
* 25 Mar 2002 - Matt Domsch <Matt_Domsch@dell.com> * 25 Mar 2002 - Matt Domsch <Matt_Domsch@dell.com>
* move uuid_unparse() to include/asm-ia64/efi.h:efi_guid_unparse() * move uuid_unparse() to include/asm-ia64/efi.h:efi_guid_to_str()
* *
* 12 Feb 2002 - Matt Domsch <Matt_Domsch@dell.com> * 12 Feb 2002 - Matt Domsch <Matt_Domsch@dell.com>
* use list_for_each_safe when deleting vars. * use list_for_each_safe when deleting vars.
...@@ -128,7 +128,7 @@ efivar_guid_read(struct efivar_entry *entry, char *buf) ...@@ -128,7 +128,7 @@ efivar_guid_read(struct efivar_entry *entry, char *buf)
if (!entry || !buf) if (!entry || !buf)
return 0; return 0;
efi_guid_unparse(&var->VendorGuid, str); efi_guid_to_str(&var->VendorGuid, str);
str += strlen(str); str += strlen(str);
str += sprintf(str, "\n"); str += sprintf(str, "\n");
...@@ -569,7 +569,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var) ...@@ -569,7 +569,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
private variables from another's. */ private variables from another's. */
*(short_name + strlen(short_name)) = '-'; *(short_name + strlen(short_name)) = '-';
efi_guid_unparse(&new_var->var.VendorGuid, efi_guid_to_str(&new_var->var.VendorGuid,
short_name + strlen(short_name)); short_name + strlen(short_name));
new_var->kobj.kset = efivars_kset; new_var->kobj.kset = efivars_kset;
......
...@@ -24,3 +24,17 @@ lib-y := efi-stub-helper.o ...@@ -24,3 +24,17 @@ lib-y := efi-stub-helper.o
lib-$(CONFIG_EFI_ARMSTUB) += arm-stub.o fdt.o lib-$(CONFIG_EFI_ARMSTUB) += arm-stub.o fdt.o
CFLAGS_fdt.o += -I$(srctree)/scripts/dtc/libfdt/ CFLAGS_fdt.o += -I$(srctree)/scripts/dtc/libfdt/
#
# arm64 puts the stub in the kernel proper, which will unnecessarily retain all
# code indefinitely unless it is annotated as __init/__initdata/__initconst etc.
# So let's apply the __init annotations at the section level, by prefixing
# the section names directly. This will ensure that even all the inline string
# literals are covered.
#
extra-$(CONFIG_ARM64) := $(lib-y)
lib-$(CONFIG_ARM64) := $(patsubst %.o,%.init.o,$(lib-y))
OBJCOPYFLAGS := --prefix-alloc-sections=.init
$(obj)/%.init.o: $(obj)/%.o FORCE
$(call if_changed,objcopy)
...@@ -17,10 +17,10 @@ ...@@ -17,10 +17,10 @@
#include "efistub.h" #include "efistub.h"
static int __init efi_secureboot_enabled(efi_system_table_t *sys_table_arg) static int efi_secureboot_enabled(efi_system_table_t *sys_table_arg)
{ {
static efi_guid_t const var_guid __initconst = EFI_GLOBAL_VARIABLE_GUID; static efi_guid_t const var_guid = EFI_GLOBAL_VARIABLE_GUID;
static efi_char16_t const var_name[] __initconst = { static efi_char16_t const var_name[] = {
'S', 'e', 'c', 'u', 'r', 'e', 'B', 'o', 'o', 't', 0 }; 'S', 'e', 'c', 'u', 'r', 'e', 'B', 'o', 'o', 't', 0 };
efi_get_variable_t *f_getvar = sys_table_arg->runtime->get_variable; efi_get_variable_t *f_getvar = sys_table_arg->runtime->get_variable;
...@@ -164,7 +164,7 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table, ...@@ -164,7 +164,7 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table,
* for both archictectures, with the arch-specific code provided in the * for both archictectures, with the arch-specific code provided in the
* handle_kernel_image() function. * handle_kernel_image() function.
*/ */
unsigned long __init efi_entry(void *handle, efi_system_table_t *sys_table, unsigned long efi_entry(void *handle, efi_system_table_t *sys_table,
unsigned long *image_addr) unsigned long *image_addr)
{ {
efi_loaded_image_t *image; efi_loaded_image_t *image;
......
...@@ -66,25 +66,29 @@ efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg, ...@@ -66,25 +66,29 @@ efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg,
unsigned long key; unsigned long key;
u32 desc_version; u32 desc_version;
*map_size = sizeof(*m) * 32; *map_size = 0;
again: *desc_size = 0;
key = 0;
status = efi_call_early(get_memory_map, map_size, NULL,
&key, desc_size, &desc_version);
if (status != EFI_BUFFER_TOO_SMALL)
return EFI_LOAD_ERROR;
/* /*
* Add an additional efi_memory_desc_t because we're doing an * Add an additional efi_memory_desc_t because we're doing an
* allocation which may be in a new descriptor region. * allocation which may be in a new descriptor region.
*/ */
*map_size += sizeof(*m); *map_size += *desc_size;
status = efi_call_early(allocate_pool, EFI_LOADER_DATA, status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
*map_size, (void **)&m); *map_size, (void **)&m);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto fail; goto fail;
*desc_size = 0;
key = 0;
status = efi_call_early(get_memory_map, map_size, m, status = efi_call_early(get_memory_map, map_size, m,
&key, desc_size, &desc_version); &key, desc_size, &desc_version);
if (status == EFI_BUFFER_TOO_SMALL) { if (status == EFI_BUFFER_TOO_SMALL) {
efi_call_early(free_pool, m); efi_call_early(free_pool, m);
goto again; return EFI_LOAD_ERROR;
} }
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
...@@ -101,7 +105,7 @@ efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg, ...@@ -101,7 +105,7 @@ efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg,
} }
unsigned long __init get_dram_base(efi_system_table_t *sys_table_arg) unsigned long get_dram_base(efi_system_table_t *sys_table_arg)
{ {
efi_status_t status; efi_status_t status;
unsigned long map_size; unsigned long map_size;
......
...@@ -191,7 +191,7 @@ int __init efi_runtime_map_init(struct kobject *efi_kobj) ...@@ -191,7 +191,7 @@ int __init efi_runtime_map_init(struct kobject *efi_kobj)
return 0; return 0;
out_add_entry: out_add_entry:
for (j = i - 1; j > 0; j--) { for (j = i - 1; j >= 0; j--) {
entry = *(map_entries + j); entry = *(map_entries + j);
kobject_put(&entry->kobj); kobject_put(&entry->kobj);
} }
......
...@@ -218,6 +218,7 @@ static int __init efi_rtc_probe(struct platform_device *dev) ...@@ -218,6 +218,7 @@ static int __init efi_rtc_probe(struct platform_device *dev)
if (IS_ERR(rtc)) if (IS_ERR(rtc))
return PTR_ERR(rtc); return PTR_ERR(rtc);
rtc->uie_unsupported = 1;
platform_set_drvdata(dev, rtc); platform_set_drvdata(dev, rtc);
return 0; return 0;
......
...@@ -165,6 +165,7 @@ config HUGETLB_PAGE ...@@ -165,6 +165,7 @@ config HUGETLB_PAGE
def_bool HUGETLBFS def_bool HUGETLBFS
source "fs/configfs/Kconfig" source "fs/configfs/Kconfig"
source "fs/efivarfs/Kconfig"
endmenu endmenu
...@@ -209,7 +210,6 @@ source "fs/sysv/Kconfig" ...@@ -209,7 +210,6 @@ source "fs/sysv/Kconfig"
source "fs/ufs/Kconfig" source "fs/ufs/Kconfig"
source "fs/exofs/Kconfig" source "fs/exofs/Kconfig"
source "fs/f2fs/Kconfig" source "fs/f2fs/Kconfig"
source "fs/efivarfs/Kconfig"
endif # MISC_FILESYSTEMS endif # MISC_FILESYSTEMS
......
config EFIVAR_FS config EFIVAR_FS
tristate "EFI Variable filesystem" tristate "EFI Variable filesystem"
depends on EFI depends on EFI
default m
help help
efivarfs is a replacement filesystem for the old EFI efivarfs is a replacement filesystem for the old EFI
variable support via sysfs, as it doesn't suffer from the variable support via sysfs, as it doesn't suffer from the
......
...@@ -140,7 +140,7 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor, ...@@ -140,7 +140,7 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
name[len] = '-'; name[len] = '-';
efi_guid_unparse(&entry->var.VendorGuid, name + len + 1); efi_guid_to_str(&entry->var.VendorGuid, name + len + 1);
name[len + EFI_VARIABLE_GUID_LEN+1] = '\0'; name[len + EFI_VARIABLE_GUID_LEN+1] = '\0';
......
...@@ -848,7 +848,7 @@ efi_guidcmp (efi_guid_t left, efi_guid_t right) ...@@ -848,7 +848,7 @@ efi_guidcmp (efi_guid_t left, efi_guid_t right)
} }
static inline char * static inline char *
efi_guid_unparse(efi_guid_t *guid, char *out) efi_guid_to_str(efi_guid_t *guid, char *out)
{ {
sprintf(out, "%pUl", guid->b); sprintf(out, "%pUl", guid->b);
return out; return out;
......
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