summaryrefslogtreecommitdiff
path: root/lib/efi_loader
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2023-10-02 10:55:44 -0400
committerTom Rini <[email protected]>2023-10-02 10:55:44 -0400
commitac897385bbfa30cfdfb62ccf24acfcd4b274b2ff (patch)
treeae567980737beb24ca24e2ee8cfeaf6eb9e26e3f /lib/efi_loader
parent4459ed60cb1e0562bc5b40405e2b4b9bbf766d57 (diff)
parente29b932aa07fa0226d325b35d96cd4eea0370129 (diff)
Merge branch 'next'
Signed-off-by: Tom Rini <[email protected]>
Diffstat (limited to 'lib/efi_loader')
-rw-r--r--lib/efi_loader/Kconfig8
-rw-r--r--lib/efi_loader/Makefile4
-rw-r--r--lib/efi_loader/capsule_esl.dtsi.in11
-rw-r--r--lib/efi_loader/efi_setup.c20
-rw-r--r--lib/efi_loader/efi_smbios.c72
5 files changed, 77 insertions, 38 deletions
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 9989e3f384e..d20aaab6dba 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -272,6 +272,14 @@ config EFI_CAPSULE_MAX
Select the max capsule index value used for capsule report
variables. This value is used to create CapsuleMax variable.
+config EFI_CAPSULE_ESL_FILE
+ string "Path to the EFI Signature List File"
+ depends on EFI_CAPSULE_AUTHENTICATE
+ help
+ Provides the path to the EFI Signature List file which will
+ be embedded in the platform's device tree and used for
+ capsule authentication at the time of capsule update.
+
config EFI_DEVICE_PATH_TO_TEXT
bool "Device path to text protocol"
default y
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index 1a8c8d7cab5..8d31fc61c60 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -78,8 +78,8 @@ obj-$(CONFIG_EFI_ESRT) += efi_esrt.o
obj-$(CONFIG_VIDEO) += efi_gop.o
obj-$(CONFIG_BLK) += efi_disk.o
obj-$(CONFIG_NETDEVICES) += efi_net.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += efi_acpi.o
-obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += efi_smbios.o
+obj-$(CONFIG_ACPI) += efi_acpi.o
+obj-$(CONFIG_SMBIOS) += efi_smbios.o
obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_rng.o
obj-$(CONFIG_EFI_TCG2_PROTOCOL) += efi_tcg2.o
obj-$(CONFIG_EFI_RISCV_BOOT_PROTOCOL) += efi_riscv.o
diff --git a/lib/efi_loader/capsule_esl.dtsi.in b/lib/efi_loader/capsule_esl.dtsi.in
new file mode 100644
index 00000000000..61a9f2b25e9
--- /dev/null
+++ b/lib/efi_loader/capsule_esl.dtsi.in
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0+
+/**
+ * Devicetree file with the public key EFI Signature List(ESL)
+ * node. This file is used to generate the dtsi file to be
+ * included into the DTB.
+*/
+/ {
+ signature {
+ capsule-key = /incbin/("ESL_BIN_FILE");
+ };
+};
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index 58d4e134023..e6de685e879 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -321,16 +321,16 @@ efi_status_t efi_init_obj_list(void)
if (ret != EFI_SUCCESS)
goto out;
#endif
-#ifdef CONFIG_GENERATE_ACPI_TABLE
- ret = efi_acpi_register();
- if (ret != EFI_SUCCESS)
- goto out;
-#endif
-#ifdef CONFIG_GENERATE_SMBIOS_TABLE
- ret = efi_smbios_register();
- if (ret != EFI_SUCCESS)
- goto out;
-#endif
+ if (IS_ENABLED(CONFIG_ACPI)) {
+ ret = efi_acpi_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
+ }
+ if (IS_ENABLED(CONFIG_SMBIOS)) {
+ ret = efi_smbios_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
+ }
ret = efi_watchdog_register();
if (ret != EFI_SUCCESS)
goto out;
diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c
index 306c0bc54f9..48446f654d9 100644
--- a/lib/efi_loader/efi_smbios.c
+++ b/lib/efi_loader/efi_smbios.c
@@ -10,8 +10,14 @@
#include <common.h>
#include <efi_loader.h>
#include <log.h>
+#include <malloc.h>
#include <mapmem.h>
#include <smbios.h>
+#include <linux/sizes.h>
+
+enum {
+ TABLE_SIZE = SZ_4K,
+};
/*
* Install the SMBIOS table as a configuration table.
@@ -20,36 +26,50 @@
*/
efi_status_t efi_smbios_register(void)
{
- /* Map within the low 32 bits, to allow for 32bit SMBIOS tables */
- u64 dmi_addr = U32_MAX;
+ ulong addr;
efi_status_t ret;
- void *dmi;
- /* Reserve 4kiB page for SMBIOS */
- ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
- EFI_RUNTIME_SERVICES_DATA, 1, &dmi_addr);
+ addr = gd->arch.smbios_start;
+ if (!addr) {
+ log_err("No SMBIOS tables to install\n");
+ return EFI_NOT_FOUND;
+ }
+
+ /* Mark space used for tables */
+ ret = efi_add_memory_map(addr, TABLE_SIZE, EFI_RUNTIME_SERVICES_DATA);
+ if (ret)
+ return ret;
+
+ log_debug("EFI using SMBIOS tables at %lx\n", addr);
+
+ /* Install SMBIOS information as configuration table */
+ return efi_install_configuration_table(&smbios_guid,
+ map_sysmem(addr, 0));
+}
+
+static int install_smbios_table(void)
+{
+ ulong addr;
+ void *buf;
- if (ret != EFI_SUCCESS) {
- /* Could not find space in lowmem, use highmem instead */
- ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
- EFI_RUNTIME_SERVICES_DATA, 1,
- &dmi_addr);
+ if (!IS_ENABLED(CONFIG_GENERATE_SMBIOS_TABLE) || IS_ENABLED(CONFIG_X86))
+ return 0;
- if (ret != EFI_SUCCESS)
- return ret;
+ /* Align the table to a 4KB boundary to keep EFI happy */
+ buf = memalign(SZ_4K, TABLE_SIZE);
+ if (!buf)
+ return log_msg_ret("mem", -ENOMEM);
+
+ addr = map_to_sysmem(buf);
+ if (!write_smbios_table(addr)) {
+ log_err("Failed to write SMBIOS table\n");
+ return log_msg_ret("smbios", -EINVAL);
}
- /*
- * Generate SMBIOS tables - we know that efi_allocate_pages() returns
- * a 4k-aligned address, so it is safe to assume that
- * write_smbios_table() will write the table at that address.
- */
- assert(!(dmi_addr & 0xf));
- dmi = (void *)(uintptr_t)dmi_addr;
- if (write_smbios_table(map_to_sysmem(dmi)))
- /* Install SMBIOS information as configuration table */
- return efi_install_configuration_table(&smbios_guid, dmi);
- efi_free_pages(dmi_addr, 1);
- log_err("Cannot create SMBIOS table\n");
- return EFI_SUCCESS;
+ /* Make a note of where we put it */
+ log_debug("SMBIOS tables written to %lx\n", addr);
+ gd->arch.smbios_start = addr;
+
+ return 0;
}
+EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, install_smbios_table);