[PATCH] smbios: arm64: Allow table to be written at a fixed addr

Simon Glass sjg at chromium.org
Sat Oct 21 02:45:21 CEST 2023


U-Boot typically sets up its malloc() pool near the top of memory. On
ARM64 systems this can result in an SMBIOS table above 4GB which is
not supported by SMBIOSv2.

Work around this problem by providing a new option to choose an address
just below 4GB, if needed.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 lib/Kconfig                 | 17 +++++++++++++++++
 lib/efi_loader/efi_smbios.c | 12 ++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/lib/Kconfig b/lib/Kconfig
index f6ca559897e7..a77f2f3e9089 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -994,6 +994,23 @@ config GENERATE_SMBIOS_TABLE
 	  See also SMBIOS_SYSINFO which allows SMBIOS values to be provided in
 	  the devicetree.
 
+config SMBIOS_TABLE_FIXED
+	bool "Place the SMBIOS table at a special address"
+	depends on GENERATE_SMBIOS_TABLE && ARM64 && SMBIOS && EFI_LOADER
+	default y
+	help
+	  Use this option to place the SMBIOS table at a fixed address.
+
+	  U-Boot typically sets up its malloc() pool near the top of memory. On
+	  ARM64 systems this can result in an SMBIOS table above 4GB which is
+	  not supported by SMBIOSv2. This option works around this problem by
+	  chosing an address just below 4GB, if needed.
+
+config SMBIOS_TABLE_FIXED_ADDR
+	hex "Fixed address for use for SMBIOS table"
+	depends on SMBIOS_TABLE_FIXED
+	default 0xffff0000
+
 endmenu
 
 config LIB_RATIONAL
diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c
index 48446f654d9b..84ea027ea48c 100644
--- a/lib/efi_loader/efi_smbios.c
+++ b/lib/efi_loader/efi_smbios.c
@@ -61,6 +61,18 @@ static int install_smbios_table(void)
 		return log_msg_ret("mem", -ENOMEM);
 
 	addr = map_to_sysmem(buf);
+
+	/*
+	 * Deal with a fixed address if needed. For simplicity we assume that
+	 * the SMBIOS-table size is <64KB and that the malloc region does not
+	 * straddle the 4GB boundary.
+	 */
+	if (IS_ENABLED(CONFIG_SMBIOS_TABLE_FIXED) && addr >= SZ_4G - SZ_64K) {
+		addr = IF_ENABLED_INT(CONFIG_SMBIOS_TABLE_FIXED,
+				      CONFIG_SMBIOS_TABLE_FIXED_ADDR);
+		log_warning("Forcing SMBIOS table to address %lx\n", addr);
+	}
+
 	if (!write_smbios_table(addr)) {
 		log_err("Failed to write SMBIOS table\n");
 		return log_msg_ret("smbios", -EINVAL);
-- 
2.42.0.655.g421f12c284-goog



More information about the U-Boot mailing list