lib/smbios: Add 32 bit entry point if below 4G

If the smbios table is not below 4G there is no need to have a 32 bit
entry point. Even worse it could cause the payload to try to use the
entry point.

Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com>
Change-Id: I4cb426bb0c45282ed03ff4c65d15004b7f985dab
Reviewed-on: https://review.coreboot.org/c/coreboot/+/76911
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
This commit is contained in:
Maximilian Brune 2023-08-02 13:20:00 +02:00 committed by Lean Sheng Tan
parent 8256c355b6
commit 48169e8036

View file

@ -1203,7 +1203,7 @@ static int smbios_walk_device_tree(struct device *tree, int *handle, unsigned lo
unsigned long smbios_write_tables(unsigned long current) unsigned long smbios_write_tables(unsigned long current)
{ {
struct smbios_entry *se; struct smbios_entry *se = NULL;
struct smbios_entry30 *se3; struct smbios_entry30 *se3;
unsigned long tables; unsigned long tables;
int len = 0; int len = 0;
@ -1213,9 +1213,12 @@ unsigned long smbios_write_tables(unsigned long current)
current = ALIGN_UP(current, 16); current = ALIGN_UP(current, 16);
printk(BIOS_DEBUG, "%s: %08lx\n", __func__, current); printk(BIOS_DEBUG, "%s: %08lx\n", __func__, current);
se = (struct smbios_entry *)current; // only add a 32 bit entry point if SMBIOS table is below 4G
current += sizeof(*se); if (current < UINT32_MAX) {
current = ALIGN_UP(current, 16); se = (struct smbios_entry *)current;
current += sizeof(*se);
current = ALIGN_UP(current, 16);
}
se3 = (struct smbios_entry30 *)current; se3 = (struct smbios_entry30 *)current;
current += sizeof(*se3); current += sizeof(*se3);
@ -1253,21 +1256,23 @@ unsigned long smbios_write_tables(unsigned long current)
update_max(len, max_struct_size, smbios_write_type127(&current, handle++)); update_max(len, max_struct_size, smbios_write_type127(&current, handle++));
/* Install SMBIOS 2.1 entry point */ if (se) {
memset(se, 0, sizeof(*se)); /* Install SMBIOS 2.1 entry point */
memcpy(se->anchor, "_SM_", 4); memset(se, 0, sizeof(*se));
se->length = sizeof(*se); memcpy(se->anchor, "_SM_", 4);
se->major_version = 3; se->length = sizeof(*se);
se->minor_version = 0; se->major_version = 3;
se->max_struct_size = max_struct_size; se->minor_version = 0;
se->struct_count = handle; se->max_struct_size = max_struct_size;
memcpy(se->intermediate_anchor_string, "_DMI_", 5); se->struct_count = handle;
memcpy(se->intermediate_anchor_string, "_DMI_", 5);
se->struct_table_address = (u32)tables; se->struct_table_address = (u32)tables;
se->struct_table_length = len; se->struct_table_length = len;
se->intermediate_checksum = smbios_checksum((u8 *)se + 0x10, sizeof(*se) - 0x10); se->intermediate_checksum = smbios_checksum((u8 *)se + 0x10, sizeof(*se) - 0x10);
se->checksum = smbios_checksum((u8 *)se, sizeof(*se)); se->checksum = smbios_checksum((u8 *)se, sizeof(*se));
}
/* Install SMBIOS 3.0 entry point */ /* Install SMBIOS 3.0 entry point */
memset(se3, 0, sizeof(*se3)); memset(se3, 0, sizeof(*se3));