aboutsummaryrefslogtreecommitdiff
path: root/lib/smbios.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-12-31 08:25:47 -0700
committerSimon Glass <sjg@chromium.org>2024-01-07 13:45:06 -0700
commit70924294f375c351339f029b9615b52608e04cf4 (patch)
tree0439d95d7bb8926aacede0981ccb8ce55c1fca6b /lib/smbios.c
parentde4b91ca686f1bedf46319f31b626cfe26665810 (diff)
downloadu-boot-70924294f375c351339f029b9615b52608e04cf4.zip
u-boot-70924294f375c351339f029b9615b52608e04cf4.tar.gz
u-boot-70924294f375c351339f029b9615b52608e04cf4.tar.bz2
smbios: Use SMBIOS 3.0 to support an address above 4GB
When the SMBIOS table is written to an address above 4GB a 32-bit table address is not large enough. Use an SMBIOS3 table in that case. Note that we cannot use efi_allocate_pages() since this function has nothing to do with EFI. There is no equivalent function to allocate memory below 4GB in U-Boot. One solution would be to create a separate malloc() pool, or just always put the malloc() pool below 4GB. - Use log_debug() for warning - Rebase on Heinrich's smbios.h patch - Set the checksum for SMBIOS3 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'lib/smbios.c')
-rw-r--r--lib/smbios.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/lib/smbios.c b/lib/smbios.c
index eea7267..7f79d96 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -567,7 +567,11 @@ ulong write_smbios_table(ulong addr)
addr = ALIGN(addr, 16);
start_addr = addr;
- addr += sizeof(struct smbios_entry);
+ /*
+ * So far we don't know which struct will be used, but they both end
+ * up using the same amount of 16-bit-aligned space
+ */
+ addr += max(sizeof(struct smbios_entry), sizeof(struct smbios3_entry));
addr = ALIGN(addr, 16);
tables = addr;
@@ -590,16 +594,32 @@ ulong write_smbios_table(ulong addr)
* We must use a pointer here so things work correctly on sandbox. The
* user of this table is not aware of the mapping of addresses to
* sandbox's DRAM buffer.
+ *
+ * Check the address of the end of the tables. If it is above 4GB then
+ * it is sensible to use SMBIOS3 even if the start of the table is below
+ * 4GB (this case is very unlikely to happen in practice)
*/
table_addr = (ulong)map_sysmem(tables, 0);
- if (sizeof(table_addr) > sizeof(u32) && table_addr > (ulong)UINT_MAX) {
+ if (sizeof(table_addr) > sizeof(u32) && addr >= (ulong)UINT_MAX) {
+ struct smbios3_entry *se;
/*
* We need to put this >32-bit pointer into the table but the
* field is only 32 bits wide.
*/
- printf("WARNING: SMBIOS table_address overflow %llx\n",
- (unsigned long long)table_addr);
- addr = 0;
+ log_debug("WARNING: Using SMBIOS3.0 due to table-address overflow %lx\n",
+ table_addr);
+ se = map_sysmem(start_addr, sizeof(struct smbios_entry));
+ memset(se, '\0', sizeof(struct smbios_entry));
+ memcpy(se->anchor, "_SM3_", 5);
+ se->length = sizeof(struct smbios3_entry);
+ se->major_ver = SMBIOS_MAJOR_VER;
+ se->minor_ver = SMBIOS_MINOR_VER;
+ se->doc_rev = 0;
+ se->entry_point_rev = 1;
+ se->max_struct_size = len;
+ se->struct_table_address = table_addr;
+ se->checksum = table_compute_checksum(se,
+ sizeof(struct smbios3_entry));
} else {
struct smbios_entry *se;