summaryrefslogtreecommitdiff
path: root/lib/efi_loader
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2018-10-17 07:20:52 -0400
committerTom Rini <[email protected]>2018-10-17 07:20:52 -0400
commite3beca3a2fe172ca707a0e70310f9f7ebd3b3f0f (patch)
treea99de7d9340f72890662d92ddbb64b64de5a65d8 /lib/efi_loader
parentd0423c44f1acc68da10da8c16af4d82016479d7b (diff)
parentd081f27fc28d3a0f9fbb6045e4121709bc303028 (diff)
Merge tag 'signed-efi-2018.11' of git://github.com/agraf/u-boot
Patch queue for efi - 2018-10-17 A few bug fixes for the 2018.11 release: - Fix block seeking on 32bit - Fix execution with DEBUG set - Fix a few Coverity found bugs - Fix warnings Heinrich Schuchardt (13): efi_loader: fix relocation on x86_64 efi_loader: correct signature of GetPosition, SetPosition efi_loader: execute efi_save_gd() first efi_loader: efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, ...) efi_loader: error handling in read_console() efi_loader: return type efi_console_register() efi_loader: superfluous statement in is_dir() efi_loader: memory leak in efi_set_variable() efi_loader: remove lcd.h from efi_net.c arm: do not include efi_loader.h twice efi_loader: fix typo in efi_boottime.c efi_selftest: creating new handle in controller test efi_loader: efi_dp_get_next_instance() superfluous statement Tom Rini (2): efi_loader: Fix warning in efi_load_image() fs: fat: Fix warning in normalize_longname()
Diffstat (limited to 'lib/efi_loader')
-rw-r--r--lib/efi_loader/efi_boottime.c10
-rw-r--r--lib/efi_loader/efi_console.c4
-rw-r--r--lib/efi_loader/efi_device_path.c1
-rw-r--r--lib/efi_loader/efi_file.c48
-rw-r--r--lib/efi_loader/efi_net.c1
-rw-r--r--lib/efi_loader/efi_runtime.c16
-rw-r--r--lib/efi_loader/efi_variable.c6
7 files changed, 63 insertions, 23 deletions
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 97eb19cd14d..da978d2b34a 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1599,7 +1599,7 @@ static efi_status_t EFIAPI efi_load_image(bool boot_policy,
efi_uintn_t source_size,
efi_handle_t *image_handle)
{
- struct efi_loaded_image *info;
+ struct efi_loaded_image *info = NULL;
struct efi_loaded_image_obj **image_obj =
(struct efi_loaded_image_obj **)image_handle;
efi_status_t ret;
@@ -2023,7 +2023,7 @@ static efi_status_t EFIAPI efi_open_protocol_information(
/* Copy entries */
buffer_size = count * sizeof(struct efi_open_protocol_info_entry);
- r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, buffer_size,
+ r = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, buffer_size,
(void **)entry_buffer);
if (r != EFI_SUCCESS)
goto out;
@@ -2080,7 +2080,7 @@ static efi_status_t EFIAPI efi_protocols_per_handle(
size_t j = 0;
buffer_size = sizeof(efi_guid_t *) * *protocol_buffer_count;
- r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, buffer_size,
+ r = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, buffer_size,
(void **)protocol_buffer);
if (r != EFI_SUCCESS)
return EFI_EXIT(r);
@@ -2133,7 +2133,7 @@ static efi_status_t EFIAPI efi_locate_handle_buffer(
*buffer);
if (r != EFI_BUFFER_TOO_SMALL)
goto out;
- r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, buffer_size,
+ r = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, buffer_size,
(void **)buffer);
if (r != EFI_SUCCESS)
goto out;
@@ -2506,7 +2506,7 @@ static efi_status_t efi_protocol_open(
if (item->info.attributes & EFI_OPEN_PROTOCOL_BY_DRIVER)
opened_by_driver = true;
}
- /* Only one controller can be conncected */
+ /* Only one controller can be connected */
if (opened_by_driver)
return EFI_ACCESS_DENIED;
}
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index 7ecdbb16669..0225222a616 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -1045,8 +1045,10 @@ static void EFIAPI efi_key_notify(struct efi_event *event, void *context)
* efi_console_register() - install the console protocols
*
* This function is called from do_bootefi_exec().
+ *
+ * Return: status code
*/
-int efi_console_register(void)
+efi_status_t efi_console_register(void)
{
efi_status_t r;
struct efi_object *efi_console_output_obj;
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 5a61a1c1dcf..46a24f78824 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -382,7 +382,6 @@ struct efi_device_path *efi_dp_get_next_instance(struct efi_device_path **dp,
*size = 0;
if (!dp || !*dp)
return NULL;
- p = *dp;
sz = efi_dp_instance_size(*dp);
p = dp_alloc(sz + sizeof(END));
if (!p)
diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
index 0753a36a20b..beb4fba917d 100644
--- a/lib/efi_loader/efi_file.c
+++ b/lib/efi_loader/efi_file.c
@@ -52,11 +52,18 @@ static int set_blk_dev(struct file_handle *fh)
return fs_set_blk_dev_with_part(fh->fs->desc, fh->fs->part);
}
+/**
+ * is_dir() - check if file handle points to directory
+ *
+ * We assume that set_blk_dev(fh) has been called already.
+ *
+ * @fh: file handle
+ * Return: true if file handle points to a directory
+ */
static int is_dir(struct file_handle *fh)
{
struct fs_dir_stream *dirs;
- set_blk_dev(fh);
dirs = fs_opendir(fh->path);
if (!dirs)
return 0;
@@ -436,28 +443,51 @@ error:
return EFI_EXIT(ret);
}
+/**
+ * efi_file_getpos() - get current position in file
+ *
+ * This function implements the GetPosition service of the EFI file protocol.
+ * See the UEFI spec for details.
+ *
+ * @file: file handle
+ * @pos: pointer to file position
+ * Return: status code
+ */
static efi_status_t EFIAPI efi_file_getpos(struct efi_file_handle *file,
- efi_uintn_t *pos)
+ u64 *pos)
{
+ efi_status_t ret = EFI_SUCCESS;
struct file_handle *fh = to_fh(file);
EFI_ENTRY("%p, %p", file, pos);
- if (fh->offset <= SIZE_MAX) {
- *pos = fh->offset;
- return EFI_EXIT(EFI_SUCCESS);
- } else {
- return EFI_EXIT(EFI_DEVICE_ERROR);
+ if (fh->isdir) {
+ ret = EFI_UNSUPPORTED;
+ goto out;
}
+
+ *pos = fh->offset;
+out:
+ return EFI_EXIT(ret);
}
+/**
+ * efi_file_setpos() - set current position in file
+ *
+ * This function implements the SetPosition service of the EFI file protocol.
+ * See the UEFI spec for details.
+ *
+ * @file: file handle
+ * @pos: new file position
+ * Return: status code
+ */
static efi_status_t EFIAPI efi_file_setpos(struct efi_file_handle *file,
- efi_uintn_t pos)
+ u64 pos)
{
struct file_handle *fh = to_fh(file);
efi_status_t ret = EFI_SUCCESS;
- EFI_ENTRY("%p, %zu", file, pos);
+ EFI_ENTRY("%p, %llu", file, pos);
if (fh->isdir) {
if (pos != 0) {
diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c
index 034d0d2ed03..4e8b2d597df 100644
--- a/lib/efi_loader/efi_net.c
+++ b/lib/efi_loader/efi_net.c
@@ -7,7 +7,6 @@
#include <common.h>
#include <efi_loader.h>
-#include <lcd.h>
#include <malloc.h>
static const efi_guid_t efi_net_guid = EFI_SIMPLE_NETWORK_GUID;
diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index c5fbd91fa38..f059dc97fd4 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -41,9 +41,13 @@ static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void);
#elif defined(__arm__)
#define R_RELATIVE R_ARM_RELATIVE
#define R_MASK 0xffULL
-#elif defined(__x86_64__) || defined(__i386__)
+#elif defined(__i386__)
#define R_RELATIVE R_386_RELATIVE
#define R_MASK 0xffULL
+#elif defined(__x86_64__)
+#define R_RELATIVE R_X86_64_RELATIVE
+#define R_MASK 0xffffffffULL
+#define IS_RELA 1
#elif defined(__riscv)
#define R_RELATIVE R_RISCV_RELATIVE
#define R_MASK 0xffULL
@@ -358,7 +362,8 @@ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map)
p = (void*)((ulong)rel->offset - base) + gd->relocaddr;
- debug("%s: rel->info=%#lx *p=%#lx rel->offset=%p\n", __func__, rel->info, *p, rel->offset);
+ debug("%s: rel->info=%#lx *p=%#lx rel->offset=%p\n", __func__,
+ rel->info, *p, rel->offset);
switch (rel->info & R_MASK) {
case R_RELATIVE:
@@ -377,6 +382,9 @@ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map)
}
#endif
default:
+ if (!efi_runtime_tobedetached(p))
+ printf("%s: Unknown relocation type %llx\n",
+ __func__, rel->info & R_MASK);
continue;
}
@@ -385,8 +393,8 @@ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map)
newaddr > (map->virtual_start +
(map->num_pages << EFI_PAGE_SHIFT)))) {
if (!efi_runtime_tobedetached(p))
- printf("U-Boot EFI: Relocation at %p is out of "
- "range (%lx)\n", p, newaddr);
+ printf("%s: Relocation at %p is out of "
+ "range (%lx)\n", __func__, p, newaddr);
continue;
}
diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
index a1313fa2158..19d9cb865f2 100644
--- a/lib/efi_loader/efi_variable.c
+++ b/lib/efi_loader/efi_variable.c
@@ -294,8 +294,10 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, efi_guid_t *vendor,
}
val = malloc(2 * data_size + strlen("{ro,run,boot}(blob)") + 1);
- if (!val)
- return EFI_EXIT(EFI_OUT_OF_RESOURCES);
+ if (!val) {
+ ret = EFI_OUT_OF_RESOURCES;
+ goto out;
+ }
s = val;