summaryrefslogtreecommitdiff
path: root/lib/efi_loader
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2024-10-20 08:27:15 -0600
committerTom Rini <[email protected]>2024-10-20 08:27:15 -0600
commitfa0ed06a749c8e3c65d8b12a7d2d33a055a08aad (patch)
treeda947666cff586b29d08d7f61768d1dc41e1b789 /lib/efi_loader
parent7036abbd5c3934059b020d5fd5bcb8b3bf3c788c (diff)
parent640c6c6cbaafa1b049118d431cf218d9dce3cdd8 (diff)
Merge tag 'efi-2025-01-rc1-2' of https://source.denx.de/u-boot/custodians/u-boot-efi
Pull request efi-2025-01-rc1-2 CI: https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/22810 Documentation: * Add document describing Ethernet boot on AM62x SoC * Fix typo in blkmap command example UEFI: * Avoid #ifdef in efi_setup.c * Reduce message noisiness if ESP is missing * Remove ERROR:, WARNING: prefixes in messages * Use blk_create_devicef() in block device driver Others: * Let CONFIG_CMD_WGET depend on CONFIG_CMD_NET
Diffstat (limited to 'lib/efi_loader')
-rw-r--r--lib/efi_loader/efi_helper.c20
-rw-r--r--lib/efi_loader/efi_memory.c2
-rw-r--r--lib/efi_loader/efi_setup.c25
-rw-r--r--lib/efi_loader/efi_var_file.c22
4 files changed, 35 insertions, 34 deletions
diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c
index a481eb4b7e3..00167bd2a10 100644
--- a/lib/efi_loader/efi_helper.c
+++ b/lib/efi_loader/efi_helper.c
@@ -412,7 +412,7 @@ static efi_status_t copy_fdt(void **fdtp)
EFI_ACPI_RECLAIM_MEMORY, fdt_pages,
&new_fdt_addr);
if (ret != EFI_SUCCESS) {
- log_err("ERROR: Failed to reserve space for FDT\n");
+ log_err("Failed to reserve space for FDT\n");
goto done;
}
new_fdt = (void *)(uintptr_t)new_fdt_addr;
@@ -468,7 +468,7 @@ efi_status_t efi_install_fdt(void *fdt)
* but not both.
*/
if (CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) && fdt)
- log_warning("WARNING: Can't have ACPI table and device tree - ignoring DT.\n");
+ log_warning("Can't have ACPI table and device tree - ignoring DT.\n");
if (fdt == EFI_FDT_USE_INTERNAL) {
const char *fdt_opt;
@@ -483,13 +483,13 @@ efi_status_t efi_install_fdt(void *fdt)
if (!fdt_opt) {
fdt_opt = env_get("fdtcontroladdr");
if (!fdt_opt) {
- log_err("ERROR: need device tree\n");
+ log_err("need device tree\n");
return EFI_NOT_FOUND;
}
}
fdt_addr = hextoul(fdt_opt, NULL);
if (!fdt_addr) {
- log_err("ERROR: invalid $fdt_addr or $fdtcontroladdr\n");
+ log_err("invalid $fdt_addr or $fdtcontroladdr\n");
return EFI_LOAD_ERROR;
}
fdt = map_sysmem(fdt_addr, 0);
@@ -497,7 +497,7 @@ efi_status_t efi_install_fdt(void *fdt)
/* Install device tree */
if (fdt_check_header(fdt)) {
- log_err("ERROR: invalid device tree\n");
+ log_err("invalid device tree\n");
return EFI_LOAD_ERROR;
}
@@ -510,12 +510,12 @@ efi_status_t efi_install_fdt(void *fdt)
/* Prepare device tree for payload */
ret = copy_fdt(&fdt);
if (ret) {
- log_err("ERROR: out of memory\n");
+ log_err("out of memory\n");
return EFI_OUT_OF_RESOURCES;
}
if (image_setup_libfdt(&img, fdt, false)) {
- log_err("ERROR: failed to process device tree\n");
+ log_err("failed to process device tree\n");
return EFI_LOAD_ERROR;
}
@@ -527,7 +527,7 @@ efi_status_t efi_install_fdt(void *fdt)
if (CONFIG_IS_ENABLED(EFI_TCG2_PROTOCOL_MEASURE_DTB)) {
ret = efi_tcg2_measure_dtb(fdt);
if (ret == EFI_SECURITY_VIOLATION) {
- log_err("ERROR: failed to measure DTB\n");
+ log_err("failed to measure DTB\n");
return ret;
}
}
@@ -535,7 +535,7 @@ efi_status_t efi_install_fdt(void *fdt)
/* Install device tree as UEFI table */
ret = efi_install_configuration_table(&efi_guid_fdt, fdt);
if (ret != EFI_SUCCESS) {
- log_err("ERROR: failed to install device tree\n");
+ log_err("failed to install device tree\n");
return ret;
}
@@ -574,7 +574,7 @@ efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options)
*/
ret = efi_set_watchdog(300);
if (ret != EFI_SUCCESS) {
- log_err("ERROR: Failed to set watchdog timer\n");
+ log_err("failed to set watchdog timer\n");
goto out;
}
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index b63b5cca71e..3d742fa1915 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -652,7 +652,7 @@ void *efi_alloc(size_t size)
if (efi_allocate_pool(EFI_BOOT_SERVICES_DATA, size, &buf) !=
EFI_SUCCESS) {
- log_err("out of memory");
+ log_err("out of memory\n");
return NULL;
}
memset(buf, 0, size);
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index a610e032d2f..aa59bc7779d 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -86,7 +86,6 @@ out:
return ret;
}
-#ifdef CONFIG_EFI_SECURE_BOOT
/**
* efi_init_secure_boot - initialize secure boot state
*
@@ -112,12 +111,6 @@ static efi_status_t efi_init_secure_boot(void)
return ret;
}
-#else
-static efi_status_t efi_init_secure_boot(void)
-{
- return EFI_SUCCESS;
-}
-#endif /* CONFIG_EFI_SECURE_BOOT */
/**
* efi_init_capsule - initialize capsule update state
@@ -302,9 +295,11 @@ efi_status_t efi_init_obj_list(void)
}
/* Secure boot */
- ret = efi_init_secure_boot();
- if (ret != EFI_SUCCESS)
- goto out;
+ if (IS_ENABLED(CONFIG_EFI_SECURE_BOOT)) {
+ ret = efi_init_secure_boot();
+ if (ret != EFI_SUCCESS)
+ goto out;
+ }
/* Indicate supported runtime services */
ret = efi_init_runtime_supported();
@@ -322,11 +317,11 @@ efi_status_t efi_init_obj_list(void)
if (ret != EFI_SUCCESS)
goto out;
}
-#ifdef CONFIG_NETDEVICES
- ret = efi_net_register();
- if (ret != EFI_SUCCESS)
- goto out;
-#endif
+ if (IS_ENABLED(CONFIG_NETDEVICES)) {
+ ret = efi_net_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
+ }
if (IS_ENABLED(CONFIG_ACPI)) {
ret = efi_acpi_register();
if (ret != EFI_SUCCESS)
diff --git a/lib/efi_loader/efi_var_file.c b/lib/efi_loader/efi_var_file.c
index 413e1794e88..ba0bf33ffbd 100644
--- a/lib/efi_loader/efi_var_file.c
+++ b/lib/efi_loader/efi_var_file.c
@@ -37,18 +37,16 @@ static efi_status_t __maybe_unused efi_set_blk_dev_to_system_partition(void)
char part_str[PART_STR_LEN];
int r;
- if (efi_system_partition.uclass_id == UCLASS_INVALID) {
- log_err("No EFI system partition\n");
+ if (efi_system_partition.uclass_id == UCLASS_INVALID)
return EFI_DEVICE_ERROR;
- }
+
snprintf(part_str, PART_STR_LEN, "%x:%x",
efi_system_partition.devnum, efi_system_partition.part);
r = fs_set_blk_dev(blk_get_uclass_name(efi_system_partition.uclass_id),
part_str, FS_TYPE_ANY);
- if (r) {
- log_err("Cannot read EFI system partition\n");
+ if (r)
return EFI_DEVICE_ERROR;
- }
+
return EFI_SUCCESS;
}
@@ -67,14 +65,21 @@ efi_status_t efi_var_to_file(void)
loff_t len;
loff_t actlen;
int r;
+ static bool once;
ret = efi_var_collect(&buf, &len, EFI_VARIABLE_NON_VOLATILE);
if (ret != EFI_SUCCESS)
goto error;
ret = efi_set_blk_dev_to_system_partition();
- if (ret != EFI_SUCCESS)
- goto error;
+ if (ret != EFI_SUCCESS) {
+ if (!once) {
+ log_warning("Cannot persist EFI variables without system partition\n");
+ once = true;
+ }
+ goto out;
+ }
+ once = false;
r = fs_write(EFI_VAR_FILE_NAME, map_to_sysmem(buf), 0, len, &actlen);
if (r || len != actlen)
@@ -83,6 +88,7 @@ efi_status_t efi_var_to_file(void)
error:
if (ret != EFI_SUCCESS)
log_err("Failed to persist EFI variables\n");
+out:
free(buf);
return ret;
#else