aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firmware
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2015-01-29 13:16:40 -0500
committerIngo Molnar <mingo@kernel.org>2015-01-29 13:16:40 -0500
commit3c01b74e818a7a3b2ee9b0d584cca0bc154a031c (patch)
treef037af086f4c31070a45760b781a2ce483ff76d5 /drivers/firmware
parentc59c961ca511dc7ee2f4f7e9c224d16f5c76ca6e (diff)
parent11629305043c513454c4ccb4fc384a1bfe610647 (diff)
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: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'drivers/firmware')
-rw-r--r--drivers/firmware/efi/Kconfig4
-rw-r--r--drivers/firmware/efi/efi.c17
-rw-r--r--drivers/firmware/efi/efivars.c6
-rw-r--r--drivers/firmware/efi/libstub/Makefile14
-rw-r--r--drivers/firmware/efi/libstub/arm-stub.c8
-rw-r--r--drivers/firmware/efi/libstub/efi-stub-helper.c18
-rw-r--r--drivers/firmware/efi/runtime-map.c2
7 files changed, 45 insertions, 24 deletions
diff --git a/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig
index f712d47f30d8..8de4da5c9ab6 100644
--- a/drivers/firmware/efi/Kconfig
+++ b/drivers/firmware/efi/Kconfig
@@ -12,11 +12,11 @@ config EFI_VARS
12 12
13 Note that using this driver in concert with efibootmgr requires 13 Note that using this driver in concert with efibootmgr requires
14 at least test release version 0.5.0-test3 or later, which is 14 at least test release version 0.5.0-test3 or later, which is
15 available from Matt Domsch's website located at: 15 available from:
16 <http://linux.dell.com/efibootmgr/testing/efibootmgr-0.5.0-test3.tar.gz> 16 <http://linux.dell.com/efibootmgr/testing/efibootmgr-0.5.0-test3.tar.gz>
17 17
18 Subsequent efibootmgr releases may be found at: 18 Subsequent efibootmgr releases may be found at:
19 <http://linux.dell.com/efibootmgr> 19 <http://github.com/vathpela/efibootmgr>
20 20
21config EFI_VARS_PSTORE 21config EFI_VARS_PSTORE
22 tristate "Register efivars backend for pstore" 22 tristate "Register efivars backend for pstore"
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 9035c1b74d58..fccb464928c3 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -115,15 +115,24 @@ EFI_ATTR_SHOW(fw_vendor);
115EFI_ATTR_SHOW(runtime); 115EFI_ATTR_SHOW(runtime);
116EFI_ATTR_SHOW(config_table); 116EFI_ATTR_SHOW(config_table);
117 117
118static ssize_t fw_platform_size_show(struct kobject *kobj,
119 struct kobj_attribute *attr, char *buf)
120{
121 return sprintf(buf, "%d\n", efi_enabled(EFI_64BIT) ? 64 : 32);
122}
123
118static struct kobj_attribute efi_attr_fw_vendor = __ATTR_RO(fw_vendor); 124static struct kobj_attribute efi_attr_fw_vendor = __ATTR_RO(fw_vendor);
119static struct kobj_attribute efi_attr_runtime = __ATTR_RO(runtime); 125static struct kobj_attribute efi_attr_runtime = __ATTR_RO(runtime);
120static struct kobj_attribute efi_attr_config_table = __ATTR_RO(config_table); 126static struct kobj_attribute efi_attr_config_table = __ATTR_RO(config_table);
127static struct kobj_attribute efi_attr_fw_platform_size =
128 __ATTR_RO(fw_platform_size);
121 129
122static struct attribute *efi_subsys_attrs[] = { 130static struct attribute *efi_subsys_attrs[] = {
123 &efi_attr_systab.attr, 131 &efi_attr_systab.attr,
124 &efi_attr_fw_vendor.attr, 132 &efi_attr_fw_vendor.attr,
125 &efi_attr_runtime.attr, 133 &efi_attr_runtime.attr,
126 &efi_attr_config_table.attr, 134 &efi_attr_config_table.attr,
135 &efi_attr_fw_platform_size.attr,
127 NULL, 136 NULL,
128}; 137};
129 138
@@ -272,15 +281,10 @@ static __init int match_config_table(efi_guid_t *guid,
272 unsigned long table, 281 unsigned long table,
273 efi_config_table_type_t *table_types) 282 efi_config_table_type_t *table_types)
274{ 283{
275 u8 str[EFI_VARIABLE_GUID_LEN + 1];
276 int i; 284 int i;
277 285
278 if (table_types) { 286 if (table_types) {
279 efi_guid_unparse(guid, str);
280
281 for (i = 0; efi_guidcmp(table_types[i].guid, NULL_GUID); i++) { 287 for (i = 0; efi_guidcmp(table_types[i].guid, NULL_GUID); i++) {
282 efi_guid_unparse(&table_types[i].guid, str);
283
284 if (!efi_guidcmp(*guid, table_types[i].guid)) { 288 if (!efi_guidcmp(*guid, table_types[i].guid)) {
285 *(table_types[i].ptr) = table; 289 *(table_types[i].ptr) = table;
286 pr_cont(" %s=0x%lx ", 290 pr_cont(" %s=0x%lx ",
@@ -403,8 +407,7 @@ static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
403 u64 val; 407 u64 val;
404 int i, len; 408 int i, len;
405 409
406 if (depth != 1 || 410 if (depth != 1 || strcmp(uname, "chosen") != 0)
407 (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0))
408 return 0; 411 return 0;
409 412
410 for (i = 0; i < ARRAY_SIZE(dt_params); i++) { 413 for (i = 0; i < ARRAY_SIZE(dt_params); i++) {
diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
index f256ecd8a176..7b2e0496e0c0 100644
--- a/drivers/firmware/efi/efivars.c
+++ b/drivers/firmware/efi/efivars.c
@@ -39,7 +39,7 @@
39 * fix locking per Peter Chubb's findings 39 * fix locking per Peter Chubb's findings
40 * 40 *
41 * 25 Mar 2002 - Matt Domsch <Matt_Domsch@dell.com> 41 * 25 Mar 2002 - Matt Domsch <Matt_Domsch@dell.com>
42 * move uuid_unparse() to include/asm-ia64/efi.h:efi_guid_unparse() 42 * move uuid_unparse() to include/asm-ia64/efi.h:efi_guid_to_str()
43 * 43 *
44 * 12 Feb 2002 - Matt Domsch <Matt_Domsch@dell.com> 44 * 12 Feb 2002 - Matt Domsch <Matt_Domsch@dell.com>
45 * use list_for_each_safe when deleting vars. 45 * use list_for_each_safe when deleting vars.
@@ -128,7 +128,7 @@ efivar_guid_read(struct efivar_entry *entry, char *buf)
128 if (!entry || !buf) 128 if (!entry || !buf)
129 return 0; 129 return 0;
130 130
131 efi_guid_unparse(&var->VendorGuid, str); 131 efi_guid_to_str(&var->VendorGuid, str);
132 str += strlen(str); 132 str += strlen(str);
133 str += sprintf(str, "\n"); 133 str += sprintf(str, "\n");
134 134
@@ -569,7 +569,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
569 private variables from another's. */ 569 private variables from another's. */
570 570
571 *(short_name + strlen(short_name)) = '-'; 571 *(short_name + strlen(short_name)) = '-';
572 efi_guid_unparse(&new_var->var.VendorGuid, 572 efi_guid_to_str(&new_var->var.VendorGuid,
573 short_name + strlen(short_name)); 573 short_name + strlen(short_name));
574 574
575 new_var->kobj.kset = efivars_kset; 575 new_var->kobj.kset = efivars_kset;
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index b14bc2b9fb4d..8902f52e0998 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -24,3 +24,17 @@ lib-y := efi-stub-helper.o
24lib-$(CONFIG_EFI_ARMSTUB) += arm-stub.o fdt.o 24lib-$(CONFIG_EFI_ARMSTUB) += arm-stub.o fdt.o
25 25
26CFLAGS_fdt.o += -I$(srctree)/scripts/dtc/libfdt/ 26CFLAGS_fdt.o += -I$(srctree)/scripts/dtc/libfdt/
27
28#
29# arm64 puts the stub in the kernel proper, which will unnecessarily retain all
30# code indefinitely unless it is annotated as __init/__initdata/__initconst etc.
31# So let's apply the __init annotations at the section level, by prefixing
32# the section names directly. This will ensure that even all the inline string
33# literals are covered.
34#
35extra-$(CONFIG_ARM64) := $(lib-y)
36lib-$(CONFIG_ARM64) := $(patsubst %.o,%.init.o,$(lib-y))
37
38OBJCOPYFLAGS := --prefix-alloc-sections=.init
39$(obj)/%.init.o: $(obj)/%.o FORCE
40 $(call if_changed,objcopy)
diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c
index eb48a1a1a576..2b3814702dcf 100644
--- a/drivers/firmware/efi/libstub/arm-stub.c
+++ b/drivers/firmware/efi/libstub/arm-stub.c
@@ -17,10 +17,10 @@
17 17
18#include "efistub.h" 18#include "efistub.h"
19 19
20static int __init efi_secureboot_enabled(efi_system_table_t *sys_table_arg) 20static int efi_secureboot_enabled(efi_system_table_t *sys_table_arg)
21{ 21{
22 static efi_guid_t const var_guid __initconst = EFI_GLOBAL_VARIABLE_GUID; 22 static efi_guid_t const var_guid = EFI_GLOBAL_VARIABLE_GUID;
23 static efi_char16_t const var_name[] __initconst = { 23 static efi_char16_t const var_name[] = {
24 'S', 'e', 'c', 'u', 'r', 'e', 'B', 'o', 'o', 't', 0 }; 24 'S', 'e', 'c', 'u', 'r', 'e', 'B', 'o', 'o', 't', 0 };
25 25
26 efi_get_variable_t *f_getvar = sys_table_arg->runtime->get_variable; 26 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 * for both archictectures, with the arch-specific code provided in the 164 * for both archictectures, with the arch-specific code provided in the
165 * handle_kernel_image() function. 165 * handle_kernel_image() function.
166 */ 166 */
167unsigned long __init efi_entry(void *handle, efi_system_table_t *sys_table, 167unsigned long efi_entry(void *handle, efi_system_table_t *sys_table,
168 unsigned long *image_addr) 168 unsigned long *image_addr)
169{ 169{
170 efi_loaded_image_t *image; 170 efi_loaded_image_t *image;
diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index a920fec8fe88..d073e3946383 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -66,25 +66,29 @@ efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg,
66 unsigned long key; 66 unsigned long key;
67 u32 desc_version; 67 u32 desc_version;
68 68
69 *map_size = sizeof(*m) * 32; 69 *map_size = 0;
70again: 70 *desc_size = 0;
71 key = 0;
72 status = efi_call_early(get_memory_map, map_size, NULL,
73 &key, desc_size, &desc_version);
74 if (status != EFI_BUFFER_TOO_SMALL)
75 return EFI_LOAD_ERROR;
76
71 /* 77 /*
72 * Add an additional efi_memory_desc_t because we're doing an 78 * Add an additional efi_memory_desc_t because we're doing an
73 * allocation which may be in a new descriptor region. 79 * allocation which may be in a new descriptor region.
74 */ 80 */
75 *map_size += sizeof(*m); 81 *map_size += *desc_size;
76 status = efi_call_early(allocate_pool, EFI_LOADER_DATA, 82 status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
77 *map_size, (void **)&m); 83 *map_size, (void **)&m);
78 if (status != EFI_SUCCESS) 84 if (status != EFI_SUCCESS)
79 goto fail; 85 goto fail;
80 86
81 *desc_size = 0;
82 key = 0;
83 status = efi_call_early(get_memory_map, map_size, m, 87 status = efi_call_early(get_memory_map, map_size, m,
84 &key, desc_size, &desc_version); 88 &key, desc_size, &desc_version);
85 if (status == EFI_BUFFER_TOO_SMALL) { 89 if (status == EFI_BUFFER_TOO_SMALL) {
86 efi_call_early(free_pool, m); 90 efi_call_early(free_pool, m);
87 goto again; 91 return EFI_LOAD_ERROR;
88 } 92 }
89 93
90 if (status != EFI_SUCCESS) 94 if (status != EFI_SUCCESS)
@@ -101,7 +105,7 @@ fail:
101} 105}
102 106
103 107
104unsigned long __init get_dram_base(efi_system_table_t *sys_table_arg) 108unsigned long get_dram_base(efi_system_table_t *sys_table_arg)
105{ 109{
106 efi_status_t status; 110 efi_status_t status;
107 unsigned long map_size; 111 unsigned long map_size;
diff --git a/drivers/firmware/efi/runtime-map.c b/drivers/firmware/efi/runtime-map.c
index 018c29a26615..87b8e3b900d2 100644
--- a/drivers/firmware/efi/runtime-map.c
+++ b/drivers/firmware/efi/runtime-map.c
@@ -191,7 +191,7 @@ int __init efi_runtime_map_init(struct kobject *efi_kobj)
191 191
192 return 0; 192 return 0;
193out_add_entry: 193out_add_entry:
194 for (j = i - 1; j > 0; j--) { 194 for (j = i - 1; j >= 0; j--) {
195 entry = *(map_entries + j); 195 entry = *(map_entries + j);
196 kobject_put(&entry->kobj); 196 kobject_put(&entry->kobj);
197 } 197 }