aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-12-31 08:25:55 -0700
committerSimon Glass <sjg@chromium.org>2024-01-07 13:45:07 -0700
commit06ef8089f876b6dabf56caba31a05c003f03c629 (patch)
treec1d2db5800d5cc1de95c804b3ea31615bfab7f39 /lib
parenta8efebe71978b3b21e04c7f104987ada879e0800 (diff)
downloadu-boot-06ef8089f876b6dabf56caba31a05c003f03c629.zip
u-boot-06ef8089f876b6dabf56caba31a05c003f03c629.tar.gz
u-boot-06ef8089f876b6dabf56caba31a05c003f03c629.tar.bz2
efi: Correct smbios-table installation
At present this code allocates memory when writing the tables and then unnecessarily adds another memory map when installing it. Adjust the code to allocate the tables using the normal U-Boot mechanism. This avoids doing an EFI memory allocation early in U-Boot, which may use memory that would be overwritten by a 'load' command, for example. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/efi_smbios.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c
index 5db342e..eb6d2ba 100644
--- a/lib/efi_loader/efi_smbios.c
+++ b/lib/efi_loader/efi_smbios.c
@@ -54,27 +54,25 @@ efi_status_t efi_smbios_register(void)
static int install_smbios_table(void)
{
- u64 addr;
- efi_status_t ret;
+ ulong addr;
+ void *buf;
if (!IS_ENABLED(CONFIG_GENERATE_SMBIOS_TABLE) || IS_ENABLED(CONFIG_X86))
return 0;
- addr = SZ_4G;
- ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
- EFI_RUNTIME_SERVICES_DATA,
- efi_size_in_pages(TABLE_SIZE), &addr);
- if (ret != EFI_SUCCESS)
+ /* 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((void *)(uintptr_t)addr);
+ addr = map_to_sysmem(buf);
if (!write_smbios_table(addr)) {
log_err("Failed to write SMBIOS table\n");
return log_msg_ret("smbios", -EINVAL);
}
/* Make a note of where we put it */
- log_debug("SMBIOS tables written to %llx\n", addr);
+ log_debug("SMBIOS tables written to %lx\n", addr);
gd->arch.smbios_start = addr;
return 0;