summaryrefslogtreecommitdiff
path: root/lib/efi_loader
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-05-08 14:56:23 -0400
committerTom Rini <trini@konsulko.com>2020-05-08 14:56:23 -0400
commita5e609b982a004e009e8ee0aa6066785db425ac2 (patch)
tree3e687989c84d8a2f4bb9b4f06bb4b4bfe558d98a /lib/efi_loader
parentea02cfb6495eb5f54bf239405316746a19d303b2 (diff)
parentd7ca3ce3d3b990503cb6e0bafad91aa2a7c96b9d (diff)
Merge tag 'efi-2020-07-rc2-3' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
Pull request for UEFI sub-system for efi-2020-07-rc2-3 This series contains bug fixes and code simplifications. Following clarification in the discussion of the EBBR specification device trees will be passed as EfiACPIReclaimMemory to UEFI applications.
Diffstat (limited to 'lib/efi_loader')
-rw-r--r--lib/efi_loader/Makefile1
-rw-r--r--lib/efi_loader/efi_device_path.c2
-rw-r--r--lib/efi_loader/efi_image_loader.c6
-rw-r--r--lib/efi_loader/efi_variable.c39
4 files changed, 27 insertions, 21 deletions
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index eff3c25ec3..84d61df55b 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -17,6 +17,7 @@ CFLAGS_REMOVE_helloworld.o := $(CFLAGS_NON_EFI)
ifneq ($(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),)
always += helloworld.efi
+targets += helloworld.o
endif
obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 73f1fe75a8..f9349484a6 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -530,7 +530,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
#ifdef CONFIG_SANDBOX
case UCLASS_ROOT: {
/* stop traversing parents at this point: */
- struct efi_device_path_vendor *dp = buf;
+ struct efi_device_path_vendor *dp;
struct blk_desc *desc = dev_get_uclass_platdata(dev);
dp_fill(buf, dev->parent);
diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c
index 5a9a6424cc..4e075ae416 100644
--- a/lib/efi_loader/efi_image_loader.c
+++ b/lib/efi_loader/efi_image_loader.c
@@ -13,7 +13,8 @@
#include <malloc.h>
#include <pe.h>
#include <sort.h>
-#include "crypto/pkcs7_parser.h"
+#include <crypto/pkcs7_parser.h>
+#include <linux/err.h>
const efi_guid_t efi_global_variable_guid = EFI_GLOBAL_VARIABLE_GUID;
const efi_guid_t efi_guid_device_path = EFI_DEVICE_PATH_PROTOCOL_GUID;
@@ -538,8 +539,9 @@ static bool efi_image_authenticate(void *efi, size_t efi_size)
}
msg = pkcs7_parse_message((void *)wincert + sizeof(*wincert),
wincert->dwLength - sizeof(*wincert));
- if (!msg) {
+ if (IS_ERR(msg)) {
debug("Parsing image's signature failed\n");
+ msg = NULL;
goto err;
}
diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
index 58f8fae358..60c1201757 100644
--- a/lib/efi_loader/efi_variable.c
+++ b/lib/efi_loader/efi_variable.c
@@ -30,6 +30,18 @@ static u8 efi_vendor_keys;
#define READ_ONLY BIT(31)
+static efi_status_t efi_get_variable_common(u16 *variable_name,
+ const efi_guid_t *vendor,
+ u32 *attributes,
+ efi_uintn_t *data_size, void *data);
+
+static efi_status_t efi_set_variable_common(u16 *variable_name,
+ const efi_guid_t *vendor,
+ u32 attributes,
+ efi_uintn_t data_size,
+ const void *data,
+ bool ro_check);
+
/*
* Mapping between EFI variables and u-boot variables:
*
@@ -169,13 +181,6 @@ static const char *parse_attr(const char *str, u32 *attrp, u64 *timep)
return str;
}
-static efi_status_t efi_set_variable_common(u16 *variable_name,
- const efi_guid_t *vendor,
- u32 attributes,
- efi_uintn_t data_size,
- const void *data,
- bool ro_check);
-
/**
* efi_set_secure_state - modify secure boot state variables
* @sec_boot: value of SecureBoot
@@ -300,8 +305,8 @@ static efi_status_t efi_init_secure_state(void)
*/
size = 0;
- ret = EFI_CALL(efi_get_variable(L"PK", &efi_global_variable_guid,
- NULL, &size, NULL));
+ ret = efi_get_variable_common(L"PK", &efi_global_variable_guid,
+ NULL, &size, NULL);
if (ret == EFI_BUFFER_TOO_SMALL) {
if (IS_ENABLED(CONFIG_EFI_SECURE_BOOT))
mode = EFI_MODE_USER;
@@ -519,9 +524,8 @@ static efi_status_t efi_variable_authenticate(u16 *variable,
var_sig = efi_variable_parse_signature(auth->auth_info.cert_data,
auth->auth_info.hdr.dwLength
- sizeof(auth->auth_info));
- if (IS_ERR(var_sig)) {
+ if (!var_sig) {
debug("Parsing variable's signature failed\n");
- var_sig = NULL;
goto err;
}
@@ -587,8 +591,7 @@ static efi_status_t efi_variable_authenticate(u16 *variable,
}
#endif /* CONFIG_EFI_SECURE_BOOT */
-static
-efi_status_t EFIAPI efi_get_variable_common(u16 *variable_name,
+static efi_status_t efi_get_variable_common(u16 *variable_name,
const efi_guid_t *vendor,
u32 *attributes,
efi_uintn_t *data_size, void *data)
@@ -893,8 +896,8 @@ static efi_status_t efi_set_variable_common(u16 *variable_name,
/* check if a variable exists */
old_size = 0;
attr = 0;
- ret = EFI_CALL(efi_get_variable(variable_name, vendor, &attr,
- &old_size, NULL));
+ ret = efi_get_variable_common(variable_name, vendor, &attr,
+ &old_size, NULL);
append = !!(attributes & EFI_VARIABLE_APPEND_WRITE);
attributes &= ~(u32)EFI_VARIABLE_APPEND_WRITE;
delete = !append && (!data_size || !attributes);
@@ -981,11 +984,11 @@ static efi_status_t efi_set_variable_common(u16 *variable_name,
if (append) {
old_data = malloc(old_size);
if (!old_data) {
- return EFI_OUT_OF_RESOURCES;
+ ret = EFI_OUT_OF_RESOURCES;
goto err;
}
- ret = EFI_CALL(efi_get_variable(variable_name, vendor,
- &attr, &old_size, old_data));
+ ret = efi_get_variable_common(variable_name, vendor,
+ &attr, &old_size, old_data);
if (ret != EFI_SUCCESS)
goto err;
} else {