Ben Frisch (bfrisch@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10163
-gerrit
commit e471cd07a1cea118b7a20475f8e836df1d9e00d2 Author: Ben Frisch bfrisch@gmail.com Date: Sat May 9 19:52:18 2015 -0500
Replaced hardcoded SMBIOS Max Struct size with a calculated one
The SMBIOS Specification defines Max Struct size as the maximum size of any table in the entire SMBIOS. The hardcoded size is too small to accurately represent the maximum SMBIOS structure sizes. While the field is not used by Linux it is used by some RTOS implementations.
Change-Id: I98087975c53a02857742dea283f4e303485b2ffe Signed-off-by: Ben Frisch bfrisch@gmail.com --- src/arch/x86/boot/smbios.c | 48 +++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-)
diff --git a/src/arch/x86/boot/smbios.c b/src/arch/x86/boot/smbios.c index c3ac54a..c2e4c3a 100644 --- a/src/arch/x86/boot/smbios.c +++ b/src/arch/x86/boot/smbios.c @@ -531,7 +531,7 @@ unsigned long smbios_write_tables(unsigned long current) { struct smbios_entry *se; unsigned long tables; - int len, handle = 0; + int len, max_struct_size, table_len, handle = 0;
current = ALIGN(current, 16); printk(BIOS_DEBUG, "%s: %08lx\n", __func__, current); @@ -541,28 +541,50 @@ unsigned long smbios_write_tables(unsigned long current) current = ALIGN(current, 16);
tables = current; - len = smbios_write_type0(¤t, handle++); - len += smbios_write_type1(¤t, handle++); - len += smbios_write_type2(¤t, handle++); - len += smbios_write_type3(¤t, handle++); - len += smbios_write_type4(¤t, handle++); - len += smbios_write_type11(¤t, &handle); + table_len = smbios_write_type0(¤t, handle++); + max_struct_size = table_len; + len = table_len; + table_len = smbios_write_type1(¤t, handle++); + max_struct_size = MAX(max_struct_size, table_len); + len += table_len; + table_len = smbios_write_type2(¤t, handle++); + max_struct_size = MAX(max_struct_size, table_len); + len += table_len; + table_len = smbios_write_type3(¤t, handle++); + max_struct_size = MAX(max_struct_size, table_len); + len += table_len; + table_len = smbios_write_type4(¤t, handle++); + max_struct_size = MAX(max_struct_size, table_len); + len += table_len; + table_len = smbios_write_type11(¤t, &handle); + max_struct_size = MAX(max_struct_size, table_len); + len += table_len; #if CONFIG_ELOG - len += elog_smbios_write_type15(¤t, handle++); + table_len = elog_smbios_write_type15(¤t, handle++); + max_struct_size = MAX(max_struct_size, table_len); + len += table_len; #endif - len += smbios_write_type17(¤t, &handle); - len += smbios_write_type32(¤t, handle++); + table_len = smbios_write_type17(¤t, &handle); + max_struct_size = MAX(max_struct_size, table_len); + len += table_len; + table_len = smbios_write_type32(¤t, handle++); + max_struct_size = MAX(max_struct_size, table_len); + len += table_len;
- len += smbios_walk_device_tree(all_devices, &handle, ¤t); + table_len = smbios_walk_device_tree(all_devices, &handle, ¤t); + max_struct_size = MAX(max_struct_size, table_len); + len += table_len;
- len += smbios_write_type127(¤t, handle++); + table_len = smbios_write_type127(¤t, handle++); + max_struct_size = MAX(max_struct_size, table_len); + len += table_len;
memset(se, 0, sizeof(struct smbios_entry)); memcpy(se->anchor, "_SM_", 4); se->length = sizeof(struct smbios_entry); se->major_version = 2; se->minor_version = 7; - se->max_struct_size = 24; + se->max_struct_size = max_struct_size; se->struct_count = handle; memcpy(se->intermediate_anchor_string, "_DMI_", 5);