From b2b58e1ef5c3f60ce6db1d6192c265d4ee45b170 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 31 Dec 2023 08:25:48 -0700 Subject: smbios: Correct gd_smbios_start() This should access arch-specific properties. Fix it and update the existing usage. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- lib/efi_loader/efi_smbios.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/efi_loader/efi_smbios.c') diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c index bbb8421ce1..49adc87e45 100644 --- a/lib/efi_loader/efi_smbios.c +++ b/lib/efi_loader/efi_smbios.c @@ -28,7 +28,7 @@ efi_status_t efi_smbios_register(void) ulong addr; efi_status_t ret; - addr = gd->arch.smbios_start; + addr = gd_smbios_start(); if (!addr) { log_err("No SMBIOS tables to install\n"); return EFI_NOT_FOUND; -- cgit v1.2.3 From 138e69149b84180753da4dca59d4cb4f03da3ca7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 31 Dec 2023 08:25:49 -0700 Subject: efi: Use the correct GUID for the SMBIOS table EFI does not use the 'anchor string' to determine the SMBIOS table version, instead preferring to have two separate GUIDs. Use the correct one, depending on the table version. Call unmap_system() to balance to the use of map_sysmem() Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- include/efi_api.h | 4 ++++ lib/efi_loader/efi_smbios.c | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'lib/efi_loader/efi_smbios.c') diff --git a/include/efi_api.h b/include/efi_api.h index 0e92cb8a7f..ab40b1b5dd 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -433,6 +433,10 @@ struct efi_runtime_services { EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3, \ 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) +#define SMBIOS3_TABLE_GUID \ + EFI_GUID(0xf2fd1544, 0x9794, 0x4a2c, \ + 0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94) + #define EFI_LOAD_FILE_PROTOCOL_GUID \ EFI_GUID(0x56ec3091, 0x954c, 0x11d2, \ 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c index 49adc87e45..5cbce6dc4e 100644 --- a/lib/efi_loader/efi_smbios.c +++ b/lib/efi_loader/efi_smbios.c @@ -14,6 +14,8 @@ #include #include +const efi_guid_t smbios3_guid = SMBIOS3_TABLE_GUID; + enum { TABLE_SIZE = SZ_4K, }; @@ -25,8 +27,10 @@ enum { */ efi_status_t efi_smbios_register(void) { + const efi_guid_t *guid; ulong addr; efi_status_t ret; + void *buf; addr = gd_smbios_start(); if (!addr) { @@ -42,8 +46,12 @@ efi_status_t efi_smbios_register(void) 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)); + buf = map_sysmem(addr, 0); + guid = !memcmp(buf, "_SM_", 4) ? &smbios_guid : &smbios3_guid; + ret = efi_install_configuration_table(guid, buf); + unmap_sysmem(buf); + + return ret; } static int install_smbios_table(void) -- cgit v1.2.3 From aa8499680c14afa80ed731b4cfcd6934b4f93712 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 31 Dec 2023 08:25:52 -0700 Subject: efi: smbios: Drop support for SMBIOS2 tables Only the v3 table is supported now, so always use this when installing the EFI table. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_smbios.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/efi_loader/efi_smbios.c') diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c index 5cbce6dc4e..5db342ee0d 100644 --- a/lib/efi_loader/efi_smbios.c +++ b/lib/efi_loader/efi_smbios.c @@ -27,7 +27,6 @@ enum { */ efi_status_t efi_smbios_register(void) { - const efi_guid_t *guid; ulong addr; efi_status_t ret; void *buf; @@ -47,8 +46,7 @@ efi_status_t efi_smbios_register(void) /* Install SMBIOS information as configuration table */ buf = map_sysmem(addr, 0); - guid = !memcmp(buf, "_SM_", 4) ? &smbios_guid : &smbios3_guid; - ret = efi_install_configuration_table(guid, buf); + ret = efi_install_configuration_table(&smbios3_guid, buf); unmap_sysmem(buf); return ret; -- cgit v1.2.3 From 06ef8089f876b6dabf56caba31a05c003f03c629 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 31 Dec 2023 08:25:55 -0700 Subject: 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 --- lib/efi_loader/efi_smbios.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'lib/efi_loader/efi_smbios.c') diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c index 5db342ee0d..eb6d2ba43c 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; -- cgit v1.2.3